author | Tero Marttila <terom@fixme.fi> |
Fri, 18 Jul 2008 21:28:42 +0300 | |
changeset 11175 | 020c61e39c94 |
parent 11146 | fb7703b62a99 |
permissions | -rw-r--r-- |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
1 |
/* $Id$ */ |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
2 |
|
10429
1b99254f9607
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
10222
diff
changeset
|
3 |
/** @file timetable_gui.cpp GUI for time tabling. */ |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
4 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
5 |
#include "stdafx.h" |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
6 |
#include "openttd.h" |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
7 |
#include "variables.h" |
8612
6414fc21c2f3
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
8610
diff
changeset
|
8 |
#include "command_func.h" |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
9 |
#include "gui.h" |
8603
88c5ce6a5215
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8602
diff
changeset
|
10 |
#include "window_gui.h" |
88c5ce6a5215
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8602
diff
changeset
|
11 |
#include "textbuf_gui.h" |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
12 |
#include "cargotype.h" |
8610
17cc343a23dd
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8603
diff
changeset
|
13 |
#include "strings_func.h" |
8640
1e93b81e96d2
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents:
8636
diff
changeset
|
14 |
#include "vehicle_base.h" |
8710
52015340050c
(svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium
parents:
8640
diff
changeset
|
15 |
#include "string_func.h" |
8720
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8710
diff
changeset
|
16 |
#include "gfx_func.h" |
8750
fdd6054e7bae
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8733
diff
changeset
|
17 |
#include "player_func.h" |
10168
24907819f29b
(svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents:
10139
diff
changeset
|
18 |
#include "order_func.h" |
8766
c86cfa3a7580
(svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents:
8760
diff
changeset
|
19 |
#include "settings_type.h" |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
20 |
|
8760
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
21 |
#include "table/strings.h" |
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
22 |
|
9218
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
23 |
enum TimetableViewWindowWidgets { |
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
24 |
TTV_WIDGET_CLOSEBOX = 0, |
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
25 |
TTV_CAPTION, |
9241
38c0bd6beae1
(svn r12441) -Feature: open the time table when pressing the order button while pressing the CTRL key. Patch by Phil Sophus.
rubidium
parents:
9218
diff
changeset
|
26 |
TTV_ORDER_VIEW, |
9218
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
27 |
TTV_STICKY, |
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
28 |
TTV_TIMETABLE_PANEL, |
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
29 |
TTV_SCROLLBAR, |
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
30 |
TTV_SUMMARY_PANEL, |
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
31 |
TTV_CHANGE_TIME, |
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
32 |
TTV_CLEAR_TIME, |
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
33 |
TTV_RESET_LATENESS, |
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
34 |
TTV_AUTOFILL, |
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
35 |
TTV_EMPTY, |
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
36 |
TTV_RESIZE, |
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
37 |
}; |
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
38 |
|
10168
24907819f29b
(svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents:
10139
diff
changeset
|
39 |
void SetTimetableParams(int param1, int param2, uint32 time) |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
40 |
{ |
10775
7061477bfbcf
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
10703
diff
changeset
|
41 |
if (_settings_client.gui.timetable_in_ticks) { |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
42 |
SetDParam(param1, STR_TIMETABLE_TICKS); |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
43 |
SetDParam(param2, time); |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
44 |
} else { |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
45 |
SetDParam(param1, STR_TIMETABLE_DAYS); |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
46 |
SetDParam(param2, time / DAY_TICKS); |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
47 |
} |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
48 |
} |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
49 |
|
10575
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
50 |
struct TimetableWindow : Window { |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
51 |
int sel_index; |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
52 |
|
10575
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
53 |
TimetableWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
54 |
{ |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
55 |
this->caption_color = GetVehicle(window_number)->owner; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
56 |
this->vscroll.cap = 8; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
57 |
this->resize.step_height = 10; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
58 |
this->sel_index = -1; |
10681
3aa3de4d448b
(svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138
parents:
10641
diff
changeset
|
59 |
|
3aa3de4d448b
(svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138
parents:
10641
diff
changeset
|
60 |
this->FindWindowPlacementAndResize(desc); |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
61 |
} |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
62 |
|
10575
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
63 |
int GetOrderFromTimetableWndPt(int y, const Vehicle *v) |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
64 |
{ |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
65 |
/* |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
66 |
* Calculation description: |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
67 |
* 15 = 14 (this->widget[TTV_ORDER_VIEW].top) + 1 (frame-line) |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
68 |
* 10 = order text hight |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
69 |
*/ |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
70 |
int sel = (y - 15) / 10; |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
71 |
|
10575
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
72 |
if ((uint)sel >= this->vscroll.cap) return INVALID_ORDER; |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
73 |
|
10575
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
74 |
sel += this->vscroll.pos; |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
75 |
|
10575
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
76 |
return (sel <= v->num_orders * 2 && sel >= 0) ? sel : INVALID_ORDER; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
77 |
} |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
78 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
79 |
void OnPaint() |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
80 |
{ |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
81 |
const Vehicle *v = GetVehicle(this->window_number); |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
82 |
int selected = this->sel_index; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
83 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
84 |
SetVScrollCount(this, v->num_orders * 2); |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
85 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
86 |
if (v->owner == _local_player) { |
11146
fb7703b62a99
(svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents:
11144
diff
changeset
|
87 |
bool disable = true; |
fb7703b62a99
(svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents:
11144
diff
changeset
|
88 |
if (selected != -1) { |
10575
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
89 |
const Order *order = GetVehicleOrder(v, (selected + 1) / 2); |
11146
fb7703b62a99
(svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents:
11144
diff
changeset
|
90 |
if (selected % 2 == 1) { |
fb7703b62a99
(svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents:
11144
diff
changeset
|
91 |
disable = order != NULL && order->IsType(OT_CONDITIONAL); |
fb7703b62a99
(svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents:
11144
diff
changeset
|
92 |
} else { |
fb7703b62a99
(svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents:
11144
diff
changeset
|
93 |
disable = order == NULL || ((!order->IsType(OT_GOTO_STATION) || (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION)) && !order->IsType(OT_CONDITIONAL)); |
fb7703b62a99
(svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents:
11144
diff
changeset
|
94 |
} |
fb7703b62a99
(svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents:
11144
diff
changeset
|
95 |
} |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
96 |
|
11146
fb7703b62a99
(svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents:
11144
diff
changeset
|
97 |
this->SetWidgetDisabledState(TTV_CHANGE_TIME, disable); |
fb7703b62a99
(svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents:
11144
diff
changeset
|
98 |
this->SetWidgetDisabledState(TTV_CLEAR_TIME, disable); |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
99 |
|
10575
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
100 |
this->EnableWidget(TTV_RESET_LATENESS); |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
101 |
this->EnableWidget(TTV_AUTOFILL); |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
102 |
} else { |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
103 |
this->DisableWidget(TTV_CHANGE_TIME); |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
104 |
this->DisableWidget(TTV_CLEAR_TIME); |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
105 |
this->DisableWidget(TTV_RESET_LATENESS); |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
106 |
this->DisableWidget(TTV_AUTOFILL); |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
107 |
} |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
108 |
|
10575
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
109 |
this->SetWidgetLoweredState(TTV_AUTOFILL, HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE)); |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
110 |
|
10575
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
111 |
SetDParam(0, v->index); |
10595
7957c71b0dfe
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents:
10575
diff
changeset
|
112 |
this->DrawWidgets(); |
7569
8e639c5079a2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7562
diff
changeset
|
113 |
|
10575
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
114 |
int y = 15; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
115 |
int i = this->vscroll.pos; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
116 |
VehicleOrderID order_id = (i + 1) / 2; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
117 |
bool final_order = false; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
118 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
119 |
const Order *order = GetVehicleOrder(v, order_id); |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
120 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
121 |
while (order != NULL) { |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
122 |
/* Don't draw anything if it extends past the end of the window. */ |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
123 |
if (i - this->vscroll.pos >= this->vscroll.cap) break; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
124 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
125 |
if (i % 2 == 0) { |
11144
7eff560780d2
(svn r13702) -Fix: do not overflow the order/timetable window when 'long' orders are displayed.
rubidium
parents:
11090
diff
changeset
|
126 |
DrawOrderString(v, order, order_id, y, i == selected, true, this->widget[TTV_TIMETABLE_PANEL].right - 4); |
10575
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
127 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
128 |
order_id++; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
129 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
130 |
if (order_id >= v->num_orders) { |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
131 |
order = GetVehicleOrder(v, 0); |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
132 |
final_order = true; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
133 |
} else { |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
134 |
order = order->next; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
135 |
} |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
136 |
} else { |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
137 |
StringID string; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
138 |
|
11146
fb7703b62a99
(svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents:
11144
diff
changeset
|
139 |
if (order->IsType(OT_CONDITIONAL)) { |
fb7703b62a99
(svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents:
11144
diff
changeset
|
140 |
string = STR_TIMETABLE_NO_TRAVEL; |
fb7703b62a99
(svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents:
11144
diff
changeset
|
141 |
} else if (order->travel_time == 0) { |
10575
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
142 |
string = STR_TIMETABLE_TRAVEL_NOT_TIMETABLED; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
143 |
} else { |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
144 |
SetTimetableParams(0, 1, order->travel_time); |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
145 |
string = STR_TIMETABLE_TRAVEL_FOR; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
146 |
} |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
147 |
|
11144
7eff560780d2
(svn r13702) -Fix: do not overflow the order/timetable window when 'long' orders are displayed.
rubidium
parents:
11090
diff
changeset
|
148 |
DrawStringTruncated(2, y, string, (i == selected) ? TC_WHITE : TC_BLACK, this->widget[TTV_TIMETABLE_PANEL].right - 4); |
10575
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
149 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
150 |
if (final_order) break; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
151 |
} |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
152 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
153 |
i++; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
154 |
y += 10; |
7569
8e639c5079a2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7562
diff
changeset
|
155 |
} |
8e639c5079a2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7562
diff
changeset
|
156 |
|
10575
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
157 |
y = this->widget[TTV_SUMMARY_PANEL].top + 1; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
158 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
159 |
{ |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
160 |
uint total_time = 0; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
161 |
bool complete = true; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
162 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
163 |
for (const Order *order = GetVehicleOrder(v, 0); order != NULL; order = order->next) { |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
164 |
total_time += order->travel_time + order->wait_time; |
11146
fb7703b62a99
(svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents:
11144
diff
changeset
|
165 |
if (order->travel_time == 0 && !order->IsType(OT_CONDITIONAL)) complete = false; |
10575
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
166 |
if (order->wait_time == 0 && order->IsType(OT_GOTO_STATION) && !(order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION)) complete = false; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
167 |
} |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
168 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
169 |
if (total_time != 0) { |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
170 |
SetTimetableParams(0, 1, total_time); |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
171 |
DrawString(2, y, complete ? STR_TIMETABLE_TOTAL_TIME : STR_TIMETABLE_TOTAL_TIME_INCOMPLETE, TC_BLACK); |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
172 |
} |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
173 |
} |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
174 |
y += 10; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
175 |
|
10775
7061477bfbcf
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
10703
diff
changeset
|
176 |
if (v->lateness_counter == 0 || (!_settings_client.gui.timetable_in_ticks && v->lateness_counter / DAY_TICKS == 0)) { |
10575
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
177 |
DrawString(2, y, STR_TIMETABLE_STATUS_ON_TIME, TC_BLACK); |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
178 |
} else { |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
179 |
SetTimetableParams(0, 1, abs(v->lateness_counter)); |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
180 |
DrawString(2, y, v->lateness_counter < 0 ? STR_TIMETABLE_STATUS_EARLY : STR_TIMETABLE_STATUS_LATE, TC_BLACK); |
7569
8e639c5079a2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7562
diff
changeset
|
181 |
} |
8e639c5079a2
(svn r10338) -Codechange: Show the total time that the timetable will take.
maedhros
parents:
7562
diff
changeset
|
182 |
} |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
183 |
|
10575
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
184 |
static inline uint32 PackTimetableArgs(const Vehicle *v, uint selected) |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
185 |
{ |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
186 |
uint order_number = (selected + 1) / 2; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
187 |
uint is_journey = (selected % 2 == 1) ? 1 : 0; |
7562
f6f62814907b
(svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents:
7553
diff
changeset
|
188 |
|
10575
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
189 |
if (order_number >= v->num_orders) order_number = 0; |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
190 |
|
10575
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
191 |
return v->index | (order_number << 16) | (is_journey << 24); |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
192 |
} |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
193 |
|
10575
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
194 |
virtual void OnClick(Point pt, int widget) |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
195 |
{ |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
196 |
const Vehicle *v = GetVehicle(this->window_number); |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
197 |
|
10575
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
198 |
switch (widget) { |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
199 |
case TTV_ORDER_VIEW: /* Order view button */ |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
200 |
ShowOrdersWindow(v); |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
201 |
break; |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
202 |
|
10575
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
203 |
case TTV_TIMETABLE_PANEL: { /* Main panel. */ |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
204 |
int selected = GetOrderFromTimetableWndPt(pt.y, v); |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
205 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
206 |
if (selected == INVALID_ORDER || selected == this->sel_index) { |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
207 |
/* Deselect clicked order */ |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
208 |
this->sel_index = -1; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
209 |
} else { |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
210 |
/* Select clicked order */ |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
211 |
this->sel_index = selected; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
212 |
} |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
213 |
} break; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
214 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
215 |
case TTV_CHANGE_TIME: { /* "Wait For" button. */ |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
216 |
int selected = this->sel_index; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
217 |
VehicleOrderID real = (selected + 1) / 2; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
218 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
219 |
if (real >= v->num_orders) real = 0; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
220 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
221 |
const Order *order = GetVehicleOrder(v, real); |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
222 |
StringID current = STR_EMPTY; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
223 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
224 |
if (order != NULL) { |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
225 |
uint time = (selected % 2 == 1) ? order->travel_time : order->wait_time; |
10775
7061477bfbcf
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
10703
diff
changeset
|
226 |
if (!_settings_client.gui.timetable_in_ticks) time /= DAY_TICKS; |
10575
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
227 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
228 |
if (time != 0) { |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
229 |
SetDParam(0, time); |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
230 |
current = STR_CONFIG_PATCHES_INT32; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
231 |
} |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
232 |
} |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
233 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
234 |
ShowQueryString(current, STR_TIMETABLE_CHANGE_TIME, 31, 150, this, CS_NUMERAL); |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
235 |
} break; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
236 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
237 |
case TTV_CLEAR_TIME: { /* Clear waiting time button. */ |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
238 |
uint32 p1 = PackTimetableArgs(v, this->sel_index); |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
239 |
DoCommandP(0, p1, 0, NULL, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE)); |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
240 |
} break; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
241 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
242 |
case TTV_RESET_LATENESS: /* Reset the vehicle's late counter. */ |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
243 |
DoCommandP(0, v->index, 0, NULL, CMD_SET_VEHICLE_ON_TIME | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE)); |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
244 |
break; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
245 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
246 |
case TTV_AUTOFILL: /* Autofill the timetable. */ |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
247 |
DoCommandP(0, v->index, HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE) ? 0 : 1, NULL, CMD_AUTOFILL_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE)); |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
248 |
break; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
249 |
} |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
250 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
251 |
this->SetDirty(); |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
252 |
} |
10575
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
253 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
254 |
virtual void OnQueryTextFinished(char *str) |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
255 |
{ |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
256 |
if (str == NULL) return; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
257 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
258 |
const Vehicle *v = GetVehicle(this->window_number); |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
259 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
260 |
uint32 p1 = PackTimetableArgs(v, this->sel_index); |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
261 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
262 |
uint64 time = StrEmpty(str) ? 0 : strtoul(str, NULL, 10); |
10775
7061477bfbcf
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
10703
diff
changeset
|
263 |
if (!_settings_client.gui.timetable_in_ticks) time *= DAY_TICKS; |
10575
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
264 |
|
11090
3ac220ac9a47
(svn r13647) -Codechange: replace MAX_UVALUE() for std types with the equivalent constant
skidd13
parents:
10775
diff
changeset
|
265 |
uint32 p2 = minu(time, UINT16_MAX); |
10575
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
266 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
267 |
DoCommandP(0, p1, p2, NULL, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE)); |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
268 |
} |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
269 |
|
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
270 |
virtual void OnResize(Point new_size, Point delta) |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
271 |
{ |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
272 |
/* Update the scroll + matrix */ |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
273 |
this->vscroll.cap = (this->widget[TTV_TIMETABLE_PANEL].bottom - this->widget[TTV_TIMETABLE_PANEL].top) / 10; |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
274 |
} |
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
275 |
}; |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
276 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
277 |
static const Widget _timetable_widgets[] = { |
9218
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
278 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // TTV_WIDGET_CLOSEBOX |
9241
38c0bd6beae1
(svn r12441) -Feature: open the time table when pressing the order button while pressing the CTRL key. Patch by Phil Sophus.
rubidium
parents:
9218
diff
changeset
|
279 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 326, 0, 13, STR_TIMETABLE_TITLE, STR_018C_WINDOW_TITLE_DRAG_THIS}, // TTV_CAPTION |
38c0bd6beae1
(svn r12441) -Feature: open the time table when pressing the order button while pressing the CTRL key. Patch by Phil Sophus.
rubidium
parents:
9218
diff
changeset
|
280 |
{ WWT_PUSHTXTBTN, RESIZE_LR, 14, 327, 387, 0, 13, STR_ORDER_VIEW, STR_ORDER_VIEW_TOOLTIP}, // TTV_ORDER_VIEW |
9218
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
281 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 388, 399, 0, 13, STR_NULL, STR_STICKY_BUTTON}, // TTV_STICKY |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
282 |
|
9218
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
283 |
{ WWT_PANEL, RESIZE_RB, 14, 0, 387, 14, 95, STR_NULL, STR_TIMETABLE_TOOLTIP}, // TTV_TIMETABLE_PANEL |
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
284 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 388, 399, 14, 95, STR_NULL, STR_0190_SCROLL_BAR_SCROLLS_LIST}, // TTV_SCROLLBAR |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
285 |
|
9218
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
286 |
{ WWT_PANEL, RESIZE_RTB, 14, 0, 399, 96, 117, STR_NULL, STR_NULL}, // TTV_SUMMARY_PANEL |
7553
bb88bdf61f6d
(svn r10322) -Codechange: Make the timetable window smaller by default so it doesn't take up so much space on small resolutions.
maedhros
parents:
7545
diff
changeset
|
287 |
|
9218
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
288 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 109, 118, 129, STR_TIMETABLE_CHANGE_TIME, STR_TIMETABLE_WAIT_TIME_TOOLTIP}, // TTV_CHANGE_TIME |
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
289 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 110, 219, 118, 129, STR_CLEAR_TIME, STR_TIMETABLE_CLEAR_TIME_TOOLTIP}, // TTV_CLEAR_TIME |
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
290 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 220, 337, 118, 129, STR_RESET_LATENESS, STR_TIMETABLE_RESET_LATENESS_TOOLTIP}, // TTV_RESET_LATENESS |
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
291 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 338, 387, 118, 129, STR_TIMETABLE_AUTOFILL, STR_TIMETABLE_AUTOFILL_TOOLTIP}, // TTV_AUTOFILL |
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
292 |
|
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
293 |
{ WWT_PANEL, RESIZE_RTB, 14, 388, 387, 118, 129, STR_NULL, STR_NULL}, // TTV_EMPTY |
5fd7cb5ebf87
(svn r12397) -Codechange [FS#1856]: enumify widget number for time tables. Patch by Phil Sophus.
rubidium
parents:
8920
diff
changeset
|
294 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 388, 399, 118, 129, STR_NULL, STR_RESIZE_BUTTON}, // TTV_RESIZE |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
295 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
296 |
{ WIDGETS_END } |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
297 |
}; |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
298 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
299 |
static const WindowDesc _timetable_desc = { |
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7808
diff
changeset
|
300 |
WDP_AUTO, WDP_AUTO, 400, 130, 400, 130, |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
301 |
WC_VEHICLE_TIMETABLE, WC_VEHICLE_VIEW, |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
302 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
303 |
_timetable_widgets, |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
304 |
}; |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
305 |
|
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
306 |
void ShowTimetableWindow(const Vehicle *v) |
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
307 |
{ |
10575
fab9a236c1f5
(svn r13119) -Codechange: make a class of the timetable window.
rubidium
parents:
10484
diff
changeset
|
308 |
AllocateWindowDescFront<TimetableWindow>(&_timetable_desc, v->index); |
7477
1f22e188617e
(svn r10237) -Fix (r10236): It helps if you use svn add with new files...
maedhros
parents:
diff
changeset
|
309 |
} |