author | dominik |
Mon, 24 Jan 2005 23:24:34 +0000 | |
changeset 1154 | 6ef8293e90f2 |
parent 1151 | 614cbcb5b9fe |
child 1179 | abea5b669f74 |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
460
diff
changeset
|
3 |
#include "table/strings.h" |
679
e959706a3e4d
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
601
diff
changeset
|
4 |
#include "map.h" |
0 | 5 |
#include "window.h" |
6 |
#include "gui.h" |
|
7 |
#include "gfx.h" |
|
8 |
#include "vehicle.h" |
|
9 |
#include "viewport.h" |
|
10 |
#include "station.h" |
|
11 |
#include "command.h" |
|
12 |
#include "player.h" |
|
13 |
#include "engine.h" |
|
588 | 14 |
#include "vehicle_gui.h" |
0 | 15 |
|
420
d3a089648ec3
(svn r617) -newgrf: Support for parameter 0x8E (train Y-pitch in info windows) both setting and testing. This should fix displaced wagons in DBSetXL as reported by DarkVater. (pasky)
darkvater
parents:
395
diff
changeset
|
16 |
|
d3a089648ec3
(svn r617) -newgrf: Support for parameter 0x8E (train Y-pitch in info windows) both setting and testing. This should fix displaced wagons in DBSetXL as reported by DarkVater. (pasky)
darkvater
parents:
395
diff
changeset
|
17 |
int _traininfo_vehicle_pitch = 0; |
d3a089648ec3
(svn r617) -newgrf: Support for parameter 0x8E (train Y-pitch in info windows) both setting and testing. This should fix displaced wagons in DBSetXL as reported by DarkVater. (pasky)
darkvater
parents:
395
diff
changeset
|
18 |
|
842 | 19 |
void Set_DPARAM_Train_Engine_Build_Window(uint16 engine_number) |
20 |
{ |
|
21 |
const RailVehicleInfo *rvi = RailVehInfo(engine_number); |
|
22 |
Engine *e; |
|
23 |
int multihead = (rvi->flags&RVI_MULTIHEAD?1:0); |
|
24 |
YearMonthDay ymd; |
|
25 |
||
26 |
||
27 |
SetDParam(0, rvi->base_cost * (_price.build_railvehicle >> 3) >> 5); |
|
28 |
SetDParam(2, rvi->max_speed * 10 >> 4); |
|
29 |
SetDParam(3, rvi->power << multihead); |
|
30 |
SetDParam(1, rvi->weight << multihead); |
|
31 |
SetDParam(4, (rvi->running_cost_base * _price.running_rail[rvi->engclass] >> 8) << multihead); |
|
32 |
||
33 |
SetDParam(5, STR_8838_N_A); |
|
34 |
if (rvi->capacity != 0) { |
|
35 |
SetDParam(6, rvi->capacity << multihead); |
|
36 |
SetDParam(5, _cargoc.names_long_p[rvi->cargo_type]); |
|
37 |
} |
|
38 |
||
39 |
e = &_engines[engine_number]; |
|
40 |
||
41 |
SetDParam(8, e->lifelength); |
|
42 |
SetDParam(9, e->reliability * 100 >> 16); |
|
43 |
ConvertDayToYMD(&ymd, e->intro_date); |
|
44 |
SetDParam(7, ymd.year + 1920); |
|
45 |
} |
|
46 |
||
47 |
void Set_DPARAM_Train_Car_Build_Window(Window *w, uint16 engine_number) |
|
48 |
{ |
|
49 |
const RailVehicleInfo *rvi = RailVehInfo(engine_number); |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
50 |
|
842 | 51 |
SetDParam(0, DoCommandByTile(w->window_number, engine_number, 0, DC_QUERY_COST, CMD_BUILD_RAIL_VEHICLE) ); |
52 |
SetDParam(4, rvi->capacity); |
|
53 |
SetDParam(1, rvi->weight); |
|
54 |
SetDParam(3, _cargoc.names_long_p[rvi->cargo_type]); |
|
55 |
SetDParam(2, (_cargoc.weights[rvi->cargo_type] * rvi->capacity >> 4) + rvi->weight); |
|
56 |
} |
|
0 | 57 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
540
diff
changeset
|
58 |
void CcBuildWagon(bool success, uint tile, uint32 p1, uint32 p2) |
0 | 59 |
{ |
60 |
Vehicle *v,*found; |
|
61 |
||
62 |
if (!success) |
|
63 |
return; |
|
64 |
||
65 |
// find a locomotive in the depot. |
|
66 |
found = NULL; |
|
67 |
FOR_ALL_VEHICLES(v) { |
|
1067
a083a6dd1419
(svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents:
1019
diff
changeset
|
68 |
if (v->type == VEH_Train && v->subtype == TS_Front_Engine && |
0 | 69 |
v->tile == tile && |
70 |
v->u.rail.track == 0x80) { |
|
71 |
if (found != NULL) // must be exactly one. |
|
72 |
return; |
|
73 |
found = v; |
|
74 |
} |
|
75 |
} |
|
76 |
||
77 |
// if we found a loco, |
|
78 |
if (found != NULL) { |
|
79 |
found = GetLastVehicleInChain(found); |
|
80 |
// put the new wagon at the end of the loco. |
|
81 |
DoCommandP(0, _new_wagon_id | (found->index<<16), 0, NULL, CMD_MOVE_RAIL_VEHICLE); |
|
588 | 82 |
RebuildVehicleLists(); |
0 | 83 |
} |
84 |
} |
|
85 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
540
diff
changeset
|
86 |
void CcBuildLoco(bool success, uint tile, uint32 p1, uint32 p2) |
0 | 87 |
{ |
88 |
Vehicle *v; |
|
89 |
||
90 |
if (!success) |
|
91 |
return; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
92 |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
93 |
v = GetVehicle(_new_train_id); |
0 | 94 |
if (tile == _backup_orders_tile) { |
95 |
_backup_orders_tile = 0; |
|
96 |
RestoreVehicleOrders(v, _backup_orders_data); |
|
97 |
} |
|
98 |
ShowTrainViewWindow(v); |
|
99 |
} |
|
100 |
||
524
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
101 |
static void engine_drawing_loop(int *x, int *y, int *pos, int *sel, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
102 |
int *selected_id, byte railtype, byte show_max, bool is_engine) |
524
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
103 |
{ |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
104 |
int i; |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
105 |
|
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
106 |
for (i = 0; i < NUM_TRAIN_ENGINES; i++) { |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
107 |
const Engine *e = DEREF_ENGINE(i); |
539 | 108 |
const RailVehicleInfo *rvi = RailVehInfo(i); |
524
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
109 |
|
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
110 |
if (e->railtype != railtype || !(rvi->flags & RVI_WAGON) != is_engine || |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
111 |
!HASBIT(e->player_avail, _local_player)) |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
112 |
continue; |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
113 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
114 |
if (*sel == 0) |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
115 |
*selected_id = i; |
524
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
116 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
117 |
if (IS_INT_INSIDE(--*pos, -show_max, 0)) { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
118 |
DrawString(*x + 59, *y + 2, GetCustomEngineName(i), *sel == 0 ? 0xC : 0x10); |
524
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
119 |
DrawTrainEngine(*x + 29, *y + 6 + _traininfo_vehicle_pitch, i, |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
120 |
SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player))); |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
121 |
*y += 14; |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
122 |
} |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
123 |
--*sel; |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
124 |
} |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
125 |
} |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
126 |
|
0 | 127 |
static void NewRailVehicleWndProc(Window *w, WindowEvent *e) |
128 |
{ |
|
129 |
switch(e->event) { |
|
130 |
case WE_PAINT: |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
131 |
|
0 | 132 |
if (w->window_number == 0) |
133 |
SETBIT(w->disabled_state, 5); |
|
134 |
||
135 |
{ |
|
136 |
int count = 0; |
|
460
f11659d28617
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
420
diff
changeset
|
137 |
byte railtype = WP(w,buildtrain_d).railtype; |
f11659d28617
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
420
diff
changeset
|
138 |
int i; |
f11659d28617
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
420
diff
changeset
|
139 |
|
f11659d28617
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
420
diff
changeset
|
140 |
for (i = 0; i < NUM_TRAIN_ENGINES; i++) { |
524
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
141 |
const Engine *e = DEREF_ENGINE(i); |
460
f11659d28617
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
420
diff
changeset
|
142 |
if (e->railtype == railtype |
f11659d28617
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
420
diff
changeset
|
143 |
&& HASBIT(e->player_avail, _local_player)) |
0 | 144 |
count++; |
460
f11659d28617
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
420
diff
changeset
|
145 |
} |
0 | 146 |
SetVScrollCount(w, count); |
147 |
} |
|
148 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
149 |
SetDParam(0, WP(w,buildtrain_d).railtype + STR_881C_NEW_RAIL_VEHICLES); |
0 | 150 |
DrawWindowWidgets(w); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
151 |
|
0 | 152 |
{ |
460
f11659d28617
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
420
diff
changeset
|
153 |
byte railtype = WP(w,buildtrain_d).railtype; |
0 | 154 |
int sel = WP(w,buildtrain_d).sel_index; |
155 |
int pos = w->vscroll.pos; |
|
156 |
int x = 1; |
|
157 |
int y = 15; |
|
158 |
int selected_id = -1; |
|
159 |
||
460
f11659d28617
(svn r677) -newgrf: Fix some custom electric trains appearing in maglev depots (pasky).
darkvater
parents:
420
diff
changeset
|
160 |
/* Ensure that custom engines which substituted wagons |
524
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
161 |
* are sorted correctly. |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
162 |
* XXX - DO NOT EVER DO THIS EVER AGAIN! GRRR hacking in wagons as |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
163 |
* engines to get more types.. Stays here until we have our own format |
6ed367906581
(svn r854) -Fix [1070274] Invisible trains. Weird macros and MSVC optimizing don't always mix. (Tron)
darkvater
parents:
517
diff
changeset
|
164 |
* then it is exit!!! */ |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
165 |
engine_drawing_loop(&x, &y, &pos, &sel, &selected_id, railtype, w->vscroll.cap, true); // True engines |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
166 |
engine_drawing_loop(&x, &y, &pos, &sel, &selected_id, railtype, w->vscroll.cap, false); // Feeble wagons |
0 | 167 |
|
168 |
WP(w,buildtrain_d).sel_engine = selected_id; |
|
169 |
||
170 |
if (selected_id != -1) { |
|
539 | 171 |
const RailVehicleInfo *rvi = RailVehInfo(selected_id); |
0 | 172 |
|
173 |
if (!(rvi->flags & RVI_WAGON)) { |
|
174 |
/* it's an engine */ |
|
842 | 175 |
Set_DPARAM_Train_Engine_Build_Window(selected_id); |
0 | 176 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
177 |
DrawString(2, w->widget[4].top + 1, STR_8817_COST_WEIGHT_T_SPEED_POWER, 0); |
0 | 178 |
} else { |
179 |
/* it's a wagon */ |
|
842 | 180 |
Set_DPARAM_Train_Car_Build_Window(w, selected_id); |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
181 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
182 |
DrawString(2, w->widget[4].top + 1, STR_8821_COST_WEIGHT_T_T_CAPACITY, 0); |
0 | 183 |
} |
184 |
} |
|
185 |
} |
|
186 |
break; |
|
187 |
||
188 |
case WE_CLICK: { |
|
189 |
switch(e->click.widget) { |
|
190 |
case 2: { |
|
191 |
uint i = (e->click.pt.y - 14) / 14; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
192 |
if (i < w->vscroll.cap) { |
0 | 193 |
WP(w,buildtrain_d).sel_index = i + w->vscroll.pos; |
194 |
SetWindowDirty(w); |
|
195 |
} |
|
196 |
} break; |
|
197 |
case 5: { |
|
198 |
int sel_eng; |
|
199 |
sel_eng = WP(w,buildtrain_d).sel_engine; |
|
200 |
if (sel_eng != -1) |
|
540
fbed599dadbb
(svn r924) Use RailVehInfo() instead of &_rail_vehicle_info[]
tron
parents:
539
diff
changeset
|
201 |
DoCommandP(w->window_number, sel_eng, 0, (RailVehInfo(sel_eng)->flags & RVI_WAGON) ? CcBuildWagon : CcBuildLoco, CMD_BUILD_RAIL_VEHICLE | CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE)); |
0 | 202 |
} break; |
968
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
203 |
case 6: { /* rename */ |
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
204 |
int sel_eng = WP(w,buildtrain_d).sel_engine; |
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
205 |
if (sel_eng != -1) { |
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
206 |
WP(w,buildtrain_d).rename_engine = sel_eng; |
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
207 |
ShowQueryString(GetCustomEngineName(sel_eng), |
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
208 |
STR_886A_RENAME_TRAIN_VEHICLE_TYPE, 31, 160, w->window_class, w->window_number); |
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
209 |
} |
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
919
diff
changeset
|
210 |
} break; |
0 | 211 |
} |
212 |
} break; |
|
213 |
||
214 |
case WE_4: |
|
215 |
if (w->window_number != 0 && !FindWindowById(WC_VEHICLE_DEPOT, w->window_number)) { |
|
216 |
DeleteWindow(w); |
|
217 |
} |
|
218 |
break; |
|
219 |
||
220 |
case WE_ON_EDIT_TEXT: { |
|
221 |
byte *b = e->edittext.str; |
|
222 |
if (*b == 0) |
|
223 |
return; |
|
224 |
||
225 |
memcpy(_decode_parameters, b, 32); |
|
226 |
DoCommandP(0, WP(w,buildtrain_d).rename_engine, 0, NULL, CMD_RENAME_ENGINE | CMD_MSG(STR_886B_CAN_T_RENAME_TRAIN_VEHICLE)); |
|
227 |
} break; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
228 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
229 |
case WE_RESIZE: { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
230 |
if (e->sizing.diff.y == 0) |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
231 |
break; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
232 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
233 |
w->vscroll.cap += e->sizing.diff.y / 14; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
234 |
w->widget[2].unkA = (w->vscroll.cap << 8) + 1; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
235 |
} break; |
0 | 236 |
} |
237 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
238 |
|
0 | 239 |
static const Widget _new_rail_vehicle_widgets[] = { |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
240 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1017
608592d4d7a6
(svn r1518) -Fix: server issue where some company names were wrong
darkvater
parents:
1006
diff
changeset
|
241 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 227, 0, 13, STR_JUST_STRING, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
242 |
{ WWT_MATRIX, RESIZE_BOTTOM, 14, 0, 215, 14, 125, 0x801, STR_8843_TRAIN_VEHICLE_SELECTION}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
243 |
{ WWT_SCROLLBAR, RESIZE_BOTTOM, 14, 216, 227, 14, 125, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
244 |
{ WWT_PANEL, RESIZE_TB, 14, 0, 227, 126, 187, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
245 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 107, 188, 199, STR_881F_BUILD_VEHICLE, STR_8844_BUILD_THE_HIGHLIGHTED_TRAIN}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
246 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 108, 215, 188, 199, STR_8820_RENAME, STR_8845_RENAME_TRAIN_VEHICLE_TYPE}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
247 |
{ WWT_RESIZEBOX, RESIZE_TB, 14, 216, 227, 188, 199, 0x0, STR_RESIZE_BUTTON}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
248 |
{ WIDGETS_END}, |
0 | 249 |
}; |
250 |
||
251 |
static const WindowDesc _new_rail_vehicle_desc = { |
|
252 |
-1, -1, 228, 200, |
|
253 |
WC_BUILD_VEHICLE,0, |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
254 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
0 | 255 |
_new_rail_vehicle_widgets, |
256 |
NewRailVehicleWndProc |
|
257 |
}; |
|
258 |
||
259 |
static void ShowBuildTrainWindow(uint tile) |
|
260 |
{ |
|
261 |
Window *w; |
|
262 |
||
263 |
DeleteWindowById(WC_BUILD_VEHICLE, tile); |
|
264 |
||
265 |
w = AllocateWindowDesc(&_new_rail_vehicle_desc); |
|
266 |
w->window_number = tile; |
|
267 |
w->vscroll.cap = 8; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
268 |
w->widget[2].unkA = (w->vscroll.cap << 8) + 1; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
269 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
270 |
w->resize.step_height = 14; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
271 |
w->resize.height = w->height - 14 * 4; /* Minimum of 4 vehicles in the display */ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
272 |
|
0 | 273 |
if (tile != 0) { |
274 |
w->caption_color = _map_owner[tile]; |
|
275 |
WP(w,buildtrain_d).railtype = _map3_lo[tile] & 0xF; |
|
276 |
} else { |
|
277 |
w->caption_color = _local_player; |
|
278 |
WP(w,buildtrain_d).railtype = DEREF_PLAYER(_local_player)->max_railtype - 1; |
|
279 |
} |
|
280 |
} |
|
281 |
||
282 |
static void DrawTrainImage(Vehicle *v, int x, int y, int count, int skip, VehicleID selection) |
|
283 |
{ |
|
284 |
do { |
|
285 |
if (--skip < 0) { |
|
286 |
int image = GetTrainImage(v, 6); |
|
287 |
uint32 ormod = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)); |
|
288 |
if (v->vehstatus & VS_CRASHED) ormod = 0x3248000; |
|
420
d3a089648ec3
(svn r617) -newgrf: Support for parameter 0x8E (train Y-pitch in info windows) both setting and testing. This should fix displaced wagons in DBSetXL as reported by DarkVater. (pasky)
darkvater
parents:
395
diff
changeset
|
289 |
DrawSprite(image | ormod, x+14, y+6+_traininfo_vehicle_pitch); |
0 | 290 |
if (v->index == selection) DrawFrameRect(x-1, y-1, x+28, y+12, 15, 0x10); |
291 |
x += 29; |
|
292 |
count--; |
|
293 |
} |
|
294 |
||
295 |
if (!(v = v->next)) |
|
296 |
break; |
|
297 |
} while (count); |
|
298 |
} |
|
299 |
||
300 |
static void DrawTrainDepotWindow(Window *w) |
|
301 |
{ |
|
302 |
uint tile; |
|
303 |
Vehicle *v, *u; |
|
304 |
int num,x,y,i, hnum; |
|
305 |
Depot *d; |
|
306 |
||
307 |
tile = w->window_number; |
|
308 |
||
309 |
/* setup disabled buttons */ |
|
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
968
diff
changeset
|
310 |
w->disabled_state = (_map_owner[tile]==_local_player) ? 0 : ((1<<4)|(1<<5)|(1<<8)); |
0 | 311 |
|
312 |
/* determine amount of items for scroller */ |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
313 |
num = 0; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
314 |
hnum = 1; |
0 | 315 |
FOR_ALL_VEHICLES(v) { |
316 |
if (v->type == VEH_Train && |
|
1067
a083a6dd1419
(svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents:
1019
diff
changeset
|
317 |
(v->subtype == TS_Front_Engine || v->subtype == TS_Free_Car) && |
0 | 318 |
v->tile == (TileIndex)tile && |
319 |
v->u.rail.track == 0x80) { |
|
320 |
num++; |
|
321 |
// determine number of items in the X direction. |
|
1067
a083a6dd1419
(svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents:
1019
diff
changeset
|
322 |
if (v->subtype == TS_Front_Engine) { |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
323 |
i = 0; |
0 | 324 |
u = v; |
325 |
do i++; while ( (u=u->next) != NULL); |
|
326 |
if (i > hnum) hnum = i; |
|
327 |
} |
|
328 |
} |
|
329 |
} |
|
914
c3ad2a35b937
(svn r1401) -Fix: glitches in train-depot GUI (tnx to Hackykid)
truelight
parents:
894
diff
changeset
|
330 |
|
c3ad2a35b937
(svn r1401) -Fix: glitches in train-depot GUI (tnx to Hackykid)
truelight
parents:
894
diff
changeset
|
331 |
/* Always have 1 empty row, so people can change the setting of the train */ |
c3ad2a35b937
(svn r1401) -Fix: glitches in train-depot GUI (tnx to Hackykid)
truelight
parents:
894
diff
changeset
|
332 |
num++; |
c3ad2a35b937
(svn r1401) -Fix: glitches in train-depot GUI (tnx to Hackykid)
truelight
parents:
894
diff
changeset
|
333 |
|
0 | 334 |
SetVScrollCount(w, num); |
335 |
SetHScrollCount(w, hnum); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
336 |
|
0 | 337 |
/* locate the depot struct */ |
877
a0849f41e748
(svn r1358) Assert bounds of depot list when searching for a depot
tron
parents:
867
diff
changeset
|
338 |
for (d = _depots; d->xy != (TileIndex)tile; d++) { |
878 | 339 |
assert(d < endof(_depots)); |
877
a0849f41e748
(svn r1358) Assert bounds of depot list when searching for a depot
tron
parents:
867
diff
changeset
|
340 |
} |
0 | 341 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
342 |
SetDParam(0, d->town_index); |
0 | 343 |
DrawWindowWidgets(w); |
344 |
||
345 |
x = 2; |
|
346 |
y = 15; |
|
347 |
num = w->vscroll.pos; |
|
348 |
||
349 |
// draw all trains |
|
350 |
FOR_ALL_VEHICLES(v) { |
|
351 |
if (v->type == VEH_Train && |
|
1067
a083a6dd1419
(svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents:
1019
diff
changeset
|
352 |
v->subtype == TS_Front_Engine && |
0 | 353 |
v->tile == (TileIndex)tile && |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
354 |
v->u.rail.track == 0x80 && |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
355 |
--num < 0 && num >= -w->vscroll.cap) { |
0 | 356 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
357 |
DrawTrainImage(v, x+21, y, w->hscroll.cap, w->hscroll.pos, WP(w,traindepot_d).sel); |
22 | 358 |
/* Draw the train number */ |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
359 |
SetDParam(0, v->unitnumber); |
0 | 360 |
DrawString(x, y, (v->max_age - 366 < v->age) ? STR_00E3 : STR_00E2, 0); |
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1017
diff
changeset
|
361 |
|
1002
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
362 |
/*Draw the train counter */ |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
363 |
i = 0; |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
364 |
u = v; |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
365 |
do i++; while ( (u=u->next) != NULL); //Determine length of train |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
366 |
SetDParam(0, i); //Set the counter |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
367 |
i = (w->hscroll.cap * 29) + (x + 26); //Calculate position of text according to window size |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
368 |
DrawStringCentered(i, y+5, STR_TINY_BLACK, 0); //Draw the counter |
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1017
diff
changeset
|
369 |
|
22 | 370 |
/* Draw the pretty flag */ |
0 | 371 |
DrawSprite(v->vehstatus&VS_STOPPED ? 0xC12 : 0xC13, x+15, y); |
372 |
||
373 |
y += 14; |
|
374 |
} |
|
375 |
} |
|
376 |
||
377 |
// draw all remaining vehicles |
|
378 |
FOR_ALL_VEHICLES(v) { |
|
379 |
if (v->type == VEH_Train && |
|
1067
a083a6dd1419
(svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents:
1019
diff
changeset
|
380 |
v->subtype == TS_Free_Car && |
0 | 381 |
v->tile == (TileIndex)tile && |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
382 |
v->u.rail.track == 0x80 && |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
383 |
--num < 0 && num >= -w->vscroll.cap) { |
0 | 384 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
385 |
DrawTrainImage(v, x+50, y, w->hscroll.cap - 1, 0, WP(w,traindepot_d).sel); |
0 | 386 |
DrawString(x, y+2, STR_8816, 0); |
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1017
diff
changeset
|
387 |
|
1002
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
388 |
/*Draw the train counter */ |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
389 |
i = 0; |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
390 |
u = v; |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
391 |
do i++; while ( (u=u->next) != NULL); //Determine length of train |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
392 |
SetDParam(0, i); //Set the counter |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
393 |
i = (w->hscroll.cap * 29) + (x + 26); //Calculate position of text according to window size |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
394 |
DrawStringCentered(i, y+5, STR_TINY_BLACK, 0); //Draw the counter |
0 | 395 |
y += 14; |
396 |
} |
|
397 |
} |
|
398 |
} |
|
399 |
||
400 |
typedef struct GetDepotVehiclePtData { |
|
401 |
Vehicle *head; |
|
402 |
Vehicle *wagon; |
|
403 |
} GetDepotVehiclePtData; |
|
404 |
||
405 |
static int GetVehicleFromTrainDepotWndPt(Window *w, int x, int y, GetDepotVehiclePtData *d) |
|
406 |
{ |
|
407 |
int area_x; |
|
408 |
int row; |
|
409 |
Vehicle *v; |
|
410 |
||
411 |
x = x - 23; |
|
412 |
if (x < 0) { |
|
413 |
area_x = (x >= -10) ? -2 : -1; |
|
414 |
} else { |
|
415 |
area_x = x / 29; |
|
416 |
} |
|
417 |
||
418 |
row = (y - 14) / 14; |
|
914
c3ad2a35b937
(svn r1401) -Fix: glitches in train-depot GUI (tnx to Hackykid)
truelight
parents:
894
diff
changeset
|
419 |
if ( (uint) row >= w->vscroll.cap) |
0 | 420 |
return 1; /* means err */ |
421 |
||
422 |
row += w->vscroll.pos; |
|
423 |
||
424 |
/* go through all the locomotives */ |
|
425 |
FOR_ALL_VEHICLES(v) { |
|
426 |
if (v->type == VEH_Train && |
|
1067
a083a6dd1419
(svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents:
1019
diff
changeset
|
427 |
v->subtype == TS_Front_Engine && |
0 | 428 |
v->tile == w->window_number && |
429 |
v->u.rail.track == 0x80 && |
|
430 |
--row < 0) { |
|
517
8729a9a72d78
(svn r842) -Fix: [ 985925 ] Start/stop flag in train depots always works, regardless of the horizontal scroll position
tron
parents:
507
diff
changeset
|
431 |
if (area_x >= 0) area_x += w->hscroll.pos; |
0 | 432 |
goto found_it; |
433 |
} |
|
434 |
} |
|
435 |
||
436 |
area_x--; /* free wagons don't have an initial loco. */ |
|
437 |
||
438 |
/* and then the list of free wagons */ |
|
439 |
FOR_ALL_VEHICLES(v) { |
|
440 |
if (v->type == VEH_Train && |
|
1067
a083a6dd1419
(svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents:
1019
diff
changeset
|
441 |
v->subtype == TS_Free_Car && |
0 | 442 |
v->tile == w->window_number && |
443 |
v->u.rail.track == 0x80 && |
|
444 |
--row < 0) |
|
445 |
goto found_it; |
|
446 |
} |
|
447 |
||
448 |
d->head = NULL; |
|
449 |
d->wagon = NULL; |
|
450 |
||
451 |
/* didn't find anything, get out */ |
|
452 |
return 0; |
|
453 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
454 |
found_it: |
0 | 455 |
d->head = d->wagon = v; |
456 |
||
457 |
/* either pressed the flag or the number, but only when it's a loco */ |
|
1067
a083a6dd1419
(svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents:
1019
diff
changeset
|
458 |
if (area_x < 0 && v->subtype == TS_Front_Engine) |
0 | 459 |
return area_x; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
460 |
|
0 | 461 |
/* find the vehicle in this row that was clicked */ |
462 |
while (--area_x >= 0) { |
|
463 |
v = v->next; |
|
464 |
if (v == NULL) break; |
|
465 |
} |
|
466 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
467 |
d->wagon = v; |
0 | 468 |
|
469 |
return 0; |
|
470 |
} |
|
471 |
||
472 |
static void TrainDepotMoveVehicle(Vehicle *wagon, int sel, Vehicle *head) |
|
473 |
{ |
|
474 |
Vehicle *v; |
|
475 |
||
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
476 |
v = GetVehicle(sel); |
0 | 477 |
|
1067
a083a6dd1419
(svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents:
1019
diff
changeset
|
478 |
if (/*v->subtype == TS_Front_Engine ||*/ v == wagon) |
0 | 479 |
return; |
480 |
||
481 |
if (wagon == NULL) { |
|
482 |
if (head != NULL) |
|
483 |
wagon = GetLastVehicleInChain(head); |
|
484 |
} else { |
|
485 |
wagon = GetPrevVehicleInChain(wagon); |
|
486 |
if (wagon == NULL) |
|
487 |
return; |
|
488 |
} |
|
489 |
||
490 |
if (wagon == v) |
|
491 |
return; |
|
492 |
||
493 |
DoCommandP(v->tile, v->index + ((wagon==NULL ? (uint32)-1 : wagon->index) << 16), _ctrl_pressed ? 1 : 0, NULL, CMD_MOVE_RAIL_VEHICLE | CMD_MSG(STR_8837_CAN_T_MOVE_VEHICLE)); |
|
494 |
} |
|
495 |
||
496 |
static void TrainDepotClickTrain(Window *w, int x, int y) |
|
497 |
{ |
|
498 |
GetDepotVehiclePtData gdvp; |
|
499 |
int mode, sel; |
|
500 |
Vehicle *v; |
|
501 |
||
502 |
mode = GetVehicleFromTrainDepotWndPt(w, x, y, &gdvp); |
|
10
c35ab8426202
(svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents:
0
diff
changeset
|
503 |
|
c35ab8426202
(svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents:
0
diff
changeset
|
504 |
// share / copy orders |
0 | 505 |
if (_thd.place_mode && mode <= 0) { _place_clicked_vehicle = gdvp.head; return; } |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
506 |
|
0 | 507 |
v = gdvp.wagon; |
508 |
||
509 |
switch(mode) { |
|
10
c35ab8426202
(svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents:
0
diff
changeset
|
510 |
case 0: // start dragging of vehicle |
0 | 511 |
sel = (int16)WP(w,traindepot_d).sel; |
512 |
if (sel != -1) { |
|
513 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
514 |
TrainDepotMoveVehicle(v, sel, gdvp.head); |
|
515 |
} else if (v != NULL) { |
|
516 |
WP(w,traindepot_d).sel = v->index; |
|
517 |
SetObjectToPlaceWnd( SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)) + GetTrainImage(v, 6), 4, w); |
|
518 |
SetWindowDirty(w); |
|
519 |
} |
|
520 |
break; |
|
521 |
||
10
c35ab8426202
(svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents:
0
diff
changeset
|
522 |
case -1: // show info window |
0 | 523 |
ShowTrainViewWindow(v); |
524 |
break; |
|
525 |
||
10
c35ab8426202
(svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents:
0
diff
changeset
|
526 |
case -2: // click start/stop flag |
0 | 527 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN)); |
528 |
break; |
|
529 |
} |
|
530 |
} |
|
531 |
||
532 |
static void TrainDepotWndProc(Window *w, WindowEvent *e) |
|
533 |
{ |
|
534 |
switch(e->event) { |
|
535 |
case WE_PAINT: |
|
536 |
DrawTrainDepotWindow(w); |
|
537 |
break; |
|
538 |
||
539 |
case WE_CLICK: { |
|
540 |
switch(e->click.widget) { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
541 |
case 8: |
0 | 542 |
ShowBuildTrainWindow(w->window_number); |
543 |
break; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
544 |
case 9: |
0 | 545 |
ScrollMainWindowToTile(w->window_number); |
546 |
break; |
|
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
968
diff
changeset
|
547 |
case 6: |
0 | 548 |
TrainDepotClickTrain(w, e->click.pt.x, e->click.pt.y); |
549 |
break; |
|
550 |
} |
|
551 |
} break; |
|
552 |
||
553 |
case WE_DESTROY: |
|
554 |
DeleteWindowById(WC_BUILD_VEHICLE, w->window_number); |
|
555 |
break; |
|
556 |
||
557 |
case WE_DRAGDROP: { |
|
558 |
switch(e->click.widget) { |
|
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
968
diff
changeset
|
559 |
case 4: case 5: { |
0 | 560 |
Vehicle *v; |
561 |
int sell_cmd; |
|
562 |
||
563 |
/* sell vehicle */ |
|
564 |
if (w->disabled_state & (1 << e->click.widget)) |
|
565 |
return; |
|
566 |
||
567 |
if (WP(w,traindepot_d).sel == INVALID_VEHICLE) |
|
568 |
return; |
|
569 |
||
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
570 |
v = GetVehicle(WP(w,traindepot_d).sel); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
571 |
|
0 | 572 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
573 |
SetWindowDirty(w); |
|
574 |
||
575 |
HandleButtonClick(w, e->click.widget); |
|
576 |
||
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
968
diff
changeset
|
577 |
sell_cmd = (e->click.widget == 5 || _ctrl_pressed) ? 1 : 0; |
0 | 578 |
|
1067
a083a6dd1419
(svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents:
1019
diff
changeset
|
579 |
if (v->subtype != TS_Front_Engine) { |
0 | 580 |
DoCommandP(v->tile, v->index, sell_cmd, NULL, CMD_SELL_RAIL_WAGON | CMD_MSG(STR_8839_CAN_T_SELL_RAILROAD_VEHICLE)); |
581 |
} else { |
|
582 |
_backup_orders_tile = v->tile; |
|
583 |
BackupVehicleOrders(v, _backup_orders_data); |
|
584 |
if (!DoCommandP(v->tile, v->index, sell_cmd, NULL, CMD_SELL_RAIL_WAGON | CMD_MSG(STR_8839_CAN_T_SELL_RAILROAD_VEHICLE))) |
|
585 |
_backup_orders_tile = 0; |
|
586 |
} |
|
587 |
} break; |
|
588 |
||
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
968
diff
changeset
|
589 |
case 6: { |
0 | 590 |
GetDepotVehiclePtData gdvp; |
591 |
VehicleID sel = WP(w,traindepot_d).sel; |
|
592 |
||
593 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
594 |
SetWindowDirty(w); |
|
595 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
596 |
if (GetVehicleFromTrainDepotWndPt(w, e->dragdrop.pt.x, e->dragdrop.pt.y, &gdvp) == 0 && |
0 | 597 |
sel != INVALID_VEHICLE) { |
598 |
if (gdvp.wagon == NULL || gdvp.wagon->index != sel) { |
|
599 |
TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head); |
|
1067
a083a6dd1419
(svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents:
1019
diff
changeset
|
600 |
} else if (gdvp.head != NULL && gdvp.head->subtype == TS_Front_Engine) { |
0 | 601 |
ShowTrainViewWindow(gdvp.head); |
602 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
603 |
} |
0 | 604 |
} break; |
605 |
||
606 |
default: |
|
607 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
608 |
SetWindowDirty(w); |
|
609 |
break; |
|
610 |
} |
|
611 |
} break; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
612 |
case WE_RESIZE: { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
613 |
/* Update the scroll + matrix */ |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
614 |
w->vscroll.cap += e->sizing.diff.y / 14; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
615 |
w->hscroll.cap += e->sizing.diff.x / 29; |
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
968
diff
changeset
|
616 |
w->widget[6].unkA = (w->vscroll.cap << 8) + 1; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
617 |
} break; |
0 | 618 |
} |
619 |
} |
|
620 |
||
621 |
static const Widget _train_depot_widgets[] = { |
|
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
968
diff
changeset
|
622 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1002
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
623 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 348, 0, 13, STR_8800_TRAIN_DEPOT, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
624 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 349, 360, 0, 13, 0x0, STR_STICKY_BUTTON}, |
0 | 625 |
|
1002
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
626 |
{ WWT_PANEL, RESIZE_LRB, 14, 326, 348, 14, 13, 0x0, STR_NULL}, |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
627 |
{ WWT_PANEL, RESIZE_LRTB, 14, 326, 348, 14, 54, 0x2A9, STR_8841_DRAG_TRAIN_VEHICLE_TO_HERE}, |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
628 |
{ WWT_PANEL, RESIZE_LRTB, 14, 326, 348, 55, 109, 0x2BF, STR_DRAG_WHOLE_TRAIN_TO_SELL_TIP}, |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
629 |
|
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
630 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 325, 14, 97, 0x601, STR_883F_TRAINS_CLICK_ON_TRAIN_FOR}, |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
631 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 349, 360, 14, 109, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
914
c3ad2a35b937
(svn r1401) -Fix: glitches in train-depot GUI (tnx to Hackykid)
truelight
parents:
894
diff
changeset
|
632 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 167, 110, 121, STR_8815_NEW_VEHICLES, STR_8840_BUILD_NEW_TRAIN_VEHICLE}, |
1002
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
633 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 168, 348, 110, 121, STR_00E4_LOCATION, STR_8842_CENTER_MAIN_VIEW_ON_TRAIN}, |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
634 |
{ WWT_HSCROLLBAR, RESIZE_RTB, 14, 0, 325, 98, 109, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
635 |
{ WWT_PANEL, RESIZE_RTB, 14, 349, 348, 110, 121, 0x0, STR_NULL}, |
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
636 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 349, 360, 110, 121, 0x0, STR_RESIZE_BUTTON}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
637 |
{ WIDGETS_END}, |
0 | 638 |
}; |
639 |
||
640 |
static const WindowDesc _train_depot_desc = { |
|
1002
ef08eb80686a
(svn r1500) -Feature: Train window shows now the number of vehicles per row (mpetrov)
celestar
parents:
982
diff
changeset
|
641 |
-1, -1, 361, 122, |
0 | 642 |
WC_VEHICLE_DEPOT,0, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
643 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 644 |
_train_depot_widgets, |
645 |
TrainDepotWndProc |
|
646 |
}; |
|
647 |
||
648 |
||
649 |
void ShowTrainDepotWindow(uint tile) |
|
650 |
{ |
|
651 |
Window *w; |
|
652 |
||
653 |
w = AllocateWindowDescFront(&_train_depot_desc, tile); |
|
654 |
if (w) { |
|
655 |
w->caption_color = _map_owner[w->window_number]; |
|
656 |
w->vscroll.cap = 6; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
657 |
w->hscroll.cap = 10; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
658 |
w->resize.step_width = 29; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
659 |
w->resize.step_height = 14; |
0 | 660 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
661 |
_backup_orders_tile = 0; |
|
662 |
} |
|
663 |
} |
|
664 |
||
665 |
const byte _rail_vehicle_refit_types[4][16] = { |
|
666 |
{ 0,1,2,4,5,6,7,8,9,10,0xFF }, // normal |
|
667 |
{ 0,1,4,5,6,7,9,11,10,0xFF }, // arctic |
|
668 |
{ 0,4,5,8,6,7,9,10,0xFF }, // desert |
|
669 |
{ 0,1,3,5,7,8,9,6,4,10,11,0xFF }// candy |
|
670 |
}; |
|
671 |
||
672 |
static void RailVehicleRefitWndProc(Window *w, WindowEvent *e) |
|
673 |
{ |
|
674 |
switch(e->event) { |
|
675 |
case WE_PAINT: { |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
676 |
Vehicle *v = GetVehicle(w->window_number); |
0 | 677 |
const byte *b; |
678 |
int sel; |
|
679 |
int x,y; |
|
680 |
byte color; |
|
681 |
int cargo; |
|
682 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
683 |
SetDParam(0, v->string_id); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
684 |
SetDParam(1, v->unitnumber); |
0 | 685 |
DrawWindowWidgets(w); |
686 |
||
687 |
DrawString(1, 15, STR_983F_SELECT_CARGO_TYPE_TO_CARRY, 0); |
|
688 |
||
689 |
cargo = -1; |
|
690 |
x = 6; |
|
691 |
y = 25; |
|
692 |
sel = WP(w,refit_d).sel; |
|
382
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
693 |
|
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
694 |
#define show_cargo(ctype) { \ |
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
695 |
color = 16; \ |
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
696 |
if (sel == 0) { \ |
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
697 |
cargo = ctype; \ |
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
698 |
color = 12; \ |
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
699 |
} \ |
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
700 |
sel--; \ |
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
701 |
DrawString(x, y, _cargoc.names_s[ctype], color); \ |
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
702 |
y += 10; \ |
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
703 |
} |
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
704 |
|
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
705 |
if (_engine_refit_masks[v->engine_type]) { |
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
706 |
uint32 mask = _engine_refit_masks[v->engine_type]; |
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
707 |
int cid = 0; |
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
708 |
|
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
709 |
for (; mask; mask >>= 1, cid++) { |
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
710 |
if (!(mask & 1)) // not this cid |
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
711 |
continue; |
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
712 |
if (!(_local_cargo_id_landscape[cid] & (1 << _opt.landscape))) // not in this landscape |
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
713 |
continue; |
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
714 |
|
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
715 |
show_cargo(_local_cargo_id_ctype[cid]); |
0 | 716 |
} |
382
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
717 |
|
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
718 |
} else { // generic refit list |
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
719 |
b = _rail_vehicle_refit_types[_opt.landscape]; |
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
720 |
do { |
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
721 |
show_cargo(*b); |
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
722 |
} while (*++b != 255); |
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
723 |
} |
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
724 |
|
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
725 |
#undef show_cargo |
0 | 726 |
|
727 |
WP(w,refit_d).cargo = cargo; |
|
728 |
||
729 |
if (cargo != -1) { |
|
730 |
int32 cost = DoCommandByTile(v->tile, v->index, cargo, 0, CMD_REFIT_RAIL_VEHICLE); |
|
731 |
if (cost != CMD_ERROR) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
732 |
SetDParam(2, cost); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
733 |
SetDParam(0, _cargoc.names_long_p[cargo]); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
734 |
SetDParam(1, _returned_refit_amount); |
0 | 735 |
DrawString(1, 137, STR_9840_NEW_CAPACITY_COST_OF_REFIT, 0); |
736 |
} |
|
737 |
} |
|
738 |
break; |
|
739 |
} |
|
740 |
||
741 |
case WE_CLICK: |
|
742 |
switch(e->click.widget) { |
|
743 |
case 2: { /* listbox */ |
|
744 |
int y = e->click.pt.y - 25; |
|
745 |
if (y >= 0) { |
|
746 |
WP(w,refit_d).sel = y / 10; |
|
747 |
SetWindowDirty(w); |
|
748 |
} |
|
749 |
} break; |
|
750 |
case 4: /* refit button */ |
|
751 |
if (WP(w,refit_d).cargo != 0xFF) { |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
752 |
Vehicle *v = GetVehicle(w->window_number); |
0 | 753 |
if (DoCommandP(v->tile, v->index, WP(w,refit_d).cargo, NULL, CMD_REFIT_RAIL_VEHICLE | CMD_MSG(STR_RAIL_CAN_T_REFIT_VEHICLE))) |
754 |
DeleteWindow(w); |
|
755 |
} |
|
756 |
break; |
|
757 |
} |
|
758 |
break; |
|
759 |
} |
|
760 |
} |
|
761 |
||
762 |
||
763 |
static const Widget _rail_vehicle_refit_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
764 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
765 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 239, 0, 13, STR_983B_REFIT, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
766 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 239, 14, 135, 0x0, STR_RAIL_SELECT_TYPE_OF_CARGO_FOR}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
767 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 239, 136, 157, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
768 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 239, 158, 169, STR_RAIL_REFIT_VEHICLE,STR_RAIL_REFIT_TO_CARRY_HIGHLIGHTED}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
769 |
{ WIDGETS_END}, |
0 | 770 |
}; |
771 |
||
772 |
static const WindowDesc _rail_vehicle_refit_desc = { |
|
773 |
-1,-1, 240, 170, |
|
774 |
WC_VEHICLE_REFIT,WC_VEHICLE_VIEW, |
|
775 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
776 |
_rail_vehicle_refit_widgets, |
|
777 |
RailVehicleRefitWndProc, |
|
778 |
}; |
|
779 |
||
780 |
static void ShowRailVehicleRefitWindow(Vehicle *v) |
|
781 |
{ |
|
782 |
Window *w; |
|
783 |
DeleteWindowById(WC_VEHICLE_REFIT, v->index); |
|
784 |
_alloc_wnd_parent_num = v->index; |
|
785 |
w = AllocateWindowDesc(&_rail_vehicle_refit_desc); |
|
786 |
w->window_number = v->index; |
|
787 |
w->caption_color = v->owner; |
|
788 |
WP(w,refit_d).sel = -1; |
|
789 |
} |
|
790 |
||
791 |
static Widget _train_view_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
792 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5,STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
793 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 237, 0, 13, STR_882E,STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
794 |
{ WWT_STICKYBOX, RESIZE_NONE, 14, 238, 249, 0, 13, 0x0, STR_STICKY_BUTTON}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
795 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 231, 14, 121, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
796 |
{ WWT_6, RESIZE_NONE, 14, 2, 229, 16, 119, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
797 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 0, 249, 122, 133, 0x0, STR_8846_CURRENT_TRAIN_ACTION_CLICK}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
798 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 232, 249, 14, 31, 0x2AB, STR_8848_CENTER_MAIN_VIEW_ON_TRAIN}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
799 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 232, 249, 32, 49, 0x2AD, STR_8849_SEND_TRAIN_TO_DEPOT}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
800 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 232, 249, 50, 67, 0x2B1, STR_884A_FORCE_TRAIN_TO_PROCEED}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
801 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 232, 249, 68, 85, 0x2CB, STR_884B_REVERSE_DIRECTION_OF_TRAIN}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
802 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 232, 249, 86, 103, 0x2B2, STR_8847_SHOW_TRAIN_S_ORDERS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
803 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 232, 249, 104, 121, 0x2B3, STR_884C_SHOW_TRAIN_DETAILS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
804 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 232, 249, 68, 85, 0x2B4, STR_RAIL_REFIT_VEHICLE_TO_CARRY}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
805 |
{ WIDGETS_END}, |
0 | 806 |
}; |
807 |
||
808 |
static void TrainViewWndProc(Window *w, WindowEvent *e) |
|
809 |
{ |
|
810 |
switch(e->event) { |
|
811 |
case WE_PAINT: { |
|
812 |
Vehicle *v; |
|
813 |
StringID str; |
|
814 |
||
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
815 |
v = GetVehicle(w->window_number); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
816 |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
817 |
w->disabled_state = (v->owner == _local_player) ? 0 : 0x380; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
818 |
|
1006
c55d1a0359a3
(svn r1505) -Fix: Refit engine button is now disabled when cargo capacity equals zero
celestar
parents:
1002
diff
changeset
|
819 |
if (v->cargo_cap == 0) { |
c55d1a0359a3
(svn r1505) -Fix: Refit engine button is now disabled when cargo capacity equals zero
celestar
parents:
1002
diff
changeset
|
820 |
//we cannot refit this engine |
c55d1a0359a3
(svn r1505) -Fix: Refit engine button is now disabled when cargo capacity equals zero
celestar
parents:
1002
diff
changeset
|
821 |
SETBIT(w->disabled_state, 12); |
c55d1a0359a3
(svn r1505) -Fix: Refit engine button is now disabled when cargo capacity equals zero
celestar
parents:
1002
diff
changeset
|
822 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
823 |
|
0 | 824 |
/* draw widgets & caption */ |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
825 |
SetDParam(0, v->string_id); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
826 |
SetDParam(1, v->unitnumber); |
0 | 827 |
DrawWindowWidgets(w); |
828 |
||
829 |
/* draw the flag */ |
|
830 |
DrawSprite( (v->vehstatus&VS_STOPPED) ? 0xC12 : 0xC13, 2, 123); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
831 |
|
0 | 832 |
if (v->u.rail.crash_anim_pos != 0) { |
833 |
str = STR_8863_CRASHED; |
|
834 |
} else if (v->breakdown_ctr == 1) { |
|
835 |
str = STR_885C_BROKEN_DOWN; |
|
836 |
} else if (v->vehstatus & VS_STOPPED) { |
|
837 |
if (v->u.rail.last_speed == 0) { |
|
838 |
str = STR_8861_STOPPED; |
|
839 |
} else { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
840 |
SetDParam(0, v->u.rail.last_speed * 10 >> 4); |
0 | 841 |
str = STR_TRAIN_STOPPING + _patches.vehicle_speed; |
842 |
} |
|
843 |
} else { |
|
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
844 |
switch (v->current_order.type) { |
0 | 845 |
case OT_GOTO_STATION: { |
846 |
str = STR_HEADING_FOR_STATION + _patches.vehicle_speed; |
|
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
847 |
SetDParam(0, v->current_order.station); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
848 |
SetDParam(1, v->u.rail.last_speed * 10 >> 4); |
0 | 849 |
} break; |
850 |
||
851 |
case OT_GOTO_DEPOT: { |
|
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
852 |
Depot *dep = &_depots[v->current_order.station]; |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
853 |
SetDParam(0, dep->town_index); |
0 | 854 |
str = STR_HEADING_FOR_TRAIN_DEPOT + _patches.vehicle_speed; |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
855 |
SetDParam(1, v->u.rail.last_speed * 10 >> 4); |
0 | 856 |
} break; |
857 |
||
858 |
case OT_LOADING: |
|
859 |
case OT_LEAVESTATION: |
|
860 |
str = STR_882F_LOADING_UNLOADING; |
|
861 |
break; |
|
862 |
||
395
4c990f33dab7
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
382
diff
changeset
|
863 |
case OT_GOTO_WAYPOINT: { |
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
864 |
SetDParam(0, v->current_order.station); |
395
4c990f33dab7
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
382
diff
changeset
|
865 |
str = STR_HEADING_FOR_WAYPOINT + _patches.vehicle_speed; |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
866 |
SetDParam(1, v->u.rail.last_speed * 10 >> 4); |
0 | 867 |
break; |
868 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
869 |
|
0 | 870 |
default: |
871 |
if (v->num_orders == 0) { |
|
872 |
str = STR_NO_ORDERS + _patches.vehicle_speed; |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
873 |
SetDParam(0, v->u.rail.last_speed * 10 >> 4); |
0 | 874 |
} else |
875 |
str = STR_EMPTY; |
|
876 |
break; |
|
877 |
} |
|
878 |
} |
|
879 |
||
880 |
DrawStringCentered(125, 123, str, 0); |
|
881 |
DrawWindowViewport(w); |
|
882 |
} break; |
|
883 |
||
884 |
case WE_CLICK: { |
|
885 |
int wid = e->click.widget; |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
886 |
Vehicle *v = GetVehicle(w->window_number); |
0 | 887 |
|
888 |
switch(wid) { |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
889 |
case 5: /* start/stop train */ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
890 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN)); |
0 | 891 |
break; |
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
892 |
case 6: /* center main view */ |
0 | 893 |
ScrollMainWindowTo(v->x_pos, v->y_pos); |
894 |
break; |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
895 |
case 7: /* goto depot */ |
601
952c0295f79a
(svn r1025) -Fix: [Network] [ 1083687 ] Sending to depot caused desync because the
truelight
parents:
588
diff
changeset
|
896 |
/* TrainGotoDepot has a nice randomizer in the pathfinder, which causes desyncs... */ |
952c0295f79a
(svn r1025) -Fix: [Network] [ 1083687 ] Sending to depot caused desync because the
truelight
parents:
588
diff
changeset
|
897 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_TRAIN_GOTO_DEPOT | CMD_NO_TEST_IF_IN_NETWORK | CMD_MSG(STR_8830_CAN_T_SEND_TRAIN_TO_DEPOT)); |
0 | 898 |
break; |
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
899 |
case 8: /* force proceed */ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
900 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_FORCE_TRAIN_PROCEED | CMD_MSG(STR_8862_CAN_T_MAKE_TRAIN_PASS_SIGNAL)); |
0 | 901 |
break; |
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
902 |
case 9: /* reverse direction */ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
903 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_8869_CAN_T_REVERSE_DIRECTION)); |
0 | 904 |
break; |
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
905 |
case 10: /* show train orders */ |
0 | 906 |
ShowOrdersWindow(v); |
907 |
break; |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
908 |
case 11: /* show train details */ |
0 | 909 |
ShowTrainDetailsWindow(v); |
910 |
break; |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
911 |
case 12: |
0 | 912 |
ShowRailVehicleRefitWindow(v); |
913 |
break; |
|
914 |
} |
|
915 |
} break; |
|
916 |
||
917 |
case WE_DESTROY: |
|
338
04ad3e897bf8
(svn r514) -Fix: [1053397] Refit Train Window Stays Open
tron
parents:
243
diff
changeset
|
918 |
DeleteWindowById(WC_VEHICLE_REFIT, w->window_number); |
0 | 919 |
DeleteWindowById(WC_VEHICLE_ORDERS, w->window_number); |
920 |
DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number); |
|
921 |
break; |
|
922 |
||
923 |
case WE_MOUSELOOP: { |
|
924 |
Vehicle *v; |
|
925 |
uint32 h; |
|
926 |
||
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
927 |
v = GetVehicle(w->window_number); |
0 | 928 |
assert(v->type == VEH_Train); |
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
929 |
h = CheckStoppedInDepot(v) >= 0 ? (1 << 9) : (1 << 12); |
0 | 930 |
if (h != w->hidden_state) { |
931 |
w->hidden_state = h; |
|
932 |
SetWindowDirty(w); |
|
933 |
} |
|
934 |
break; |
|
935 |
} |
|
936 |
||
937 |
} |
|
938 |
} |
|
939 |
||
940 |
static const WindowDesc _train_view_desc = { |
|
941 |
-1,-1, 250, 134, |
|
942 |
WC_VEHICLE_VIEW,0, |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
943 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, |
0 | 944 |
_train_view_widgets, |
945 |
TrainViewWndProc |
|
946 |
}; |
|
947 |
||
948 |
void ShowTrainViewWindow(Vehicle *v) |
|
949 |
{ |
|
950 |
Window *w; |
|
951 |
||
952 |
w = AllocateWindowDescFront(&_train_view_desc,v->index); |
|
953 |
if (w) { |
|
954 |
w->caption_color = v->owner; |
|
955 |
AssignWindowViewport(w, 3, 17, 0xE2, 0x66, w->window_number | (1 << 31), 0); |
|
956 |
} |
|
957 |
} |
|
958 |
||
959 |
static void TrainDetailsCargoTab(Vehicle *v, int x, int y) |
|
960 |
{ |
|
961 |
int num; |
|
962 |
StringID str; |
|
963 |
||
964 |
if (v->cargo_cap != 0) { |
|
965 |
num = v->cargo_count; |
|
966 |
str = STR_8812_EMPTY; |
|
967 |
if (num != 0) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
968 |
SetDParam(0, v->cargo_type); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
969 |
SetDParam(1, num); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
970 |
SetDParam(2, v->cargo_source); |
0 | 971 |
str = STR_8813_FROM; |
972 |
} |
|
973 |
DrawString(x, y, str, 0); |
|
974 |
} |
|
975 |
} |
|
976 |
||
977 |
static void TrainDetailsInfoTab(Vehicle *v, int x, int y) |
|
978 |
{ |
|
540
fbed599dadbb
(svn r924) Use RailVehInfo() instead of &_rail_vehicle_info[]
tron
parents:
539
diff
changeset
|
979 |
const RailVehicleInfo *rvi = RailVehInfo(v->engine_type); |
0 | 980 |
|
981 |
if (!(rvi->flags & RVI_WAGON)) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
982 |
SetDParam(0, GetCustomEngineName(v->engine_type)); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
983 |
SetDParam(1, v->build_year + 1920); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
984 |
SetDParam(2, v->value); |
0 | 985 |
DrawString(x, y, STR_882C_BUILT_VALUE, 0x10); |
986 |
} else { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
987 |
SetDParam(0, GetCustomEngineName(v->engine_type)); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
988 |
SetDParam(1, v->value); |
0 | 989 |
DrawString(x, y, STR_882D_VALUE, 0x10); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
990 |
} |
0 | 991 |
} |
992 |
||
993 |
static void TrainDetailsCapacityTab(Vehicle *v, int x, int y) |
|
994 |
{ |
|
995 |
if (v->cargo_cap != 0) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
996 |
SetDParam(1, v->cargo_cap); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
997 |
SetDParam(0, _cargoc.names_long_p[v->cargo_type]); |
0 | 998 |
DrawString(x, y, STR_013F_CAPACITY, 0); |
999 |
} |
|
1000 |
} |
|
1001 |
||
1002 |
typedef void TrainDetailsDrawerProc(Vehicle *v, int x, int y); |
|
1003 |
||
1004 |
static TrainDetailsDrawerProc * const _train_details_drawer_proc[3] = { |
|
1005 |
TrainDetailsCargoTab, |
|
1006 |
TrainDetailsInfoTab, |
|
1007 |
TrainDetailsCapacityTab, |
|
1008 |
}; |
|
1009 |
||
1010 |
static void DrawTrainDetailsWindow(Window *w) |
|
1011 |
{ |
|
1012 |
Vehicle *v, *u; |
|
1013 |
uint16 tot_cargo[NUM_CARGO][2]; // count total cargo ([0]-actual cargo, [1]-total cargo) |
|
1014 |
int i,num,x,y,sel; |
|
1015 |
StringID str; |
|
1016 |
byte det_tab = WP(w, traindetails_d).tab; |
|
1017 |
||
1018 |
/* Count number of vehicles */ |
|
1019 |
num = 0; |
|
1020 |
||
1021 |
// det_tab == 3 <-- Total Cargo tab |
|
1022 |
if (det_tab == 3) // reset tot_cargo array to 0 values |
|
1023 |
memset(tot_cargo, 0, sizeof(tot_cargo)); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1024 |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
1025 |
u = v = GetVehicle(w->window_number); |
0 | 1026 |
do { |
1027 |
if (det_tab != 3) |
|
1028 |
num++; |
|
1029 |
else { |
|
1030 |
tot_cargo[u->cargo_type][0] += u->cargo_count; |
|
1031 |
tot_cargo[u->cargo_type][1] += u->cargo_cap; |
|
1032 |
} |
|
1033 |
} while ( (u = u->next) != NULL); |
|
1034 |
||
1035 |
/* set scroll-amount seperately from counting, as to not |
|
1036 |
compute num double for more carriages of the same type |
|
1037 |
*/ |
|
1038 |
if (det_tab == 3) { |
|
1039 |
for (i = 0; i != NUM_CARGO; i++) { |
|
1040 |
if (tot_cargo[i][1] > 0) // only count carriages that the train has |
|
1041 |
num++; |
|
1042 |
} |
|
1043 |
num++; // needs one more because first line is description string |
|
1044 |
} |
|
1045 |
||
1046 |
SetVScrollCount(w, num); |
|
1047 |
||
1048 |
w->disabled_state = 1 << (det_tab + 9); |
|
1049 |
if (v->owner != _local_player) |
|
1050 |
w->disabled_state |= (1 << 2); |
|
1051 |
||
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
22
diff
changeset
|
1052 |
if (!_patches.servint_trains) // disable service-scroller when interval is set to disabled |
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
22
diff
changeset
|
1053 |
w->disabled_state |= (1 << 6) | (1 << 7); |
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
22
diff
changeset
|
1054 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1055 |
SetDParam(0, v->string_id); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1056 |
SetDParam(1, v->unitnumber); |
0 | 1057 |
DrawWindowWidgets(w); |
1058 |
||
1059 |
num = v->age / 366; |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1060 |
SetDParam(1, num); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1061 |
|
0 | 1062 |
x = 2; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1063 |
|
0 | 1064 |
str = STR_0199_YEAR; |
1065 |
if (num != 1) { |
|
1066 |
str += STR_019A_YEARS - STR_0199_YEAR; |
|
1067 |
if ((uint16)(v->max_age - 366) < v->age) |
|
1068 |
str += STR_019B_YEARS - STR_019A_YEARS; |
|
1069 |
} |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1070 |
SetDParam(0, str); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1071 |
SetDParam(2, v->max_age / 366); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1072 |
SetDParam(3, GetTrainRunningCost(v) >> 8); |
0 | 1073 |
DrawString(x, 15, STR_885D_AGE_RUNNING_COST_YR, 0); |
1074 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1075 |
SetDParam(2, v->max_speed * 10 >> 4); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1076 |
SetDParam(1, v->u.rail.cached_power); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1077 |
SetDParam(0, v->u.rail.cached_weight); |
0 | 1078 |
DrawString(x, 25, STR_885E_WEIGHT_T_POWER_HP_MAX_SPEED, 0); |
1079 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1080 |
SetDParam(0, v->profit_this_year); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1081 |
SetDParam(1, v->profit_last_year); |
0 | 1082 |
DrawString(x, 35, STR_885F_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
1083 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1084 |
SetDParam(0, 100 * (v->reliability>>8) >> 8); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1085 |
SetDParam(1, v->breakdowns_since_last_service); |
0 | 1086 |
DrawString(x, 45, STR_8860_RELIABILITY_BREAKDOWNS, 0); |
1087 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1088 |
SetDParam(0, v->service_interval); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1089 |
SetDParam(1, v->date_of_last_service); |
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
22
diff
changeset
|
1090 |
DrawString(x + 11, 141, _patches.servint_ispercent?STR_SERVICING_INTERVAL_PERCENT:STR_883C_SERVICING_INTERVAL_DAYS, 0); |
0 | 1091 |
|
1092 |
x = 1; |
|
1093 |
y = 57; |
|
1094 |
sel = w->vscroll.pos; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1095 |
|
0 | 1096 |
// draw the first 3 details tabs |
1097 |
if (det_tab != 3) { |
|
1098 |
for(;;) { |
|
1099 |
if (--sel < 0 && sel >= -6) { |
|
1100 |
DrawTrainImage(v, x, y, 1, 0, INVALID_VEHICLE); |
|
1101 |
_train_details_drawer_proc[WP(w,traindetails_d).tab](v, x + 30, y + 2); |
|
1102 |
y += 14; |
|
1103 |
} |
|
1104 |
if ( (v=v->next) == NULL) |
|
1105 |
return; |
|
1106 |
} |
|
1107 |
} |
|
1108 |
else { // draw total cargo tab |
|
1109 |
i = 0; |
|
1110 |
DrawString(x, y + 2, STR_013F_TOTAL_CAPACITY_TEXT, 0); |
|
1111 |
do { |
|
1112 |
if (tot_cargo[i][1] > 0 && --sel < 0 && sel >= -5) { |
|
1113 |
y += 14; |
|
1114 |
// STR_013F_TOTAL_CAPACITY :{LTBLUE}- {CARGO} ({SHORTCARGO}) |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1115 |
SetDParam(0, i); // {CARGO} #1 |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1116 |
SetDParam(1, tot_cargo[i][0]); // {CARGO} #2 |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1117 |
SetDParam(2, i); // {SHORTCARGO} #1 |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1118 |
SetDParam(3, tot_cargo[i][1]); // {SHORTCARGO} #2 |
0 | 1119 |
DrawString(x, y, STR_013F_TOTAL_CAPACITY, 0); |
1120 |
} |
|
1121 |
} while (++i != NUM_CARGO); |
|
1122 |
} |
|
1123 |
} |
|
1124 |
||
1125 |
static void TrainDetailsWndProc(Window *w, WindowEvent *e) |
|
1126 |
{ |
|
1127 |
switch(e->event) { |
|
1128 |
case WE_PAINT: |
|
1129 |
DrawTrainDetailsWindow(w); |
|
1130 |
break; |
|
1131 |
case WE_CLICK: { |
|
1132 |
int mod; |
|
1133 |
Vehicle *v; |
|
1134 |
switch(e->click.widget) { |
|
1135 |
case 2: /* name train */ |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
1136 |
v = GetVehicle(w->window_number); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
1137 |
SetDParam(0, v->unitnumber); |
0 | 1138 |
ShowQueryString(v->string_id, STR_8865_NAME_TRAIN, 31, 150, w->window_class, w->window_number); |
1139 |
break; |
|
1140 |
case 6: /* inc serv interval */ |
|
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
22
diff
changeset
|
1141 |
mod = _ctrl_pressed? 5 : 10; |
0 | 1142 |
goto do_change_service_int; |
1143 |
||
1144 |
case 7: /* dec serv interval */ |
|
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
22
diff
changeset
|
1145 |
mod = _ctrl_pressed? -5 : -10; |
0 | 1146 |
do_change_service_int: |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
1147 |
v = GetVehicle(w->window_number); |
0 | 1148 |
mod += v->service_interval; |
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
22
diff
changeset
|
1149 |
|
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
22
diff
changeset
|
1150 |
/* %-based service interval max 5%-90% |
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
22
diff
changeset
|
1151 |
day-based service interval max 30-800 days */ |
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
22
diff
changeset
|
1152 |
mod = _patches.servint_ispercent ? clamp(mod, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : clamp(mod, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS+1); |
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
22
diff
changeset
|
1153 |
if (mod == v->service_interval) |
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
22
diff
changeset
|
1154 |
return; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1155 |
|
0 | 1156 |
DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_TRAIN_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING)); |
1157 |
break; |
|
1158 |
/* details buttons*/ |
|
1159 |
case 9: // Cargo |
|
1160 |
case 10: // Information |
|
1161 |
case 11: // Capacities |
|
1162 |
case 12: // Total cargo |
|
1163 |
CLRBIT(w->disabled_state, 9); |
|
1164 |
CLRBIT(w->disabled_state, 10); |
|
1165 |
CLRBIT(w->disabled_state, 11); |
|
1166 |
CLRBIT(w->disabled_state, 12); |
|
1167 |
SETBIT(w->disabled_state, e->click.widget); |
|
1168 |
WP(w,traindetails_d).tab = e->click.widget - 9; |
|
1169 |
SetWindowDirty(w); |
|
1170 |
break; |
|
1171 |
} |
|
1172 |
} break; |
|
1173 |
||
1174 |
case WE_4: |
|
1175 |
if (FindWindowById(WC_VEHICLE_VIEW, w->window_number) == NULL) |
|
1176 |
DeleteWindow(w); |
|
1177 |
break; |
|
1178 |
||
1179 |
case WE_ON_EDIT_TEXT: { |
|
1180 |
byte *b = e->edittext.str; |
|
1181 |
if (*b == 0) |
|
1182 |
return; |
|
1183 |
memcpy(_decode_parameters, b, 32); |
|
1184 |
DoCommandP(0, w->window_number, 0, NULL, CMD_NAME_VEHICLE | CMD_MSG(STR_8866_CAN_T_NAME_TRAIN)); |
|
1185 |
} break; |
|
1186 |
} |
|
1187 |
} |
|
1188 |
||
1189 |
static const Widget _train_details_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1190 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1191 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 329, 0, 13, STR_8802_DETAILS,STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1192 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 330, 369, 0, 13, STR_01AA_NAME, STR_8867_NAME_TRAIN}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1193 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 369, 14, 55, 0x0, STR_NULL}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
1194 |
{ WWT_MATRIX, RESIZE_NONE, 14, 0, 357, 56, 139, 0x601, STR_NULL}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
1195 |
{ WWT_SCROLLBAR, RESIZE_NONE, 14, 358, 369, 56, 139, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1196 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 10, 140, 145, STR_0188, STR_884D_INCREASE_SERVICING_INTERVAL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1197 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 10, 146, 151, STR_0189, STR_884E_DECREASE_SERVICING_INTERVAL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1198 |
{ WWT_PANEL, RESIZE_NONE, 14, 11, 369, 140, 151, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1199 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 92, 152, 163, STR_013C_CARGO, STR_884F_SHOW_DETAILS_OF_CARGO_CARRIED}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1200 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 93, 184, 152, 163, STR_013D_INFORMATION, STR_8850_SHOW_DETAILS_OF_TRAIN_VEHICLES}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1201 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 185, 277, 152, 163, STR_013E_CAPACITIES, STR_8851_SHOW_CAPACITIES_OF_EACH}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1202 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 278, 369, 152, 163, STR_013E_TOTAL_CARGO, STR_8852_SHOW_TOTAL_CARGO}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
1203 |
{ WIDGETS_END}, |
0 | 1204 |
}; |
1205 |
||
1206 |
||
1207 |
static const WindowDesc _train_details_desc = { |
|
1208 |
-1,-1, 370, 164, |
|
1209 |
WC_VEHICLE_DETAILS,WC_VEHICLE_VIEW, |
|
1210 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
1211 |
_train_details_widgets, |
|
1212 |
TrainDetailsWndProc |
|
1213 |
}; |
|
1214 |
||
1215 |
||
1216 |
void ShowTrainDetailsWindow(Vehicle *v) |
|
1217 |
{ |
|
1218 |
Window *w; |
|
1219 |
VehicleID veh = v->index; |
|
1220 |
||
1221 |
DeleteWindowById(WC_VEHICLE_ORDERS, veh); |
|
1222 |
DeleteWindowById(WC_VEHICLE_DETAILS, veh); |
|
1223 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1224 |
_alloc_wnd_parent_num = veh; |
0 | 1225 |
w = AllocateWindowDesc(&_train_details_desc); |
1226 |
||
1227 |
w->window_number = veh; |
|
1228 |
w->caption_color = v->owner; |
|
1229 |
w->vscroll.cap = 6; |
|
1230 |
WP(w,traindetails_d).tab = 0; |
|
1231 |
} |
|
1232 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1233 |
static const Widget _player_trains_widgets[] = { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1234 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1235 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 312, 0, 13, STR_881B_TRAINS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1236 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 313, 324, 0, 13, 0x0, STR_STICKY_BUTTON}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1237 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_ORDER_TIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1238 |
{ WWT_PANEL, RESIZE_NONE, 14, 81, 232, 14, 25, 0x0, STR_SORT_CRITERIA_TIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1239 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 233, 243, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1240 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 244, 324, 14, 25, 0x0, STR_NULL}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
1241 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 312, 26, 207, 0x701, STR_883D_TRAINS_CLICK_ON_TRAIN_FOR}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
1242 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 313, 324, 26, 207, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1243 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 156, 208, 219, STR_8815_NEW_VEHICLES, STR_883E_BUILD_NEW_TRAINS_REQUIRES}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
1244 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 157, 312, 208, 219, STR_REPLACE_VEHICLES, STR_REPLACE_HELP}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
1245 |
{ WWT_PANEL, RESIZE_RTB, 14, 313, 312, 208, 219, 0x0, STR_NULL}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
1246 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 313, 324, 208, 219, 0x0, STR_RESIZE_BUTTON}, |
588 | 1247 |
{ WIDGETS_END}, |
1248 |
}; |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1249 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1250 |
static const Widget _other_player_trains_widgets[] = { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1251 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1252 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 312, 0, 13, STR_881B_TRAINS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1253 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 313, 324, 0, 13, 0x0, STR_STICKY_BUTTON}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1254 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_ORDER_TIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1255 |
{ WWT_PANEL, RESIZE_NONE, 14, 81, 232, 14, 25, 0x0, STR_SORT_CRITERIA_TIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1256 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 233, 243, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1257 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 244, 324, 14, 25, 0x0, STR_NULL}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
1258 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 312, 26, 207, 0x701, STR_883D_TRAINS_CLICK_ON_TRAIN_FOR}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
1259 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 313, 324, 26, 207, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
1260 |
{ WWT_PANEL, RESIZE_RTB, 14, 0, 312, 208, 219, 0x0, STR_NULL}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
1261 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 313, 324, 208, 219, 0x0, STR_RESIZE_BUTTON}, |
588 | 1262 |
{ WIDGETS_END}, |
1263 |
}; |
|
0 | 1264 |
|
1265 |
static void PlayerTrainsWndProc(Window *w, WindowEvent *e) |
|
1266 |
{ |
|
588 | 1267 |
int station = (int)w->window_number >> 16; |
1268 |
int owner = w->window_number & 0xff; |
|
1269 |
vehiclelist_d *vl = &WP(w, vehiclelist_d); |
|
1270 |
||
0 | 1271 |
switch(e->event) { |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1272 |
case WE_PAINT: { |
588 | 1273 |
int x = 2; |
1274 |
int y = PLY_WND_PRC__OFFSET_TOP_WIDGET; |
|
1275 |
int max; |
|
1276 |
int i; |
|
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1277 |
|
588 | 1278 |
BuildVehicleList(vl, VEH_Train, owner, station); |
1279 |
SortVehicleList(vl); |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1280 |
|
588 | 1281 |
SetVScrollCount(w, vl->list_length); |
1282 |
||
1283 |
// disable 'Sort By' tooltip on Unsorted sorting criteria |
|
1284 |
if (vl->sort_type == SORT_BY_UNSORTED) |
|
757 | 1285 |
w->disabled_state |= (1 << 3); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1286 |
|
0 | 1287 |
/* draw the widgets */ |
1288 |
{ |
|
588 | 1289 |
const Player *p = DEREF_PLAYER(owner); |
1290 |
if (station == -1) { |
|
1291 |
/* Company Name -- (###) Trains */ |
|
1292 |
SetDParam(0, p->name_1); |
|
1293 |
SetDParam(1, p->name_2); |
|
1294 |
SetDParam(2, w->vscroll.count); |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1295 |
w->widget[1].unkA = STR_881B_TRAINS; |
588 | 1296 |
} else { |
1297 |
/* Station Name -- (###) Trains */ |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
1298 |
SetDParam(0, GetStation(station)->index); |
588 | 1299 |
SetDParam(1, w->vscroll.count); |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1300 |
w->widget[1].unkA = STR_SCHEDULED_TRAINS; |
588 | 1301 |
} |
0 | 1302 |
DrawWindowWidgets(w); |
1303 |
} |
|
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1304 |
/* draw sorting criteria string */ |
588 | 1305 |
DrawString(85, 15, _vehicle_sort_listing[vl->sort_type], 0x10); |
1306 |
/* draw arrow pointing up/down for ascending/descending sorting */ |
|
1307 |
DoDrawString( |
|
1308 |
vl->flags & VL_DESC ? "\xAA" : "\xA0", 69, 15, 0x10); |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1309 |
|
588 | 1310 |
max = min(w->vscroll.pos + w->vscroll.cap, vl->list_length); |
1311 |
for (i = w->vscroll.pos; i < max; ++i) { |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
1312 |
Vehicle *v = GetVehicle(vl->sort_list[i].index); |
588 | 1313 |
StringID str; |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1314 |
|
588 | 1315 |
assert(v->type == VEH_Train && v->owner == owner); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1316 |
|
588 | 1317 |
DrawTrainImage( |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1318 |
v, x + 21, y + 6 + _traininfo_vehicle_pitch, w->hscroll.cap, 0, INVALID_VEHICLE); |
588 | 1319 |
DrawVehicleProfitButton(v, x, y + 13); |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1320 |
|
588 | 1321 |
SetDParam(0, v->unitnumber); |
1151
614cbcb5b9fe
(svn r1652) Fix: train and road vehicle lists are now redrawn when vehicles enters/leaves a depot (Hackykid)
bjarni
parents:
1067
diff
changeset
|
1322 |
if (IsTrainDepotTile(v->tile) && (v->vehstatus & VS_HIDDEN)) |
588 | 1323 |
str = STR_021F; |
1324 |
else |
|
1325 |
str = v->age > v->max_age - 366 ? STR_00E3 : STR_00E2; |
|
1326 |
DrawString(x, y + 2, str, 0); |
|
1327 |
||
1328 |
SetDParam(0, v->profit_this_year); |
|
1329 |
SetDParam(1, v->profit_last_year); |
|
1330 |
DrawString(x + 21, y + 18, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
|
1331 |
||
1332 |
if (v->string_id != STR_SV_TRAIN_NAME) { |
|
1333 |
SetDParam(0, v->string_id); |
|
1334 |
DrawString(x + 21, y, STR_01AB, 0); |
|
0 | 1335 |
} |
588 | 1336 |
|
1337 |
y += PLY_WND_PRC__SIZE_OF_ROW_SMALL; |
|
0 | 1338 |
} |
588 | 1339 |
break; |
1340 |
} |
|
0 | 1341 |
|
1342 |
case WE_CLICK: { |
|
1343 |
switch(e->click.widget) { |
|
757 | 1344 |
case 3: /* Flip sorting method ascending/descending */ |
588 | 1345 |
vl->flags ^= VL_DESC; |
1346 |
vl->flags |= VL_RESORT; |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1347 |
SetWindowDirty(w); |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1348 |
break; |
588 | 1349 |
|
757 | 1350 |
case 4: case 5:/* Select sorting criteria dropdown menu */ |
842 | 1351 |
ShowDropDownMenu(w, _vehicle_sort_listing, vl->sort_type, 5, 0, 0); |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1352 |
return; |
588 | 1353 |
|
757 | 1354 |
case 7: { /* Matrix to show vehicles */ |
174
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
168
diff
changeset
|
1355 |
uint32 id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_SMALL; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1356 |
|
174
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
168
diff
changeset
|
1357 |
if (id_v >= w->vscroll.cap) { return;} // click out of bounds |
0 | 1358 |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1359 |
id_v += w->vscroll.pos; |
0 | 1360 |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1361 |
{ |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1362 |
Vehicle *v; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1363 |
|
588 | 1364 |
if (id_v >= vl->list_length) return; // click out of list bound |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1365 |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
1366 |
v = GetVehicle(vl->sort_list[id_v].index); |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1367 |
|
1067
a083a6dd1419
(svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents:
1019
diff
changeset
|
1368 |
assert(v->type == VEH_Train && v->subtype == TS_Front_Engine && v->owner == owner); |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1369 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1370 |
ShowTrainViewWindow(v); |
0 | 1371 |
} |
1372 |
} break; |
|
1373 |
||
757 | 1374 |
case 9: { /* Build new Vehicle */ |
0 | 1375 |
uint tile; |
1376 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1377 |
if (!IsWindowOfPrototype(w, _player_trains_widgets)) |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1378 |
break; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1379 |
|
0 | 1380 |
tile = _last_built_train_depot_tile; |
1381 |
do { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1382 |
if (_map_owner[tile] == _local_player && IsTrainDepotTile(tile)) { |
0 | 1383 |
ShowTrainDepotWindow(tile); |
1384 |
ShowBuildTrainWindow(tile); |
|
1385 |
return; |
|
1386 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1387 |
|
0 | 1388 |
tile = TILE_MASK(tile + 1); |
1389 |
} while(tile != _last_built_train_depot_tile); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1390 |
|
0 | 1391 |
ShowBuildTrainWindow(0); |
1392 |
} break; |
|
842 | 1393 |
case 10: { |
886
4442d7859ea7
(svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents:
878
diff
changeset
|
1394 |
if (!IsWindowOfPrototype(w, _player_trains_widgets)) |
4442d7859ea7
(svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents:
878
diff
changeset
|
1395 |
break; |
4442d7859ea7
(svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents:
878
diff
changeset
|
1396 |
|
842 | 1397 |
ShowReplaceVehicleWindow(VEH_Train); |
1398 |
break; |
|
1399 |
} |
|
1400 |
||
0 | 1401 |
} |
1402 |
} break; |
|
1403 |
||
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1404 |
case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */ |
588 | 1405 |
if (vl->sort_type != e->dropdown.index) { |
1406 |
// value has changed -> resort |
|
1407 |
vl->flags |= VL_RESORT; |
|
1408 |
vl->sort_type = e->dropdown.index; |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1409 |
|
588 | 1410 |
// enable 'Sort By' if a sorter criteria is chosen |
1411 |
if (vl->sort_type != SORT_BY_UNSORTED) |
|
757 | 1412 |
w->disabled_state &= ~(1 << 3); |
588 | 1413 |
} |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1414 |
SetWindowDirty(w); |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1415 |
break; |
588 | 1416 |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1417 |
case WE_CREATE: /* set up resort timer */ |
588 | 1418 |
vl->sort_list = NULL; |
1419 |
vl->flags = VL_REBUILD; |
|
1420 |
vl->sort_type = SORT_BY_UNSORTED; |
|
1421 |
vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1422 |
break; |
588 | 1423 |
|
767 | 1424 |
case WE_DESTROY: |
1425 |
free(vl->sort_list); |
|
1426 |
break; |
|
1427 |
||
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1428 |
case WE_TICK: /* resort the list every 20 seconds orso (10 days) */ |
588 | 1429 |
if (--vl->resort_timer == 0) { |
1430 |
DEBUG(misc, 1) ("Periodic resort trains list player %d station %d", |
|
1431 |
owner, station); |
|
1432 |
vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; |
|
1433 |
vl->flags |= VL_RESORT; |
|
1434 |
SetWindowDirty(w); |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1435 |
} |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1436 |
break; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1437 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1438 |
case WE_RESIZE: |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1439 |
/* Update the scroll + matrix */ |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1440 |
w->hscroll.cap += e->sizing.diff.x / 29; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1441 |
w->vscroll.cap += e->sizing.diff.y / PLY_WND_PRC__SIZE_OF_ROW_SMALL; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1442 |
w->widget[7].unkA = (w->vscroll.cap << 8) + 1; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1443 |
break; |
0 | 1444 |
} |
1445 |
} |
|
1446 |
||
1447 |
static const WindowDesc _player_trains_desc = { |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1448 |
-1, -1, 325, 220, |
0 | 1449 |
WC_TRAINS_LIST,0, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1450 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 1451 |
_player_trains_widgets, |
1452 |
PlayerTrainsWndProc |
|
1453 |
}; |
|
1454 |
||
1455 |
static const WindowDesc _other_player_trains_desc = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1456 |
-1, -1, 325, 220, |
0 | 1457 |
WC_TRAINS_LIST,0, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1458 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 1459 |
_other_player_trains_widgets, |
1460 |
PlayerTrainsWndProc |
|
1461 |
}; |
|
1462 |
||
588 | 1463 |
void ShowPlayerTrains(int player, int station) |
0 | 1464 |
{ |
1465 |
Window *w; |
|
1466 |
||
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1467 |
if (player == _local_player) { |
588 | 1468 |
w = AllocateWindowDescFront(&_player_trains_desc, (station << 16) | player); |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1469 |
} else { |
588 | 1470 |
w = AllocateWindowDescFront(&_other_player_trains_desc, (station << 16) | player); |
0 | 1471 |
} |
1472 |
if (w) { |
|
1473 |
w->caption_color = w->window_number; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1474 |
w->hscroll.cap = 10; |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1475 |
w->vscroll.cap = 7; // maximum number of vehicles shown |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1476 |
w->widget[7].unkA = (w->vscroll.cap << 8) + 1; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1477 |
w->resize.step_height = PLY_WND_PRC__SIZE_OF_ROW_SMALL; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1478 |
w->resize.step_width = 29; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1479 |
w->resize.height = 220 - (PLY_WND_PRC__SIZE_OF_ROW_SMALL * 3); /* Minimum of 4 vehicles */ |
0 | 1480 |
} |
1481 |
} |