author | rubidium |
Tue, 06 May 2008 22:08:18 +0000 | |
changeset 9116 | f2491d3c321b |
parent 9111 | 48ce04029fe4 |
child 9143 | 029e126e3439 |
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 |
|
9111
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
8962
diff
changeset
|
3 |
/** @file timetable_gui.cpp GUI for time tabling. */ |
6981
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" |
8114
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8107
diff
changeset
|
13 |
#include "strings_func.h" |
8144
65cec0877b78
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents:
8140
diff
changeset
|
14 |
#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
|
15 |
#include "string_func.h" |
8224
c5a64d87cc54
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8214
diff
changeset
|
16 |
#include "gfx_func.h" |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8237
diff
changeset
|
17 |
#include "player_func.h" |
8929
ebb6e864b545
(svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents:
8903
diff
changeset
|
18 |
#include "order_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 |
|
8896
8ffef4030fe1
(svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
rubidium
parents:
8894
diff
changeset
|
39 |
struct timetable_d { |
8ffef4030fe1
(svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
rubidium
parents:
8894
diff
changeset
|
40 |
int sel; |
8ffef4030fe1
(svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
rubidium
parents:
8894
diff
changeset
|
41 |
}; |
8ffef4030fe1
(svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
rubidium
parents:
8894
diff
changeset
|
42 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(timetable_d)); |
8ffef4030fe1
(svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
rubidium
parents:
8894
diff
changeset
|
43 |
|
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
44 |
static int GetOrderFromTimetableWndPt(Window *w, int y, const Vehicle *v) |
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 |
/* |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
47 |
* Calculation description: |
8896
8ffef4030fe1
(svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
rubidium
parents:
8894
diff
changeset
|
48 |
* 15 = 14 (w->widget[TTV_ORDER_VIEW].top) + 1 (frame-line) |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
49 |
* 10 = order text hight |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
50 |
*/ |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
51 |
int sel = (y - 15) / 10; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
52 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
53 |
if ((uint)sel >= w->vscroll.cap) return INVALID_ORDER; |
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 |
sel += w->vscroll.pos; |
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 |
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
|
58 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
59 |
|
8929
ebb6e864b545
(svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents:
8903
diff
changeset
|
60 |
void SetTimetableParams(int param1, int param2, uint32 time) |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
61 |
{ |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
62 |
if (_patches.timetable_in_ticks) { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
63 |
SetDParam(param1, STR_TIMETABLE_TICKS); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
64 |
SetDParam(param2, time); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
65 |
} else { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
66 |
SetDParam(param1, STR_TIMETABLE_DAYS); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
67 |
SetDParam(param2, time / DAY_TICKS); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
68 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
69 |
} |
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 |
static void DrawTimetableWindow(Window *w) |
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 |
const Vehicle *v = GetVehicle(w->window_number); |
8896
8ffef4030fe1
(svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
rubidium
parents:
8894
diff
changeset
|
74 |
int selected = WP(w, timetable_d).sel; |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
75 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
76 |
SetVScrollCount(w, v->num_orders * 2); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
77 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
78 |
if (v->owner == _local_player) { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
79 |
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
|
80 |
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
|
81 |
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
|
82 |
} 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
|
83 |
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
|
84 |
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
|
85 |
} else { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
86 |
const Order *order = GetVehicleOrder(v, (selected + 1) / 2); |
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
|
87 |
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
|
88 |
|
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
89 |
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
|
90 |
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
|
91 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
92 |
|
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
93 |
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
|
94 |
w->EnableWidget(TTV_AUTOFILL); |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
95 |
} else { |
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
96 |
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
|
97 |
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
|
98 |
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
|
99 |
w->DisableWidget(TTV_AUTOFILL); |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
100 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
101 |
|
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
102 |
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
|
103 |
|
7049
0ebe47348074
(svn r10314) -Codechange: Refer to vehicle names by index
peter1138
parents:
6983
diff
changeset
|
104 |
SetDParam(0, v->index); |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
105 |
DrawWindowWidgets(w); |
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 |
int y = 15; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
108 |
int i = w->vscroll.pos; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
109 |
VehicleOrderID order_id = (i + 1) / 2; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
110 |
bool final_order = false; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
111 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
112 |
const Order *order = GetVehicleOrder(v, order_id); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
113 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
114 |
while (order != NULL) { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
115 |
/* Don't draw anything if it extends past the end of the window. */ |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
116 |
if (i - w->vscroll.pos >= w->vscroll.cap) break; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
117 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
118 |
if (i % 2 == 0) { |
8929
ebb6e864b545
(svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents:
8903
diff
changeset
|
119 |
DrawOrderString(v, order, order_id, y, i == selected, true); |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
120 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
121 |
order_id++; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
122 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
123 |
if (order_id >= v->num_orders) { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
124 |
order = GetVehicleOrder(v, 0); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
125 |
final_order = true; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
126 |
} else { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
127 |
order = order->next; |
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 |
} else { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
130 |
StringID string; |
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 |
if (order->travel_time == 0) { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
133 |
string = STR_TIMETABLE_TRAVEL_NOT_TIMETABLED; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
134 |
} else { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
135 |
SetTimetableParams(0, 1, order->travel_time); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
136 |
string = STR_TIMETABLE_TRAVEL_FOR; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
137 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
138 |
|
8929
ebb6e864b545
(svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents:
8903
diff
changeset
|
139 |
DrawString(22, 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
|
140 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
141 |
if (final_order) break; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
142 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
143 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
144 |
i++; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
145 |
y += 10; |
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 |
|
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
148 |
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
|
149 |
|
7073
ca7cb4b5c5e2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7066
diff
changeset
|
150 |
{ |
ca7cb4b5c5e2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7066
diff
changeset
|
151 |
uint total_time = 0; |
ca7cb4b5c5e2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7066
diff
changeset
|
152 |
bool complete = true; |
ca7cb4b5c5e2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7066
diff
changeset
|
153 |
|
ca7cb4b5c5e2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7066
diff
changeset
|
154 |
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
|
155 |
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
|
156 |
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
|
157 |
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
|
158 |
} |
ca7cb4b5c5e2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7066
diff
changeset
|
159 |
|
ca7cb4b5c5e2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7066
diff
changeset
|
160 |
if (total_time != 0) { |
ca7cb4b5c5e2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7066
diff
changeset
|
161 |
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
|
162 |
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
|
163 |
} |
ca7cb4b5c5e2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7066
diff
changeset
|
164 |
} |
ca7cb4b5c5e2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7066
diff
changeset
|
165 |
y += 10; |
ca7cb4b5c5e2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7066
diff
changeset
|
166 |
|
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
167 |
if (v->lateness_counter == 0 || (!_patches.timetable_in_ticks && v->lateness_counter / DAY_TICKS == 0)) { |
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
|
168 |
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
|
169 |
} else { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
170 |
SetTimetableParams(0, 1, abs(v->lateness_counter)); |
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
|
171 |
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
|
172 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
173 |
} |
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 |
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
|
176 |
{ |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
177 |
uint order_number = (selected + 1) / 2; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
178 |
uint is_journey = (selected % 2 == 1) ? 1 : 0; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
179 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
180 |
if (order_number >= v->num_orders) order_number = 0; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
181 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
182 |
return v->index | (order_number << 16) | (is_journey << 24); |
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 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
185 |
static void TimetableWndProc(Window *w, WindowEvent *we) |
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 |
switch (we->event) { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
188 |
case WE_PAINT: |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
189 |
DrawTimetableWindow(w); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
190 |
break; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
191 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
192 |
case WE_CLICK: { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
193 |
const Vehicle *v = GetVehicle(w->window_number); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
194 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
195 |
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
|
196 |
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
|
197 |
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
|
198 |
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
|
199 |
|
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
200 |
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
|
201 |
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
|
202 |
|
8896
8ffef4030fe1
(svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
rubidium
parents:
8894
diff
changeset
|
203 |
if (selected == INVALID_ORDER || selected == WP(w, timetable_d).sel) { |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
204 |
/* Deselect clicked order */ |
8896
8ffef4030fe1
(svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
rubidium
parents:
8894
diff
changeset
|
205 |
WP(w, timetable_d).sel = -1; |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
206 |
} else { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
207 |
/* Select clicked order */ |
8896
8ffef4030fe1
(svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
rubidium
parents:
8894
diff
changeset
|
208 |
WP(w, timetable_d).sel = selected; |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
209 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
210 |
} break; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
211 |
|
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
212 |
case TTV_CHANGE_TIME: { /* "Wait For" button. */ |
8896
8ffef4030fe1
(svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
rubidium
parents:
8894
diff
changeset
|
213 |
int selected = WP(w, timetable_d).sel; |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
214 |
VehicleOrderID real = (selected + 1) / 2; |
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 |
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
|
217 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
218 |
const Order *order = GetVehicleOrder(v, real); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
219 |
StringID current = STR_EMPTY; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
220 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
221 |
if (order != NULL) { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
222 |
uint time = (selected % 2 == 1) ? order->travel_time : order->wait_time; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
223 |
if (!_patches.timetable_in_ticks) time /= DAY_TICKS; |
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 |
if (time != 0) { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
226 |
SetDParam(0, time); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
227 |
current = STR_CONFIG_PATCHES_INT32; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
228 |
} |
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 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
231 |
ShowQueryString(current, STR_TIMETABLE_CHANGE_TIME, 31, 150, w, CS_NUMERAL); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
232 |
} break; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
233 |
|
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
234 |
case TTV_CLEAR_TIME: { /* Clear waiting time button. */ |
8896
8ffef4030fe1
(svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
rubidium
parents:
8894
diff
changeset
|
235 |
uint32 p1 = PackTimetableArgs(v, WP(w, timetable_d).sel); |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
236 |
DoCommandP(0, p1, 0, NULL, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE)); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
237 |
} break; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
238 |
|
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
239 |
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
|
240 |
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
|
241 |
break; |
7066
e5d16aa8d6ca
(svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents:
7057
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_AUTOFILL: /* Autofill the timetable. */ |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7824
diff
changeset
|
244 |
DoCommandP(0, v->index, HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE) ? 0 : 1, NULL, CMD_AUTOFILL_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE)); |
7066
e5d16aa8d6ca
(svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents:
7057
diff
changeset
|
245 |
break; |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
246 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
247 |
|
9116
f2491d3c321b
(svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents:
9111
diff
changeset
|
248 |
w->SetDirty(); |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
249 |
} break; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
250 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
251 |
case WE_ON_EDIT_TEXT: { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
252 |
const Vehicle *v = GetVehicle(w->window_number); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
253 |
|
8896
8ffef4030fe1
(svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
rubidium
parents:
8894
diff
changeset
|
254 |
uint32 p1 = PackTimetableArgs(v, WP(w, timetable_d).sel); |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
255 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
256 |
uint64 time = StrEmpty(we->we.edittext.str) ? 0 : strtoul(we->we.edittext.str, NULL, 10); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
257 |
if (!_patches.timetable_in_ticks) time *= DAY_TICKS; |
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 |
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
|
260 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
261 |
DoCommandP(0, p1, p2, NULL, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE)); |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
262 |
} break; |
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 |
case WE_RESIZE: |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
265 |
/* 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
|
266 |
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
|
267 |
break; |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
268 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
269 |
} |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
270 |
} |
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 |
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
|
273 |
{ 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
|
274 |
{ 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
|
275 |
{ 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
|
276 |
{ 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
|
277 |
|
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
278 |
{ 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
|
279 |
{ 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
|
280 |
|
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
281 |
{ 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
|
282 |
|
8722
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
283 |
{ 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
|
284 |
{ 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
|
285 |
{ 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
|
286 |
{ 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
|
287 |
|
6c3a3816bff5
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8424
diff
changeset
|
288 |
{ 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
|
289 |
{ 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
|
290 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
291 |
{ WIDGETS_END } |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
292 |
}; |
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 |
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
|
295 |
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
|
296 |
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
|
297 |
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
|
298 |
_timetable_widgets, |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
299 |
TimetableWndProc |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
300 |
}; |
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 |
void ShowTimetableWindow(const Vehicle *v) |
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 |
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
|
305 |
|
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
306 |
if (w != NULL) { |
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
307 |
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
|
308 |
w->vscroll.cap = 8; |
6981
9af49f50fe33
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
309 |
w->resize.step_height = 10; |
8896
8ffef4030fe1
(svn r12663) -Codechange: move the definition from 'order_d' to a more appropriate place and do not misuse it for the time table GUI.
rubidium
parents:
8894
diff
changeset
|
310 |
WP(w, timetable_d).sel = -1; |
6981
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 |
} |