author | darkvater |
Sun, 14 Nov 2004 20:50:38 +0000 | |
changeset 413 | 36f14a6d63d7 |
parent 395 | 788a9bba0889 |
child 420 | d4aa4a1df3c6 |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
3 |
||
4 |
#include "window.h" |
|
5 |
#include "gui.h" |
|
6 |
#include "gfx.h" |
|
7 |
#include "vehicle.h" |
|
8 |
#include "viewport.h" |
|
9 |
#include "station.h" |
|
10 |
#include "command.h" |
|
11 |
#include "player.h" |
|
12 |
#include "engine.h" |
|
13 |
||
14 |
static Engine * const _rail_engines[3] = { |
|
15 |
&_engines[0], |
|
16 |
&_engines[NUM_NORMAL_RAIL_ENGINES], |
|
17 |
&_engines[NUM_MONORAIL_ENGINES + NUM_NORMAL_RAIL_ENGINES], |
|
18 |
}; |
|
19 |
||
20 |
const byte _rail_engines_count[3] = { |
|
21 |
NUM_NORMAL_RAIL_ENGINES, |
|
22 |
NUM_MONORAIL_ENGINES, |
|
23 |
NUM_MAGLEV_ENGINES, |
|
24 |
}; |
|
25 |
||
26 |
const byte _rail_engines_start[3] = { |
|
27 |
0, |
|
28 |
NUM_NORMAL_RAIL_ENGINES, |
|
29 |
NUM_MONORAIL_ENGINES + NUM_NORMAL_RAIL_ENGINES, |
|
30 |
}; |
|
31 |
||
32 |
static void CcBuildWagon(bool success, uint tile, uint32 p1, uint32 p2) |
|
33 |
{ |
|
34 |
Vehicle *v,*found; |
|
35 |
||
36 |
if (!success) |
|
37 |
return; |
|
38 |
||
39 |
// find a locomotive in the depot. |
|
40 |
found = NULL; |
|
41 |
FOR_ALL_VEHICLES(v) { |
|
42 |
if (v->type == VEH_Train && v->subtype==0 && |
|
43 |
v->tile == tile && |
|
44 |
v->u.rail.track == 0x80) { |
|
45 |
if (found != NULL) // must be exactly one. |
|
46 |
return; |
|
47 |
found = v; |
|
48 |
} |
|
49 |
} |
|
50 |
||
51 |
// if we found a loco, |
|
52 |
if (found != NULL) { |
|
53 |
found = GetLastVehicleInChain(found); |
|
54 |
// put the new wagon at the end of the loco. |
|
55 |
DoCommandP(0, _new_wagon_id | (found->index<<16), 0, NULL, CMD_MOVE_RAIL_VEHICLE); |
|
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
|
56 |
_vehicle_sort_dirty[VEHTRAIN] = true; |
0 | 57 |
} |
58 |
} |
|
59 |
||
60 |
static void CcBuildLoco(bool success, uint tile, uint32 p1, uint32 p2) |
|
61 |
{ |
|
62 |
Vehicle *v; |
|
63 |
||
64 |
if (!success) |
|
65 |
return; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
66 |
|
0 | 67 |
v = &_vehicles[_new_train_id]; |
68 |
if (tile == _backup_orders_tile) { |
|
69 |
_backup_orders_tile = 0; |
|
70 |
RestoreVehicleOrders(v, _backup_orders_data); |
|
71 |
} |
|
72 |
ShowTrainViewWindow(v); |
|
73 |
} |
|
74 |
||
75 |
static void NewRailVehicleWndProc(Window *w, WindowEvent *e) |
|
76 |
{ |
|
77 |
switch(e->event) { |
|
78 |
case WE_PAINT: |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
79 |
|
0 | 80 |
if (w->window_number == 0) |
81 |
SETBIT(w->disabled_state, 5); |
|
82 |
||
83 |
{ |
|
84 |
int count = 0; |
|
85 |
int num = _rail_engines_count[WP(w,buildtrain_d).railtype]; |
|
86 |
Engine *e = _rail_engines[WP(w,buildtrain_d).railtype]; |
|
87 |
do { |
|
88 |
if (HASBIT(e->player_avail, _local_player)) |
|
89 |
count++; |
|
90 |
} while (++e,--num); |
|
91 |
SetVScrollCount(w, count); |
|
92 |
} |
|
93 |
||
94 |
SET_DPARAM16(0, WP(w,buildtrain_d).railtype + STR_881C_NEW_RAIL_VEHICLES); |
|
95 |
DrawWindowWidgets(w); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
96 |
|
0 | 97 |
{ |
98 |
int num = _rail_engines_count[WP(w,buildtrain_d).railtype]; |
|
99 |
Engine *e = _rail_engines[WP(w,buildtrain_d).railtype]; |
|
100 |
int sel = WP(w,buildtrain_d).sel_index; |
|
101 |
int pos = w->vscroll.pos; |
|
102 |
int x = 1; |
|
103 |
int y = 15; |
|
104 |
int engine_id = _rail_engines_start[WP(w,buildtrain_d).railtype]; |
|
105 |
int selected_id = -1; |
|
106 |
||
107 |
do { |
|
108 |
if (HASBIT(e->player_avail, _local_player)) { |
|
109 |
if (sel==0) selected_id = engine_id; |
|
110 |
if (IS_INT_INSIDE(--pos, -8, 0)) { |
|
111 |
DrawString(x+59, y+2, GetCustomEngineName(engine_id), sel==0 ? 0xC : 0x10); |
|
112 |
DrawTrainEngine(x+29, y+6, engine_id, SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player))); |
|
113 |
y += 14; |
|
114 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
115 |
sel--; |
0 | 116 |
} |
117 |
} while (++engine_id, ++e,--num); |
|
118 |
||
119 |
WP(w,buildtrain_d).sel_engine = selected_id; |
|
120 |
||
121 |
if (selected_id != -1) { |
|
122 |
const RailVehicleInfo *rvi = &_rail_vehicle_info[selected_id]; |
|
123 |
Engine *e; |
|
124 |
YearMonthDay ymd; |
|
125 |
||
126 |
if (!(rvi->flags & RVI_WAGON)) { |
|
127 |
/* it's an engine */ |
|
128 |
int multihead = (rvi->flags&RVI_MULTIHEAD?1:0); |
|
129 |
||
130 |
SET_DPARAM32(0, rvi->base_cost * (_price.build_railvehicle >> 3) >> 5); |
|
131 |
SET_DPARAM16(2, rvi->max_speed * 10 >> 4); |
|
132 |
SET_DPARAM16(3, rvi->power << multihead); |
|
133 |
SET_DPARAM16(1, rvi->weight << multihead); |
|
134 |
SET_DPARAM32(4, (rvi->running_cost_base * _price.running_rail[rvi->engclass] >> 8) << multihead); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
135 |
|
0 | 136 |
SET_DPARAM16(5, STR_8838_N_A); |
137 |
if (rvi->capacity != 0) { |
|
138 |
SET_DPARAM16(6, rvi->capacity << multihead); |
|
139 |
SET_DPARAM16(5, _cargoc.names_long_p[rvi->cargo_type]); |
|
140 |
} |
|
141 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
142 |
e = &_engines[selected_id]; |
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
143 |
|
0 | 144 |
SET_DPARAM16(8, e->lifelength); |
145 |
SET_DPARAM8(9, e->reliability * 100 >> 16); |
|
146 |
ConvertDayToYMD(&ymd, e->intro_date); |
|
147 |
SET_DPARAM16(7, ymd.year + 1920); |
|
148 |
||
149 |
DrawString(2, 0x7F, STR_8817_COST_WEIGHT_T_SPEED_POWER, 0); |
|
150 |
} else { |
|
151 |
/* it's a wagon */ |
|
152 |
||
153 |
SET_DPARAM32(0, |
|
154 |
DoCommandByTile(w->window_number, selected_id, 0, DC_QUERY_COST, CMD_BUILD_RAIL_VEHICLE) |
|
155 |
); |
|
156 |
SET_DPARAM16(4, rvi->capacity); |
|
157 |
SET_DPARAM16(1, rvi->weight); |
|
158 |
SET_DPARAM16(3, _cargoc.names_long_p[rvi->cargo_type]); |
|
159 |
SET_DPARAM16(2, (_cargoc.weights[rvi->cargo_type] * rvi->capacity >> 4) + rvi->weight); |
|
160 |
DrawString(2, 0x7F, STR_8821_COST_WEIGHT_T_T_CAPACITY, 0); |
|
161 |
} |
|
162 |
} |
|
163 |
} |
|
164 |
break; |
|
165 |
||
166 |
case WE_CLICK: { |
|
167 |
switch(e->click.widget) { |
|
168 |
case 2: { |
|
169 |
uint i = (e->click.pt.y - 14) / 14; |
|
170 |
if (i < 8) { |
|
171 |
WP(w,buildtrain_d).sel_index = i + w->vscroll.pos; |
|
172 |
SetWindowDirty(w); |
|
173 |
} |
|
174 |
} break; |
|
175 |
case 5: { |
|
176 |
int sel_eng; |
|
177 |
sel_eng = WP(w,buildtrain_d).sel_engine; |
|
178 |
if (sel_eng != -1) |
|
179 |
DoCommandP(w->window_number, sel_eng, 0, (_rail_vehicle_info[sel_eng].flags & RVI_WAGON) ? CcBuildWagon : CcBuildLoco, CMD_BUILD_RAIL_VEHICLE | CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE)); |
|
180 |
} break; |
|
181 |
case 6: |
|
182 |
WP(w,buildtrain_d).rename_engine = WP(w,buildtrain_d).sel_engine; |
|
183 |
ShowQueryString( |
|
184 |
GetCustomEngineName(WP(w,buildtrain_d).sel_engine), |
|
185 |
STR_886A_RENAME_TRAIN_VEHICLE_TYPE, |
|
186 |
31, |
|
187 |
160, |
|
188 |
w->window_class, |
|
189 |
w->window_number); |
|
190 |
break; |
|
191 |
} |
|
192 |
} break; |
|
193 |
||
194 |
case WE_4: |
|
195 |
if (w->window_number != 0 && !FindWindowById(WC_VEHICLE_DEPOT, w->window_number)) { |
|
196 |
DeleteWindow(w); |
|
197 |
} |
|
198 |
break; |
|
199 |
||
200 |
case WE_ON_EDIT_TEXT: { |
|
201 |
byte *b = e->edittext.str; |
|
202 |
if (*b == 0) |
|
203 |
return; |
|
204 |
||
205 |
memcpy(_decode_parameters, b, 32); |
|
206 |
DoCommandP(0, WP(w,buildtrain_d).rename_engine, 0, NULL, CMD_RENAME_ENGINE | CMD_MSG(STR_886B_CAN_T_RENAME_TRAIN_VEHICLE)); |
|
207 |
} break; |
|
208 |
} |
|
209 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
210 |
|
0 | 211 |
static const Widget _new_rail_vehicle_widgets[] = { |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
212 |
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
213 |
{ WWT_CAPTION, 14, 11, 227, 0, 13, STR_0315, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
214 |
{ WWT_MATRIX, 14, 0, 216, 14, 125, 0x801, STR_8843_TRAIN_VEHICLE_SELECTION}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
215 |
{ WWT_SCROLLBAR, 14, 217, 227, 14, 125, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
216 |
{ WWT_PANEL, 14, 0, 227, 126, 187, 0x0, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
217 |
{ WWT_PUSHTXTBTN, 14, 0, 113, 188, 199, STR_881F_BUILD_VEHICLE, STR_8844_BUILD_THE_HIGHLIGHTED_TRAIN}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
218 |
{ WWT_PUSHTXTBTN, 14, 114, 227, 188, 199, STR_8820_RENAME, STR_8845_RENAME_TRAIN_VEHICLE_TYPE}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
219 |
{ WIDGETS_END}, |
0 | 220 |
}; |
221 |
||
222 |
static const WindowDesc _new_rail_vehicle_desc = { |
|
223 |
-1, -1, 228, 200, |
|
224 |
WC_BUILD_VEHICLE,0, |
|
225 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
226 |
_new_rail_vehicle_widgets, |
|
227 |
NewRailVehicleWndProc |
|
228 |
}; |
|
229 |
||
230 |
static void ShowBuildTrainWindow(uint tile) |
|
231 |
{ |
|
232 |
Window *w; |
|
233 |
||
234 |
DeleteWindowById(WC_BUILD_VEHICLE, tile); |
|
235 |
||
236 |
w = AllocateWindowDesc(&_new_rail_vehicle_desc); |
|
237 |
w->window_number = tile; |
|
238 |
w->vscroll.cap = 8; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
239 |
|
0 | 240 |
if (tile != 0) { |
241 |
w->caption_color = _map_owner[tile]; |
|
242 |
WP(w,buildtrain_d).railtype = _map3_lo[tile] & 0xF; |
|
243 |
} else { |
|
244 |
w->caption_color = _local_player; |
|
245 |
WP(w,buildtrain_d).railtype = DEREF_PLAYER(_local_player)->max_railtype - 1; |
|
246 |
} |
|
247 |
} |
|
248 |
||
249 |
static void DrawTrainImage(Vehicle *v, int x, int y, int count, int skip, VehicleID selection) |
|
250 |
{ |
|
251 |
do { |
|
252 |
if (--skip < 0) { |
|
253 |
int image = GetTrainImage(v, 6); |
|
254 |
uint32 ormod = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)); |
|
255 |
if (v->vehstatus & VS_CRASHED) ormod = 0x3248000; |
|
256 |
DrawSprite(image | ormod, x+14, y+6); |
|
257 |
if (v->index == selection) DrawFrameRect(x-1, y-1, x+28, y+12, 15, 0x10); |
|
258 |
x += 29; |
|
259 |
count--; |
|
260 |
} |
|
261 |
||
262 |
if (!(v = v->next)) |
|
263 |
break; |
|
264 |
} while (count); |
|
265 |
} |
|
266 |
||
267 |
static void DrawTrainDepotWindow(Window *w) |
|
268 |
{ |
|
269 |
uint tile; |
|
270 |
Vehicle *v, *u; |
|
271 |
int num,x,y,i, hnum; |
|
272 |
Depot *d; |
|
273 |
||
274 |
tile = w->window_number; |
|
275 |
||
276 |
/* setup disabled buttons */ |
|
277 |
w->disabled_state = (_map_owner[tile]==_local_player) ? 0 : ((1<<3)|(1<<4)|(1<<6)); |
|
278 |
||
279 |
/* determine amount of items for scroller */ |
|
280 |
num = 1; |
|
281 |
hnum = 0; |
|
282 |
FOR_ALL_VEHICLES(v) { |
|
283 |
if (v->type == VEH_Train && |
|
284 |
(v->subtype == 0 || v->subtype == 4) && |
|
285 |
v->tile == (TileIndex)tile && |
|
286 |
v->u.rail.track == 0x80) { |
|
287 |
num++; |
|
288 |
// determine number of items in the X direction. |
|
289 |
if (v->subtype == 0) { |
|
290 |
i = -1; |
|
291 |
u = v; |
|
292 |
do i++; while ( (u=u->next) != NULL); |
|
293 |
if (i > hnum) hnum = i; |
|
294 |
} |
|
295 |
} |
|
296 |
} |
|
297 |
SetVScrollCount(w, num); |
|
298 |
SetHScrollCount(w, hnum); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
299 |
|
0 | 300 |
/* locate the depot struct */ |
301 |
for(d=_depots; d->xy != (TileIndex)tile; d++) {} |
|
302 |
||
303 |
SET_DPARAM16(0,d->town_index); |
|
304 |
DrawWindowWidgets(w); |
|
305 |
||
306 |
x = 2; |
|
307 |
y = 15; |
|
308 |
num = w->vscroll.pos; |
|
309 |
||
310 |
// draw all trains |
|
311 |
FOR_ALL_VEHICLES(v) { |
|
312 |
if (v->type == VEH_Train && |
|
313 |
v->subtype == 0 && |
|
314 |
v->tile == (TileIndex)tile && |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
315 |
v->u.rail.track == 0x80 && |
0 | 316 |
--num < 0 && num >= -6) { |
317 |
||
318 |
DrawTrainImage(v, x+21, y, 10, w->hscroll.pos, WP(w,traindepot_d).sel); |
|
22 | 319 |
/* Draw the train number */ |
0 | 320 |
SET_DPARAM16(0, v->unitnumber); |
321 |
DrawString(x, y, (v->max_age - 366 < v->age) ? STR_00E3 : STR_00E2, 0); |
|
22 | 322 |
/* Draw the pretty flag */ |
0 | 323 |
DrawSprite(v->vehstatus&VS_STOPPED ? 0xC12 : 0xC13, x+15, y); |
324 |
||
325 |
y += 14; |
|
326 |
} |
|
327 |
} |
|
328 |
||
329 |
// draw all remaining vehicles |
|
330 |
FOR_ALL_VEHICLES(v) { |
|
331 |
if (v->type == VEH_Train && |
|
332 |
v->subtype == 4 && |
|
333 |
v->tile == (TileIndex)tile && |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
334 |
v->u.rail.track == 0x80 && |
0 | 335 |
--num < 0 && num >= -6) { |
336 |
||
337 |
DrawTrainImage(v, x+50, y, 9, 0, WP(w,traindepot_d).sel); |
|
338 |
DrawString(x, y+2, STR_8816, 0); |
|
339 |
y += 14; |
|
340 |
} |
|
341 |
} |
|
342 |
} |
|
343 |
||
344 |
typedef struct GetDepotVehiclePtData { |
|
345 |
Vehicle *head; |
|
346 |
Vehicle *wagon; |
|
347 |
} GetDepotVehiclePtData; |
|
348 |
||
349 |
static int GetVehicleFromTrainDepotWndPt(Window *w, int x, int y, GetDepotVehiclePtData *d) |
|
350 |
{ |
|
351 |
int area_x; |
|
352 |
int row; |
|
353 |
Vehicle *v; |
|
354 |
||
355 |
x = x - 23; |
|
356 |
if (x < 0) { |
|
357 |
area_x = (x >= -10) ? -2 : -1; |
|
358 |
} else { |
|
359 |
area_x = x / 29; |
|
360 |
} |
|
361 |
||
362 |
row = (y - 14) / 14; |
|
363 |
if ( (uint) row >= 6) |
|
364 |
return 1; /* means err */ |
|
365 |
||
366 |
row += w->vscroll.pos; |
|
367 |
||
368 |
/* go through all the locomotives */ |
|
369 |
FOR_ALL_VEHICLES(v) { |
|
370 |
if (v->type == VEH_Train && |
|
371 |
v->subtype == 0 && |
|
372 |
v->tile == w->window_number && |
|
373 |
v->u.rail.track == 0x80 && |
|
374 |
--row < 0) { |
|
375 |
area_x += w->hscroll.pos; |
|
376 |
goto found_it; |
|
377 |
} |
|
378 |
} |
|
379 |
||
380 |
area_x--; /* free wagons don't have an initial loco. */ |
|
381 |
||
382 |
/* and then the list of free wagons */ |
|
383 |
FOR_ALL_VEHICLES(v) { |
|
384 |
if (v->type == VEH_Train && |
|
385 |
v->subtype == 4 && |
|
386 |
v->tile == w->window_number && |
|
387 |
v->u.rail.track == 0x80 && |
|
388 |
--row < 0) |
|
389 |
goto found_it; |
|
390 |
} |
|
391 |
||
392 |
d->head = NULL; |
|
393 |
d->wagon = NULL; |
|
394 |
||
395 |
/* didn't find anything, get out */ |
|
396 |
return 0; |
|
397 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
398 |
found_it: |
0 | 399 |
d->head = d->wagon = v; |
400 |
||
401 |
/* either pressed the flag or the number, but only when it's a loco */ |
|
402 |
if (area_x < 0 && v->subtype==0) |
|
403 |
return area_x; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
404 |
|
0 | 405 |
/* find the vehicle in this row that was clicked */ |
406 |
while (--area_x >= 0) { |
|
407 |
v = v->next; |
|
408 |
if (v == NULL) break; |
|
409 |
} |
|
410 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
411 |
d->wagon = v; |
0 | 412 |
|
413 |
return 0; |
|
414 |
} |
|
415 |
||
416 |
static void TrainDepotMoveVehicle(Vehicle *wagon, int sel, Vehicle *head) |
|
417 |
{ |
|
418 |
Vehicle *v; |
|
419 |
||
420 |
v = &_vehicles[sel]; |
|
421 |
||
422 |
if (/*v->subtype == 0 ||*/ v == wagon) |
|
423 |
return; |
|
424 |
||
425 |
if (wagon == NULL) { |
|
426 |
if (head != NULL) |
|
427 |
wagon = GetLastVehicleInChain(head); |
|
428 |
} else { |
|
429 |
wagon = GetPrevVehicleInChain(wagon); |
|
430 |
if (wagon == NULL) |
|
431 |
return; |
|
432 |
} |
|
433 |
||
434 |
if (wagon == v) |
|
435 |
return; |
|
436 |
||
437 |
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)); |
|
438 |
} |
|
439 |
||
440 |
static void TrainDepotClickTrain(Window *w, int x, int y) |
|
441 |
{ |
|
442 |
GetDepotVehiclePtData gdvp; |
|
443 |
int mode, sel; |
|
444 |
Vehicle *v; |
|
445 |
||
446 |
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
|
447 |
|
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
|
448 |
// share / copy orders |
0 | 449 |
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
|
450 |
|
0 | 451 |
v = gdvp.wagon; |
452 |
||
453 |
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
|
454 |
case 0: // start dragging of vehicle |
0 | 455 |
sel = (int16)WP(w,traindepot_d).sel; |
456 |
if (sel != -1) { |
|
457 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
458 |
TrainDepotMoveVehicle(v, sel, gdvp.head); |
|
459 |
} else if (v != NULL) { |
|
460 |
WP(w,traindepot_d).sel = v->index; |
|
461 |
SetObjectToPlaceWnd( SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)) + GetTrainImage(v, 6), 4, w); |
|
462 |
SetWindowDirty(w); |
|
463 |
} |
|
464 |
break; |
|
465 |
||
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
|
466 |
case -1: // show info window |
0 | 467 |
ShowTrainViewWindow(v); |
468 |
break; |
|
469 |
||
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
|
470 |
case -2: // click start/stop flag |
0 | 471 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN)); |
472 |
break; |
|
473 |
} |
|
474 |
} |
|
475 |
||
476 |
static void TrainDepotWndProc(Window *w, WindowEvent *e) |
|
477 |
{ |
|
478 |
switch(e->event) { |
|
479 |
case WE_PAINT: |
|
480 |
DrawTrainDepotWindow(w); |
|
481 |
break; |
|
482 |
||
483 |
case WE_CLICK: { |
|
484 |
switch(e->click.widget) { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
485 |
case 6: |
0 | 486 |
ShowBuildTrainWindow(w->window_number); |
487 |
break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
488 |
case 7: |
0 | 489 |
ScrollMainWindowToTile(w->window_number); |
490 |
break; |
|
491 |
case 2: |
|
492 |
TrainDepotClickTrain(w, e->click.pt.x, e->click.pt.y); |
|
493 |
break; |
|
494 |
} |
|
495 |
} break; |
|
496 |
||
497 |
case WE_DESTROY: |
|
498 |
DeleteWindowById(WC_BUILD_VEHICLE, w->window_number); |
|
499 |
break; |
|
500 |
||
501 |
case WE_DRAGDROP: { |
|
502 |
switch(e->click.widget) { |
|
503 |
case 4: |
|
504 |
case 3: { |
|
505 |
Vehicle *v; |
|
506 |
int sell_cmd; |
|
507 |
||
508 |
/* sell vehicle */ |
|
509 |
if (w->disabled_state & (1 << e->click.widget)) |
|
510 |
return; |
|
511 |
||
512 |
if (WP(w,traindepot_d).sel == INVALID_VEHICLE) |
|
513 |
return; |
|
514 |
||
515 |
v = &_vehicles[WP(w,traindepot_d).sel]; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
516 |
|
0 | 517 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
518 |
SetWindowDirty(w); |
|
519 |
||
520 |
HandleButtonClick(w, e->click.widget); |
|
521 |
||
522 |
sell_cmd = (e->click.widget == 4 || _ctrl_pressed) ? 1 : 0; |
|
523 |
||
524 |
if (v->subtype != 0) { |
|
525 |
DoCommandP(v->tile, v->index, sell_cmd, NULL, CMD_SELL_RAIL_WAGON | CMD_MSG(STR_8839_CAN_T_SELL_RAILROAD_VEHICLE)); |
|
526 |
} else { |
|
527 |
_backup_orders_tile = v->tile; |
|
528 |
BackupVehicleOrders(v, _backup_orders_data); |
|
529 |
if (!DoCommandP(v->tile, v->index, sell_cmd, NULL, CMD_SELL_RAIL_WAGON | CMD_MSG(STR_8839_CAN_T_SELL_RAILROAD_VEHICLE))) |
|
530 |
_backup_orders_tile = 0; |
|
531 |
} |
|
532 |
} break; |
|
533 |
||
534 |
case 2: { |
|
535 |
GetDepotVehiclePtData gdvp; |
|
536 |
VehicleID sel = WP(w,traindepot_d).sel; |
|
537 |
||
538 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
539 |
SetWindowDirty(w); |
|
540 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
541 |
if (GetVehicleFromTrainDepotWndPt(w, e->dragdrop.pt.x, e->dragdrop.pt.y, &gdvp) == 0 && |
0 | 542 |
sel != INVALID_VEHICLE) { |
543 |
if (gdvp.wagon == NULL || gdvp.wagon->index != sel) { |
|
544 |
TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head); |
|
545 |
} else if (gdvp.head != NULL && gdvp.head->subtype==0) { |
|
546 |
ShowTrainViewWindow(gdvp.head); |
|
547 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
548 |
} |
0 | 549 |
} break; |
550 |
||
551 |
default: |
|
552 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
553 |
SetWindowDirty(w); |
|
554 |
break; |
|
555 |
} |
|
556 |
} break; |
|
557 |
} |
|
558 |
} |
|
559 |
||
560 |
||
561 |
static const Widget _train_depot_widgets[] = { |
|
562 |
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
|
563 |
{ WWT_CAPTION, 14, 11, 348, 0, 13, STR_8800_TRAIN_DEPOT, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
|
564 |
{ WWT_MATRIX, 14, 0, 313, 14, 97, 0x601, STR_883F_TRAINS_CLICK_ON_TRAIN_FOR}, |
|
565 |
{ WWT_PANEL, 14, 314, 337, 14, 54, 0x2A9, STR_8841_DRAG_TRAIN_VEHICLE_TO_HERE}, |
|
566 |
{ WWT_PANEL, 14, 314, 337, 55, 108, 0x2BF, STR_DRAG_WHOLE_TRAIN_TO_SELL_TIP}, |
|
567 |
||
568 |
{ WWT_SCROLLBAR, 14, 338, 348, 14, 108, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
|
569 |
{ WWT_PUSHTXTBTN, 14, 0, 173, 109, 120, STR_8815_NEW_VEHICLES, STR_8840_BUILD_NEW_TRAIN_VEHICLE}, |
|
570 |
{ WWT_PUSHTXTBTN, 14, 174, 348, 109, 120, STR_00E4_LOCATION, STR_8842_CENTER_MAIN_VIEW_ON_TRAIN}, |
|
571 |
{ WWT_HSCROLLBAR, 14, 0, 313, 98, 108, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
572 |
{ WIDGETS_END}, |
0 | 573 |
}; |
574 |
||
575 |
static const WindowDesc _train_depot_desc = { |
|
576 |
-1, -1, 349, 121, |
|
577 |
WC_VEHICLE_DEPOT,0, |
|
578 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
579 |
_train_depot_widgets, |
|
580 |
TrainDepotWndProc |
|
581 |
}; |
|
582 |
||
583 |
||
584 |
void ShowTrainDepotWindow(uint tile) |
|
585 |
{ |
|
586 |
Window *w; |
|
587 |
||
588 |
w = AllocateWindowDescFront(&_train_depot_desc, tile); |
|
589 |
if (w) { |
|
590 |
w->caption_color = _map_owner[w->window_number]; |
|
591 |
w->vscroll.cap = 6; |
|
592 |
w->hscroll.cap = 9; |
|
593 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
594 |
_backup_orders_tile = 0; |
|
595 |
} |
|
596 |
} |
|
597 |
||
598 |
const byte _rail_vehicle_refit_types[4][16] = { |
|
599 |
{ 0,1,2,4,5,6,7,8,9,10,0xFF }, // normal |
|
600 |
{ 0,1,4,5,6,7,9,11,10,0xFF }, // arctic |
|
601 |
{ 0,4,5,8,6,7,9,10,0xFF }, // desert |
|
602 |
{ 0,1,3,5,7,8,9,6,4,10,11,0xFF }// candy |
|
603 |
}; |
|
604 |
||
605 |
static void RailVehicleRefitWndProc(Window *w, WindowEvent *e) |
|
606 |
{ |
|
607 |
switch(e->event) { |
|
608 |
case WE_PAINT: { |
|
609 |
Vehicle *v = &_vehicles[w->window_number]; |
|
610 |
const byte *b; |
|
611 |
int sel; |
|
612 |
int x,y; |
|
613 |
byte color; |
|
614 |
int cargo; |
|
615 |
||
616 |
SET_DPARAM16(0, v->string_id); |
|
617 |
SET_DPARAM16(1, v->unitnumber); |
|
618 |
DrawWindowWidgets(w); |
|
619 |
||
620 |
DrawString(1, 15, STR_983F_SELECT_CARGO_TYPE_TO_CARRY, 0); |
|
621 |
||
622 |
cargo = -1; |
|
623 |
x = 6; |
|
624 |
y = 25; |
|
625 |
sel = WP(w,refit_d).sel; |
|
382
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
626 |
|
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
627 |
#define show_cargo(ctype) { \ |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
628 |
color = 16; \ |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
629 |
if (sel == 0) { \ |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
630 |
cargo = ctype; \ |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
631 |
color = 12; \ |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
632 |
} \ |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
633 |
sel--; \ |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
634 |
DrawString(x, y, _cargoc.names_s[ctype], color); \ |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
635 |
y += 10; \ |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
636 |
} |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
637 |
|
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
638 |
if (_engine_refit_masks[v->engine_type]) { |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
639 |
uint32 mask = _engine_refit_masks[v->engine_type]; |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
640 |
int cid = 0; |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
641 |
|
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
642 |
for (; mask; mask >>= 1, cid++) { |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
643 |
if (!(mask & 1)) // not this cid |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
644 |
continue; |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
645 |
if (!(_local_cargo_id_landscape[cid] & (1 << _opt.landscape))) // not in this landscape |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
646 |
continue; |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
647 |
|
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
648 |
show_cargo(_local_cargo_id_ctype[cid]); |
0 | 649 |
} |
382
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
650 |
|
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
651 |
} else { // generic refit list |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
652 |
b = _rail_vehicle_refit_types[_opt.landscape]; |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
653 |
do { |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
654 |
show_cargo(*b); |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
655 |
} while (*++b != 255); |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
656 |
} |
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
657 |
|
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
338
diff
changeset
|
658 |
#undef show_cargo |
0 | 659 |
|
660 |
WP(w,refit_d).cargo = cargo; |
|
661 |
||
662 |
if (cargo != -1) { |
|
663 |
int32 cost = DoCommandByTile(v->tile, v->index, cargo, 0, CMD_REFIT_RAIL_VEHICLE); |
|
664 |
if (cost != CMD_ERROR) { |
|
665 |
SET_DPARAM32(2, cost); |
|
666 |
SET_DPARAM16(0, _cargoc.names_long_p[cargo]); |
|
667 |
SET_DPARAM16(1, _returned_refit_amount); |
|
668 |
DrawString(1, 137, STR_9840_NEW_CAPACITY_COST_OF_REFIT, 0); |
|
669 |
} |
|
670 |
} |
|
671 |
break; |
|
672 |
} |
|
673 |
||
674 |
case WE_CLICK: |
|
675 |
switch(e->click.widget) { |
|
676 |
case 2: { /* listbox */ |
|
677 |
int y = e->click.pt.y - 25; |
|
678 |
if (y >= 0) { |
|
679 |
WP(w,refit_d).sel = y / 10; |
|
680 |
SetWindowDirty(w); |
|
681 |
} |
|
682 |
} break; |
|
683 |
case 4: /* refit button */ |
|
684 |
if (WP(w,refit_d).cargo != 0xFF) { |
|
685 |
Vehicle *v = &_vehicles[w->window_number]; |
|
686 |
if (DoCommandP(v->tile, v->index, WP(w,refit_d).cargo, NULL, CMD_REFIT_RAIL_VEHICLE | CMD_MSG(STR_RAIL_CAN_T_REFIT_VEHICLE))) |
|
687 |
DeleteWindow(w); |
|
688 |
} |
|
689 |
break; |
|
690 |
} |
|
691 |
break; |
|
692 |
} |
|
693 |
} |
|
694 |
||
695 |
||
696 |
static const Widget _rail_vehicle_refit_widgets[] = { |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
697 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
698 |
{ WWT_CAPTION, 14, 11, 239, 0, 13, STR_983B_REFIT, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
699 |
{ WWT_IMGBTN, 14, 0, 239, 14, 135, 0x0, STR_RAIL_SELECT_TYPE_OF_CARGO_FOR}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
700 |
{ WWT_IMGBTN, 14, 0, 239, 136, 157, 0x0, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
701 |
{ WWT_PUSHTXTBTN, 14, 0, 239, 158, 169, STR_RAIL_REFIT_VEHICLE,STR_RAIL_REFIT_TO_CARRY_HIGHLIGHTED}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
702 |
{ WIDGETS_END}, |
0 | 703 |
}; |
704 |
||
705 |
static const WindowDesc _rail_vehicle_refit_desc = { |
|
706 |
-1,-1, 240, 170, |
|
707 |
WC_VEHICLE_REFIT,WC_VEHICLE_VIEW, |
|
708 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
709 |
_rail_vehicle_refit_widgets, |
|
710 |
RailVehicleRefitWndProc, |
|
711 |
}; |
|
712 |
||
713 |
static void ShowRailVehicleRefitWindow(Vehicle *v) |
|
714 |
{ |
|
715 |
Window *w; |
|
716 |
DeleteWindowById(WC_VEHICLE_REFIT, v->index); |
|
717 |
_alloc_wnd_parent_num = v->index; |
|
718 |
w = AllocateWindowDesc(&_rail_vehicle_refit_desc); |
|
719 |
w->window_number = v->index; |
|
720 |
w->caption_color = v->owner; |
|
721 |
WP(w,refit_d).sel = -1; |
|
722 |
} |
|
723 |
||
724 |
static Widget _train_view_widgets[] = { |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
725 |
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5,STR_018B_CLOSE_WINDOW}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
726 |
{ WWT_CAPTION, 14, 11, 249, 0, 13, STR_882E,STR_018C_WINDOW_TITLE_DRAG_THIS}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
727 |
{ WWT_PANEL, 14, 0, 231, 14, 121, 0x0, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
728 |
{ WWT_6, 14, 2, 229, 16, 119, 0x0, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
729 |
{ WWT_PUSHIMGBTN, 14, 0, 249, 122, 133, 0x0, STR_8846_CURRENT_TRAIN_ACTION_CLICK}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
730 |
{ WWT_PUSHIMGBTN, 14, 232, 249, 14, 31, 0x2AB, STR_8848_CENTER_MAIN_VIEW_ON_TRAIN}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
731 |
{ WWT_PUSHIMGBTN, 14, 232, 249, 32, 49, 0x2AD, STR_8849_SEND_TRAIN_TO_DEPOT}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
732 |
{ WWT_PUSHIMGBTN, 14, 232, 249, 50, 67, 0x2B1, STR_884A_FORCE_TRAIN_TO_PROCEED}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
733 |
{ WWT_PUSHIMGBTN, 14, 232, 249, 68, 85, 0x2CB, STR_884B_REVERSE_DIRECTION_OF_TRAIN}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
734 |
{ WWT_PUSHIMGBTN, 14, 232, 249, 86, 103, 0x2B2, STR_8847_SHOW_TRAIN_S_ORDERS}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
735 |
{ WWT_PUSHIMGBTN, 14, 232, 249, 104, 121, 0x2B3, STR_884C_SHOW_TRAIN_DETAILS}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
736 |
{ WWT_PUSHIMGBTN, 14, 232, 249, 68, 85, 0x2B4, STR_RAIL_REFIT_VEHICLE_TO_CARRY}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
737 |
{ WIDGETS_END}, |
0 | 738 |
}; |
739 |
||
740 |
static void TrainViewWndProc(Window *w, WindowEvent *e) |
|
741 |
{ |
|
742 |
switch(e->event) { |
|
743 |
case WE_PAINT: { |
|
744 |
Vehicle *v; |
|
745 |
StringID str; |
|
746 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
747 |
v = &_vehicles[w->window_number]; |
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
748 |
|
0 | 749 |
w->disabled_state = (v->owner == _local_player) ? 0 : 0x1C0; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
750 |
|
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
751 |
|
0 | 752 |
/* draw widgets & caption */ |
753 |
SET_DPARAM16(0, v->string_id); |
|
754 |
SET_DPARAM16(1, v->unitnumber); |
|
755 |
DrawWindowWidgets(w); |
|
756 |
||
757 |
/* draw the flag */ |
|
758 |
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
|
759 |
|
0 | 760 |
if (v->u.rail.crash_anim_pos != 0) { |
761 |
str = STR_8863_CRASHED; |
|
762 |
} else if (v->breakdown_ctr == 1) { |
|
763 |
str = STR_885C_BROKEN_DOWN; |
|
764 |
} else if (v->vehstatus & VS_STOPPED) { |
|
765 |
if (v->u.rail.last_speed == 0) { |
|
766 |
str = STR_8861_STOPPED; |
|
767 |
} else { |
|
768 |
SET_DPARAM16(0, v->u.rail.last_speed * 10 >> 4); |
|
769 |
str = STR_TRAIN_STOPPING + _patches.vehicle_speed; |
|
770 |
} |
|
771 |
} else { |
|
772 |
switch(v->next_order & OT_MASK) { |
|
773 |
case OT_GOTO_STATION: { |
|
774 |
str = STR_HEADING_FOR_STATION + _patches.vehicle_speed; |
|
775 |
SET_DPARAM16(0, v->next_order_param); |
|
776 |
SET_DPARAM16(1, v->u.rail.last_speed * 10 >> 4); |
|
777 |
} break; |
|
778 |
||
779 |
case OT_GOTO_DEPOT: { |
|
780 |
Depot *dep = &_depots[v->next_order_param]; |
|
781 |
SET_DPARAM16(0, dep->town_index); |
|
782 |
str = STR_HEADING_FOR_TRAIN_DEPOT + _patches.vehicle_speed; |
|
783 |
SET_DPARAM16(1, v->u.rail.last_speed * 10 >> 4); |
|
784 |
} break; |
|
785 |
||
786 |
case OT_LOADING: |
|
787 |
case OT_LEAVESTATION: |
|
788 |
str = STR_882F_LOADING_UNLOADING; |
|
789 |
break; |
|
790 |
||
395
788a9bba0889
(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
|
791 |
case OT_GOTO_WAYPOINT: { |
0 | 792 |
SET_DPARAM16(0, v->next_order_param); |
395
788a9bba0889
(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
|
793 |
str = STR_HEADING_FOR_WAYPOINT + _patches.vehicle_speed; |
0 | 794 |
SET_DPARAM16(1, v->u.rail.last_speed * 10 >> 4); |
795 |
break; |
|
796 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
797 |
|
0 | 798 |
default: |
799 |
if (v->num_orders == 0) { |
|
800 |
str = STR_NO_ORDERS + _patches.vehicle_speed; |
|
801 |
SET_DPARAM16(0, v->u.rail.last_speed * 10 >> 4); |
|
802 |
} else |
|
803 |
str = STR_EMPTY; |
|
804 |
break; |
|
805 |
} |
|
806 |
} |
|
807 |
||
808 |
DrawStringCentered(125, 123, str, 0); |
|
809 |
DrawWindowViewport(w); |
|
810 |
} break; |
|
811 |
||
812 |
case WE_CLICK: { |
|
813 |
int wid = e->click.widget; |
|
814 |
Vehicle *v = &_vehicles[w->window_number]; |
|
815 |
||
816 |
switch(wid) { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
817 |
case 4: /* start/stop train */ |
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
818 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN)); |
0 | 819 |
break; |
820 |
case 5: /* center main view */ |
|
821 |
ScrollMainWindowTo(v->x_pos, v->y_pos); |
|
822 |
break; |
|
823 |
case 6: /* goto depot */ |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
824 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_TRAIN_GOTO_DEPOT | CMD_MSG(STR_8830_CAN_T_SEND_TRAIN_TO_DEPOT)); |
0 | 825 |
break; |
826 |
case 7: /* force proceed */ |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
827 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_FORCE_TRAIN_PROCEED | CMD_MSG(STR_8862_CAN_T_MAKE_TRAIN_PASS_SIGNAL)); |
0 | 828 |
break; |
829 |
case 8: /* reverse direction */ |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
830 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_8869_CAN_T_REVERSE_DIRECTION)); |
0 | 831 |
break; |
832 |
case 9: /* show train orders */ |
|
833 |
ShowOrdersWindow(v); |
|
834 |
break; |
|
835 |
case 10: /* show train details */ |
|
836 |
ShowTrainDetailsWindow(v); |
|
837 |
break; |
|
838 |
case 11: |
|
839 |
ShowRailVehicleRefitWindow(v); |
|
840 |
break; |
|
841 |
} |
|
842 |
} break; |
|
843 |
||
844 |
case WE_DESTROY: |
|
338
37500d4214f3
(svn r514) -Fix: [1053397] Refit Train Window Stays Open
tron
parents:
243
diff
changeset
|
845 |
DeleteWindowById(WC_VEHICLE_REFIT, w->window_number); |
0 | 846 |
DeleteWindowById(WC_VEHICLE_ORDERS, w->window_number); |
847 |
DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number); |
|
848 |
break; |
|
849 |
||
850 |
case WE_MOUSELOOP: { |
|
851 |
Vehicle *v; |
|
852 |
uint32 h; |
|
853 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
854 |
v = &_vehicles[w->window_number]; |
0 | 855 |
assert(v->type == VEH_Train); |
856 |
h = CheckStoppedInDepot(v) >= 0 ? (1 << 8) : (1 << 11); |
|
857 |
if (h != w->hidden_state) { |
|
858 |
w->hidden_state = h; |
|
859 |
SetWindowDirty(w); |
|
860 |
} |
|
861 |
break; |
|
862 |
} |
|
863 |
||
864 |
} |
|
865 |
} |
|
866 |
||
867 |
static const WindowDesc _train_view_desc = { |
|
868 |
-1,-1, 250, 134, |
|
869 |
WC_VEHICLE_VIEW,0, |
|
870 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
871 |
_train_view_widgets, |
|
872 |
TrainViewWndProc |
|
873 |
}; |
|
874 |
||
875 |
void ShowTrainViewWindow(Vehicle *v) |
|
876 |
{ |
|
877 |
Window *w; |
|
878 |
||
879 |
w = AllocateWindowDescFront(&_train_view_desc,v->index); |
|
880 |
if (w) { |
|
881 |
w->caption_color = v->owner; |
|
882 |
AssignWindowViewport(w, 3, 17, 0xE2, 0x66, w->window_number | (1 << 31), 0); |
|
883 |
} |
|
884 |
} |
|
885 |
||
886 |
static void TrainDetailsCargoTab(Vehicle *v, int x, int y) |
|
887 |
{ |
|
888 |
int num; |
|
889 |
StringID str; |
|
890 |
||
891 |
if (v->cargo_cap != 0) { |
|
892 |
num = v->cargo_count; |
|
893 |
str = STR_8812_EMPTY; |
|
894 |
if (num != 0) { |
|
895 |
SET_DPARAM8(0, v->cargo_type); |
|
896 |
SET_DPARAM16(1, num); |
|
897 |
SET_DPARAM16(2, v->cargo_source); |
|
898 |
str = STR_8813_FROM; |
|
899 |
} |
|
900 |
DrawString(x, y, str, 0); |
|
901 |
} |
|
902 |
} |
|
903 |
||
904 |
static void TrainDetailsInfoTab(Vehicle *v, int x, int y) |
|
905 |
{ |
|
906 |
const RailVehicleInfo *rvi; |
|
907 |
||
908 |
rvi = &_rail_vehicle_info[v->engine_type]; |
|
909 |
||
910 |
if (!(rvi->flags & RVI_WAGON)) { |
|
911 |
SET_DPARAM16(0, GetCustomEngineName(v->engine_type)); |
|
912 |
SET_DPARAM16(1, v->build_year + 1920); |
|
913 |
SET_DPARAM32(2, v->value); |
|
914 |
DrawString(x, y, STR_882C_BUILT_VALUE, 0x10); |
|
915 |
} else { |
|
916 |
SET_DPARAM16(0, GetCustomEngineName(v->engine_type)); |
|
917 |
SET_DPARAM32(1, v->value); |
|
918 |
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
|
919 |
} |
0 | 920 |
} |
921 |
||
922 |
static void TrainDetailsCapacityTab(Vehicle *v, int x, int y) |
|
923 |
{ |
|
924 |
if (v->cargo_cap != 0) { |
|
925 |
SET_DPARAM16(1, v->cargo_cap); |
|
926 |
SET_DPARAM16(0, _cargoc.names_long_p[v->cargo_type]); |
|
927 |
DrawString(x, y, STR_013F_CAPACITY, 0); |
|
928 |
} |
|
929 |
} |
|
930 |
||
931 |
typedef void TrainDetailsDrawerProc(Vehicle *v, int x, int y); |
|
932 |
||
933 |
static TrainDetailsDrawerProc * const _train_details_drawer_proc[3] = { |
|
934 |
TrainDetailsCargoTab, |
|
935 |
TrainDetailsInfoTab, |
|
936 |
TrainDetailsCapacityTab, |
|
937 |
}; |
|
938 |
||
939 |
static void DrawTrainDetailsWindow(Window *w) |
|
940 |
{ |
|
941 |
Vehicle *v, *u; |
|
942 |
uint16 tot_cargo[NUM_CARGO][2]; // count total cargo ([0]-actual cargo, [1]-total cargo) |
|
943 |
int i,num,x,y,sel; |
|
944 |
StringID str; |
|
945 |
byte det_tab = WP(w, traindetails_d).tab; |
|
946 |
||
947 |
/* Count number of vehicles */ |
|
948 |
num = 0; |
|
949 |
||
950 |
// det_tab == 3 <-- Total Cargo tab |
|
951 |
if (det_tab == 3) // reset tot_cargo array to 0 values |
|
952 |
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
|
953 |
|
0 | 954 |
u = v = &_vehicles[w->window_number]; |
955 |
do { |
|
956 |
if (det_tab != 3) |
|
957 |
num++; |
|
958 |
else { |
|
959 |
tot_cargo[u->cargo_type][0] += u->cargo_count; |
|
960 |
tot_cargo[u->cargo_type][1] += u->cargo_cap; |
|
961 |
} |
|
962 |
} while ( (u = u->next) != NULL); |
|
963 |
||
964 |
/* set scroll-amount seperately from counting, as to not |
|
965 |
compute num double for more carriages of the same type |
|
966 |
*/ |
|
967 |
if (det_tab == 3) { |
|
968 |
for (i = 0; i != NUM_CARGO; i++) { |
|
969 |
if (tot_cargo[i][1] > 0) // only count carriages that the train has |
|
970 |
num++; |
|
971 |
} |
|
972 |
num++; // needs one more because first line is description string |
|
973 |
} |
|
974 |
||
975 |
SetVScrollCount(w, num); |
|
976 |
||
977 |
w->disabled_state = 1 << (det_tab + 9); |
|
978 |
if (v->owner != _local_player) |
|
979 |
w->disabled_state |= (1 << 2); |
|
980 |
||
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
|
981 |
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
|
982 |
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
|
983 |
|
0 | 984 |
SET_DPARAM16(0, v->string_id); |
985 |
SET_DPARAM16(1, v->unitnumber); |
|
986 |
DrawWindowWidgets(w); |
|
987 |
||
988 |
num = v->age / 366; |
|
989 |
SET_DPARAM16(1, num); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
990 |
|
0 | 991 |
x = 2; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
992 |
|
0 | 993 |
str = STR_0199_YEAR; |
994 |
if (num != 1) { |
|
995 |
str += STR_019A_YEARS - STR_0199_YEAR; |
|
996 |
if ((uint16)(v->max_age - 366) < v->age) |
|
997 |
str += STR_019B_YEARS - STR_019A_YEARS; |
|
998 |
} |
|
999 |
SET_DPARAM16(0, str); |
|
1000 |
SET_DPARAM16(2, v->max_age / 366); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1001 |
SET_DPARAM32(3, GetTrainRunningCost(v) >> 8); |
0 | 1002 |
DrawString(x, 15, STR_885D_AGE_RUNNING_COST_YR, 0); |
1003 |
||
1004 |
SET_DPARAM16(2, v->max_speed * 10 >> 4); |
|
1005 |
SET_DPARAM32(1, v->u.rail.cached_power); |
|
1006 |
SET_DPARAM16(0, v->u.rail.cached_weight); |
|
1007 |
DrawString(x, 25, STR_885E_WEIGHT_T_POWER_HP_MAX_SPEED, 0); |
|
1008 |
||
1009 |
SET_DPARAM32(0, v->profit_this_year); |
|
1010 |
SET_DPARAM32(1, v->profit_last_year); |
|
1011 |
DrawString(x, 35, STR_885F_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
|
1012 |
||
1013 |
SET_DPARAM8(0, 100 * (v->reliability>>8) >> 8); |
|
1014 |
SET_DPARAM16(1, v->breakdowns_since_last_service); |
|
1015 |
DrawString(x, 45, STR_8860_RELIABILITY_BREAKDOWNS, 0); |
|
1016 |
||
1017 |
SET_DPARAM16(0, v->service_interval); |
|
1018 |
SET_DPARAM16(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
|
1019 |
DrawString(x + 11, 141, _patches.servint_ispercent?STR_SERVICING_INTERVAL_PERCENT:STR_883C_SERVICING_INTERVAL_DAYS, 0); |
0 | 1020 |
|
1021 |
x = 1; |
|
1022 |
y = 57; |
|
1023 |
sel = w->vscroll.pos; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1024 |
|
0 | 1025 |
// draw the first 3 details tabs |
1026 |
if (det_tab != 3) { |
|
1027 |
for(;;) { |
|
1028 |
if (--sel < 0 && sel >= -6) { |
|
1029 |
DrawTrainImage(v, x, y, 1, 0, INVALID_VEHICLE); |
|
1030 |
_train_details_drawer_proc[WP(w,traindetails_d).tab](v, x + 30, y + 2); |
|
1031 |
y += 14; |
|
1032 |
} |
|
1033 |
if ( (v=v->next) == NULL) |
|
1034 |
return; |
|
1035 |
} |
|
1036 |
} |
|
1037 |
else { // draw total cargo tab |
|
1038 |
i = 0; |
|
1039 |
DrawString(x, y + 2, STR_013F_TOTAL_CAPACITY_TEXT, 0); |
|
1040 |
do { |
|
1041 |
if (tot_cargo[i][1] > 0 && --sel < 0 && sel >= -5) { |
|
1042 |
y += 14; |
|
1043 |
// STR_013F_TOTAL_CAPACITY :{LTBLUE}- {CARGO} ({SHORTCARGO}) |
|
1044 |
SET_DPARAM8(0, i); // {CARGO} #1 |
|
1045 |
SET_DPARAM16(1, tot_cargo[i][0]); // {CARGO} #2 |
|
1046 |
SET_DPARAM8(2, i); // {SHORTCARGO} #1 |
|
1047 |
SET_DPARAM16(3, tot_cargo[i][1]); // {SHORTCARGO} #2 |
|
1048 |
DrawString(x, y, STR_013F_TOTAL_CAPACITY, 0); |
|
1049 |
} |
|
1050 |
} while (++i != NUM_CARGO); |
|
1051 |
} |
|
1052 |
} |
|
1053 |
||
1054 |
static void TrainDetailsWndProc(Window *w, WindowEvent *e) |
|
1055 |
{ |
|
1056 |
switch(e->event) { |
|
1057 |
case WE_PAINT: |
|
1058 |
DrawTrainDetailsWindow(w); |
|
1059 |
break; |
|
1060 |
case WE_CLICK: { |
|
1061 |
int mod; |
|
1062 |
Vehicle *v; |
|
1063 |
switch(e->click.widget) { |
|
1064 |
case 2: /* name train */ |
|
1065 |
v = &_vehicles[w->window_number]; |
|
1066 |
SET_DPARAM16(0, v->unitnumber); |
|
1067 |
ShowQueryString(v->string_id, STR_8865_NAME_TRAIN, 31, 150, w->window_class, w->window_number); |
|
1068 |
break; |
|
1069 |
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
|
1070 |
mod = _ctrl_pressed? 5 : 10; |
0 | 1071 |
goto do_change_service_int; |
1072 |
||
1073 |
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
|
1074 |
mod = _ctrl_pressed? -5 : -10; |
0 | 1075 |
do_change_service_int: |
1076 |
v = &_vehicles[w->window_number]; |
|
1077 |
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
|
1078 |
|
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
|
1079 |
/* %-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
|
1080 |
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
|
1081 |
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
|
1082 |
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
|
1083 |
return; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1084 |
|
0 | 1085 |
DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_TRAIN_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING)); |
1086 |
break; |
|
1087 |
/* details buttons*/ |
|
1088 |
case 9: // Cargo |
|
1089 |
case 10: // Information |
|
1090 |
case 11: // Capacities |
|
1091 |
case 12: // Total cargo |
|
1092 |
CLRBIT(w->disabled_state, 9); |
|
1093 |
CLRBIT(w->disabled_state, 10); |
|
1094 |
CLRBIT(w->disabled_state, 11); |
|
1095 |
CLRBIT(w->disabled_state, 12); |
|
1096 |
SETBIT(w->disabled_state, e->click.widget); |
|
1097 |
WP(w,traindetails_d).tab = e->click.widget - 9; |
|
1098 |
SetWindowDirty(w); |
|
1099 |
break; |
|
1100 |
} |
|
1101 |
} break; |
|
1102 |
||
1103 |
case WE_4: |
|
1104 |
if (FindWindowById(WC_VEHICLE_VIEW, w->window_number) == NULL) |
|
1105 |
DeleteWindow(w); |
|
1106 |
break; |
|
1107 |
||
1108 |
case WE_ON_EDIT_TEXT: { |
|
1109 |
byte *b = e->edittext.str; |
|
1110 |
if (*b == 0) |
|
1111 |
return; |
|
1112 |
memcpy(_decode_parameters, b, 32); |
|
1113 |
DoCommandP(0, w->window_number, 0, NULL, CMD_NAME_VEHICLE | CMD_MSG(STR_8866_CAN_T_NAME_TRAIN)); |
|
1114 |
} break; |
|
1115 |
} |
|
1116 |
} |
|
1117 |
||
1118 |
static const Widget _train_details_widgets[] = { |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
1119 |
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
1120 |
{ WWT_CAPTION, 14, 11, 329, 0, 13, STR_8802_DETAILS,STR_018C_WINDOW_TITLE_DRAG_THIS}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
1121 |
{ WWT_PUSHTXTBTN, 14, 330, 369, 0, 13, STR_01AA_NAME, STR_8867_NAME_TRAIN}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
1122 |
{ WWT_PANEL, 14, 0, 369, 14, 55, 0x0, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
1123 |
{ WWT_MATRIX, 14, 0, 358, 56, 139, 0x601, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
1124 |
{ WWT_SCROLLBAR, 14, 359, 369, 56, 139, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
1125 |
{ WWT_PUSHTXTBTN, 14, 0, 10, 140, 145, STR_0188, STR_884D_INCREASE_SERVICING_INTERVAL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
1126 |
{ WWT_PUSHTXTBTN, 14, 0, 10, 146, 151, STR_0189, STR_884E_DECREASE_SERVICING_INTERVAL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
1127 |
{ WWT_PANEL, 14, 11, 369, 140, 151, 0x0, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
1128 |
{ WWT_PUSHTXTBTN, 14, 0, 92, 152, 163, STR_013C_CARGO, STR_884F_SHOW_DETAILS_OF_CARGO_CARRIED}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
1129 |
{ WWT_PUSHTXTBTN, 14, 93, 184, 152, 163, STR_013D_INFORMATION, STR_8850_SHOW_DETAILS_OF_TRAIN_VEHICLES}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
1130 |
{ WWT_PUSHTXTBTN, 14, 185, 277, 152, 163, STR_013E_CAPACITIES, STR_8851_SHOW_CAPACITIES_OF_EACH}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
1131 |
{ WWT_PUSHTXTBTN, 14, 278, 369, 152, 163, STR_013E_TOTAL_CARGO, STR_8852_SHOW_TOTAL_CARGO}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
1132 |
{ WIDGETS_END}, |
0 | 1133 |
}; |
1134 |
||
1135 |
||
1136 |
static const WindowDesc _train_details_desc = { |
|
1137 |
-1,-1, 370, 164, |
|
1138 |
WC_VEHICLE_DETAILS,WC_VEHICLE_VIEW, |
|
1139 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
1140 |
_train_details_widgets, |
|
1141 |
TrainDetailsWndProc |
|
1142 |
}; |
|
1143 |
||
1144 |
||
1145 |
void ShowTrainDetailsWindow(Vehicle *v) |
|
1146 |
{ |
|
1147 |
Window *w; |
|
1148 |
VehicleID veh = v->index; |
|
1149 |
||
1150 |
DeleteWindowById(WC_VEHICLE_ORDERS, veh); |
|
1151 |
DeleteWindowById(WC_VEHICLE_DETAILS, veh); |
|
1152 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1153 |
_alloc_wnd_parent_num = veh; |
0 | 1154 |
w = AllocateWindowDesc(&_train_details_desc); |
1155 |
||
1156 |
w->window_number = veh; |
|
1157 |
w->caption_color = v->owner; |
|
1158 |
w->vscroll.cap = 6; |
|
1159 |
WP(w,traindetails_d).tab = 0; |
|
1160 |
} |
|
1161 |
||
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
|
1162 |
// used to get a sorted list of the vehicles |
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
|
1163 |
static SortStruct _train_sort[NUM_NORMAL_VEHICLES]; |
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
|
1164 |
static uint16 _num_train_sort[MAX_PLAYERS]; |
0 | 1165 |
|
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1166 |
static void GlobalSortTrainList() |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1167 |
{ |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1168 |
const Vehicle *v; |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1169 |
uint16 *i; |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1170 |
uint32 n = 0; |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1171 |
|
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1172 |
// reset #-of trains to 0 because ++ is used for value-assignment |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1173 |
for (i = _num_train_sort; i != endof(_num_train_sort); i++) {*i = 0;} |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1174 |
|
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1175 |
FOR_ALL_VEHICLES(v) { |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1176 |
if(v->type == VEH_Train && v->subtype == 0) { |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1177 |
_train_sort[n].index = v->index; |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1178 |
_train_sort[n++].owner = v->owner; |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1179 |
_num_train_sort[v->owner]++; // add number of trains of player |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1180 |
} |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1181 |
} |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1182 |
|
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1183 |
// create cumulative train-ownership |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1184 |
// trains are stored as a cummulative index, eg 25, 41, 43. This means |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1185 |
// Player0: 25; Player1: (41-25) 16; Player2: (43-41) 2 |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1186 |
for (i = &_num_train_sort[1]; i != endof(_num_train_sort); i++) {*i += *(i-1);} |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1187 |
|
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1188 |
qsort(_train_sort, n, sizeof(_train_sort[0]), GeneralOwnerSorter); // sort by owner |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1189 |
|
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1190 |
// since indexes are messed up after adding/removing a station, mark all lists dirty |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1191 |
memset(_train_sort_dirty, true, sizeof(_train_sort_dirty)); |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1192 |
_vehicle_sort_dirty[VEHTRAIN] = false; |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1193 |
|
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1194 |
DEBUG(misc, 1) ("Resorting global trains list..."); |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1195 |
} |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1196 |
|
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
|
1197 |
static void MakeSortedTrainList(byte owner) |
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
|
1198 |
{ |
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
|
1199 |
SortStruct *firstelement; |
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
|
1200 |
uint32 n = 0; |
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
|
1201 |
|
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
|
1202 |
if (owner == 0) { // first element starts at 0th element and has n elements as described above |
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
|
1203 |
firstelement = &_train_sort[0]; |
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
|
1204 |
n = _num_train_sort[0]; |
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
|
1205 |
} else { // nth element starts at the end of the previous one, and has n elements as described above |
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
|
1206 |
firstelement = &_train_sort[_num_train_sort[owner-1]]; |
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
|
1207 |
n = _num_train_sort[owner] - _num_train_sort[owner-1]; |
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
|
1208 |
} |
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
|
1209 |
|
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
|
1210 |
_internal_sort_order = _train_sort_order[owner]; |
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
|
1211 |
_internal_name_sorter_id = STR_SV_TRAIN_NAME; |
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1212 |
_last_vehicle_idx = 0; // used for "cache" in namesorting |
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1213 |
qsort(firstelement, n, sizeof(_train_sort[0]), _vehicle_sorter[_train_sort_type[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
|
1214 |
|
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1215 |
_train_sort_dirty[owner] = false; |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1216 |
|
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
|
1217 |
DEBUG(misc, 1) ("Resorting Trains list player %d...", owner+1); |
0 | 1218 |
} |
1219 |
||
1220 |
static void PlayerTrainsWndProc(Window *w, WindowEvent *e) |
|
1221 |
{ |
|
1222 |
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
|
1223 |
case WE_PAINT: { |
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
|
1224 |
uint32 i; |
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
|
1225 |
const byte window_number = (byte)w->window_number; |
0 | 1226 |
|
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
|
1227 |
if (_train_sort_type[window_number] == SORT_BY_UNSORTED) // disable 'Sort By' tooltip on Unsorted sorting criteria |
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1228 |
w->disabled_state |= (1 << 2); |
0 | 1229 |
|
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1230 |
// resort trains window if roadvehicles have been added/removed |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1231 |
if (_vehicle_sort_dirty[VEHTRAIN]) |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1232 |
GlobalSortTrainList(); |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1233 |
|
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1234 |
if (_train_sort_dirty[window_number]) { |
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
|
1235 |
MakeSortedTrainList(window_number); |
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
|
1236 |
/* reset sorting timeout */ |
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
|
1237 |
w->custom[0] = DAY_TICKS; |
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
|
1238 |
w->custom[1] = PERIODIC_RESORT_DAYS; |
0 | 1239 |
} |
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
|
1240 |
|
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
|
1241 |
// Trains are stored as a cummulative index, eg 25, 41, 43. This means |
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
|
1242 |
// Player0: 25; Player1: (41-25) 16; Player2: (43-41) 2 trains |
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
|
1243 |
i = (window_number == 0) ? 0 : _num_train_sort[window_number-1]; |
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
|
1244 |
SetVScrollCount(w, _num_train_sort[window_number] - i); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1245 |
|
0 | 1246 |
/* draw the widgets */ |
1247 |
{ |
|
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
|
1248 |
Player *p = DEREF_PLAYER(window_number); |
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 |
/* Company Name -- (###) Trains */ |
0 | 1250 |
SET_DPARAM16(0, p->name_1); |
1251 |
SET_DPARAM32(1, p->name_2); |
|
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
|
1252 |
SET_DPARAM16(2, w->vscroll.count); |
0 | 1253 |
DrawWindowWidgets(w); |
1254 |
} |
|
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1255 |
/* draw sorting criteria string */ |
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1256 |
DrawString(85, 15, _vehicle_sort_listing[_train_sort_type[window_number]], 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
|
1257 |
/* draw arrow pointing up/down for ascending/descending soring */ |
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1258 |
DoDrawString(_train_sort_order[window_number] & 1 ? "\xAA" : "\xA0", 69, 15, 0x10); |
0 | 1259 |
|
1260 |
/* draw the trains */ |
|
1261 |
{ |
|
1262 |
Vehicle *v; |
|
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
|
1263 |
int n = 0; |
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
|
1264 |
const int x = 2; // offset from left side of widget |
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
|
1265 |
int y = PLY_WND_PRC__OFFSET_TOP_WIDGET; // offset from top of widget |
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
|
1266 |
i += w->vscroll.pos; // offset from sorted trains list of current player |
0 | 1267 |
|
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
|
1268 |
while (i < _num_train_sort[window_number]) { |
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
|
1269 |
StringID str; |
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
|
1270 |
v = DEREF_VEHICLE(_train_sort[i].index); |
0 | 1271 |
|
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
|
1272 |
assert(v->type == VEH_Train && v->subtype == 0 && v->owner == window_number); |
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
168
diff
changeset
|
1273 |
|
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
|
1274 |
DrawTrainImage(v, x + 21, y + 6, 10, 0, INVALID_VEHICLE); |
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
|
1275 |
DrawVehicleProfitButton(v, x, y+13); |
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
|
1276 |
|
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
|
1277 |
SET_DPARAM16(0, v->unitnumber); |
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
|
1278 |
if (IsTrainDepotTile(v->tile)) { |
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
|
1279 |
str = STR_021F; |
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 |
} else { |
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
|
1281 |
str = v->age > v->max_age - 366 ? STR_00E3 : STR_00E2; |
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
|
1282 |
} |
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
|
1283 |
DrawString(x, y+2, str, 0); |
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
|
1284 |
|
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
|
1285 |
SET_DPARAM32(0, v->profit_this_year); |
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
|
1286 |
SET_DPARAM32(1, v->profit_last_year); |
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
|
1287 |
DrawString(x + 21, y + 18, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1288 |
|
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
|
1289 |
if (v->string_id != STR_SV_TRAIN_NAME) { |
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
|
1290 |
SET_DPARAM16(0, v->string_id); |
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
|
1291 |
DrawString(x+21, y, STR_01AB, 0); |
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
|
1292 |
} |
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
|
1293 |
|
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
|
1294 |
y += PLY_WND_PRC__SIZE_OF_ROW_SMALL; |
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
|
1295 |
i++; // next train |
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
|
1296 |
if (++n == w->vscroll.cap) { break;} // max number of trains in the window |
0 | 1297 |
} |
1298 |
} |
|
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
|
1299 |
} break; |
0 | 1300 |
|
1301 |
case WE_CLICK: { |
|
1302 |
switch(e->click.widget) { |
|
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1303 |
case 2: /* Flip sorting method ascending/descending */ |
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
|
1304 |
_train_sort_order[(byte)w->window_number] ^= 1; |
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
|
1305 |
_train_sort_dirty[(byte)w->window_number] = true; |
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
|
1306 |
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
|
1307 |
break; |
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1308 |
case 3: case 4:/* Select sorting criteria dropdown menu */ |
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1309 |
ShowDropDownMenu(w, _vehicle_sort_listing, _train_sort_type[(byte)w->window_number], 4, 0); // do it for widget 4 |
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
|
1310 |
return; |
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
|
1311 |
case 6: { /* 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
|
1312 |
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
|
1313 |
|
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
|
1314 |
if (id_v >= w->vscroll.cap) { return;} // click out of bounds |
0 | 1315 |
|
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
|
1316 |
id_v += w->vscroll.pos; |
0 | 1317 |
|
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
|
1318 |
{ |
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
|
1319 |
const byte owner = (byte)w->window_number; |
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 |
Vehicle *v; |
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
|
1321 |
id_v += (owner == 0) ? 0 : _num_train_sort[owner - 1]; // first element in list |
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
|
1322 |
|
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
|
1323 |
if (id_v >= _num_train_sort[owner]) { return;} // click out of vehicle 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
|
1324 |
|
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
|
1325 |
v = DEREF_VEHICLE(_train_sort[id_v].index); // add the offset id_x to that |
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
|
1326 |
|
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
|
1327 |
assert(v->type == VEH_Train && v->subtype == 0 && 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
|
1328 |
|
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
|
1329 |
ShowTrainViewWindow(v); |
0 | 1330 |
} |
1331 |
} break; |
|
1332 |
||
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
|
1333 |
case 8: { /* Build new Vehicle */ |
0 | 1334 |
uint tile; |
1335 |
||
1336 |
tile = _last_built_train_depot_tile; |
|
1337 |
do { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1338 |
if (_map_owner[tile] == _local_player && IsTrainDepotTile(tile)) { |
0 | 1339 |
ShowTrainDepotWindow(tile); |
1340 |
ShowBuildTrainWindow(tile); |
|
1341 |
return; |
|
1342 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1343 |
|
0 | 1344 |
tile = TILE_MASK(tile + 1); |
1345 |
} 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
|
1346 |
|
0 | 1347 |
ShowBuildTrainWindow(0); |
1348 |
} break; |
|
1349 |
} |
|
1350 |
} break; |
|
1351 |
||
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 |
case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */ |
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
|
1353 |
if (_train_sort_type[(byte)w->window_number] != e->dropdown.index) // if value hasn't changed, dont resort list |
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
|
1354 |
_train_sort_dirty[(byte)w->window_number] = true; |
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
|
1355 |
|
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
|
1356 |
_train_sort_type[(byte)w->window_number] = e->dropdown.index; |
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
|
1357 |
|
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
|
1358 |
if (_train_sort_type[(byte)w->window_number] != SORT_BY_UNSORTED) // enable 'Sort By' if a sorter criteria is chosen |
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1359 |
w->disabled_state &= ~(1 << 2); |
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
|
1360 |
|
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 |
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
|
1362 |
break; |
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 |
case WE_CREATE: /* set up resort timer */ |
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
|
1364 |
w->custom[0] = DAY_TICKS; |
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 |
w->custom[1] = PERIODIC_RESORT_DAYS; |
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
|
1366 |
break; |
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 |
case WE_TICK: /* resort the list every 20 seconds orso (10 days) */ |
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
|
1368 |
if (--w->custom[0] == 0) { |
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 |
w->custom[0] = DAY_TICKS; |
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 |
if (--w->custom[1] == 0) { |
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
|
1371 |
w->custom[1] = PERIODIC_RESORT_DAYS; |
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
|
1372 |
_train_sort_dirty[(byte)w->window_number] = true; |
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
|
1373 |
DEBUG(misc, 1) ("Periodic resort Trains list player %d...", w->window_number+1); |
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
|
1374 |
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
|
1375 |
} |
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
|
1376 |
} |
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
|
1377 |
break; |
0 | 1378 |
} |
1379 |
} |
|
1380 |
||
1381 |
static const Widget _player_trains_widgets[] = { |
|
1382 |
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
|
1383 |
{ WWT_CAPTION, 14, 11, 324, 0, 13, STR_881B_TRAINS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
|
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1384 |
{ WWT_PUSHTXTBTN, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_TIP}, |
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1385 |
{ WWT_PANEL, 14, 81, 232, 14, 25, 0x0, STR_SORT_TIP}, |
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1386 |
{ WWT_CLOSEBOX, 14, 233, 243, 14, 25, STR_0225, STR_SORT_TIP}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
1387 |
{ WWT_PANEL, 14, 244, 324, 14, 25, 0x0, STR_NULL}, |
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
|
1388 |
{ WWT_MATRIX, 14, 0, 313, 26, 207, 0x701, STR_883D_TRAINS_CLICK_ON_TRAIN_FOR}, |
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
|
1389 |
{ WWT_SCROLLBAR, 14, 314, 324, 26, 207, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
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
|
1390 |
{ WWT_PUSHTXTBTN, 14, 0, 161, 208, 219, STR_8815_NEW_VEHICLES, STR_883E_BUILD_NEW_TRAINS_REQUIRES}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
1391 |
{ WWT_PANEL, 14, 162, 324, 208, 219, 0x0, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
1392 |
{ WIDGETS_END}, |
0 | 1393 |
}; |
1394 |
||
1395 |
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
|
1396 |
-1, -1, 325, 220, |
0 | 1397 |
WC_TRAINS_LIST,0, |
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1398 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
0 | 1399 |
_player_trains_widgets, |
1400 |
PlayerTrainsWndProc |
|
1401 |
}; |
|
1402 |
||
1403 |
static const Widget _other_player_trains_widgets[] = { |
|
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 |
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
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
|
1405 |
{ WWT_CAPTION, 14, 11, 324, 0, 13, STR_881B_TRAINS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1406 |
{ WWT_PUSHTXTBTN, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_TIP}, |
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1407 |
{ WWT_PANEL, 14, 81, 232, 14, 25, 0x0, STR_SORT_TIP}, |
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1408 |
{ WWT_CLOSEBOX, 14, 233, 243, 14, 25, STR_0225, STR_SORT_TIP}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
1409 |
{ WWT_PANEL, 14, 244, 324, 14, 25, 0x0, STR_NULL}, |
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
|
1410 |
{ WWT_MATRIX, 14, 0, 313, 26, 207, 0x701, STR_883D_TRAINS_CLICK_ON_TRAIN_FOR}, |
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
|
1411 |
{ WWT_SCROLLBAR, 14, 314, 324, 26, 207, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
1412 |
{ WIDGETS_END}, |
0 | 1413 |
}; |
1414 |
||
1415 |
static const WindowDesc _other_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
|
1416 |
-1, -1, 325, 208, |
0 | 1417 |
WC_TRAINS_LIST,0, |
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1418 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
0 | 1419 |
_other_player_trains_widgets, |
1420 |
PlayerTrainsWndProc |
|
1421 |
}; |
|
1422 |
||
1423 |
void ShowPlayerTrains(int player) |
|
1424 |
{ |
|
1425 |
Window *w; |
|
1426 |
||
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
|
1427 |
if (player == _local_player) { |
0 | 1428 |
w = AllocateWindowDescFront(&_player_trains_desc, 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
|
1429 |
} else { |
0 | 1430 |
w = AllocateWindowDescFront(&_other_player_trains_desc, player); |
1431 |
} |
|
1432 |
if (w) { |
|
1433 |
w->caption_color = w->window_number; |
|
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
|
1434 |
w->vscroll.cap = 7; // maximum number of vehicles shown |
0 | 1435 |
} |
1436 |
} |