author | rubidium |
Mon, 07 Apr 2008 08:59:04 +0000 | |
changeset 8848 | 635cb164edd4 |
parent 8843 | 45fdf630deaa |
child 8853 | 3266f0374302 |
permissions | -rw-r--r-- |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
1 |
/* $Id$ */ |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
2 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
3 |
/** @file timetable_gui.cpp */ |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
4 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
5 |
#include "stdafx.h" |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
6 |
#include "openttd.h" |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
7 |
#include "variables.h" |
8116
8da76dcb3287
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
8114
diff
changeset
|
8 |
#include "command_func.h" |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
9 |
#include "gui.h" |
8107
bb7deea89175
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8106
diff
changeset
|
10 |
#include "window_gui.h" |
bb7deea89175
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8106
diff
changeset
|
11 |
#include "textbuf_gui.h" |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
12 |
#include "cargotype.h" |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
13 |
#include "depot.h" |
8114
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8107
diff
changeset
|
14 |
#include "strings_func.h" |
8144
65cec0877b78
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents:
8140
diff
changeset
|
15 |
#include "vehicle_base.h" |
8214
971f861d5543
(svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium
parents:
8144
diff
changeset
|
16 |
#include "string_func.h" |
8224
c5a64d87cc54
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8214
diff
changeset
|
17 |
#include "gfx_func.h" |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8237
diff
changeset
|
18 |
#include "player_func.h" |
8270
e7c342f6b14c
(svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents:
8264
diff
changeset
|
19 |
#include "settings_type.h" |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
20 |
|
8264
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
21 |
#include "table/strings.h" |
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
22 |
|
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
23 |
enum TimetableViewWindowWidgets { |
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
24 |
TTV_WIDGET_CLOSEBOX = 0, |
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
25 |
TTV_CAPTION, |
8745
5bfa77abab47
(svn r12441) -Feature: open the time table when pressing the order button while pressing the CTRL key. Patch by Phil Sophus.
rubidium
parents:
8722
diff
changeset
|
26 |
TTV_ORDER_VIEW, |
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
27 |
TTV_STICKY, |
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
28 |
TTV_TIMETABLE_PANEL, |
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
29 |
TTV_SCROLLBAR, |
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
30 |
TTV_SUMMARY_PANEL, |
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
31 |
TTV_CHANGE_TIME, |
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
32 |
TTV_CLEAR_TIME, |
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
33 |
TTV_RESET_LATENESS, |
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
34 |
TTV_AUTOFILL, |
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
35 |
TTV_EMPTY, |
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
36 |
TTV_RESIZE, |
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
37 |
}; |
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
38 |
|
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
39 |
static int GetOrderFromTimetableWndPt(Window *w, int y, const Vehicle *v) |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
40 |
{ |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
41 |
/* |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
42 |
* Calculation description: |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
43 |
* 15 = 14 (w->widget[ORDER_WIDGET_ORDER_LIST].top) + 1 (frame-line) |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
44 |
* 10 = order text hight |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
45 |
*/ |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
46 |
int sel = (y - 15) / 10; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
47 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
48 |
if ((uint)sel >= w->vscroll.cap) return INVALID_ORDER; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
49 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
50 |
sel += w->vscroll.pos; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
51 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
52 |
return (sel <= v->num_orders * 2 && sel >= 0) ? sel : INVALID_ORDER; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
53 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
54 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
55 |
static inline void SetTimetableParams(int param1, int param2, uint32 time) |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
56 |
{ |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
57 |
if (_patches.timetable_in_ticks) { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
58 |
SetDParam(param1, STR_TIMETABLE_TICKS); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
59 |
SetDParam(param2, time); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
60 |
} else { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
61 |
SetDParam(param1, STR_TIMETABLE_DAYS); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
62 |
SetDParam(param2, time / DAY_TICKS); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
63 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
64 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
65 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
66 |
static void DrawTimetableWindow(Window *w) |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
67 |
{ |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
68 |
const Vehicle *v = GetVehicle(w->window_number); |
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
7997
diff
changeset
|
69 |
int selected = WP(w, order_d).sel; |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
70 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
71 |
SetVScrollCount(w, v->num_orders * 2); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
72 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
73 |
if (v->owner == _local_player) { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
74 |
if (selected == -1) { |
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
75 |
w->DisableWidget(TTV_CHANGE_TIME); |
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
76 |
w->DisableWidget(TTV_CLEAR_TIME); |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
77 |
} else if (selected % 2 == 1) { |
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
78 |
w->EnableWidget(TTV_CHANGE_TIME); |
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
79 |
w->EnableWidget(TTV_CLEAR_TIME); |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
80 |
} else { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
81 |
const Order *order = GetVehicleOrder(v, (selected + 1) / 2); |
8848
635cb164edd4
(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:
8843
diff
changeset
|
82 |
bool disable = order == NULL || !order->IsType(OT_GOTO_STATION) || (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION); |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
83 |
|
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
84 |
w->SetWidgetDisabledState(TTV_CHANGE_TIME, disable); |
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
85 |
w->SetWidgetDisabledState(TTV_CLEAR_TIME, disable); |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
86 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
87 |
|
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
88 |
w->EnableWidget(TTV_RESET_LATENESS); |
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
89 |
w->EnableWidget(TTV_AUTOFILL); |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
90 |
} else { |
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
91 |
w->DisableWidget(TTV_CHANGE_TIME); |
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
92 |
w->DisableWidget(TTV_CLEAR_TIME); |
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
93 |
w->DisableWidget(TTV_RESET_LATENESS); |
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
94 |
w->DisableWidget(TTV_AUTOFILL); |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
95 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
96 |
|
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
97 |
w->SetWidgetLoweredState(TTV_AUTOFILL, HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE)); |
7066
e5d16aa8d6ca
(svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents:
7057
diff
changeset
|
98 |
|
7049
0ebe47348074
(svn r10314) -Codechange: Refer to vehicle names by index
peter1138
parents:
6983
diff
changeset
|
99 |
SetDParam(0, v->index); |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
100 |
DrawWindowWidgets(w); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
101 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
102 |
int y = 15; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
103 |
int i = w->vscroll.pos; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
104 |
VehicleOrderID order_id = (i + 1) / 2; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
105 |
bool final_order = false; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
106 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
107 |
const Order *order = GetVehicleOrder(v, order_id); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
108 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
109 |
while (order != NULL) { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
110 |
/* Don't draw anything if it extends past the end of the window. */ |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
111 |
if (i - w->vscroll.pos >= w->vscroll.cap) break; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
112 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
113 |
if (i % 2 == 0) { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
114 |
SetDParam(2, STR_EMPTY); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
115 |
|
8836
f6f1ea3d7e93
(svn r12584) -Codechange: do not access the order type directly.
rubidium
parents:
8786
diff
changeset
|
116 |
switch (order->GetType()) { |
7312
9e89be4bc9a2
(svn r10664) -Codechange: simplify a small piece of code (skidd13)
truelight
parents:
7266
diff
changeset
|
117 |
case OT_DUMMY: |
9e89be4bc9a2
(svn r10664) -Codechange: simplify a small piece of code (skidd13)
truelight
parents:
7266
diff
changeset
|
118 |
SetDParam(0, STR_INVALID_ORDER); |
9e89be4bc9a2
(svn r10664) -Codechange: simplify a small piece of code (skidd13)
truelight
parents:
7266
diff
changeset
|
119 |
break; |
9e89be4bc9a2
(svn r10664) -Codechange: simplify a small piece of code (skidd13)
truelight
parents:
7266
diff
changeset
|
120 |
|
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
121 |
case OT_GOTO_STATION: |
8848
635cb164edd4
(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:
8843
diff
changeset
|
122 |
SetDParam(0, (order->GetNonStopType() != ONSF_STOP_EVERYWHERE) ? STR_880A_GO_NON_STOP_TO : STR_8806_GO_TO); |
8840
332412c2e9c1
(svn r12588) -Codechange: do not access the destination of an order directly.
rubidium
parents:
8836
diff
changeset
|
123 |
SetDParam(1, order->GetDestination()); |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
124 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
125 |
if (order->wait_time > 0) { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
126 |
SetDParam(2, STR_TIMETABLE_STAY_FOR); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
127 |
SetTimetableParams(3, 4, order->wait_time); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
128 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
129 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
130 |
break; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
131 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
132 |
case OT_GOTO_DEPOT: { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
133 |
StringID string = STR_EMPTY; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
134 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
135 |
if (v->type == VEH_AIRCRAFT) { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
136 |
string = STR_GO_TO_AIRPORT_HANGAR; |
8840
332412c2e9c1
(svn r12588) -Codechange: do not access the destination of an order directly.
rubidium
parents:
8836
diff
changeset
|
137 |
SetDParam(1, order->GetDestination()); |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
138 |
} else { |
8840
332412c2e9c1
(svn r12588) -Codechange: do not access the destination of an order directly.
rubidium
parents:
8836
diff
changeset
|
139 |
SetDParam(1, GetDepot(order->GetDestination())->town_index); |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
140 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
141 |
switch (v->type) { |
8848
635cb164edd4
(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:
8843
diff
changeset
|
142 |
case VEH_TRAIN: string = (order->GetNonStopType() != ONSF_STOP_EVERYWHERE) ? STR_880F_GO_NON_STOP_TO_TRAIN_DEPOT : STR_GO_TO_TRAIN_DEPOT; break; |
8424
c3477565c975
(svn r11994) -Codechange: Remove numbers from string names where the strings aren't present in TTD, since they don't correspond to either TTD's TextIDs or OpenTTD's StringIDs.
maedhros
parents:
8302
diff
changeset
|
143 |
case VEH_ROAD: string = STR_GO_TO_ROADVEH_DEPOT; break; |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
144 |
case VEH_SHIP: string = STR_GO_TO_SHIP_DEPOT; break; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
145 |
default: break; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
146 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
147 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
148 |
|
8843
45fdf630deaa
(svn r12593) -Codechange: hide Order's flags in most of the code.
rubidium
parents:
8840
diff
changeset
|
149 |
if (order->GetDepotOrderType() & OFB_SERVICE_IF_NEEDED) string++; /* service at */ |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
150 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
151 |
SetDParam(0, string); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
152 |
} break; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
153 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
154 |
case OT_GOTO_WAYPOINT: |
8848
635cb164edd4
(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:
8843
diff
changeset
|
155 |
SetDParam(0, (order->GetNonStopType() != ONSF_STOP_EVERYWHERE) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT); |
8840
332412c2e9c1
(svn r12588) -Codechange: do not access the destination of an order directly.
rubidium
parents:
8836
diff
changeset
|
156 |
SetDParam(1, order->GetDestination()); |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
157 |
break; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
158 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
159 |
default: break; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
160 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
161 |
|
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7341
diff
changeset
|
162 |
DrawString(2, y, STR_TIMETABLE_GO_TO, (i == selected) ? TC_WHITE : TC_BLACK); |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
163 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
164 |
order_id++; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
165 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
166 |
if (order_id >= v->num_orders) { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
167 |
order = GetVehicleOrder(v, 0); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
168 |
final_order = true; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
169 |
} else { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
170 |
order = order->next; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
171 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
172 |
} else { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
173 |
StringID string; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
174 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
175 |
if (order->travel_time == 0) { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
176 |
string = STR_TIMETABLE_TRAVEL_NOT_TIMETABLED; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
177 |
} else { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
178 |
SetTimetableParams(0, 1, order->travel_time); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
179 |
string = STR_TIMETABLE_TRAVEL_FOR; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
180 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
181 |
|
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7341
diff
changeset
|
182 |
DrawString(12, y, string, (i == selected) ? TC_WHITE : TC_BLACK); |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
183 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
184 |
if (final_order) break; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
185 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
186 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
187 |
i++; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
188 |
y += 10; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
189 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
190 |
|
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
191 |
y = w->widget[TTV_SUMMARY_PANEL].top + 1; |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
192 |
|
7073
ca7cb4b5c5e2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7066
diff
changeset
|
193 |
{ |
ca7cb4b5c5e2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7066
diff
changeset
|
194 |
uint total_time = 0; |
ca7cb4b5c5e2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7066
diff
changeset
|
195 |
bool complete = true; |
ca7cb4b5c5e2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7066
diff
changeset
|
196 |
|
ca7cb4b5c5e2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7066
diff
changeset
|
197 |
for (const Order *order = GetVehicleOrder(v, 0); order != NULL; order = order->next) { |
ca7cb4b5c5e2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7066
diff
changeset
|
198 |
total_time += order->travel_time + order->wait_time; |
ca7cb4b5c5e2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7066
diff
changeset
|
199 |
if (order->travel_time == 0) complete = false; |
8848
635cb164edd4
(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:
8843
diff
changeset
|
200 |
if (order->wait_time == 0 && order->IsType(OT_GOTO_STATION) && !(order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION)) complete = false; |
7073
ca7cb4b5c5e2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7066
diff
changeset
|
201 |
} |
ca7cb4b5c5e2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7066
diff
changeset
|
202 |
|
ca7cb4b5c5e2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7066
diff
changeset
|
203 |
if (total_time != 0) { |
ca7cb4b5c5e2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7066
diff
changeset
|
204 |
SetTimetableParams(0, 1, total_time); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7341
diff
changeset
|
205 |
DrawString(2, y, complete ? STR_TIMETABLE_TOTAL_TIME : STR_TIMETABLE_TOTAL_TIME_INCOMPLETE, TC_BLACK); |
7073
ca7cb4b5c5e2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7066
diff
changeset
|
206 |
} |
ca7cb4b5c5e2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7066
diff
changeset
|
207 |
} |
ca7cb4b5c5e2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7066
diff
changeset
|
208 |
y += 10; |
ca7cb4b5c5e2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7066
diff
changeset
|
209 |
|
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
210 |
if (v->lateness_counter == 0 || (!_patches.timetable_in_ticks && v->lateness_counter / DAY_TICKS == 0)) { |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7341
diff
changeset
|
211 |
DrawString(2, y, STR_TIMETABLE_STATUS_ON_TIME, TC_BLACK); |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
212 |
} else { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
213 |
SetTimetableParams(0, 1, abs(v->lateness_counter)); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7341
diff
changeset
|
214 |
DrawString(2, y, v->lateness_counter < 0 ? STR_TIMETABLE_STATUS_EARLY : STR_TIMETABLE_STATUS_LATE, TC_BLACK); |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
215 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
216 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
217 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
218 |
static inline uint32 PackTimetableArgs(const Vehicle *v, uint selected) |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
219 |
{ |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
220 |
uint order_number = (selected + 1) / 2; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
221 |
uint is_journey = (selected % 2 == 1) ? 1 : 0; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
222 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
223 |
if (order_number >= v->num_orders) order_number = 0; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
224 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
225 |
return v->index | (order_number << 16) | (is_journey << 24); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
226 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
227 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
228 |
static void TimetableWndProc(Window *w, WindowEvent *we) |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
229 |
{ |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
230 |
switch (we->event) { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
231 |
case WE_PAINT: |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
232 |
DrawTimetableWindow(w); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
233 |
break; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
234 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
235 |
case WE_CLICK: { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
236 |
const Vehicle *v = GetVehicle(w->window_number); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
237 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
238 |
switch (we->we.click.widget) { |
8745
5bfa77abab47
(svn r12441) -Feature: open the time table when pressing the order button while pressing the CTRL key. Patch by Phil Sophus.
rubidium
parents:
8722
diff
changeset
|
239 |
case TTV_ORDER_VIEW: /* Order view button */ |
5bfa77abab47
(svn r12441) -Feature: open the time table when pressing the order button while pressing the CTRL key. Patch by Phil Sophus.
rubidium
parents:
8722
diff
changeset
|
240 |
ShowOrdersWindow(v); |
5bfa77abab47
(svn r12441) -Feature: open the time table when pressing the order button while pressing the CTRL key. Patch by Phil Sophus.
rubidium
parents:
8722
diff
changeset
|
241 |
break; |
5bfa77abab47
(svn r12441) -Feature: open the time table when pressing the order button while pressing the CTRL key. Patch by Phil Sophus.
rubidium
parents:
8722
diff
changeset
|
242 |
|
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
243 |
case TTV_TIMETABLE_PANEL: { /* Main panel. */ |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
244 |
int selected = GetOrderFromTimetableWndPt(w, we->we.click.pt.y, v); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
245 |
|
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
7997
diff
changeset
|
246 |
if (selected == INVALID_ORDER || selected == WP(w, order_d).sel) { |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
247 |
/* Deselect clicked order */ |
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
7997
diff
changeset
|
248 |
WP(w, order_d).sel = -1; |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
249 |
} else { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
250 |
/* Select clicked order */ |
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
7997
diff
changeset
|
251 |
WP(w, order_d).sel = selected; |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
252 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
253 |
} break; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
254 |
|
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
255 |
case TTV_CHANGE_TIME: { /* "Wait For" button. */ |
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
7997
diff
changeset
|
256 |
int selected = WP(w, order_d).sel; |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
257 |
VehicleOrderID real = (selected + 1) / 2; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
258 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
259 |
if (real >= v->num_orders) real = 0; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
260 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
261 |
const Order *order = GetVehicleOrder(v, real); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
262 |
StringID current = STR_EMPTY; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
263 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
264 |
if (order != NULL) { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
265 |
uint time = (selected % 2 == 1) ? order->travel_time : order->wait_time; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
266 |
if (!_patches.timetable_in_ticks) time /= DAY_TICKS; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
267 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
268 |
if (time != 0) { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
269 |
SetDParam(0, time); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
270 |
current = STR_CONFIG_PATCHES_INT32; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
271 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
272 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
273 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
274 |
ShowQueryString(current, STR_TIMETABLE_CHANGE_TIME, 31, 150, w, CS_NUMERAL); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
275 |
} break; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
276 |
|
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
277 |
case TTV_CLEAR_TIME: { /* Clear waiting time button. */ |
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
7997
diff
changeset
|
278 |
uint32 p1 = PackTimetableArgs(v, WP(w, order_d).sel); |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
279 |
DoCommandP(0, p1, 0, NULL, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE)); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
280 |
} break; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
281 |
|
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
282 |
case TTV_RESET_LATENESS: /* Reset the vehicle's late counter. */ |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
283 |
DoCommandP(0, v->index, 0, NULL, CMD_SET_VEHICLE_ON_TIME | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE)); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
284 |
break; |
7066
e5d16aa8d6ca
(svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents:
7057
diff
changeset
|
285 |
|
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
286 |
case TTV_AUTOFILL: /* Autofill the timetable. */ |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7824
diff
changeset
|
287 |
DoCommandP(0, v->index, HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE) ? 0 : 1, NULL, CMD_AUTOFILL_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE)); |
7066
e5d16aa8d6ca
(svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents:
7057
diff
changeset
|
288 |
break; |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
289 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
290 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
291 |
SetWindowDirty(w); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
292 |
} break; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
293 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
294 |
case WE_ON_EDIT_TEXT: { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
295 |
const Vehicle *v = GetVehicle(w->window_number); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
296 |
|
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
7997
diff
changeset
|
297 |
uint32 p1 = PackTimetableArgs(v, WP(w, order_d).sel); |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
298 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
299 |
uint64 time = StrEmpty(we->we.edittext.str) ? 0 : strtoul(we->we.edittext.str, NULL, 10); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
300 |
if (!_patches.timetable_in_ticks) time *= DAY_TICKS; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
301 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
302 |
uint32 p2 = minu(time, MAX_UVALUE(uint16)); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
303 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
304 |
DoCommandP(0, p1, p2, NULL, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE)); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
305 |
} break; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
306 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
307 |
case WE_RESIZE: |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
308 |
/* Update the scroll + matrix */ |
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
309 |
w->vscroll.cap = (w->widget[TTV_TIMETABLE_PANEL].bottom - w->widget[TTV_TIMETABLE_PANEL].top) / 10; |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
310 |
break; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
311 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
312 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
313 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
314 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
315 |
static const Widget _timetable_widgets[] = { |
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
316 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // TTV_WIDGET_CLOSEBOX |
8745
5bfa77abab47
(svn r12441) -Feature: open the time table when pressing the order button while pressing the CTRL key. Patch by Phil Sophus.
rubidium
parents:
8722
diff
changeset
|
317 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 326, 0, 13, STR_TIMETABLE_TITLE, STR_018C_WINDOW_TITLE_DRAG_THIS}, // TTV_CAPTION |
5bfa77abab47
(svn r12441) -Feature: open the time table when pressing the order button while pressing the CTRL key. Patch by Phil Sophus.
rubidium
parents:
8722
diff
changeset
|
318 |
{ WWT_PUSHTXTBTN, RESIZE_LR, 14, 327, 387, 0, 13, STR_ORDER_VIEW, STR_ORDER_VIEW_TOOLTIP}, // TTV_ORDER_VIEW |
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
319 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 388, 399, 0, 13, STR_NULL, STR_STICKY_BUTTON}, // TTV_STICKY |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
320 |
|
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
321 |
{ WWT_PANEL, RESIZE_RB, 14, 0, 387, 14, 95, STR_NULL, STR_TIMETABLE_TOOLTIP}, // TTV_TIMETABLE_PANEL |
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
322 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 388, 399, 14, 95, STR_NULL, STR_0190_SCROLL_BAR_SCROLLS_LIST}, // TTV_SCROLLBAR |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
323 |
|
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
324 |
{ WWT_PANEL, RESIZE_RTB, 14, 0, 399, 96, 117, STR_NULL, STR_NULL}, // TTV_SUMMARY_PANEL |
7057
01a2a637716d
(svn r10322) -Codechange: Make the timetable window smaller by default so it doesn't take up so much space on small resolutions.
maedhros
parents:
7049
diff
changeset
|
325 |
|
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
326 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 109, 118, 129, STR_TIMETABLE_CHANGE_TIME, STR_TIMETABLE_WAIT_TIME_TOOLTIP}, // TTV_CHANGE_TIME |
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
327 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 110, 219, 118, 129, STR_CLEAR_TIME, STR_TIMETABLE_CLEAR_TIME_TOOLTIP}, // TTV_CLEAR_TIME |
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
328 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 220, 337, 118, 129, STR_RESET_LATENESS, STR_TIMETABLE_RESET_LATENESS_TOOLTIP}, // TTV_RESET_LATENESS |
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
329 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 338, 387, 118, 129, STR_TIMETABLE_AUTOFILL, STR_TIMETABLE_AUTOFILL_TOOLTIP}, // TTV_AUTOFILL |
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
330 |
|
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
331 |
{ WWT_PANEL, RESIZE_RTB, 14, 388, 387, 118, 129, STR_NULL, STR_NULL}, // TTV_EMPTY |
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
332 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 388, 399, 118, 129, STR_NULL, STR_RESIZE_BUTTON}, // TTV_RESIZE |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
333 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
334 |
{ WIDGETS_END } |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
335 |
}; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
336 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
337 |
static const WindowDesc _timetable_desc = { |
7341
02515d0d4ced
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7312
diff
changeset
|
338 |
WDP_AUTO, WDP_AUTO, 400, 130, 400, 130, |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
339 |
WC_VEHICLE_TIMETABLE, WC_VEHICLE_VIEW, |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
340 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
341 |
_timetable_widgets, |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
342 |
TimetableWndProc |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
343 |
}; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
344 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
345 |
void ShowTimetableWindow(const Vehicle *v) |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
346 |
{ |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
347 |
Window *w = AllocateWindowDescFront(&_timetable_desc, v->index); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
348 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
349 |
if (w != NULL) { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
350 |
w->caption_color = v->owner; |
7057
01a2a637716d
(svn r10322) -Codechange: Make the timetable window smaller by default so it doesn't take up so much space on small resolutions.
maedhros
parents:
7049
diff
changeset
|
351 |
w->vscroll.cap = 8; |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
352 |
w->resize.step_height = 10; |
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
7997
diff
changeset
|
353 |
WP(w, order_d).sel = -1; |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
354 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
355 |
} |