author | darkvater |
Tue, 07 Sep 2004 19:01:06 +0000 | |
changeset 174 | bd79fb899824 |
parent 168 | 79f9ed5b23e6 |
child 176 | 84990c4b9212 |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
3 |
#include "window.h" |
|
4 |
#include "gui.h" |
|
5 |
#include "vehicle.h" |
|
6 |
#include "gfx.h" |
|
7 |
#include "station.h" |
|
8 |
#include "command.h" |
|
9 |
#include "engine.h" |
|
10 |
#include "viewport.h" |
|
11 |
#include "player.h" |
|
12 |
||
13 |
extern const byte _aircraft_cost_table[NUM_AIRCRAFT_ENGINES]; |
|
14 |
extern const byte _aircraft_speed[NUM_AIRCRAFT_ENGINES]; |
|
15 |
extern const uint16 _aircraft_num_pass[NUM_AIRCRAFT_ENGINES]; |
|
16 |
extern const byte _aircraft_num_mail[NUM_AIRCRAFT_ENGINES]; |
|
17 |
extern const byte _aircraft_running_cost[NUM_AIRCRAFT_ENGINES]; |
|
18 |
||
19 |
||
20 |
static void DrawAircraftImage(Vehicle *v, int x, int y, VehicleID selection) |
|
21 |
{ |
|
22 |
int image = GetAircraftImage(v, 6); |
|
23 |
uint32 ormod = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)); |
|
24 |
if (v->vehstatus & VS_CRASHED) ormod = 0x3248000; |
|
25 |
DrawSprite(image | ormod, x+25, y+10); |
|
26 |
if (v->subtype == 0) |
|
27 |
DrawSprite(0xF3D, x+25, y+5); |
|
28 |
if (v->index == selection) { |
|
29 |
DrawFrameRect(x-1, y-1, x+58, y+21, 0xF, 0x10); |
|
30 |
} |
|
31 |
} |
|
32 |
||
33 |
static void CcBuildAircraft(bool success, uint tile, uint32 p1, uint32 p2) |
|
34 |
{ |
|
35 |
Vehicle *v; |
|
36 |
||
37 |
if (success) { |
|
38 |
v = &_vehicles[_new_aircraft_id]; |
|
39 |
if (v->tile == _backup_orders_tile) { |
|
40 |
_backup_orders_tile = 0; |
|
41 |
RestoreVehicleOrders(v, _backup_orders_data); |
|
42 |
} |
|
43 |
ShowAircraftViewWindow(v); |
|
44 |
} |
|
45 |
} |
|
46 |
||
47 |
||
48 |
static void NewAircraftWndProc(Window *w, WindowEvent *e) |
|
49 |
{ |
|
50 |
YearMonthDay ymd; |
|
51 |
||
52 |
switch(e->event) { |
|
53 |
||
54 |
case WE_PAINT: { |
|
55 |
if (w->window_number == 0) |
|
56 |
SETBIT(w->disabled_state, 5); |
|
57 |
||
58 |
{ |
|
59 |
int count = 0; |
|
60 |
int num = NUM_AIRCRAFT_ENGINES; |
|
61 |
Engine *e = &_engines[AIRCRAFT_ENGINES_INDEX]; |
|
62 |
do { |
|
63 |
if (HASBIT(e->player_avail, _local_player)) |
|
64 |
count++; |
|
65 |
} while (++e,--num); |
|
66 |
SetVScrollCount(w, count); |
|
67 |
} |
|
68 |
||
69 |
DrawWindowWidgets(w); |
|
70 |
||
71 |
{ |
|
72 |
int num = NUM_AIRCRAFT_ENGINES; |
|
73 |
Engine *e = &_engines[AIRCRAFT_ENGINES_INDEX]; |
|
74 |
int x = 2; |
|
75 |
int y = 15; |
|
76 |
int sel = WP(w,buildtrain_d).sel_index; |
|
77 |
int pos = w->vscroll.pos; |
|
78 |
int engine_id = AIRCRAFT_ENGINES_INDEX; |
|
79 |
int selected_id = -1; |
|
80 |
||
81 |
do { |
|
82 |
if (HASBIT(e->player_avail, _local_player)) { |
|
83 |
if (sel==0) selected_id = engine_id; |
|
84 |
if (IS_INT_INSIDE(--pos, -4, 0)) { |
|
85 |
DrawString(x+62, y+7, GetCustomEngineName(engine_id), sel==0 ? 0xC : 0x10); |
|
86 |
DrawAircraftEngine(x+29, y+10, engine_id, SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player))); |
|
87 |
y += 24; |
|
88 |
} |
|
89 |
sel--; |
|
90 |
} |
|
91 |
} while (++engine_id, ++e,--num); |
|
92 |
||
93 |
WP(w,buildtrain_d).sel_engine = selected_id; |
|
94 |
||
95 |
if (selected_id != -1) { |
|
96 |
Engine *e; |
|
97 |
||
98 |
SET_DPARAM32(0, _aircraft_cost_table[selected_id - AIRCRAFT_ENGINES_INDEX] * (_price.aircraft_base>>3)>>5); |
|
99 |
SET_DPARAM16(1, _aircraft_speed[selected_id - AIRCRAFT_ENGINES_INDEX] * 8); |
|
100 |
SET_DPARAM16(2, _aircraft_num_pass[selected_id - AIRCRAFT_ENGINES_INDEX]); |
|
101 |
SET_DPARAM16(3, _aircraft_num_mail[selected_id - AIRCRAFT_ENGINES_INDEX]); |
|
102 |
SET_DPARAM32(4,_aircraft_running_cost[selected_id - AIRCRAFT_ENGINES_INDEX] * _price.aircraft_running >> 8); |
|
103 |
||
104 |
e = &_engines[selected_id]; |
|
105 |
SET_DPARAM16(6, e->lifelength); |
|
106 |
SET_DPARAM8(7, e->reliability * 100 >> 16); |
|
107 |
ConvertDayToYMD(&ymd, e->intro_date); |
|
108 |
SET_DPARAM16(5, ymd.year + 1920); |
|
109 |
||
110 |
DrawString(2, 111, STR_A007_COST_SPEED_CAPACITY_PASSENGERS, 0); |
|
111 |
} |
|
112 |
} |
|
113 |
} break; |
|
114 |
||
115 |
case WE_CLICK: |
|
116 |
switch(e->click.widget) { |
|
117 |
case 2: { /* listbox */ |
|
118 |
uint i = (e->click.pt.y - 14) / 24; |
|
119 |
if (i < 4) { |
|
120 |
WP(w,buildtrain_d).sel_index = i + w->vscroll.pos; |
|
121 |
SetWindowDirty(w); |
|
122 |
} |
|
123 |
} break; |
|
124 |
||
125 |
case 5: { /* build */ |
|
126 |
int sel_eng = WP(w,buildtrain_d).sel_engine; |
|
127 |
if (sel_eng != -1) |
|
128 |
DoCommandP(w->window_number, sel_eng, 0, CcBuildAircraft, CMD_BUILD_AIRCRAFT | CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT)); |
|
129 |
} break; |
|
130 |
||
131 |
case 6: /* rename */ |
|
132 |
WP(w,buildtrain_d).rename_engine = WP(w,buildtrain_d).sel_engine; |
|
133 |
ShowQueryString( |
|
134 |
GetCustomEngineName(WP(w,buildtrain_d).sel_engine), |
|
135 |
STR_A039_RENAME_AIRCRAFT_TYPE, |
|
136 |
31, |
|
137 |
160, |
|
138 |
w->window_class, |
|
139 |
w->window_number); |
|
140 |
break; |
|
141 |
} |
|
142 |
break; |
|
143 |
||
144 |
case WE_4: |
|
145 |
if (w->window_number != 0 && !FindWindowById(WC_VEHICLE_DEPOT, w->window_number)) { |
|
146 |
DeleteWindow(w); |
|
147 |
} |
|
148 |
break; |
|
149 |
||
150 |
case WE_ON_EDIT_TEXT: { |
|
151 |
byte *b = e->edittext.str; |
|
152 |
if (*b == 0) |
|
153 |
return; |
|
154 |
memcpy(_decode_parameters, b, 32); |
|
155 |
DoCommandP(0, WP(w,buildtrain_d).rename_engine, 0, NULL, CMD_RENAME_ENGINE | CMD_MSG(STR_A03A_CAN_T_RENAME_AIRCRAFT_TYPE)); |
|
156 |
} break; |
|
157 |
} |
|
158 |
} |
|
159 |
||
160 |
static const Widget _new_aircraft_widgets[] = { |
|
161 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
|
162 |
{ WWT_CAPTION, 14, 11, 239, 0, 13, STR_A005_NEW_AIRCRAFT, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
|
163 |
{ WWT_MATRIX, 14, 0, 228, 14, 109, 0x401, STR_A025_AIRCRAFT_SELECTION_LIST}, |
|
164 |
{ WWT_SCROLLBAR, 14, 229, 239, 14, 109, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
|
165 |
{ WWT_IMGBTN, 14, 0, 239, 110, 161, 0x0, 0}, |
|
166 |
{ WWT_PUSHTXTBTN, 14, 0, 119, 162, 173, STR_A006_BUILD_AIRCRAFT, STR_A026_BUILD_THE_HIGHLIGHTED_AIRCRAFT}, |
|
167 |
{ WWT_PUSHTXTBTN, 14, 120, 239, 162, 173, STR_A037_RENAME, STR_A038_RENAME_AIRCRAFT_TYPE}, |
|
168 |
{ WWT_LAST}, |
|
169 |
}; |
|
170 |
||
171 |
static const WindowDesc _new_aircraft_desc = { |
|
172 |
-1, -1, 240, 174, |
|
173 |
WC_BUILD_VEHICLE,0, |
|
174 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
175 |
_new_aircraft_widgets, |
|
176 |
NewAircraftWndProc |
|
177 |
}; |
|
178 |
||
179 |
static void ShowBuildAircraftWindow(uint tile) |
|
180 |
{ |
|
181 |
Window *w; |
|
182 |
||
183 |
DeleteWindowById(WC_BUILD_VEHICLE, tile); |
|
184 |
||
185 |
w = AllocateWindowDesc(&_new_aircraft_desc); |
|
186 |
w->window_number = tile; |
|
187 |
w->vscroll.cap = 4; |
|
188 |
||
189 |
if (tile != 0) { |
|
190 |
w->caption_color = _map_owner[tile]; |
|
191 |
} else { |
|
192 |
w->caption_color = _local_player; |
|
193 |
} |
|
194 |
} |
|
195 |
||
196 |
const byte _aircraft_refit_normal[] = { 0,1,4,5,6,7,8,9,10,0xFF }; |
|
197 |
const byte _aircraft_refit_arctic[] = { 0,1,4,5,6,7,9,11,10,0xFF }; |
|
198 |
const byte _aircraft_refit_desert[] = { 0,4,5,8,6,7,9,10,0xFF }; |
|
199 |
const byte _aircraft_refit_candy[] = { 0,1,3,5,7,8,9,6,4,10,11,0xFF }; |
|
200 |
||
201 |
const byte * const _aircraft_refit_types[4] = { |
|
202 |
_aircraft_refit_normal, _aircraft_refit_arctic, _aircraft_refit_desert, _aircraft_refit_candy |
|
203 |
}; |
|
204 |
||
205 |
static void AircraftRefitWndProc(Window *w, WindowEvent *e) |
|
206 |
{ |
|
207 |
switch(e->event) { |
|
208 |
case WE_PAINT: { |
|
209 |
Vehicle *v = &_vehicles[w->window_number]; |
|
210 |
const byte *b; |
|
211 |
int sel; |
|
212 |
int x,y; |
|
213 |
byte color; |
|
214 |
int cargo; |
|
215 |
||
216 |
SET_DPARAM16(0, v->string_id); |
|
217 |
SET_DPARAM16(1, v->unitnumber); |
|
218 |
DrawWindowWidgets(w); |
|
219 |
||
220 |
DrawString(1, 15, STR_A040_SELECT_CARGO_TYPE_TO_CARRY, 0); |
|
221 |
||
222 |
cargo = -1; |
|
223 |
x = 6; |
|
224 |
y = 25; |
|
225 |
sel = WP(w,refit_d).sel; |
|
226 |
b = _aircraft_refit_types[_opt.landscape]; |
|
227 |
do { |
|
228 |
color = 16; |
|
229 |
if (sel == 0) { |
|
230 |
cargo = *b; |
|
231 |
color = 12; |
|
232 |
} |
|
233 |
sel--; |
|
234 |
DrawString(x,y,_cargoc.names_s[*b], color); |
|
235 |
y += 10; |
|
236 |
} while (*++b != 0xFF); |
|
237 |
||
238 |
WP(w,refit_d).cargo = cargo; |
|
239 |
||
240 |
if (cargo != -1) { |
|
241 |
int32 cost = DoCommandByTile(v->tile, v->index, cargo, DC_QUERY_COST, CMD_REFIT_AIRCRAFT); |
|
242 |
if (cost != CMD_ERROR) { |
|
243 |
SET_DPARAM32(2, cost); |
|
244 |
SET_DPARAM16(0, _cargoc.names_long_p[cargo]); |
|
245 |
SET_DPARAM16(1, _aircraft_refit_capacity); |
|
246 |
DrawString(1, 137, STR_A041_NEW_CAPACITY_COST_OF_REFIT, 0); |
|
247 |
} |
|
248 |
} |
|
249 |
||
250 |
break; |
|
251 |
} |
|
252 |
||
253 |
case WE_CLICK: |
|
254 |
switch(e->click.widget) { |
|
255 |
case 2: { /* listbox */ |
|
256 |
int y = e->click.pt.y - 25; |
|
257 |
if (y >= 0) { |
|
258 |
WP(w,refit_d).sel = y / 10; |
|
259 |
SetWindowDirty(w); |
|
260 |
} |
|
261 |
} break; |
|
262 |
case 4: /* refit button */ |
|
263 |
if (WP(w,refit_d).cargo != 0xFF) { |
|
264 |
Vehicle *v = &_vehicles[w->window_number]; |
|
265 |
if (DoCommandP(v->tile, v->index, WP(w,refit_d).cargo, NULL, CMD_REFIT_AIRCRAFT | CMD_MSG(STR_A042_CAN_T_REFIT_AIRCRAFT))) |
|
266 |
DeleteWindow(w); |
|
267 |
} |
|
268 |
break; |
|
269 |
} |
|
270 |
break; |
|
271 |
} |
|
272 |
} |
|
273 |
||
274 |
static const Widget _aircraft_refit_widgets[] = { |
|
275 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
|
276 |
{ WWT_CAPTION, 14, 11, 239, 0, 13, STR_A03C_REFIT, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
|
277 |
{ WWT_IMGBTN, 14, 0, 239, 14, 135, 0x0, STR_A03E_SELECT_TYPE_OF_CARGO_FOR}, |
|
278 |
{ WWT_IMGBTN, 14, 0, 239, 136, 157, 0x0}, |
|
279 |
{ WWT_PUSHTXTBTN, 14, 0, 239, 158, 169, STR_A03D_REFIT_AIRCRAFT, STR_A03F_REFIT_AIRCRAFT_TO_CARRY}, |
|
280 |
{ WWT_LAST}, |
|
281 |
}; |
|
282 |
||
283 |
static const WindowDesc _aircraft_refit_desc = { |
|
284 |
-1,-1, 240, 170, |
|
285 |
WC_VEHICLE_REFIT,WC_VEHICLE_VIEW, |
|
286 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
287 |
_aircraft_refit_widgets, |
|
288 |
AircraftRefitWndProc |
|
289 |
}; |
|
290 |
||
291 |
static void ShowAircraftRefitWindow(Vehicle *v) |
|
292 |
{ |
|
293 |
Window *w; |
|
294 |
||
295 |
DeleteWindowById(WC_VEHICLE_REFIT, v->index); |
|
296 |
||
297 |
_alloc_wnd_parent_num = v->index; |
|
298 |
w = AllocateWindowDesc(&_aircraft_refit_desc); |
|
299 |
w->window_number = v->index; |
|
300 |
w->caption_color = v->owner; |
|
301 |
WP(w,refit_d).sel = -1; |
|
302 |
} |
|
303 |
||
304 |
static void AircraftDetailsWndProc(Window *w, WindowEvent *e) |
|
305 |
{ |
|
306 |
int mod; |
|
307 |
Vehicle *v = &_vehicles[w->window_number], *u; |
|
308 |
||
309 |
switch(e->event) { |
|
310 |
case WE_PAINT: |
|
311 |
w->disabled_state = v->owner == _local_player ? 0 : (1 << 2); |
|
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:
10
diff
changeset
|
312 |
if (!_patches.servint_aircraft) // 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:
10
diff
changeset
|
313 |
w->disabled_state |= (1 << 5) | (1 << 6); |
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:
10
diff
changeset
|
314 |
|
0 | 315 |
SET_DPARAM16(0, v->string_id); |
316 |
SET_DPARAM16(1, v->unitnumber); |
|
317 |
DrawWindowWidgets(w); |
|
318 |
||
319 |
/* Draw running cost */ |
|
320 |
{ |
|
321 |
int year = v->age / 366; |
|
322 |
StringID str; |
|
323 |
||
324 |
SET_DPARAM16(1, year); |
|
325 |
||
326 |
str = STR_0199_YEAR; |
|
327 |
if (year != 1) { |
|
328 |
str++; |
|
329 |
if (v->max_age - 366 < v->age) |
|
330 |
str++; |
|
331 |
} |
|
332 |
SET_DPARAM16(0, str); |
|
333 |
SET_DPARAM16(2, v->max_age / 366); |
|
334 |
SET_DPARAM32(3, _price.aircraft_running * _aircraft_running_cost[v->engine_type - AIRCRAFT_ENGINES_INDEX] >> 8); |
|
335 |
DrawString(2, 15, STR_A00D_AGE_RUNNING_COST_YR, 0); |
|
336 |
} |
|
337 |
||
338 |
/* Draw max speed */ |
|
339 |
{ |
|
340 |
SET_DPARAM16(0, v->max_speed * 8); |
|
341 |
DrawString(2, 25, STR_A00E_MAX_SPEED, 0); |
|
342 |
} |
|
343 |
||
344 |
/* Draw profit */ |
|
345 |
{ |
|
346 |
SET_DPARAM32(0, v->profit_this_year); |
|
347 |
SET_DPARAM32(1, v->profit_last_year); |
|
348 |
DrawString(2, 35, STR_A00F_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
|
349 |
} |
|
350 |
||
351 |
/* Draw breakdown & reliability */ |
|
352 |
{ |
|
353 |
SET_DPARAM8(0, v->reliability * 100 >> 16); |
|
354 |
SET_DPARAM16(1, v->breakdowns_since_last_service); |
|
355 |
DrawString(2, 45, STR_A010_RELIABILITY_BREAKDOWNS, 0); |
|
356 |
} |
|
357 |
||
358 |
/* Draw service interval text */ |
|
359 |
{ |
|
360 |
SET_DPARAM16(0, v->service_interval); |
|
361 |
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:
10
diff
changeset
|
362 |
DrawString(13, 103, _patches.servint_ispercent?STR_SERVICING_INTERVAL_PERCENT:STR_883C_SERVICING_INTERVAL_DAYS, 0); |
0 | 363 |
} |
364 |
||
365 |
DrawAircraftImage(v, 3, 57, INVALID_VEHICLE); |
|
366 |
||
367 |
{ |
|
368 |
int y = 57; |
|
369 |
||
370 |
do { |
|
371 |
if (v->subtype <= 2) { |
|
372 |
SET_DPARAM16(0, GetCustomEngineName(v->engine_type)); |
|
373 |
SET_DPARAM16(1, 1920 + v->build_year); |
|
374 |
SET_DPARAM32(2, v->value); |
|
375 |
DrawString(60, y, STR_A011_BUILT_VALUE, 0); |
|
376 |
y += 10; |
|
377 |
||
378 |
SET_DPARAM16(0, _cargoc.names_long_p[v->cargo_type]); |
|
379 |
SET_DPARAM16(1, v->cargo_cap); |
|
380 |
u = v->next; |
|
381 |
SET_DPARAM16(2, _cargoc.names_long_p[u->cargo_type]); |
|
382 |
SET_DPARAM16(3, u->cargo_cap); |
|
383 |
DrawString(60, y, STR_A019_CAPACITY + (u->cargo_cap == 0), 0); |
|
384 |
y += 14; |
|
385 |
} |
|
386 |
||
387 |
if (v->cargo_count != 0) { |
|
388 |
||
389 |
/* Cargo names (fix pluralness) */ |
|
390 |
SET_DPARAM8(0, v->cargo_type); |
|
391 |
SET_DPARAM16(1, v->cargo_count); |
|
392 |
SET_DPARAM16(2, v->cargo_source); |
|
393 |
DrawString(60, y, STR_8813_FROM, 0); |
|
394 |
||
395 |
y += 10; |
|
396 |
} |
|
397 |
} while ( (v=v->next) != NULL); |
|
398 |
} |
|
399 |
break; |
|
400 |
||
401 |
case WE_CLICK: |
|
402 |
switch(e->click.widget) { |
|
403 |
case 2: /* rename */ |
|
404 |
SET_DPARAM16(0, v->unitnumber); |
|
405 |
ShowQueryString(v->string_id, STR_A030_NAME_AIRCRAFT, 31, 150, w->window_class, w->window_number); |
|
406 |
break; |
|
407 |
||
408 |
case 5: /* increase int */ |
|
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:
10
diff
changeset
|
409 |
mod = _ctrl_pressed? 5 : 10; |
0 | 410 |
goto change_int; |
411 |
case 6: /* decrease int */ |
|
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:
10
diff
changeset
|
412 |
mod = _ctrl_pressed?- 5 : -10; |
0 | 413 |
change_int: |
414 |
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:
10
diff
changeset
|
415 |
|
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:
10
diff
changeset
|
416 |
/* %-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:
10
diff
changeset
|
417 |
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:
10
diff
changeset
|
418 |
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:
10
diff
changeset
|
419 |
if (mod == v->service_interval) |
0 | 420 |
return; |
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:
10
diff
changeset
|
421 |
|
0 | 422 |
DoCommandP(v->tile, v->index, mod, NULL, |
423 |
CMD_CHANGE_AIRCRAFT_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING)); |
|
424 |
break; |
|
425 |
} |
|
426 |
break; |
|
427 |
||
428 |
case WE_4: |
|
429 |
if (FindWindowById(WC_VEHICLE_VIEW, w->window_number) == NULL) |
|
430 |
DeleteWindow(w); |
|
431 |
break; |
|
432 |
||
433 |
case WE_ON_EDIT_TEXT: { |
|
434 |
byte *b = e->edittext.str; |
|
435 |
if (*b == 0) |
|
436 |
return; |
|
437 |
memcpy(_decode_parameters, b, 32); |
|
438 |
DoCommandP(0, w->window_number, 0, NULL, CMD_NAME_VEHICLE | CMD_MSG(STR_A031_CAN_T_NAME_AIRCRAFT)); |
|
439 |
} break; |
|
440 |
||
441 |
} |
|
442 |
} |
|
443 |
||
444 |
||
445 |
static const Widget _aircraft_details_widgets[] = { |
|
446 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
|
447 |
{ WWT_CAPTION, 14, 11, 349, 0, 13, STR_A00C_DETAILS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
|
448 |
{ WWT_PUSHTXTBTN, 14, 350, 389, 0, 13, STR_01AA_NAME, STR_A032_NAME_AIRCRAFT}, |
|
449 |
{ WWT_IMGBTN, 14, 0, 389, 14, 55, 0x0}, |
|
450 |
{ WWT_IMGBTN, 14, 0, 389, 56, 101, 0x0}, |
|
451 |
{ WWT_PUSHTXTBTN, 14, 0, 10, 102, 107, STR_0188, STR_884D_INCREASE_SERVICING_INTERVAL}, |
|
452 |
{ WWT_PUSHTXTBTN, 14, 0, 10, 108, 113, STR_0189, STR_884E_DECREASE_SERVICING_INTERVAL}, |
|
453 |
{ WWT_IMGBTN, 14, 11, 389, 102, 113, 0x0}, |
|
454 |
{ WWT_LAST}, |
|
455 |
}; |
|
456 |
||
457 |
static const WindowDesc _aircraft_details_desc = { |
|
458 |
-1,-1, 390, 114, |
|
459 |
WC_VEHICLE_DETAILS,WC_VEHICLE_VIEW, |
|
460 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
461 |
_aircraft_details_widgets, |
|
462 |
AircraftDetailsWndProc |
|
463 |
}; |
|
464 |
||
465 |
||
466 |
static void ShowAircraftDetailsWindow(Vehicle *v) |
|
467 |
{ |
|
468 |
Window *w; |
|
469 |
VehicleID veh = v->index; |
|
470 |
||
471 |
DeleteWindowById(WC_VEHICLE_ORDERS, veh); |
|
472 |
DeleteWindowById(WC_VEHICLE_DETAILS, veh); |
|
473 |
||
474 |
_alloc_wnd_parent_num = veh; |
|
475 |
w = AllocateWindowDesc(&_aircraft_details_desc); |
|
476 |
w->window_number = veh; |
|
477 |
w->caption_color = v->owner; |
|
478 |
// w->vscroll.cap = 6; |
|
479 |
// w->traindetails_d.tab = 0; |
|
480 |
} |
|
481 |
||
482 |
||
483 |
static const Widget _aircraft_view_widgets[] = { |
|
484 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
|
485 |
{ WWT_CAPTION, 14, 11, 249, 0, 13, STR_A00A, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
|
486 |
{ WWT_IMGBTN, 14, 0, 231, 14, 103, 0x0, 0}, |
|
487 |
{ WWT_6, 14, 2, 229, 16, 101, 0x0, 0}, |
|
488 |
{ WWT_PUSHIMGBTN, 14, 0, 249, 104, 115, 0x0, STR_A027_CURRENT_AIRCRAFT_ACTION}, |
|
489 |
{ WWT_PUSHIMGBTN, 14, 232, 249, 14, 31, 0x2AB, STR_A029_CENTER_MAIN_VIEW_ON_AIRCRAFT}, |
|
490 |
{ WWT_PUSHIMGBTN, 14, 232, 249, 32, 49, 0x2AF, STR_A02A_SEND_AIRCRAFT_TO_HANGAR}, |
|
491 |
{ WWT_PUSHIMGBTN, 14, 232, 249, 50, 67, 0x2B4, STR_A03B_REFIT_AIRCRAFT_TO_CARRY}, |
|
492 |
{ WWT_PUSHIMGBTN, 14, 232, 249, 68, 85, 0x2B2, STR_A028_SHOW_AIRCRAFT_S_ORDERS}, |
|
493 |
{ WWT_PUSHIMGBTN, 14, 232, 249, 86, 103, 0x2B3, STR_A02B_SHOW_AIRCRAFT_DETAILS}, |
|
494 |
{ WWT_LAST}, |
|
495 |
}; |
|
496 |
||
497 |
static void AircraftViewWndProc(Window *w, WindowEvent *e) |
|
498 |
{ |
|
499 |
switch(e->event) { |
|
500 |
case WE_PAINT: { |
|
501 |
Vehicle *v = &_vehicles[w->window_number]; |
|
502 |
uint32 disabled = 1<<7; |
|
503 |
StringID str; |
|
504 |
||
505 |
{ |
|
506 |
uint tile = v->tile; |
|
507 |
if (IS_TILETYPE(tile, MP_STATION) && |
|
508 |
(_map5[tile] == 32 || _map5[tile] == 65) && |
|
509 |
v->vehstatus&VS_STOPPED) |
|
510 |
disabled = 0; |
|
511 |
} |
|
512 |
||
513 |
if (v->owner != _local_player) |
|
514 |
disabled |= 1<<7 | 1<<6; |
|
515 |
w->disabled_state = disabled; |
|
516 |
||
517 |
/* draw widgets & caption */ |
|
518 |
SET_DPARAM16(0, v->string_id); |
|
519 |
SET_DPARAM16(1, v->unitnumber); |
|
520 |
DrawWindowWidgets(w); |
|
521 |
||
522 |
/* draw the flag */ |
|
523 |
DrawSprite((v->vehstatus & VS_STOPPED) ? 0xC12 : 0xC13, 2, 105); |
|
524 |
||
525 |
if (v->vehstatus & VS_CRASHED) { |
|
526 |
str = STR_8863_CRASHED; |
|
527 |
} else if (v->vehstatus & VS_STOPPED) { |
|
528 |
str = STR_8861_STOPPED; |
|
529 |
} else { |
|
530 |
switch(v->next_order & OT_MASK) { |
|
531 |
case OT_GOTO_STATION: { |
|
532 |
SET_DPARAM16(0, v->next_order_param); |
|
533 |
SET_DPARAM16(1, v->cur_speed * 8); |
|
534 |
str = STR_HEADING_FOR_STATION + _patches.vehicle_speed; |
|
535 |
} break; |
|
536 |
||
537 |
case OT_GOTO_DEPOT: { |
|
538 |
SET_DPARAM16(0, v->next_order_param); |
|
539 |
SET_DPARAM16(1, v->cur_speed * 8); |
|
540 |
str = STR_HEADING_FOR_HANGAR + _patches.vehicle_speed; |
|
541 |
} break; |
|
542 |
||
543 |
case OT_LOADING: |
|
544 |
str = STR_882F_LOADING_UNLOADING; |
|
545 |
break; |
|
546 |
||
547 |
default: |
|
548 |
if (v->num_orders == 0) { |
|
549 |
str = STR_NO_ORDERS + _patches.vehicle_speed; |
|
550 |
SET_DPARAM16(0, v->cur_speed * 8); |
|
551 |
} else |
|
552 |
str = STR_EMPTY; |
|
553 |
break; |
|
554 |
} |
|
555 |
} |
|
556 |
||
557 |
DrawStringCentered(125, 105, str, 0); |
|
558 |
DrawWindowViewport(w); |
|
559 |
} break; |
|
560 |
||
561 |
case WE_CLICK: { |
|
562 |
Vehicle *v = &_vehicles[w->window_number]; |
|
563 |
||
564 |
switch(e->click.widget) { |
|
565 |
case 4: /* start stop */ |
|
566 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_AIRCRAFT | CMD_MSG(STR_A016_CAN_T_STOP_START_AIRCRAFT)); |
|
567 |
break; |
|
568 |
case 5: /* center main view */ |
|
569 |
ScrollMainWindowTo(v->x_pos, v->y_pos); |
|
570 |
break; |
|
571 |
case 6: /* goto hangar */ |
|
572 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_SEND_AIRCRAFT_TO_HANGAR | CMD_MSG(STR_A012_CAN_T_SEND_AIRCRAFT_TO)); |
|
573 |
break; |
|
574 |
case 7: /* refit */ |
|
575 |
ShowAircraftRefitWindow(v); |
|
576 |
break; |
|
577 |
case 8: /* show orders */ |
|
578 |
ShowOrdersWindow(v); |
|
579 |
break; |
|
580 |
case 9: /* show details */ |
|
581 |
ShowAircraftDetailsWindow(v); |
|
582 |
break; |
|
583 |
} |
|
584 |
} break; |
|
585 |
||
586 |
case WE_DESTROY: |
|
587 |
DeleteWindowById(WC_VEHICLE_ORDERS, w->window_number); |
|
588 |
DeleteWindowById(WC_VEHICLE_REFIT, w->window_number); |
|
589 |
DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number); |
|
590 |
break; |
|
591 |
} |
|
592 |
} |
|
593 |
||
594 |
||
595 |
static const WindowDesc _aircraft_view_desc = { |
|
596 |
-1,-1, 250, 116, |
|
597 |
WC_VEHICLE_VIEW ,0, |
|
598 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
599 |
_aircraft_view_widgets, |
|
600 |
AircraftViewWndProc |
|
601 |
}; |
|
602 |
||
603 |
||
604 |
void ShowAircraftViewWindow(Vehicle *v) |
|
605 |
{ |
|
606 |
Window *w; |
|
607 |
||
608 |
w = AllocateWindowDescFront(&_aircraft_view_desc, v->index); |
|
609 |
if (w) { |
|
610 |
w->caption_color = v->owner; |
|
611 |
AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), 0); |
|
612 |
} |
|
613 |
} |
|
614 |
||
615 |
static void DrawAircraftDepotWindow(Window *w) |
|
616 |
{ |
|
617 |
uint tile; |
|
618 |
Vehicle *v; |
|
619 |
int num,x,y; |
|
620 |
||
621 |
tile = w->window_number; |
|
622 |
||
623 |
/* setup disabled buttons */ |
|
624 |
w->disabled_state = (_map_owner[tile]==_local_player) ? 0 : ((1<<3)|(1<<5)); |
|
625 |
||
626 |
/* determine amount of items for scroller */ |
|
627 |
num = 0; |
|
628 |
FOR_ALL_VEHICLES(v) { |
|
629 |
if (v->type == VEH_Aircraft && v->subtype <= 2 && v->vehstatus&VS_HIDDEN && |
|
630 |
v->tile == (TileIndex)tile) |
|
631 |
num++; |
|
632 |
} |
|
633 |
SetVScrollCount(w, (num + 3) >> 2); |
|
634 |
||
635 |
SET_DPARAM16(0, _map2[tile]); |
|
636 |
DrawWindowWidgets(w); |
|
637 |
||
638 |
x = 2; |
|
639 |
y = 15; |
|
640 |
num = w->vscroll.pos * 4; |
|
641 |
||
642 |
FOR_ALL_VEHICLES(v) { |
|
643 |
if (v->type == VEH_Aircraft && |
|
644 |
v->subtype <= 2 && |
|
645 |
v->vehstatus&VS_HIDDEN && |
|
646 |
v->tile == (TileIndex)tile && |
|
647 |
--num < 0 && num >= -8) { |
|
648 |
||
649 |
DrawAircraftImage(v, x+12, y, WP(w,traindepot_d).sel); |
|
650 |
||
651 |
SET_DPARAM16(0, v->unitnumber); |
|
652 |
DrawString(x, y+2, (uint16)(v->max_age-366) >= v->age ? STR_00E2 : STR_00E3, 0); |
|
653 |
||
654 |
DrawSprite( (v->vehstatus & VS_STOPPED) ? 0xC12 : 0xC13, x, y+12); |
|
655 |
||
656 |
if ((x+=74) == 2+74*4) { |
|
657 |
x -= 74*4; |
|
658 |
y += 24; |
|
659 |
} |
|
660 |
} |
|
661 |
} |
|
662 |
} |
|
663 |
||
664 |
static int GetVehicleFromAircraftDepotWndPt(Window *w, int x, int y, Vehicle **veh) { |
|
665 |
uint xt,yt,xm,ym; |
|
666 |
Vehicle *v; |
|
667 |
uint tile; |
|
668 |
int pos; |
|
669 |
||
670 |
xt = x / 74; |
|
671 |
xm = x % 74; |
|
672 |
if (xt >= 4) |
|
673 |
return 1; |
|
674 |
||
675 |
yt = (y - 14) / 24; |
|
676 |
ym = (y - 14) % 24; |
|
677 |
if (yt >= 2) |
|
678 |
return 1; |
|
679 |
||
680 |
pos = (yt + w->vscroll.pos) * 4 + xt; |
|
681 |
||
682 |
tile = w->window_number; |
|
683 |
FOR_ALL_VEHICLES(v) { |
|
684 |
if (v->type == VEH_Aircraft && |
|
685 |
v->subtype <= 2 && |
|
686 |
v->vehstatus&VS_HIDDEN && |
|
687 |
v->tile == (TileIndex)tile && |
|
688 |
--pos < 0) { |
|
689 |
*veh = v; |
|
690 |
if (xm >= 12) |
|
691 |
return 0; |
|
692 |
||
693 |
if (ym <= 12) |
|
694 |
return -1; /* show window */ |
|
695 |
||
696 |
return -2; /* start stop */ |
|
697 |
} |
|
698 |
} |
|
699 |
return 1; /* outside */ |
|
700 |
} |
|
701 |
||
702 |
static void AircraftDepotClickAircraft(Window *w, int x, int y) |
|
703 |
{ |
|
704 |
Vehicle *v; |
|
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
|
705 |
int mode = GetVehicleFromAircraftDepotWndPt(w, x, y, &v); |
0 | 706 |
|
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
|
707 |
// share / copy orders |
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
|
708 |
if (_thd.place_mode && mode <= 0) { _place_clicked_vehicle = v; return; } |
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
|
709 |
|
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
|
710 |
switch(mode) { |
0 | 711 |
case 1: |
712 |
return; |
|
713 |
||
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
|
714 |
case 0: // start dragging of vehicle |
0 | 715 |
if (v != NULL) { |
716 |
WP(w,traindepot_d).sel = v->index; |
|
717 |
SetWindowDirty(w); |
|
718 |
SetObjectToPlaceWnd( SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)) + GetAircraftImage(v, 6), 4, w); |
|
719 |
} |
|
720 |
break; |
|
721 |
||
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
|
722 |
case -1: // show info window |
0 | 723 |
ShowAircraftViewWindow(v); |
724 |
break; |
|
725 |
||
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
|
726 |
case -2: // click start/stop flag |
0 | 727 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_AIRCRAFT | CMD_MSG(STR_A016_CAN_T_STOP_START_AIRCRAFT)); |
728 |
break; |
|
729 |
||
730 |
default: |
|
731 |
NOT_REACHED(); |
|
732 |
} |
|
733 |
} |
|
734 |
||
735 |
static const Widget _aircraft_depot_widgets[] = { |
|
736 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
|
737 |
{ WWT_CAPTION, 14, 11, 330, 0, 13, STR_A002_AIRCRAFT_HANGAR, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
|
738 |
{ WWT_MATRIX, 14, 0, 295, 14, 61, 0x204, STR_A021_AIRCRAFT_CLICK_ON_AIRCRAFT}, |
|
739 |
{ WWT_IMGBTN, 14, 296, 319, 14, 61, 0x2A9, STR_A023_DRAG_AIRCRAFT_TO_HERE_TO}, |
|
740 |
{ WWT_SCROLLBAR, 14, 320, 330, 14, 61, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
|
741 |
{ WWT_PUSHTXTBTN, 14, 0, 164, 62, 73, STR_A003_NEW_AIRCRAFT, STR_A022_BUILD_NEW_AIRCRAFT}, |
|
742 |
{ WWT_PUSHTXTBTN, 14, 165, 330, 62, 73, STR_00E4_LOCATION, STR_A024_CENTER_MAIN_VIEW_ON_HANGAR}, |
|
743 |
{ WWT_LAST}, |
|
744 |
}; |
|
745 |
||
746 |
||
747 |
static void AircraftDepotWndProc(Window *w, WindowEvent *e) |
|
748 |
{ |
|
749 |
switch(e->event) { |
|
750 |
case WE_PAINT: |
|
751 |
DrawAircraftDepotWindow(w); |
|
752 |
break; |
|
753 |
||
754 |
case WE_CLICK: |
|
755 |
switch(e->click.widget) { |
|
756 |
case 2: /* click aircraft */ |
|
757 |
AircraftDepotClickAircraft(w, e->click.pt.x, e->click.pt.y); |
|
758 |
break; |
|
759 |
case 5: /* show build aircraft window */ |
|
760 |
ShowBuildAircraftWindow(w->window_number); |
|
761 |
break; |
|
762 |
case 6: /* scroll to tile */ |
|
763 |
ScrollMainWindowToTile(w->window_number); |
|
764 |
break; |
|
765 |
} |
|
766 |
break; |
|
767 |
||
768 |
case WE_DESTROY: |
|
769 |
DeleteWindowById(WC_BUILD_VEHICLE, w->window_number); |
|
770 |
break; |
|
771 |
||
772 |
case WE_DRAGDROP: { |
|
773 |
switch(e->click.widget) { |
|
774 |
case 2: { |
|
775 |
Vehicle *v; |
|
776 |
VehicleID sel = WP(w,traindepot_d).sel; |
|
777 |
||
778 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
779 |
SetWindowDirty(w); |
|
780 |
||
781 |
if (GetVehicleFromAircraftDepotWndPt(w, e->dragdrop.pt.x, e->dragdrop.pt.y, &v) == 0 && |
|
782 |
v != NULL && |
|
783 |
sel == v->index) { |
|
784 |
ShowAircraftViewWindow(v); |
|
785 |
} |
|
786 |
} break; |
|
787 |
||
788 |
case 3: |
|
789 |
if (!HASBIT(w->disabled_state, 3) && |
|
790 |
WP(w,traindepot_d).sel != INVALID_VEHICLE) { |
|
791 |
Vehicle *v; |
|
792 |
||
793 |
HandleButtonClick(w, 3); |
|
794 |
||
795 |
v = &_vehicles[WP(w,traindepot_d).sel]; |
|
796 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
797 |
||
798 |
_backup_orders_tile = v->tile; |
|
799 |
BackupVehicleOrders(v, _backup_orders_data); |
|
800 |
||
801 |
if (!DoCommandP(v->tile, v->index, 0, NULL, CMD_SELL_AIRCRAFT | CMD_MSG(STR_A01C_CAN_T_SELL_AIRCRAFT))) |
|
802 |
_backup_orders_tile = 0; |
|
803 |
} |
|
804 |
break; |
|
805 |
default: |
|
806 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
807 |
SetWindowDirty(w); |
|
808 |
} |
|
809 |
break; |
|
810 |
} |
|
811 |
break; |
|
812 |
} |
|
813 |
} |
|
814 |
||
815 |
||
816 |
||
817 |
static const WindowDesc _aircraft_depot_desc = { |
|
818 |
-1, -1, 331, 74, |
|
819 |
WC_VEHICLE_DEPOT,0, |
|
820 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
821 |
_aircraft_depot_widgets, |
|
822 |
AircraftDepotWndProc |
|
823 |
}; |
|
824 |
||
825 |
||
826 |
void ShowAircraftDepotWindow(uint tile) |
|
827 |
{ |
|
828 |
Window *w; |
|
829 |
||
830 |
w = AllocateWindowDescFront(&_aircraft_depot_desc, tile); |
|
831 |
if (w) { |
|
832 |
w->caption_color = _map_owner[tile]; |
|
833 |
w->vscroll.cap = 2; |
|
834 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
835 |
_backup_orders_tile = 0; |
|
836 |
} |
|
837 |
} |
|
838 |
||
839 |
static void DrawSmallSchedule(Vehicle *v, int x, int y) { |
|
840 |
uint16 *sched; |
|
841 |
int sel; |
|
842 |
uint ord; |
|
843 |
int i = 0; |
|
844 |
||
845 |
sched = v->schedule_ptr; |
|
846 |
sel = v->cur_order_index; |
|
847 |
||
848 |
while ((ord=*sched++) != 0) { |
|
849 |
if (sel == 0) { |
|
850 |
_stringwidth_base = 0xE0; |
|
851 |
DoDrawString( "\xAF", x-6, y, 16); |
|
852 |
_stringwidth_base = 0; |
|
853 |
} |
|
854 |
sel--; |
|
855 |
||
856 |
if ((ord & OT_MASK) == OT_GOTO_STATION) { |
|
857 |
SET_DPARAM16(0, ord >> 8); |
|
858 |
DrawString(x, y, STR_A036, 0); |
|
859 |
||
860 |
y += 6; |
|
861 |
if (++i == 4) |
|
862 |
break; |
|
863 |
} |
|
864 |
} |
|
865 |
} |
|
866 |
||
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
|
867 |
// 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
|
868 |
static SortStruct _aircraft_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
|
869 |
static uint16 _num_aircraft_sort[MAX_PLAYERS]; |
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
|
870 |
|
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
|
871 |
static void MakeSortedAircraftList(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
|
872 |
{ |
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
|
873 |
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
|
874 |
Vehicle *v; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
875 |
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
|
876 |
uint16 *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
|
877 |
|
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
|
878 |
if (_vehicle_sort_dirty[VEHAIRCRAFT]) { // only resort the whole array if vehicles have been added/removed |
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
|
879 |
// reset to 0 just to be sure |
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
|
880 |
for (i = _num_aircraft_sort; i != endof(_num_aircraft_sort); i++) {*i = 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
|
881 |
|
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
|
882 |
FOR_ALL_VEHICLES(v) { |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
883 |
if(v->type == VEH_Aircraft && v->subtype <= 2) { |
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
|
884 |
_aircraft_sort[n].index = v->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
|
885 |
_aircraft_sort[n++].owner = v->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
|
886 |
_num_aircraft_sort[v->owner]++; // add number of aircraft of player |
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
|
887 |
} |
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
|
888 |
} |
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
|
889 |
|
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
|
890 |
// create cumulative aircraft-ownage |
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
|
891 |
// aircraft 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
|
892 |
// Player0: 25; Player1: (41-25) 16; Player2: (43-41) 2 |
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
|
893 |
for (i = &_num_aircraft_sort[1]; i != endof(_num_aircraft_sort); i++) {*i += *(i-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
|
894 |
|
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
|
895 |
// sort by owner, then only subsort the requested owner-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
|
896 |
qsort(_aircraft_sort, n, sizeof(_aircraft_sort[0]), GeneralOwnerSorter); |
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
|
897 |
|
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
|
898 |
_last_vehicle_idx = 0; // used for "cache" in namesorting |
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
|
899 |
_vehicle_sort_dirty[VEHAIRCRAFT] = false; |
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
|
900 |
} |
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
|
901 |
|
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
|
902 |
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
|
903 |
firstelement = &_aircraft_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
|
904 |
n = _num_aircraft_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
|
905 |
} 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
|
906 |
firstelement = &_aircraft_sort[_num_aircraft_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
|
907 |
n = _num_aircraft_sort[owner] - _num_aircraft_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
|
908 |
} |
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
|
909 |
|
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
|
910 |
_internal_sort_order = _aircraft_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
|
911 |
_internal_name_sorter_id = STR_SV_AIRCRAFT_NAME; |
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
912 |
qsort(firstelement, n, sizeof(_aircraft_sort[0]), _vehicle_sorter[_aircraft_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
|
913 |
|
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
|
914 |
DEBUG(misc, 1) ("Resorting Aircraft list player %d...", 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
|
915 |
} |
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
|
916 |
|
0 | 917 |
static void PlayerAircraftWndProc(Window *w, WindowEvent *e) |
918 |
{ |
|
919 |
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
|
920 |
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
|
921 |
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
|
922 |
const byte window_number = (byte)w->window_number; |
0 | 923 |
|
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
|
924 |
if (_aircraft_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
|
925 |
w->disabled_state |= (1 << 2); |
0 | 926 |
|
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
|
927 |
if (_aircraft_sort_dirty[window_number] || _vehicle_sort_dirty[VEHAIRCRAFT]) { |
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
|
928 |
_aircraft_sort_dirty[window_number] = false; |
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
|
929 |
MakeSortedAircraftList(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
|
930 |
/* 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
|
931 |
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
|
932 |
w->custom[1] = PERIODIC_RESORT_DAYS; |
0 | 933 |
} |
934 |
||
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
|
935 |
// aircraft 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
|
936 |
// Player0: 25; Player1: (41-25) 16; Player2: (43-41) 2 aircraft |
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
|
937 |
i = (window_number == 0) ? 0 : _num_aircraft_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
|
938 |
SetVScrollCount(w, _num_aircraft_sort[window_number] - 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
|
939 |
|
0 | 940 |
/* draw the widgets */ |
941 |
{ |
|
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
|
942 |
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
|
943 |
/* Company Name -- (###) Aircraft */ |
0 | 944 |
SET_DPARAM16(0, p->name_1); |
945 |
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
|
946 |
SET_DPARAM16(2, w->vscroll.count); |
0 | 947 |
DrawWindowWidgets(w); |
948 |
} |
|
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
949 |
/* draw sorting criteria string */ |
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
950 |
DrawString(85, 15, _vehicle_sort_listing[_aircraft_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
|
951 |
/* 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
|
952 |
DoDrawString(_aircraft_sort_order[window_number] & 1 ? "\xAA" : "\xA0", 69, 15, 0x10); |
0 | 953 |
|
954 |
/* draw the aircraft */ |
|
955 |
{ |
|
956 |
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
|
957 |
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
|
958 |
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
|
959 |
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
|
960 |
i += w->vscroll.pos; // offset from sorted aircraft list of current player |
0 | 961 |
|
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
|
962 |
while (i < _num_aircraft_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
|
963 |
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
|
964 |
v = DEREF_VEHICLE(_aircraft_sort[i].index); |
0 | 965 |
|
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
|
966 |
assert(v->type == VEH_Aircraft && v->subtype <= 2 && 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
|
967 |
|
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
|
968 |
DrawAircraftImage(v, x + 19, y + 6, 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
|
969 |
DrawVehicleProfitButton(v, x, y+13); |
0 | 970 |
|
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
|
971 |
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
|
972 |
if (IsAircraftHangarTile(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
|
973 |
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
|
974 |
} 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
|
975 |
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
|
976 |
} |
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
|
977 |
DrawString(x, y+2, str, 0); |
0 | 978 |
|
979 |
||
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
|
980 |
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
|
981 |
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
|
982 |
DrawString(x+19, y + 28, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 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
|
983 |
|
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
|
984 |
if (v->string_id != STR_SV_AIRCRAFT_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
|
985 |
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
|
986 |
DrawString(x+19, y, STR_01AB, 0); |
0 | 987 |
} |
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
|
988 |
|
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
|
989 |
DrawSmallSchedule(v, x+136, y); |
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
|
990 |
|
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
|
991 |
y += PLY_WND_PRC__SIZE_OF_ROW_BIG; |
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
|
992 |
i++; // next aircraft |
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
|
993 |
if (++n == w->vscroll.cap) { break;} // max number of aircraft in the window |
0 | 994 |
} |
995 |
} |
|
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
|
996 |
} break; |
0 | 997 |
|
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
|
998 |
case WE_CLICK: { |
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
|
999 |
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
|
1000 |
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
|
1001 |
_aircraft_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
|
1002 |
_aircraft_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
|
1003 |
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
|
1004 |
break; |
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1005 |
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
|
1006 |
ShowDropDownMenu(w, _vehicle_sort_listing, _aircraft_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
|
1007 |
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
|
1008 |
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
|
1009 |
uint32 id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_BIG; |
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
|
1010 |
|
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
|
1011 |
if (id_v >= w->vscroll.cap) { return;} // click out of bounds |
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
|
1012 |
|
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
|
1013 |
id_v += w->vscroll.pos; |
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
|
1014 |
|
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
|
1015 |
{ |
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
|
1016 |
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
|
1017 |
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
|
1018 |
id_v += (owner == 0) ? 0 : _num_aircraft_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
|
1019 |
|
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
|
1020 |
if (id_v >= _num_aircraft_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
|
1021 |
|
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
|
1022 |
v = DEREF_VEHICLE(_aircraft_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
|
1023 |
|
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
|
1024 |
assert(v->type == VEH_Aircraft && v->subtype <= 2 && 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
|
1025 |
|
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
|
1026 |
ShowAircraftViewWindow(v); |
0 | 1027 |
} |
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
|
1028 |
} 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
|
1029 |
|
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
|
1030 |
case 8: { /* Build new Vehicle */ |
0 | 1031 |
uint tile; |
1032 |
||
1033 |
tile = _last_built_aircraft_depot_tile; |
|
1034 |
do { |
|
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
|
1035 |
if (_map_owner[tile] == _local_player && IsAircraftHangarTile(tile)) { |
0 | 1036 |
ShowAircraftDepotWindow(tile); |
1037 |
ShowBuildAircraftWindow(tile); |
|
1038 |
return; |
|
1039 |
} |
|
1040 |
||
1041 |
tile = TILE_MASK(tile + 1); |
|
1042 |
} while(tile != _last_built_aircraft_depot_tile); |
|
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
|
1043 |
|
0 | 1044 |
ShowBuildAircraftWindow(0); |
1045 |
} break; |
|
1046 |
} |
|
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
|
1047 |
} 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
|
1048 |
|
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
|
1049 |
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
|
1050 |
if (_aircraft_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
|
1051 |
_aircraft_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
|
1052 |
|
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
|
1053 |
_aircraft_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
|
1054 |
|
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
|
1055 |
if (_aircraft_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
|
1056 |
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
|
1057 |
|
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
|
1058 |
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
|
1059 |
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
|
1060 |
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
|
1061 |
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
|
1062 |
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
|
1063 |
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
|
1064 |
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
|
1065 |
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
|
1066 |
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
|
1067 |
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
|
1068 |
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
|
1069 |
_aircraft_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
|
1070 |
DEBUG(misc, 1) ("Periodic resort Aircraft 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
|
1071 |
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
|
1072 |
} |
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
|
1073 |
} |
0 | 1074 |
break; |
1075 |
} |
|
1076 |
} |
|
1077 |
||
1078 |
static const Widget _player_aircraft_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
|
1079 |
{ 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
|
1080 |
{ WWT_CAPTION, 14, 11, 259, 0, 13, STR_A009_AIRCRAFT, 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
|
1081 |
{ 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
|
1082 |
{ WWT_PANEL, 14, 81, 237, 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
|
1083 |
{ WWT_CLOSEBOX, 14, 238, 248, 14, 25, STR_0225, STR_SORT_TIP}, |
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1084 |
{ WWT_PANEL, 14, 249, 259, 14, 25, 0x0, 0}, |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1085 |
{ WWT_MATRIX, 14, 0, 248, 26, 169, 0x401, STR_A01F_AIRCRAFT_CLICK_ON_AIRCRAFT}, |
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
|
1086 |
{ WWT_SCROLLBAR, 14, 249, 259, 26, 169, 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
|
1087 |
{ WWT_PUSHTXTBTN, 14, 0, 129, 170, 181, STR_A003_NEW_AIRCRAFT, STR_A020_BUILD_NEW_AIRCRAFT_REQUIRES}, |
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
|
1088 |
{ WWT_PANEL, 14, 130, 259, 170, 181, 0x0, 0}, |
0 | 1089 |
{ WWT_LAST}, |
1090 |
}; |
|
1091 |
||
1092 |
static const WindowDesc _player_aircraft_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
|
1093 |
-1, -1, 260, 182, |
0 | 1094 |
WC_AIRCRAFT_LIST,0, |
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1095 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
0 | 1096 |
_player_aircraft_widgets, |
1097 |
PlayerAircraftWndProc |
|
1098 |
}; |
|
1099 |
||
1100 |
static const Widget _other_player_aircraft_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
|
1101 |
{ 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
|
1102 |
{ WWT_CAPTION, 14, 11, 259, 0, 13, STR_A009_AIRCRAFT, 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
|
1103 |
{ 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
|
1104 |
{ WWT_PANEL, 14, 81, 237, 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
|
1105 |
{ WWT_CLOSEBOX, 14, 238, 248, 14, 25, STR_0225, STR_SORT_TIP}, |
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1106 |
{ WWT_PANEL, 14, 249, 259, 14, 25, 0x0, 0}, |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1107 |
{ WWT_MATRIX, 14, 0, 248, 26, 169, 0x401, STR_A01F_AIRCRAFT_CLICK_ON_AIRCRAFT}, |
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
|
1108 |
{ WWT_SCROLLBAR, 14, 249, 259, 26, 169, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
0 | 1109 |
{ WWT_LAST}, |
1110 |
}; |
|
1111 |
||
1112 |
static const WindowDesc _other_player_aircraft_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
|
1113 |
-1, -1, 260, 170, |
0 | 1114 |
WC_AIRCRAFT_LIST,0, |
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1115 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
0 | 1116 |
_other_player_aircraft_widgets, |
1117 |
PlayerAircraftWndProc |
|
1118 |
}; |
|
1119 |
||
1120 |
void ShowPlayerAircraft(int player) |
|
1121 |
{ |
|
1122 |
Window *w; |
|
1123 |
||
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
|
1124 |
if (player == _local_player) { |
0 | 1125 |
w = AllocateWindowDescFront(&_player_aircraft_desc, player); |
1126 |
} else { |
|
1127 |
w = AllocateWindowDescFront(&_other_player_aircraft_desc, player); |
|
1128 |
} |
|
1129 |
||
1130 |
if (w) { |
|
1131 |
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
|
1132 |
w->vscroll.cap = 4; // maximum number of vehicles shown |
0 | 1133 |
} |
1134 |
} |