Mercurial > hg > openttd
annotate src/timetable_gui.cpp @ 7276:09ed8c0bd0ed draft
(svn r10606) -Fix (r8826): plural and single cargo names were mixed up.
author | peter1138 <peter1138@openttd.org> |
---|---|
date | Tue, 17 Jul 2007 20:32:27 +0000 |
parents | 550b96f71f7f |
children | d985b39f0757 |
rev | line source |
---|---|
6981
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
1 /* $Id$ */ |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
2 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
3 /** @file timetable_gui.cpp */ |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
4 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
5 #include "stdafx.h" |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
6 #include "openttd.h" |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
7 #include "functions.h" |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
8 #include "variables.h" |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
9 #include "table/strings.h" |
7266
550b96f71f7f
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium <rubidium@openttd.org>
parents:
7073
diff
changeset
|
10 #include "strings.h" |
6981
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
11 #include "command.h" |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
12 #include "date.h" |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
13 #include "engine.h" |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
14 #include "gui.h" |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
15 #include "string.h" |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
16 #include "window.h" |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
17 #include "vehicle.h" |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
18 #include "cargotype.h" |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
19 #include "depot.h" |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
20 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
21 static int GetOrderFromTimetableWndPt(Window *w, int y, const Vehicle *v) |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
22 { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
23 /* |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
24 * Calculation description: |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
25 * 15 = 14 (w->widget[ORDER_WIDGET_ORDER_LIST].top) + 1 (frame-line) |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
26 * 10 = order text hight |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
27 */ |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
28 int sel = (y - 15) / 10; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
29 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
30 if ((uint)sel >= w->vscroll.cap) return INVALID_ORDER; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
31 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
32 sel += w->vscroll.pos; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
33 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
34 return (sel <= v->num_orders * 2 && sel >= 0) ? sel : INVALID_ORDER; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
35 } |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
36 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
37 static inline void SetTimetableParams(int param1, int param2, uint32 time) |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
38 { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
39 if (_patches.timetable_in_ticks) { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
40 SetDParam(param1, STR_TIMETABLE_TICKS); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
41 SetDParam(param2, time); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
42 } else { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
43 SetDParam(param1, STR_TIMETABLE_DAYS); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
44 SetDParam(param2, time / DAY_TICKS); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
45 } |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
46 } |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
47 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
48 static void DrawTimetableWindow(Window *w) |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
49 { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
50 const Vehicle *v = GetVehicle(w->window_number); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
51 int selected = WP(w,order_d).sel; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
52 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
53 SetVScrollCount(w, v->num_orders * 2); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
54 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
55 if (v->owner == _local_player) { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
56 if (selected == -1) { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
57 DisableWindowWidget(w, 6); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
58 DisableWindowWidget(w, 7); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
59 } else if (selected % 2 == 1) { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
60 EnableWindowWidget(w, 6); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
61 EnableWindowWidget(w, 7); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
62 } else { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
63 const Order *order = GetVehicleOrder(v, (selected + 1) / 2); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
64 bool disable = order == NULL || order->type != OT_GOTO_STATION || (_patches.new_nonstop && (order->flags & OF_NON_STOP)); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
65 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
66 SetWindowWidgetDisabledState(w, 6, disable); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
67 SetWindowWidgetDisabledState(w, 7, disable); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
68 } |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
69 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
70 EnableWindowWidget(w, 8); |
7066
bd6373f5acf4
(svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros <maedhros@openttd.org>
parents:
7057
diff
changeset
|
71 EnableWindowWidget(w, 9); |
6981
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
72 } else { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
73 DisableWindowWidget(w, 6); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
74 DisableWindowWidget(w, 7); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
75 DisableWindowWidget(w, 8); |
7066
bd6373f5acf4
(svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros <maedhros@openttd.org>
parents:
7057
diff
changeset
|
76 DisableWindowWidget(w, 9); |
6981
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
77 } |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
78 |
7066
bd6373f5acf4
(svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros <maedhros@openttd.org>
parents:
7057
diff
changeset
|
79 SetWindowWidgetLoweredState(w, 9, HASBIT(v->vehicle_flags, VF_AUTOFILL_TIMETABLE)); |
bd6373f5acf4
(svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros <maedhros@openttd.org>
parents:
7057
diff
changeset
|
80 |
7049
59b52eeff08b
(svn r10314) -Codechange: Refer to vehicle names by index
peter1138 <peter1138@openttd.org>
parents:
6983
diff
changeset
|
81 SetDParam(0, v->index); |
6981
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
82 DrawWindowWidgets(w); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
83 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
84 int y = 15; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
85 int i = w->vscroll.pos; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
86 VehicleOrderID order_id = (i + 1) / 2; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
87 bool final_order = false; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
88 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
89 const Order *order = GetVehicleOrder(v, order_id); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
90 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
91 while (order != NULL) { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
92 /* Don't draw anything if it extends past the end of the window. */ |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
93 if (i - w->vscroll.pos >= w->vscroll.cap) break; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
94 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
95 if (i % 2 == 0) { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
96 SetDParam(2, STR_EMPTY); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
97 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
98 switch (order->type) { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
99 case OT_GOTO_STATION: |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
100 SetDParam(0, (order->flags & OF_NON_STOP) ? STR_880C_GO_NON_STOP_TO : STR_8806_GO_TO); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
101 SetDParam(1, order->dest); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
102 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
103 if (order->wait_time > 0) { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
104 SetDParam(2, STR_TIMETABLE_STAY_FOR); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
105 SetTimetableParams(3, 4, order->wait_time); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
106 } |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
107 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
108 break; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
109 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
110 case OT_GOTO_DEPOT: { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
111 StringID string = STR_EMPTY; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
112 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
113 if (v->type == VEH_AIRCRAFT) { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
114 string = STR_GO_TO_AIRPORT_HANGAR; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
115 SetDParam(1, order->dest); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
116 } else { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
117 SetDParam(1, GetDepot(order->dest)->town_index); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
118 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
119 switch (v->type) { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
120 case VEH_TRAIN: string = (order->flags & OF_NON_STOP) ? STR_880F_GO_NON_STOP_TO_TRAIN_DEPOT : STR_GO_TO_TRAIN_DEPOT; break; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
121 case VEH_ROAD: string = STR_9038_GO_TO_ROADVEH_DEPOT; break; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
122 case VEH_SHIP: string = STR_GO_TO_SHIP_DEPOT; break; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
123 default: break; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
124 } |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
125 } |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
126 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
127 if (order->flags & OF_FULL_LOAD) string++; // Service at orders |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
128 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
129 SetDParam(0, string); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
130 } break; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
131 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
132 case OT_GOTO_WAYPOINT: |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
133 SetDParam(0, (order->flags & OF_NON_STOP) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
134 SetDParam(1, order->dest); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
135 break; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
136 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
137 default: break; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
138 } |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
139 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
140 byte colour = (i == selected) ? 0xC : 0x10; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
141 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
142 if (order->type != OT_DUMMY) { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
143 DrawString(2, y, STR_TIMETABLE_GO_TO, colour); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
144 } else { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
145 SetDParam(0, STR_INVALID_ORDER); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
146 DrawString(2, y, STR_TIMETABLE_GO_TO, colour); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
147 } |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
148 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
149 order_id++; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
150 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
151 if (order_id >= v->num_orders) { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
152 order = GetVehicleOrder(v, 0); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
153 final_order = true; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
154 } else { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
155 order = order->next; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
156 } |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
157 } else { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
158 StringID string; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
159 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
160 if (order->travel_time == 0) { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
161 string = STR_TIMETABLE_TRAVEL_NOT_TIMETABLED; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
162 } else { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
163 SetTimetableParams(0, 1, order->travel_time); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
164 string = STR_TIMETABLE_TRAVEL_FOR; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
165 } |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
166 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
167 byte colour = (i == selected) ? 0xC : 0x10; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
168 DrawString(12, y, string, colour); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
169 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
170 if (final_order) break; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
171 } |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
172 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
173 i++; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
174 y += 10; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
175 } |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
176 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
177 y = w->widget[5].top + 1; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
178 |
7073
ea9c3ceb515f
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros <maedhros@openttd.org>
parents:
7066
diff
changeset
|
179 { |
ea9c3ceb515f
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros <maedhros@openttd.org>
parents:
7066
diff
changeset
|
180 uint total_time = 0; |
ea9c3ceb515f
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros <maedhros@openttd.org>
parents:
7066
diff
changeset
|
181 bool complete = true; |
ea9c3ceb515f
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros <maedhros@openttd.org>
parents:
7066
diff
changeset
|
182 |
ea9c3ceb515f
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros <maedhros@openttd.org>
parents:
7066
diff
changeset
|
183 for (const Order *order = GetVehicleOrder(v, 0); order != NULL; order = order->next) { |
ea9c3ceb515f
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros <maedhros@openttd.org>
parents:
7066
diff
changeset
|
184 total_time += order->travel_time + order->wait_time; |
ea9c3ceb515f
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros <maedhros@openttd.org>
parents:
7066
diff
changeset
|
185 if (order->travel_time == 0) complete = false; |
ea9c3ceb515f
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros <maedhros@openttd.org>
parents:
7066
diff
changeset
|
186 if (order->wait_time == 0 && order->type == OT_GOTO_STATION && !(_patches.new_nonstop && (order->flags & OF_NON_STOP))) complete = false; |
ea9c3ceb515f
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros <maedhros@openttd.org>
parents:
7066
diff
changeset
|
187 } |
ea9c3ceb515f
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros <maedhros@openttd.org>
parents:
7066
diff
changeset
|
188 |
ea9c3ceb515f
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros <maedhros@openttd.org>
parents:
7066
diff
changeset
|
189 if (total_time != 0) { |
ea9c3ceb515f
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros <maedhros@openttd.org>
parents:
7066
diff
changeset
|
190 SetTimetableParams(0, 1, total_time); |
ea9c3ceb515f
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros <maedhros@openttd.org>
parents:
7066
diff
changeset
|
191 DrawString(2, y, complete ? STR_TIMETABLE_TOTAL_TIME : STR_TIMETABLE_TOTAL_TIME_INCOMPLETE, 0x10); |
ea9c3ceb515f
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros <maedhros@openttd.org>
parents:
7066
diff
changeset
|
192 } |
ea9c3ceb515f
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros <maedhros@openttd.org>
parents:
7066
diff
changeset
|
193 } |
ea9c3ceb515f
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros <maedhros@openttd.org>
parents:
7066
diff
changeset
|
194 y += 10; |
ea9c3ceb515f
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros <maedhros@openttd.org>
parents:
7066
diff
changeset
|
195 |
6981
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
196 if (v->lateness_counter == 0 || (!_patches.timetable_in_ticks && v->lateness_counter / DAY_TICKS == 0)) { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
197 DrawString(2, y, STR_TIMETABLE_STATUS_ON_TIME, 0x10); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
198 } else { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
199 SetTimetableParams(0, 1, abs(v->lateness_counter)); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
200 DrawString(2, y, v->lateness_counter < 0 ? STR_TIMETABLE_STATUS_EARLY : STR_TIMETABLE_STATUS_LATE, 0x10); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
201 } |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
202 } |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
203 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
204 static inline uint32 PackTimetableArgs(const Vehicle *v, uint selected) |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
205 { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
206 uint order_number = (selected + 1) / 2; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
207 uint is_journey = (selected % 2 == 1) ? 1 : 0; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
208 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
209 if (order_number >= v->num_orders) order_number = 0; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
210 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
211 return v->index | (order_number << 16) | (is_journey << 24); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
212 } |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
213 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
214 static void TimetableWndProc(Window *w, WindowEvent *we) |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
215 { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
216 switch (we->event) { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
217 case WE_PAINT: |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
218 DrawTimetableWindow(w); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
219 break; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
220 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
221 case WE_CLICK: { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
222 const Vehicle *v = GetVehicle(w->window_number); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
223 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
224 switch (we->we.click.widget) { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
225 case 3: { /* Main panel. */ |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
226 int selected = GetOrderFromTimetableWndPt(w, we->we.click.pt.y, v); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
227 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
228 if (selected == INVALID_ORDER || selected == WP(w,order_d).sel) { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
229 /* Deselect clicked order */ |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
230 WP(w,order_d).sel = -1; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
231 } else { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
232 /* Select clicked order */ |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
233 WP(w,order_d).sel = selected; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
234 } |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
235 } break; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
236 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
237 case 6: { /* "Wait For" button. */ |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
238 int selected = WP(w,order_d).sel; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
239 VehicleOrderID real = (selected + 1) / 2; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
240 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
241 if (real >= v->num_orders) real = 0; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
242 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
243 const Order *order = GetVehicleOrder(v, real); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
244 StringID current = STR_EMPTY; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
245 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
246 if (order != NULL) { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
247 uint time = (selected % 2 == 1) ? order->travel_time : order->wait_time; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
248 if (!_patches.timetable_in_ticks) time /= DAY_TICKS; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
249 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
250 if (time != 0) { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
251 SetDParam(0, time); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
252 current = STR_CONFIG_PATCHES_INT32; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
253 } |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
254 } |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
255 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
256 ShowQueryString(current, STR_TIMETABLE_CHANGE_TIME, 31, 150, w, CS_NUMERAL); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
257 } break; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
258 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
259 case 7: { /* Clear waiting time button. */ |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
260 uint32 p1 = PackTimetableArgs(v, WP(w,order_d).sel); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
261 DoCommandP(0, p1, 0, NULL, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE)); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
262 } break; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
263 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
264 case 8: /* Reset the vehicle's late counter. */ |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
265 DoCommandP(0, v->index, 0, NULL, CMD_SET_VEHICLE_ON_TIME | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE)); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
266 break; |
7066
bd6373f5acf4
(svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros <maedhros@openttd.org>
parents:
7057
diff
changeset
|
267 |
bd6373f5acf4
(svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros <maedhros@openttd.org>
parents:
7057
diff
changeset
|
268 case 9: /* Autofill the timetable. */ |
bd6373f5acf4
(svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros <maedhros@openttd.org>
parents:
7057
diff
changeset
|
269 DoCommandP(0, v->index, HASBIT(v->vehicle_flags, VF_AUTOFILL_TIMETABLE) ? 0 : 1, NULL, CMD_AUTOFILL_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE)); |
bd6373f5acf4
(svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros <maedhros@openttd.org>
parents:
7057
diff
changeset
|
270 break; |
6981
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
271 } |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
272 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
273 SetWindowDirty(w); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
274 } break; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
275 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
276 case WE_ON_EDIT_TEXT: { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
277 const Vehicle *v = GetVehicle(w->window_number); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
278 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
279 uint32 p1 = PackTimetableArgs(v, WP(w,order_d).sel); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
280 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
281 uint64 time = StrEmpty(we->we.edittext.str) ? 0 : strtoul(we->we.edittext.str, NULL, 10); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
282 if (!_patches.timetable_in_ticks) time *= DAY_TICKS; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
283 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
284 uint32 p2 = minu(time, MAX_UVALUE(uint16)); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
285 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
286 DoCommandP(0, p1, p2, NULL, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE)); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
287 } break; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
288 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
289 case WE_RESIZE: |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
290 /* Update the scroll + matrix */ |
6982
27868bc20b41
(svn r10238) -Fix (r10236): Resizing the timetable window caused it to think it could only show one line at a time.
maedhros <maedhros@openttd.org>
parents:
6981
diff
changeset
|
291 w->vscroll.cap = (w->widget[3].bottom - w->widget[3].top) / 10; |
6981
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
292 break; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
293 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
294 } |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
295 } |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
296 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
297 static const Widget _timetable_widgets[] = { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
298 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7066
bd6373f5acf4
(svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros <maedhros@openttd.org>
parents:
7057
diff
changeset
|
299 { WWT_CAPTION, RESIZE_RIGHT, 14, 11, 387, 0, 13, STR_TIMETABLE_TITLE, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
bd6373f5acf4
(svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros <maedhros@openttd.org>
parents:
7057
diff
changeset
|
300 { WWT_STICKYBOX, RESIZE_LR, 14, 388, 399, 0, 13, STR_NULL, STR_STICKY_BUTTON}, |
6981
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
301 |
7066
bd6373f5acf4
(svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros <maedhros@openttd.org>
parents:
7057
diff
changeset
|
302 { WWT_PANEL, RESIZE_RB, 14, 0, 387, 14, 95, STR_NULL, STR_TIMETABLE_TOOLTIP}, |
bd6373f5acf4
(svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros <maedhros@openttd.org>
parents:
7057
diff
changeset
|
303 { WWT_SCROLLBAR, RESIZE_LRB, 14, 388, 399, 14, 95, STR_NULL, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
6981
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
304 |
7073
ea9c3ceb515f
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros <maedhros@openttd.org>
parents:
7066
diff
changeset
|
305 { WWT_PANEL, RESIZE_RTB, 14, 0, 399, 96, 117, STR_NULL, STR_NULL}, |
6981
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
306 |
7073
ea9c3ceb515f
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros <maedhros@openttd.org>
parents:
7066
diff
changeset
|
307 { WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 109, 118, 129, STR_TIMETABLE_CHANGE_TIME, STR_TIMETABLE_WAIT_TIME_TOOLTIP}, |
ea9c3ceb515f
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros <maedhros@openttd.org>
parents:
7066
diff
changeset
|
308 { WWT_PUSHTXTBTN, RESIZE_TB, 14, 110, 219, 118, 129, STR_CLEAR_TIME, STR_TIMETABLE_CLEAR_TIME_TOOLTIP}, |
ea9c3ceb515f
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros <maedhros@openttd.org>
parents:
7066
diff
changeset
|
309 { WWT_PUSHTXTBTN, RESIZE_TB, 14, 220, 337, 118, 129, STR_RESET_LATENESS, STR_TIMETABLE_RESET_LATENESS_TOOLTIP}, |
ea9c3ceb515f
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros <maedhros@openttd.org>
parents:
7066
diff
changeset
|
310 { WWT_PUSHTXTBTN, RESIZE_TB, 14, 338, 387, 118, 129, STR_TIMETABLE_AUTOFILL, STR_TIMETABLE_AUTOFILL_TOOLTIP}, |
6981
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
311 |
7073
ea9c3ceb515f
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros <maedhros@openttd.org>
parents:
7066
diff
changeset
|
312 { WWT_PANEL, RESIZE_RTB, 14, 388, 387, 118, 129, STR_NULL, STR_NULL}, |
ea9c3ceb515f
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros <maedhros@openttd.org>
parents:
7066
diff
changeset
|
313 { WWT_RESIZEBOX, RESIZE_LRTB, 14, 388, 399, 118, 129, STR_NULL, STR_RESIZE_BUTTON}, |
6981
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
314 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
315 { WIDGETS_END } |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
316 }; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
317 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
318 static const WindowDesc _timetable_desc = { |
7073
ea9c3ceb515f
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros <maedhros@openttd.org>
parents:
7066
diff
changeset
|
319 WDP_AUTO, WDP_AUTO, 400, 130, |
6981
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
320 WC_VEHICLE_TIMETABLE, WC_VEHICLE_VIEW, |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
321 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
322 _timetable_widgets, |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
323 TimetableWndProc |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
324 }; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
325 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
326 void ShowTimetableWindow(const Vehicle *v) |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
327 { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
328 Window *w = AllocateWindowDescFront(&_timetable_desc, v->index); |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
329 |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
330 if (w != NULL) { |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
331 w->caption_color = v->owner; |
7057
9120898eaf3b
(svn r10322) -Codechange: Make the timetable window smaller by default so it doesn't take up so much space on small resolutions.
maedhros <maedhros@openttd.org>
parents:
7049
diff
changeset
|
332 w->vscroll.cap = 8; |
6981
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
333 w->resize.step_height = 10; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
334 WP(w,order_d).sel = -1; |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
335 } |
ba2c96d43e77
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros <maedhros@openttd.org>
parents:
diff
changeset
|
336 } |