src/timetable_gui.cpp
author rubidium
Sat, 12 Apr 2008 11:58:19 +0000
changeset 10136 d808af13bf7a
parent 10135 b2777e2f98e5
child 10139 448ed1614a14
permissions -rw-r--r--
(svn r12667) -Feature: conditional 'skip/jump' orders.
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
     1
/* $Id$ */
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
     2
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
     3
/** @file timetable_gui.cpp */
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
     4
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
     5
#include "stdafx.h"
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
     6
#include "openttd.h"
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
     7
#include "variables.h"
8612
6414fc21c2f3 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8610
diff changeset
     8
#include "command_func.h"
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
     9
#include "gui.h"
8603
88c5ce6a5215 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8602
diff changeset
    10
#include "window_gui.h"
88c5ce6a5215 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8602
diff changeset
    11
#include "textbuf_gui.h"
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    12
#include "cargotype.h"
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    13
#include "depot.h"
8610
17cc343a23dd (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8603
diff changeset
    14
#include "strings_func.h"
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
    15
#include "vehicle_base.h"
8710
52015340050c (svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium
parents: 8640
diff changeset
    16
#include "string_func.h"
8720
4e60c30e2006 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8710
diff changeset
    17
#include "gfx_func.h"
8750
fdd6054e7bae (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8733
diff changeset
    18
#include "player_func.h"
8766
c86cfa3a7580 (svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents: 8760
diff changeset
    19
#include "settings_type.h"
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    20
8760
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8750
diff changeset
    21
#include "table/strings.h"
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8750
diff changeset
    22
9218
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
    23
enum TimetableViewWindowWidgets {
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
    24
	TTV_WIDGET_CLOSEBOX = 0,
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
    25
	TTV_CAPTION,
9241
38c0bd6beae1 (svn r12441) -Feature: open the time table when pressing the order button while pressing the CTRL key. Patch by Phil Sophus.
rubidium
parents: 9218
diff changeset
    26
	TTV_ORDER_VIEW,
9218
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
    27
	TTV_STICKY,
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
    28
	TTV_TIMETABLE_PANEL,
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
    29
	TTV_SCROLLBAR,
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
    30
	TTV_SUMMARY_PANEL,
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
    31
	TTV_CHANGE_TIME,
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
    32
	TTV_CLEAR_TIME,
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
    33
	TTV_RESET_LATENESS,
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
    34
	TTV_AUTOFILL,
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
    35
	TTV_EMPTY,
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
    36
	TTV_RESIZE,
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
    37
};
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
    38
10132
797415496aaa (svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
rubidium
parents: 10130
diff changeset
    39
struct timetable_d {
797415496aaa (svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
rubidium
parents: 10130
diff changeset
    40
	int sel;
797415496aaa (svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
rubidium
parents: 10130
diff changeset
    41
};
797415496aaa (svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
rubidium
parents: 10130
diff changeset
    42
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(timetable_d));
797415496aaa (svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
rubidium
parents: 10130
diff changeset
    43
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    44
static int GetOrderFromTimetableWndPt(Window *w, int y, const Vehicle *v)
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    45
{
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    46
	/*
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    47
	 * Calculation description:
10132
797415496aaa (svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
rubidium
parents: 10130
diff changeset
    48
	 * 15 = 14 (w->widget[TTV_ORDER_VIEW].top) + 1 (frame-line)
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    49
	 * 10 = order text hight
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    50
	 */
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    51
	int sel = (y - 15) / 10;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    52
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    53
	if ((uint)sel >= w->vscroll.cap) return INVALID_ORDER;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    54
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    55
	sel += w->vscroll.pos;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    56
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    57
	return (sel <= v->num_orders * 2 && sel >= 0) ? sel : INVALID_ORDER;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    58
}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    59
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    60
static inline void SetTimetableParams(int param1, int param2, uint32 time)
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    61
{
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    62
	if (_patches.timetable_in_ticks) {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    63
		SetDParam(param1, STR_TIMETABLE_TICKS);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    64
		SetDParam(param2, time);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    65
	} else {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    66
		SetDParam(param1, STR_TIMETABLE_DAYS);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    67
		SetDParam(param2, time / DAY_TICKS);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    68
	}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    69
}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    70
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    71
static void DrawTimetableWindow(Window *w)
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    72
{
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    73
	const Vehicle *v = GetVehicle(w->window_number);
10132
797415496aaa (svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
rubidium
parents: 10130
diff changeset
    74
	int selected = WP(w, timetable_d).sel;
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    75
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    76
	SetVScrollCount(w, v->num_orders * 2);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    77
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    78
	if (v->owner == _local_player) {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    79
		if (selected == -1) {
9218
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
    80
			w->DisableWidget(TTV_CHANGE_TIME);
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
    81
			w->DisableWidget(TTV_CLEAR_TIME);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    82
		} else if (selected % 2 == 1) {
9218
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
    83
			w->EnableWidget(TTV_CHANGE_TIME);
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
    84
			w->EnableWidget(TTV_CLEAR_TIME);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    85
		} else {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    86
			const Order *order = GetVehicleOrder(v, (selected + 1) / 2);
9344
1be7ac6bd504 (svn r12600) -Codechange: make GetNonStopType return a more augmented type; not is there a non-stop order but the kind of non-stop order, so one doesn't need to check _patches.new_nonstop type everywhere.
rubidium
parents: 9339
diff changeset
    87
			bool disable = order == NULL || !order->IsType(OT_GOTO_STATION) || (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    88
9218
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
    89
			w->SetWidgetDisabledState(TTV_CHANGE_TIME, disable);
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
    90
			w->SetWidgetDisabledState(TTV_CLEAR_TIME, disable);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    91
		}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    92
9218
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
    93
		w->EnableWidget(TTV_RESET_LATENESS);
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
    94
		w->EnableWidget(TTV_AUTOFILL);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
    95
	} else {
9218
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
    96
		w->DisableWidget(TTV_CHANGE_TIME);
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
    97
		w->DisableWidget(TTV_CLEAR_TIME);
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
    98
		w->DisableWidget(TTV_RESET_LATENESS);
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
    99
		w->DisableWidget(TTV_AUTOFILL);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   100
	}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   101
9218
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
   102
	w->SetWidgetLoweredState(TTV_AUTOFILL, HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE));
7562
f6f62814907b (svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents: 7553
diff changeset
   103
7545
9a4834d48970 (svn r10314) -Codechange: Refer to vehicle names by index
peter1138
parents: 7479
diff changeset
   104
	SetDParam(0, v->index);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   105
	DrawWindowWidgets(w);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   106
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   107
	int y = 15;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   108
	int i = w->vscroll.pos;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   109
	VehicleOrderID order_id = (i + 1) / 2;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   110
	bool final_order = false;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   111
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   112
	const Order *order = GetVehicleOrder(v, order_id);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   113
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   114
	while (order != NULL) {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   115
		/* Don't draw anything if it extends past the end of the window. */
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   116
		if (i - w->vscroll.pos >= w->vscroll.cap) break;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   117
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   118
		if (i % 2 == 0) {
10136
d808af13bf7a (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 10135
diff changeset
   119
			SetDParam(5, STR_EMPTY);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   120
9332
2e120d0bd632 (svn r12584) -Codechange: do not access the order type directly.
rubidium
parents: 9282
diff changeset
   121
			switch (order->GetType()) {
7808
70bb84732406 (svn r10664) -Codechange: simplify a small piece of code (skidd13)
truelight
parents: 7762
diff changeset
   122
				case OT_DUMMY:
70bb84732406 (svn r10664) -Codechange: simplify a small piece of code (skidd13)
truelight
parents: 7762
diff changeset
   123
					SetDParam(0, STR_INVALID_ORDER);
70bb84732406 (svn r10664) -Codechange: simplify a small piece of code (skidd13)
truelight
parents: 7762
diff changeset
   124
					break;
70bb84732406 (svn r10664) -Codechange: simplify a small piece of code (skidd13)
truelight
parents: 7762
diff changeset
   125
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   126
				case OT_GOTO_STATION:
10112
4cff0d575f0b (svn r12643) -Codechange: be more explicit about the orders a vehicle has (non stop and full load are ambiguous and depend on some patch settings).
rubidium
parents: 10079
diff changeset
   127
					SetDParam(0, STR_GO_TO_STATION);
4cff0d575f0b (svn r12643) -Codechange: be more explicit about the orders a vehicle has (non stop and full load are ambiguous and depend on some patch settings).
rubidium
parents: 10079
diff changeset
   128
					SetDParam(1, STR_ORDER_GO_TO + order->GetNonStopType());
4cff0d575f0b (svn r12643) -Codechange: be more explicit about the orders a vehicle has (non stop and full load are ambiguous and depend on some patch settings).
rubidium
parents: 10079
diff changeset
   129
					SetDParam(2, order->GetDestination());
4cff0d575f0b (svn r12643) -Codechange: be more explicit about the orders a vehicle has (non stop and full load are ambiguous and depend on some patch settings).
rubidium
parents: 10079
diff changeset
   130
					SetDParam(3, STR_EMPTY);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   131
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   132
					if (order->wait_time > 0) {
10136
d808af13bf7a (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 10135
diff changeset
   133
						SetDParam(5, STR_TIMETABLE_STAY_FOR);
d808af13bf7a (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 10135
diff changeset
   134
						SetTimetableParams(6, 7, order->wait_time);
10112
4cff0d575f0b (svn r12643) -Codechange: be more explicit about the orders a vehicle has (non stop and full load are ambiguous and depend on some patch settings).
rubidium
parents: 10079
diff changeset
   135
					} else {
4cff0d575f0b (svn r12643) -Codechange: be more explicit about the orders a vehicle has (non stop and full load are ambiguous and depend on some patch settings).
rubidium
parents: 10079
diff changeset
   136
						SetDParam(4, STR_EMPTY);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   137
					}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   138
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   139
					break;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   140
10129
7bfdb41c1482 (svn r12660) -Codechange: make the creation of depot order strings a little more modular (instead of causing a string explosion).
rubidium
parents: 10112
diff changeset
   141
				case OT_GOTO_DEPOT:
10135
b2777e2f98e5 (svn r12666) -Fix: the time table GUI did not show some data in the correct manner.
rubidium
parents: 10132
diff changeset
   142
					SetDParam(4, STR_EMPTY);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   143
					if (v->type == VEH_AIRCRAFT) {
10130
906ffae618b0 (svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium
parents: 10129
diff changeset
   144
						if (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) {
10135
b2777e2f98e5 (svn r12666) -Fix: the time table GUI did not show some data in the correct manner.
rubidium
parents: 10132
diff changeset
   145
							SetDParam(0, STR_GO_TO_NEAREST_DEPOT);
b2777e2f98e5 (svn r12666) -Fix: the time table GUI did not show some data in the correct manner.
rubidium
parents: 10132
diff changeset
   146
							SetDParam(2, STR_ORDER_NEAREST_HANGAR);
10130
906ffae618b0 (svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium
parents: 10129
diff changeset
   147
						} else {
10135
b2777e2f98e5 (svn r12666) -Fix: the time table GUI did not show some data in the correct manner.
rubidium
parents: 10132
diff changeset
   148
							SetDParam(0, STR_GO_TO_HANGAR);
b2777e2f98e5 (svn r12666) -Fix: the time table GUI did not show some data in the correct manner.
rubidium
parents: 10132
diff changeset
   149
							SetDParam(2, order->GetDestination());
10130
906ffae618b0 (svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium
parents: 10129
diff changeset
   150
						}
10135
b2777e2f98e5 (svn r12666) -Fix: the time table GUI did not show some data in the correct manner.
rubidium
parents: 10132
diff changeset
   151
						SetDParam(3, STR_EMPTY);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   152
					} else {
10130
906ffae618b0 (svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium
parents: 10129
diff changeset
   153
						if (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) {
10135
b2777e2f98e5 (svn r12666) -Fix: the time table GUI did not show some data in the correct manner.
rubidium
parents: 10132
diff changeset
   154
							SetDParam(0, STR_GO_TO_NEAREST_DEPOT);
b2777e2f98e5 (svn r12666) -Fix: the time table GUI did not show some data in the correct manner.
rubidium
parents: 10132
diff changeset
   155
							SetDParam(2, STR_ORDER_NEAREST_DEPOT);
10130
906ffae618b0 (svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium
parents: 10129
diff changeset
   156
						} else {
10135
b2777e2f98e5 (svn r12666) -Fix: the time table GUI did not show some data in the correct manner.
rubidium
parents: 10132
diff changeset
   157
							SetDParam(0, STR_GO_TO_DEPOT);
b2777e2f98e5 (svn r12666) -Fix: the time table GUI did not show some data in the correct manner.
rubidium
parents: 10132
diff changeset
   158
							SetDParam(2, GetDepot(order->GetDestination())->town_index);
10130
906ffae618b0 (svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium
parents: 10129
diff changeset
   159
						}
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   160
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   161
						switch (v->type) {
10129
7bfdb41c1482 (svn r12660) -Codechange: make the creation of depot order strings a little more modular (instead of causing a string explosion).
rubidium
parents: 10112
diff changeset
   162
							case VEH_TRAIN: SetDParam(3, STR_ORDER_TRAIN_DEPOT); break;
7bfdb41c1482 (svn r12660) -Codechange: make the creation of depot order strings a little more modular (instead of causing a string explosion).
rubidium
parents: 10112
diff changeset
   163
							case VEH_ROAD:  SetDParam(3, STR_ORDER_ROAD_DEPOT); break;
7bfdb41c1482 (svn r12660) -Codechange: make the creation of depot order strings a little more modular (instead of causing a string explosion).
rubidium
parents: 10112
diff changeset
   164
							case VEH_SHIP:  SetDParam(3, STR_ORDER_SHIP_DEPOT); break;
7bfdb41c1482 (svn r12660) -Codechange: make the creation of depot order strings a little more modular (instead of causing a string explosion).
rubidium
parents: 10112
diff changeset
   165
							default: NOT_REACHED();
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   166
						}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   167
					}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   168
10129
7bfdb41c1482 (svn r12660) -Codechange: make the creation of depot order strings a little more modular (instead of causing a string explosion).
rubidium
parents: 10112
diff changeset
   169
					if (order->GetDepotOrderType() & ODTFB_SERVICE) {
7bfdb41c1482 (svn r12660) -Codechange: make the creation of depot order strings a little more modular (instead of causing a string explosion).
rubidium
parents: 10112
diff changeset
   170
						SetDParam(1, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_ORDER_SERVICE_NON_STOP_AT : STR_ORDER_SERVICE_AT);
7bfdb41c1482 (svn r12660) -Codechange: make the creation of depot order strings a little more modular (instead of causing a string explosion).
rubidium
parents: 10112
diff changeset
   171
					} else {
7bfdb41c1482 (svn r12660) -Codechange: make the creation of depot order strings a little more modular (instead of causing a string explosion).
rubidium
parents: 10112
diff changeset
   172
						SetDParam(1, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_ORDER_GO_NON_STOP_TO : STR_ORDER_GO_TO);
7bfdb41c1482 (svn r12660) -Codechange: make the creation of depot order strings a little more modular (instead of causing a string explosion).
rubidium
parents: 10112
diff changeset
   173
					}
7bfdb41c1482 (svn r12660) -Codechange: make the creation of depot order strings a little more modular (instead of causing a string explosion).
rubidium
parents: 10112
diff changeset
   174
					break;
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   175
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   176
				case OT_GOTO_WAYPOINT:
9344
1be7ac6bd504 (svn r12600) -Codechange: make GetNonStopType return a more augmented type; not is there a non-stop order but the kind of non-stop order, so one doesn't need to check _patches.new_nonstop type everywhere.
rubidium
parents: 9339
diff changeset
   177
					SetDParam(0, (order->GetNonStopType() != ONSF_STOP_EVERYWHERE) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT);
9336
3f75a2c5e0d3 (svn r12588) -Codechange: do not access the destination of an order directly.
rubidium
parents: 9332
diff changeset
   178
					SetDParam(1, order->GetDestination());
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   179
					break;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   180
10136
d808af13bf7a (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 10135
diff changeset
   181
d808af13bf7a (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 10135
diff changeset
   182
				case OT_CONDITIONAL: {
d808af13bf7a (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 10135
diff changeset
   183
					extern uint ConvertSpeedToDisplaySpeed(uint speed);
d808af13bf7a (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 10135
diff changeset
   184
					OrderConditionComparator occ = order->GetConditionComparator();
d808af13bf7a (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 10135
diff changeset
   185
					SetDParam(0, (occ == OCC_IS_TRUE || occ == OCC_IS_FALSE) ? STR_CONDITIONAL_TRUE_FALSE : STR_CONDITIONAL_NUM);
d808af13bf7a (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 10135
diff changeset
   186
					SetDParam(1, order->GetConditionSkipToOrder() + 1);
d808af13bf7a (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 10135
diff changeset
   187
					SetDParam(2, STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + order->GetConditionVariable());
d808af13bf7a (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 10135
diff changeset
   188
					SetDParam(3, STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS + occ);
d808af13bf7a (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 10135
diff changeset
   189
d808af13bf7a (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 10135
diff changeset
   190
					uint value = order->GetConditionValue();
d808af13bf7a (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 10135
diff changeset
   191
					if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
d808af13bf7a (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 10135
diff changeset
   192
					SetDParam(4, value);
d808af13bf7a (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 10135
diff changeset
   193
				} break;
d808af13bf7a (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 10135
diff changeset
   194
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   195
				default: break;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   196
			}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   197
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7837
diff changeset
   198
			DrawString(2, y, STR_TIMETABLE_GO_TO, (i == selected) ? TC_WHITE : TC_BLACK);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   199
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   200
			order_id++;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   201
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   202
			if (order_id >= v->num_orders) {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   203
				order = GetVehicleOrder(v, 0);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   204
				final_order = true;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   205
			} else {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   206
				order = order->next;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   207
			}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   208
		} else {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   209
			StringID string;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   210
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   211
			if (order->travel_time == 0) {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   212
				string = STR_TIMETABLE_TRAVEL_NOT_TIMETABLED;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   213
			} else {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   214
				SetTimetableParams(0, 1, order->travel_time);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   215
				string = STR_TIMETABLE_TRAVEL_FOR;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   216
			}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   217
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7837
diff changeset
   218
			DrawString(12, y, string, (i == selected) ? TC_WHITE : TC_BLACK);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   219
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   220
			if (final_order) break;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   221
		}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   222
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   223
		i++;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   224
		y += 10;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   225
	}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   226
9218
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
   227
	y = w->widget[TTV_SUMMARY_PANEL].top + 1;
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   228
7569
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   229
	{
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   230
		uint total_time = 0;
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   231
		bool complete = true;
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   232
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   233
		for (const Order *order = GetVehicleOrder(v, 0); order != NULL; order = order->next) {
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   234
			total_time += order->travel_time + order->wait_time;
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   235
			if (order->travel_time == 0) complete = false;
9344
1be7ac6bd504 (svn r12600) -Codechange: make GetNonStopType return a more augmented type; not is there a non-stop order but the kind of non-stop order, so one doesn't need to check _patches.new_nonstop type everywhere.
rubidium
parents: 9339
diff changeset
   236
			if (order->wait_time == 0 && order->IsType(OT_GOTO_STATION) && !(order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION)) complete = false;
7569
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   237
		}
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   238
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   239
		if (total_time != 0) {
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   240
			SetTimetableParams(0, 1, total_time);
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7837
diff changeset
   241
			DrawString(2, y, complete ? STR_TIMETABLE_TOTAL_TIME : STR_TIMETABLE_TOTAL_TIME_INCOMPLETE, TC_BLACK);
7569
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   242
		}
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   243
	}
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   244
	y += 10;
8e639c5079a2 (svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents: 7562
diff changeset
   245
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   246
	if (v->lateness_counter == 0 || (!_patches.timetable_in_ticks && v->lateness_counter / DAY_TICKS == 0)) {
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7837
diff changeset
   247
		DrawString(2, y, STR_TIMETABLE_STATUS_ON_TIME, TC_BLACK);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   248
	} else {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   249
		SetTimetableParams(0, 1, abs(v->lateness_counter));
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7837
diff changeset
   250
		DrawString(2, y, v->lateness_counter < 0 ? STR_TIMETABLE_STATUS_EARLY : STR_TIMETABLE_STATUS_LATE, TC_BLACK);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   251
	}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   252
}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   253
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   254
static inline uint32 PackTimetableArgs(const Vehicle *v, uint selected)
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   255
{
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   256
	uint order_number = (selected + 1) / 2;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   257
	uint is_journey   = (selected % 2 == 1) ? 1 : 0;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   258
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   259
	if (order_number >= v->num_orders) order_number = 0;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   260
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   261
	return v->index | (order_number << 16) | (is_journey << 24);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   262
}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   263
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   264
static void TimetableWndProc(Window *w, WindowEvent *we)
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   265
{
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   266
	switch (we->event) {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   267
		case WE_PAINT:
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   268
			DrawTimetableWindow(w);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   269
			break;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   270
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   271
		case WE_CLICK: {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   272
			const Vehicle *v = GetVehicle(w->window_number);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   273
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   274
			switch (we->we.click.widget) {
9241
38c0bd6beae1 (svn r12441) -Feature: open the time table when pressing the order button while pressing the CTRL key. Patch by Phil Sophus.
rubidium
parents: 9218
diff changeset
   275
				case TTV_ORDER_VIEW: /* Order view button */
38c0bd6beae1 (svn r12441) -Feature: open the time table when pressing the order button while pressing the CTRL key. Patch by Phil Sophus.
rubidium
parents: 9218
diff changeset
   276
					ShowOrdersWindow(v);
38c0bd6beae1 (svn r12441) -Feature: open the time table when pressing the order button while pressing the CTRL key. Patch by Phil Sophus.
rubidium
parents: 9218
diff changeset
   277
					break;
38c0bd6beae1 (svn r12441) -Feature: open the time table when pressing the order button while pressing the CTRL key. Patch by Phil Sophus.
rubidium
parents: 9218
diff changeset
   278
9218
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
   279
				case TTV_TIMETABLE_PANEL: { /* Main panel. */
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   280
					int selected = GetOrderFromTimetableWndPt(w, we->we.click.pt.y, v);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   281
10132
797415496aaa (svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
rubidium
parents: 10130
diff changeset
   282
					if (selected == INVALID_ORDER || selected == WP(w, timetable_d).sel) {
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   283
						/* Deselect clicked order */
10132
797415496aaa (svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
rubidium
parents: 10130
diff changeset
   284
						WP(w, timetable_d).sel = -1;
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   285
					} else {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   286
						/* Select clicked order */
10132
797415496aaa (svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
rubidium
parents: 10130
diff changeset
   287
						WP(w, timetable_d).sel = selected;
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   288
					}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   289
				} break;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   290
9218
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
   291
				case TTV_CHANGE_TIME: { /* "Wait For" button. */
10132
797415496aaa (svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
rubidium
parents: 10130
diff changeset
   292
					int selected = WP(w, timetable_d).sel;
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   293
					VehicleOrderID real = (selected + 1) / 2;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   294
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   295
					if (real >= v->num_orders) real = 0;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   296
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   297
					const Order *order = GetVehicleOrder(v, real);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   298
					StringID current = STR_EMPTY;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   299
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   300
					if (order != NULL) {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   301
						uint time = (selected % 2 == 1) ? order->travel_time : order->wait_time;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   302
						if (!_patches.timetable_in_ticks) time /= DAY_TICKS;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   303
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   304
						if (time != 0) {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   305
							SetDParam(0, time);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   306
							current = STR_CONFIG_PATCHES_INT32;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   307
						}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   308
					}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   309
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   310
					ShowQueryString(current, STR_TIMETABLE_CHANGE_TIME, 31, 150, w, CS_NUMERAL);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   311
				} break;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   312
9218
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
   313
				case TTV_CLEAR_TIME: { /* Clear waiting time button. */
10132
797415496aaa (svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
rubidium
parents: 10130
diff changeset
   314
					uint32 p1 = PackTimetableArgs(v, WP(w, timetable_d).sel);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   315
					DoCommandP(0, p1, 0, NULL, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   316
				} break;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   317
9218
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
   318
				case TTV_RESET_LATENESS: /* Reset the vehicle's late counter. */
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   319
					DoCommandP(0, v->index, 0, NULL, CMD_SET_VEHICLE_ON_TIME | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   320
					break;
7562
f6f62814907b (svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents: 7553
diff changeset
   321
9218
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
   322
				case TTV_AUTOFILL: /* Autofill the timetable. */
8424
4a488a90ccab (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 8320
diff changeset
   323
					DoCommandP(0, v->index, HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE) ? 0 : 1, NULL, CMD_AUTOFILL_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
7562
f6f62814907b (svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents: 7553
diff changeset
   324
					break;
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   325
			}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   326
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   327
			SetWindowDirty(w);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   328
		} break;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   329
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   330
		case WE_ON_EDIT_TEXT: {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   331
			const Vehicle *v = GetVehicle(w->window_number);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   332
10132
797415496aaa (svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
rubidium
parents: 10130
diff changeset
   333
			uint32 p1 = PackTimetableArgs(v, WP(w, timetable_d).sel);
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   334
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   335
			uint64 time = StrEmpty(we->we.edittext.str) ? 0 : strtoul(we->we.edittext.str, NULL, 10);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   336
			if (!_patches.timetable_in_ticks) time *= DAY_TICKS;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   337
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   338
			uint32 p2 = minu(time, MAX_UVALUE(uint16));
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   339
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   340
			DoCommandP(0, p1, p2, NULL, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   341
		} break;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   342
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   343
		case WE_RESIZE:
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   344
			/* Update the scroll + matrix */
9218
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
   345
			w->vscroll.cap = (w->widget[TTV_TIMETABLE_PANEL].bottom - w->widget[TTV_TIMETABLE_PANEL].top) / 10;
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   346
			break;
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   347
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   348
	}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   349
}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   350
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   351
static const Widget _timetable_widgets[] = {
9218
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
   352
	{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                   STR_018B_CLOSE_WINDOW},                // TTV_WIDGET_CLOSEBOX
9241
38c0bd6beae1 (svn r12441) -Feature: open the time table when pressing the order button while pressing the CTRL key. Patch by Phil Sophus.
rubidium
parents: 9218
diff changeset
   353
	{    WWT_CAPTION,   RESIZE_RIGHT,   14,    11,   326,     0,    13, STR_TIMETABLE_TITLE,        STR_018C_WINDOW_TITLE_DRAG_THIS},      // TTV_CAPTION
38c0bd6beae1 (svn r12441) -Feature: open the time table when pressing the order button while pressing the CTRL key. Patch by Phil Sophus.
rubidium
parents: 9218
diff changeset
   354
	{ WWT_PUSHTXTBTN,   RESIZE_LR,      14,   327,   387,     0,    13, STR_ORDER_VIEW,             STR_ORDER_VIEW_TOOLTIP},               // TTV_ORDER_VIEW
9218
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
   355
	{  WWT_STICKYBOX,   RESIZE_LR,      14,   388,   399,     0,    13, STR_NULL,                   STR_STICKY_BUTTON},                    // TTV_STICKY
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   356
9218
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
   357
	{      WWT_PANEL,   RESIZE_RB,      14,     0,   387,    14,    95, STR_NULL,                   STR_TIMETABLE_TOOLTIP},                // TTV_TIMETABLE_PANEL
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
   358
	{  WWT_SCROLLBAR,   RESIZE_LRB,     14,   388,   399,    14,    95, STR_NULL,                   STR_0190_SCROLL_BAR_SCROLLS_LIST},     // TTV_SCROLLBAR
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   359
9218
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
   360
	{      WWT_PANEL,   RESIZE_RTB,     14,     0,   399,    96,   117, STR_NULL,                   STR_NULL},                             // TTV_SUMMARY_PANEL
7553
bb88bdf61f6d (svn r10322) -Codechange: Make the timetable window smaller by default so it doesn't take up so much space on small resolutions.
maedhros
parents: 7545
diff changeset
   361
9218
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
   362
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,     0,   109,   118,   129, STR_TIMETABLE_CHANGE_TIME,  STR_TIMETABLE_WAIT_TIME_TOOLTIP},      // TTV_CHANGE_TIME
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
   363
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   110,   219,   118,   129, STR_CLEAR_TIME,             STR_TIMETABLE_CLEAR_TIME_TOOLTIP},     // TTV_CLEAR_TIME
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
   364
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   220,   337,   118,   129, STR_RESET_LATENESS,         STR_TIMETABLE_RESET_LATENESS_TOOLTIP}, // TTV_RESET_LATENESS
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
   365
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   338,   387,   118,   129, STR_TIMETABLE_AUTOFILL,     STR_TIMETABLE_AUTOFILL_TOOLTIP},       // TTV_AUTOFILL
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
   366
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
   367
	{      WWT_PANEL,   RESIZE_RTB,     14,   388,   387,   118,   129, STR_NULL,                   STR_NULL},                             // TTV_EMPTY
5fd7cb5ebf87 (svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents: 8920
diff changeset
   368
	{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   388,   399,   118,   129, STR_NULL,                   STR_RESIZE_BUTTON},                    // TTV_RESIZE
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   369
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   370
	{    WIDGETS_END }
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   371
};
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   372
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   373
static const WindowDesc _timetable_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7808
diff changeset
   374
	WDP_AUTO, WDP_AUTO, 400, 130, 400, 130,
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   375
	WC_VEHICLE_TIMETABLE, WC_VEHICLE_VIEW,
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   376
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   377
	_timetable_widgets,
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   378
	TimetableWndProc
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   379
};
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   380
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   381
void ShowTimetableWindow(const Vehicle *v)
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   382
{
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   383
	Window *w = AllocateWindowDescFront(&_timetable_desc, v->index);
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   384
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   385
	if (w != NULL) {
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   386
		w->caption_color = v->owner;
7553
bb88bdf61f6d (svn r10322) -Codechange: Make the timetable window smaller by default so it doesn't take up so much space on small resolutions.
maedhros
parents: 7545
diff changeset
   387
		w->vscroll.cap = 8;
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   388
		w->resize.step_height = 10;
10132
797415496aaa (svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
rubidium
parents: 10130
diff changeset
   389
		WP(w, timetable_d).sel = -1;
7477
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   390
	}
1f22e188617e (svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff changeset
   391
}