author | rubidium |
Tue, 06 May 2008 15:11:33 +0000 | |
changeset 10429 | 1b99254f9607 |
parent 10222 | b6919c94cc77 |
child 10434 | d6accd017341 |
permissions | -rw-r--r-- |
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 |
|
10429
1b99254f9607
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
10222
diff
changeset
|
3 |
/** @file timetable_gui.cpp GUI for time tabling. */ |
7477
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" |
8610
17cc343a23dd
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8603
diff
changeset
|
13 |
#include "strings_func.h" |
8640
1e93b81e96d2
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents:
8636
diff
changeset
|
14 |
#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
|
15 |
#include "string_func.h" |
8720
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8710
diff
changeset
|
16 |
#include "gfx_func.h" |
8750
fdd6054e7bae
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8733
diff
changeset
|
17 |
#include "player_func.h" |
10168
24907819f29b
(svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents:
10139
diff
changeset
|
18 |
#include "order_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 |
|
10168
24907819f29b
(svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents:
10139
diff
changeset
|
60 |
void SetTimetableParams(int param1, int param2, uint32 time) |
7477
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) { |
10168
24907819f29b
(svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents:
10139
diff
changeset
|
119 |
DrawOrderString(v, order, order_id, y, i == selected, true); |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
120 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
121 |
order_id++; |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
122 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
123 |
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
|
124 |
order = GetVehicleOrder(v, 0); |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
125 |
final_order = true; |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
126 |
} else { |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
127 |
order = order->next; |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
128 |
} |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
129 |
} else { |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
130 |
StringID string; |
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->travel_time == 0) { |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
133 |
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
|
134 |
} else { |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
135 |
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
|
136 |
string = STR_TIMETABLE_TRAVEL_FOR; |
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 |
|
10168
24907819f29b
(svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents:
10139
diff
changeset
|
139 |
DrawString(22, 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
|
140 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
141 |
if (final_order) break; |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
142 |
} |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
143 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
144 |
i++; |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
145 |
y += 10; |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
146 |
} |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
147 |
|
9218
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
148 |
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
|
149 |
|
7569
8e639c5079a2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7562
diff
changeset
|
150 |
{ |
8e639c5079a2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7562
diff
changeset
|
151 |
uint total_time = 0; |
8e639c5079a2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7562
diff
changeset
|
152 |
bool complete = true; |
8e639c5079a2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7562
diff
changeset
|
153 |
|
8e639c5079a2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7562
diff
changeset
|
154 |
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
|
155 |
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
|
156 |
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
|
157 |
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
|
158 |
} |
8e639c5079a2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7562
diff
changeset
|
159 |
|
8e639c5079a2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7562
diff
changeset
|
160 |
if (total_time != 0) { |
8e639c5079a2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7562
diff
changeset
|
161 |
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
|
162 |
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
|
163 |
} |
8e639c5079a2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7562
diff
changeset
|
164 |
} |
8e639c5079a2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7562
diff
changeset
|
165 |
y += 10; |
8e639c5079a2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7562
diff
changeset
|
166 |
|
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
167 |
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
|
168 |
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
|
169 |
} else { |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
170 |
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
|
171 |
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
|
172 |
} |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
173 |
} |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
174 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
175 |
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
|
176 |
{ |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
177 |
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
|
178 |
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
|
179 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
180 |
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
|
181 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
182 |
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
|
183 |
} |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
184 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
185 |
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
|
186 |
{ |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
187 |
switch (we->event) { |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
188 |
case WE_PAINT: |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
189 |
DrawTimetableWindow(w); |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
190 |
break; |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
191 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
192 |
case WE_CLICK: { |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
193 |
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
|
194 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
195 |
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
|
196 |
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
|
197 |
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
|
198 |
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
|
199 |
|
9218
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
200 |
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
|
201 |
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
|
202 |
|
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
|
203 |
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
|
204 |
/* 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
|
205 |
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
|
206 |
} else { |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
207 |
/* 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
|
208 |
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
|
209 |
} |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
210 |
} break; |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
211 |
|
9218
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
212 |
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
|
213 |
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
|
214 |
VehicleOrderID real = (selected + 1) / 2; |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
215 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
216 |
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
|
217 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
218 |
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
|
219 |
StringID current = STR_EMPTY; |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
220 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
221 |
if (order != NULL) { |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
222 |
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
|
223 |
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
|
224 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
225 |
if (time != 0) { |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
226 |
SetDParam(0, time); |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
227 |
current = STR_CONFIG_PATCHES_INT32; |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
228 |
} |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
229 |
} |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
230 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
231 |
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
|
232 |
} break; |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
233 |
|
9218
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
234 |
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
|
235 |
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
|
236 |
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
|
237 |
} break; |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
238 |
|
9218
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
239 |
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
|
240 |
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
|
241 |
break; |
7562
f6f62814907b
(svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents:
7553
diff
changeset
|
242 |
|
9218
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
243 |
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
|
244 |
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
|
245 |
break; |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
246 |
} |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
247 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
248 |
SetWindowDirty(w); |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
249 |
} break; |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
250 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
251 |
case WE_ON_EDIT_TEXT: { |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
252 |
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
|
253 |
|
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
|
254 |
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
|
255 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
256 |
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
|
257 |
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
|
258 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
259 |
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
|
260 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
261 |
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
|
262 |
} break; |
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 |
case WE_RESIZE: |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
265 |
/* 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
|
266 |
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
|
267 |
break; |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
268 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
269 |
} |
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 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
272 |
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
|
273 |
{ 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
|
274 |
{ 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
|
275 |
{ 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
|
276 |
{ 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
|
277 |
|
9218
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
278 |
{ 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
|
279 |
{ 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
|
280 |
|
9218
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
281 |
{ 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
|
282 |
|
9218
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
283 |
{ 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
|
284 |
{ 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
|
285 |
{ 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
|
286 |
{ 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
|
287 |
|
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
288 |
{ 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
|
289 |
{ 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
|
290 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
291 |
{ WIDGETS_END } |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
292 |
}; |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
293 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
294 |
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
|
295 |
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
|
296 |
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
|
297 |
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
|
298 |
_timetable_widgets, |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
299 |
TimetableWndProc |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
300 |
}; |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
301 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
302 |
void ShowTimetableWindow(const Vehicle *v) |
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 |
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
|
305 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
306 |
if (w != NULL) { |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
307 |
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
|
308 |
w->vscroll.cap = 8; |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
309 |
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
|
310 |
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
|
311 |
} |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
312 |
} |