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);
|
|
312 |
SET_DPARAM16(0, v->string_id);
|
|
313 |
SET_DPARAM16(1, v->unitnumber);
|
|
314 |
DrawWindowWidgets(w);
|
|
315 |
|
|
316 |
/* Draw running cost */
|
|
317 |
{
|
|
318 |
int year = v->age / 366;
|
|
319 |
StringID str;
|
|
320 |
|
|
321 |
SET_DPARAM16(1, year);
|
|
322 |
|
|
323 |
str = STR_0199_YEAR;
|
|
324 |
if (year != 1) {
|
|
325 |
str++;
|
|
326 |
if (v->max_age - 366 < v->age)
|
|
327 |
str++;
|
|
328 |
}
|
|
329 |
SET_DPARAM16(0, str);
|
|
330 |
SET_DPARAM16(2, v->max_age / 366);
|
|
331 |
SET_DPARAM32(3, _price.aircraft_running * _aircraft_running_cost[v->engine_type - AIRCRAFT_ENGINES_INDEX] >> 8);
|
|
332 |
DrawString(2, 15, STR_A00D_AGE_RUNNING_COST_YR, 0);
|
|
333 |
}
|
|
334 |
|
|
335 |
/* Draw max speed */
|
|
336 |
{
|
|
337 |
SET_DPARAM16(0, v->max_speed * 8);
|
|
338 |
DrawString(2, 25, STR_A00E_MAX_SPEED, 0);
|
|
339 |
}
|
|
340 |
|
|
341 |
/* Draw profit */
|
|
342 |
{
|
|
343 |
SET_DPARAM32(0, v->profit_this_year);
|
|
344 |
SET_DPARAM32(1, v->profit_last_year);
|
|
345 |
DrawString(2, 35, STR_A00F_PROFIT_THIS_YEAR_LAST_YEAR, 0);
|
|
346 |
}
|
|
347 |
|
|
348 |
/* Draw breakdown & reliability */
|
|
349 |
{
|
|
350 |
SET_DPARAM8(0, v->reliability * 100 >> 16);
|
|
351 |
SET_DPARAM16(1, v->breakdowns_since_last_service);
|
|
352 |
DrawString(2, 45, STR_A010_RELIABILITY_BREAKDOWNS, 0);
|
|
353 |
}
|
|
354 |
|
|
355 |
/* Draw service interval text */
|
|
356 |
{
|
|
357 |
SET_DPARAM16(0, v->service_interval);
|
|
358 |
SET_DPARAM16(1, v->date_of_last_service);
|
|
359 |
DrawString(13, 103, STR_883C_SERVICING_INTERVAL_DAYS, 0);
|
|
360 |
}
|
|
361 |
|
|
362 |
DrawAircraftImage(v, 3, 57, INVALID_VEHICLE);
|
|
363 |
|
|
364 |
{
|
|
365 |
int y = 57;
|
|
366 |
|
|
367 |
do {
|
|
368 |
if (v->subtype <= 2) {
|
|
369 |
SET_DPARAM16(0, GetCustomEngineName(v->engine_type));
|
|
370 |
SET_DPARAM16(1, 1920 + v->build_year);
|
|
371 |
SET_DPARAM32(2, v->value);
|
|
372 |
DrawString(60, y, STR_A011_BUILT_VALUE, 0);
|
|
373 |
y += 10;
|
|
374 |
|
|
375 |
SET_DPARAM16(0, _cargoc.names_long_p[v->cargo_type]);
|
|
376 |
SET_DPARAM16(1, v->cargo_cap);
|
|
377 |
u = v->next;
|
|
378 |
SET_DPARAM16(2, _cargoc.names_long_p[u->cargo_type]);
|
|
379 |
SET_DPARAM16(3, u->cargo_cap);
|
|
380 |
DrawString(60, y, STR_A019_CAPACITY + (u->cargo_cap == 0), 0);
|
|
381 |
y += 14;
|
|
382 |
}
|
|
383 |
|
|
384 |
if (v->cargo_count != 0) {
|
|
385 |
|
|
386 |
/* Cargo names (fix pluralness) */
|
|
387 |
SET_DPARAM8(0, v->cargo_type);
|
|
388 |
SET_DPARAM16(1, v->cargo_count);
|
|
389 |
SET_DPARAM16(2, v->cargo_source);
|
|
390 |
DrawString(60, y, STR_8813_FROM, 0);
|
|
391 |
|
|
392 |
y += 10;
|
|
393 |
}
|
|
394 |
} while ( (v=v->next) != NULL);
|
|
395 |
}
|
|
396 |
break;
|
|
397 |
|
|
398 |
case WE_CLICK:
|
|
399 |
switch(e->click.widget) {
|
|
400 |
case 2: /* rename */
|
|
401 |
SET_DPARAM16(0, v->unitnumber);
|
|
402 |
ShowQueryString(v->string_id, STR_A030_NAME_AIRCRAFT, 31, 150, w->window_class, w->window_number);
|
|
403 |
break;
|
|
404 |
|
|
405 |
case 5: /* increase int */
|
|
406 |
mod = 10;
|
|
407 |
goto change_int;
|
|
408 |
case 6: /* decrease int */
|
|
409 |
mod = -10;
|
|
410 |
change_int:
|
|
411 |
mod += v->service_interval;
|
|
412 |
if (!IS_INT_INSIDE(mod, 30, 800+1))
|
|
413 |
return;
|
|
414 |
DoCommandP(v->tile, v->index, mod, NULL,
|
|
415 |
CMD_CHANGE_AIRCRAFT_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING));
|
|
416 |
break;
|
|
417 |
}
|
|
418 |
break;
|
|
419 |
|
|
420 |
case WE_4:
|
|
421 |
if (FindWindowById(WC_VEHICLE_VIEW, w->window_number) == NULL)
|
|
422 |
DeleteWindow(w);
|
|
423 |
break;
|
|
424 |
|
|
425 |
case WE_ON_EDIT_TEXT: {
|
|
426 |
byte *b = e->edittext.str;
|
|
427 |
if (*b == 0)
|
|
428 |
return;
|
|
429 |
memcpy(_decode_parameters, b, 32);
|
|
430 |
DoCommandP(0, w->window_number, 0, NULL, CMD_NAME_VEHICLE | CMD_MSG(STR_A031_CAN_T_NAME_AIRCRAFT));
|
|
431 |
} break;
|
|
432 |
|
|
433 |
}
|
|
434 |
}
|
|
435 |
|
|
436 |
|
|
437 |
static const Widget _aircraft_details_widgets[] = {
|
|
438 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
439 |
{ WWT_CAPTION, 14, 11, 349, 0, 13, STR_A00C_DETAILS, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
440 |
{ WWT_PUSHTXTBTN, 14, 350, 389, 0, 13, STR_01AA_NAME, STR_A032_NAME_AIRCRAFT},
|
|
441 |
{ WWT_IMGBTN, 14, 0, 389, 14, 55, 0x0},
|
|
442 |
{ WWT_IMGBTN, 14, 0, 389, 56, 101, 0x0},
|
|
443 |
{ WWT_PUSHTXTBTN, 14, 0, 10, 102, 107, STR_0188, STR_884D_INCREASE_SERVICING_INTERVAL},
|
|
444 |
{ WWT_PUSHTXTBTN, 14, 0, 10, 108, 113, STR_0189, STR_884E_DECREASE_SERVICING_INTERVAL},
|
|
445 |
{ WWT_IMGBTN, 14, 11, 389, 102, 113, 0x0},
|
|
446 |
{ WWT_LAST},
|
|
447 |
};
|
|
448 |
|
|
449 |
static const WindowDesc _aircraft_details_desc = {
|
|
450 |
-1,-1, 390, 114,
|
|
451 |
WC_VEHICLE_DETAILS,WC_VEHICLE_VIEW,
|
|
452 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
|
|
453 |
_aircraft_details_widgets,
|
|
454 |
AircraftDetailsWndProc
|
|
455 |
};
|
|
456 |
|
|
457 |
|
|
458 |
static void ShowAircraftDetailsWindow(Vehicle *v)
|
|
459 |
{
|
|
460 |
Window *w;
|
|
461 |
VehicleID veh = v->index;
|
|
462 |
|
|
463 |
DeleteWindowById(WC_VEHICLE_ORDERS, veh);
|
|
464 |
DeleteWindowById(WC_VEHICLE_DETAILS, veh);
|
|
465 |
|
|
466 |
_alloc_wnd_parent_num = veh;
|
|
467 |
w = AllocateWindowDesc(&_aircraft_details_desc);
|
|
468 |
w->window_number = veh;
|
|
469 |
w->caption_color = v->owner;
|
|
470 |
// w->vscroll.cap = 6;
|
|
471 |
// w->traindetails_d.tab = 0;
|
|
472 |
}
|
|
473 |
|
|
474 |
|
|
475 |
static const Widget _aircraft_view_widgets[] = {
|
|
476 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
477 |
{ WWT_CAPTION, 14, 11, 249, 0, 13, STR_A00A, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
478 |
{ WWT_IMGBTN, 14, 0, 231, 14, 103, 0x0, 0},
|
|
479 |
{ WWT_6, 14, 2, 229, 16, 101, 0x0, 0},
|
|
480 |
{ WWT_PUSHIMGBTN, 14, 0, 249, 104, 115, 0x0, STR_A027_CURRENT_AIRCRAFT_ACTION},
|
|
481 |
{ WWT_PUSHIMGBTN, 14, 232, 249, 14, 31, 0x2AB, STR_A029_CENTER_MAIN_VIEW_ON_AIRCRAFT},
|
|
482 |
{ WWT_PUSHIMGBTN, 14, 232, 249, 32, 49, 0x2AF, STR_A02A_SEND_AIRCRAFT_TO_HANGAR},
|
|
483 |
{ WWT_PUSHIMGBTN, 14, 232, 249, 50, 67, 0x2B4, STR_A03B_REFIT_AIRCRAFT_TO_CARRY},
|
|
484 |
{ WWT_PUSHIMGBTN, 14, 232, 249, 68, 85, 0x2B2, STR_A028_SHOW_AIRCRAFT_S_ORDERS},
|
|
485 |
{ WWT_PUSHIMGBTN, 14, 232, 249, 86, 103, 0x2B3, STR_A02B_SHOW_AIRCRAFT_DETAILS},
|
|
486 |
{ WWT_LAST},
|
|
487 |
};
|
|
488 |
|
|
489 |
static void AircraftViewWndProc(Window *w, WindowEvent *e)
|
|
490 |
{
|
|
491 |
switch(e->event) {
|
|
492 |
case WE_PAINT: {
|
|
493 |
Vehicle *v = &_vehicles[w->window_number];
|
|
494 |
uint32 disabled = 1<<7;
|
|
495 |
StringID str;
|
|
496 |
|
|
497 |
{
|
|
498 |
uint tile = v->tile;
|
|
499 |
if (IS_TILETYPE(tile, MP_STATION) &&
|
|
500 |
(_map5[tile] == 32 || _map5[tile] == 65) &&
|
|
501 |
v->vehstatus&VS_STOPPED)
|
|
502 |
disabled = 0;
|
|
503 |
}
|
|
504 |
|
|
505 |
if (v->owner != _local_player)
|
|
506 |
disabled |= 1<<7 | 1<<6;
|
|
507 |
w->disabled_state = disabled;
|
|
508 |
|
|
509 |
/* draw widgets & caption */
|
|
510 |
SET_DPARAM16(0, v->string_id);
|
|
511 |
SET_DPARAM16(1, v->unitnumber);
|
|
512 |
DrawWindowWidgets(w);
|
|
513 |
|
|
514 |
/* draw the flag */
|
|
515 |
DrawSprite((v->vehstatus & VS_STOPPED) ? 0xC12 : 0xC13, 2, 105);
|
|
516 |
|
|
517 |
if (v->vehstatus & VS_CRASHED) {
|
|
518 |
str = STR_8863_CRASHED;
|
|
519 |
} else if (v->vehstatus & VS_STOPPED) {
|
|
520 |
str = STR_8861_STOPPED;
|
|
521 |
} else {
|
|
522 |
switch(v->next_order & OT_MASK) {
|
|
523 |
case OT_GOTO_STATION: {
|
|
524 |
SET_DPARAM16(0, v->next_order_param);
|
|
525 |
SET_DPARAM16(1, v->cur_speed * 8);
|
|
526 |
str = STR_HEADING_FOR_STATION + _patches.vehicle_speed;
|
|
527 |
} break;
|
|
528 |
|
|
529 |
case OT_GOTO_DEPOT: {
|
|
530 |
SET_DPARAM16(0, v->next_order_param);
|
|
531 |
SET_DPARAM16(1, v->cur_speed * 8);
|
|
532 |
str = STR_HEADING_FOR_HANGAR + _patches.vehicle_speed;
|
|
533 |
} break;
|
|
534 |
|
|
535 |
case OT_LOADING:
|
|
536 |
str = STR_882F_LOADING_UNLOADING;
|
|
537 |
break;
|
|
538 |
|
|
539 |
default:
|
|
540 |
if (v->num_orders == 0) {
|
|
541 |
str = STR_NO_ORDERS + _patches.vehicle_speed;
|
|
542 |
SET_DPARAM16(0, v->cur_speed * 8);
|
|
543 |
} else
|
|
544 |
str = STR_EMPTY;
|
|
545 |
break;
|
|
546 |
}
|
|
547 |
}
|
|
548 |
|
|
549 |
DrawStringCentered(125, 105, str, 0);
|
|
550 |
DrawWindowViewport(w);
|
|
551 |
} break;
|
|
552 |
|
|
553 |
case WE_CLICK: {
|
|
554 |
Vehicle *v = &_vehicles[w->window_number];
|
|
555 |
|
|
556 |
switch(e->click.widget) {
|
|
557 |
case 4: /* start stop */
|
|
558 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_AIRCRAFT | CMD_MSG(STR_A016_CAN_T_STOP_START_AIRCRAFT));
|
|
559 |
break;
|
|
560 |
case 5: /* center main view */
|
|
561 |
ScrollMainWindowTo(v->x_pos, v->y_pos);
|
|
562 |
break;
|
|
563 |
case 6: /* goto hangar */
|
|
564 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_SEND_AIRCRAFT_TO_HANGAR | CMD_MSG(STR_A012_CAN_T_SEND_AIRCRAFT_TO));
|
|
565 |
break;
|
|
566 |
case 7: /* refit */
|
|
567 |
ShowAircraftRefitWindow(v);
|
|
568 |
break;
|
|
569 |
case 8: /* show orders */
|
|
570 |
ShowOrdersWindow(v);
|
|
571 |
break;
|
|
572 |
case 9: /* show details */
|
|
573 |
ShowAircraftDetailsWindow(v);
|
|
574 |
break;
|
|
575 |
}
|
|
576 |
} break;
|
|
577 |
|
|
578 |
case WE_DESTROY:
|
|
579 |
DeleteWindowById(WC_VEHICLE_ORDERS, w->window_number);
|
|
580 |
DeleteWindowById(WC_VEHICLE_REFIT, w->window_number);
|
|
581 |
DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number);
|
|
582 |
break;
|
|
583 |
}
|
|
584 |
}
|
|
585 |
|
|
586 |
|
|
587 |
static const WindowDesc _aircraft_view_desc = {
|
|
588 |
-1,-1, 250, 116,
|
|
589 |
WC_VEHICLE_VIEW ,0,
|
|
590 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
|
|
591 |
_aircraft_view_widgets,
|
|
592 |
AircraftViewWndProc
|
|
593 |
};
|
|
594 |
|
|
595 |
|
|
596 |
void ShowAircraftViewWindow(Vehicle *v)
|
|
597 |
{
|
|
598 |
Window *w;
|
|
599 |
|
|
600 |
w = AllocateWindowDescFront(&_aircraft_view_desc, v->index);
|
|
601 |
if (w) {
|
|
602 |
w->caption_color = v->owner;
|
|
603 |
AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), 0);
|
|
604 |
}
|
|
605 |
}
|
|
606 |
|
|
607 |
static void DrawAircraftDepotWindow(Window *w)
|
|
608 |
{
|
|
609 |
uint tile;
|
|
610 |
Vehicle *v;
|
|
611 |
int num,x,y;
|
|
612 |
|
|
613 |
tile = w->window_number;
|
|
614 |
|
|
615 |
/* setup disabled buttons */
|
|
616 |
w->disabled_state = (_map_owner[tile]==_local_player) ? 0 : ((1<<3)|(1<<5));
|
|
617 |
|
|
618 |
/* determine amount of items for scroller */
|
|
619 |
num = 0;
|
|
620 |
FOR_ALL_VEHICLES(v) {
|
|
621 |
if (v->type == VEH_Aircraft && v->subtype <= 2 && v->vehstatus&VS_HIDDEN &&
|
|
622 |
v->tile == (TileIndex)tile)
|
|
623 |
num++;
|
|
624 |
}
|
|
625 |
SetVScrollCount(w, (num + 3) >> 2);
|
|
626 |
|
|
627 |
SET_DPARAM16(0, _map2[tile]);
|
|
628 |
DrawWindowWidgets(w);
|
|
629 |
|
|
630 |
x = 2;
|
|
631 |
y = 15;
|
|
632 |
num = w->vscroll.pos * 4;
|
|
633 |
|
|
634 |
FOR_ALL_VEHICLES(v) {
|
|
635 |
if (v->type == VEH_Aircraft &&
|
|
636 |
v->subtype <= 2 &&
|
|
637 |
v->vehstatus&VS_HIDDEN &&
|
|
638 |
v->tile == (TileIndex)tile &&
|
|
639 |
--num < 0 && num >= -8) {
|
|
640 |
|
|
641 |
DrawAircraftImage(v, x+12, y, WP(w,traindepot_d).sel);
|
|
642 |
|
|
643 |
SET_DPARAM16(0, v->unitnumber);
|
|
644 |
DrawString(x, y+2, (uint16)(v->max_age-366) >= v->age ? STR_00E2 : STR_00E3, 0);
|
|
645 |
|
|
646 |
DrawSprite( (v->vehstatus & VS_STOPPED) ? 0xC12 : 0xC13, x, y+12);
|
|
647 |
|
|
648 |
if ((x+=74) == 2+74*4) {
|
|
649 |
x -= 74*4;
|
|
650 |
y += 24;
|
|
651 |
}
|
|
652 |
}
|
|
653 |
}
|
|
654 |
}
|
|
655 |
|
|
656 |
static int GetVehicleFromAircraftDepotWndPt(Window *w, int x, int y, Vehicle **veh) {
|
|
657 |
uint xt,yt,xm,ym;
|
|
658 |
Vehicle *v;
|
|
659 |
uint tile;
|
|
660 |
int pos;
|
|
661 |
|
|
662 |
xt = x / 74;
|
|
663 |
xm = x % 74;
|
|
664 |
if (xt >= 4)
|
|
665 |
return 1;
|
|
666 |
|
|
667 |
yt = (y - 14) / 24;
|
|
668 |
ym = (y - 14) % 24;
|
|
669 |
if (yt >= 2)
|
|
670 |
return 1;
|
|
671 |
|
|
672 |
pos = (yt + w->vscroll.pos) * 4 + xt;
|
|
673 |
|
|
674 |
tile = w->window_number;
|
|
675 |
FOR_ALL_VEHICLES(v) {
|
|
676 |
if (v->type == VEH_Aircraft &&
|
|
677 |
v->subtype <= 2 &&
|
|
678 |
v->vehstatus&VS_HIDDEN &&
|
|
679 |
v->tile == (TileIndex)tile &&
|
|
680 |
--pos < 0) {
|
|
681 |
*veh = v;
|
|
682 |
if (xm >= 12)
|
|
683 |
return 0;
|
|
684 |
|
|
685 |
if (ym <= 12)
|
|
686 |
return -1; /* show window */
|
|
687 |
|
|
688 |
return -2; /* start stop */
|
|
689 |
}
|
|
690 |
}
|
|
691 |
return 1; /* outside */
|
|
692 |
}
|
|
693 |
|
|
694 |
static void AircraftDepotClickAircraft(Window *w, int x, int y)
|
|
695 |
{
|
|
696 |
Vehicle *v;
|
|
697 |
|
|
698 |
switch(GetVehicleFromAircraftDepotWndPt(w, x, y, &v)) {
|
|
699 |
case 1:
|
|
700 |
return;
|
|
701 |
|
|
702 |
case 0:
|
|
703 |
if (v != NULL) {
|
|
704 |
WP(w,traindepot_d).sel = v->index;
|
|
705 |
SetWindowDirty(w);
|
|
706 |
SetObjectToPlaceWnd( SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)) + GetAircraftImage(v, 6), 4, w);
|
|
707 |
}
|
|
708 |
break;
|
|
709 |
|
|
710 |
case -1:
|
|
711 |
ShowAircraftViewWindow(v);
|
|
712 |
break;
|
|
713 |
|
|
714 |
case -2:
|
|
715 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_AIRCRAFT | CMD_MSG(STR_A016_CAN_T_STOP_START_AIRCRAFT));
|
|
716 |
break;
|
|
717 |
|
|
718 |
default:
|
|
719 |
NOT_REACHED();
|
|
720 |
}
|
|
721 |
}
|
|
722 |
|
|
723 |
static const Widget _aircraft_depot_widgets[] = {
|
|
724 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
725 |
{ WWT_CAPTION, 14, 11, 330, 0, 13, STR_A002_AIRCRAFT_HANGAR, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
726 |
{ WWT_MATRIX, 14, 0, 295, 14, 61, 0x204, STR_A021_AIRCRAFT_CLICK_ON_AIRCRAFT},
|
|
727 |
{ WWT_IMGBTN, 14, 296, 319, 14, 61, 0x2A9, STR_A023_DRAG_AIRCRAFT_TO_HERE_TO},
|
|
728 |
{ WWT_SCROLLBAR, 14, 320, 330, 14, 61, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
|
729 |
{ WWT_PUSHTXTBTN, 14, 0, 164, 62, 73, STR_A003_NEW_AIRCRAFT, STR_A022_BUILD_NEW_AIRCRAFT},
|
|
730 |
{ WWT_PUSHTXTBTN, 14, 165, 330, 62, 73, STR_00E4_LOCATION, STR_A024_CENTER_MAIN_VIEW_ON_HANGAR},
|
|
731 |
{ WWT_LAST},
|
|
732 |
};
|
|
733 |
|
|
734 |
|
|
735 |
static void AircraftDepotWndProc(Window *w, WindowEvent *e)
|
|
736 |
{
|
|
737 |
switch(e->event) {
|
|
738 |
case WE_PAINT:
|
|
739 |
DrawAircraftDepotWindow(w);
|
|
740 |
break;
|
|
741 |
|
|
742 |
case WE_CLICK:
|
|
743 |
switch(e->click.widget) {
|
|
744 |
case 2: /* click aircraft */
|
|
745 |
AircraftDepotClickAircraft(w, e->click.pt.x, e->click.pt.y);
|
|
746 |
break;
|
|
747 |
case 5: /* show build aircraft window */
|
|
748 |
ShowBuildAircraftWindow(w->window_number);
|
|
749 |
break;
|
|
750 |
case 6: /* scroll to tile */
|
|
751 |
ScrollMainWindowToTile(w->window_number);
|
|
752 |
break;
|
|
753 |
}
|
|
754 |
break;
|
|
755 |
|
|
756 |
case WE_DESTROY:
|
|
757 |
DeleteWindowById(WC_BUILD_VEHICLE, w->window_number);
|
|
758 |
break;
|
|
759 |
|
|
760 |
case WE_DRAGDROP: {
|
|
761 |
switch(e->click.widget) {
|
|
762 |
case 2: {
|
|
763 |
Vehicle *v;
|
|
764 |
VehicleID sel = WP(w,traindepot_d).sel;
|
|
765 |
|
|
766 |
WP(w,traindepot_d).sel = INVALID_VEHICLE;
|
|
767 |
SetWindowDirty(w);
|
|
768 |
|
|
769 |
if (GetVehicleFromAircraftDepotWndPt(w, e->dragdrop.pt.x, e->dragdrop.pt.y, &v) == 0 &&
|
|
770 |
v != NULL &&
|
|
771 |
sel == v->index) {
|
|
772 |
ShowAircraftViewWindow(v);
|
|
773 |
}
|
|
774 |
} break;
|
|
775 |
|
|
776 |
case 3:
|
|
777 |
if (!HASBIT(w->disabled_state, 3) &&
|
|
778 |
WP(w,traindepot_d).sel != INVALID_VEHICLE) {
|
|
779 |
Vehicle *v;
|
|
780 |
|
|
781 |
HandleButtonClick(w, 3);
|
|
782 |
|
|
783 |
v = &_vehicles[WP(w,traindepot_d).sel];
|
|
784 |
WP(w,traindepot_d).sel = INVALID_VEHICLE;
|
|
785 |
|
|
786 |
_backup_orders_tile = v->tile;
|
|
787 |
BackupVehicleOrders(v, _backup_orders_data);
|
|
788 |
|
|
789 |
if (!DoCommandP(v->tile, v->index, 0, NULL, CMD_SELL_AIRCRAFT | CMD_MSG(STR_A01C_CAN_T_SELL_AIRCRAFT)))
|
|
790 |
_backup_orders_tile = 0;
|
|
791 |
}
|
|
792 |
break;
|
|
793 |
default:
|
|
794 |
WP(w,traindepot_d).sel = INVALID_VEHICLE;
|
|
795 |
SetWindowDirty(w);
|
|
796 |
}
|
|
797 |
break;
|
|
798 |
}
|
|
799 |
break;
|
|
800 |
}
|
|
801 |
}
|
|
802 |
|
|
803 |
|
|
804 |
|
|
805 |
static const WindowDesc _aircraft_depot_desc = {
|
|
806 |
-1, -1, 331, 74,
|
|
807 |
WC_VEHICLE_DEPOT,0,
|
|
808 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
|
|
809 |
_aircraft_depot_widgets,
|
|
810 |
AircraftDepotWndProc
|
|
811 |
};
|
|
812 |
|
|
813 |
|
|
814 |
void ShowAircraftDepotWindow(uint tile)
|
|
815 |
{
|
|
816 |
Window *w;
|
|
817 |
|
|
818 |
w = AllocateWindowDescFront(&_aircraft_depot_desc, tile);
|
|
819 |
if (w) {
|
|
820 |
w->caption_color = _map_owner[tile];
|
|
821 |
w->vscroll.cap = 2;
|
|
822 |
WP(w,traindepot_d).sel = INVALID_VEHICLE;
|
|
823 |
_backup_orders_tile = 0;
|
|
824 |
}
|
|
825 |
}
|
|
826 |
|
|
827 |
static void DrawSmallSchedule(Vehicle *v, int x, int y) {
|
|
828 |
uint16 *sched;
|
|
829 |
int sel;
|
|
830 |
uint ord;
|
|
831 |
int i = 0;
|
|
832 |
|
|
833 |
sched = v->schedule_ptr;
|
|
834 |
sel = v->cur_order_index;
|
|
835 |
|
|
836 |
while ((ord=*sched++) != 0) {
|
|
837 |
if (sel == 0) {
|
|
838 |
_stringwidth_base = 0xE0;
|
|
839 |
DoDrawString( "\xAF", x-6, y, 16);
|
|
840 |
_stringwidth_base = 0;
|
|
841 |
}
|
|
842 |
sel--;
|
|
843 |
|
|
844 |
if ((ord & OT_MASK) == OT_GOTO_STATION) {
|
|
845 |
SET_DPARAM16(0, ord >> 8);
|
|
846 |
DrawString(x, y, STR_A036, 0);
|
|
847 |
|
|
848 |
y += 6;
|
|
849 |
if (++i == 4)
|
|
850 |
break;
|
|
851 |
}
|
|
852 |
}
|
|
853 |
}
|
|
854 |
|
|
855 |
static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
|
|
856 |
{
|
|
857 |
switch(e->event) {
|
|
858 |
case WE_PAINT:
|
|
859 |
/* determine amount of items for scroller */
|
|
860 |
{
|
|
861 |
Vehicle *v;
|
|
862 |
int num = 0;
|
|
863 |
byte owner = (byte)w->window_number;
|
|
864 |
|
|
865 |
FOR_ALL_VEHICLES(v) {
|
|
866 |
if (v->type == VEH_Aircraft && v->subtype <= 2 && v->owner == owner)
|
|
867 |
num++;
|
|
868 |
}
|
|
869 |
|
|
870 |
SetVScrollCount(w, num);
|
|
871 |
}
|
|
872 |
|
|
873 |
/* draw the widgets */
|
|
874 |
{
|
|
875 |
Player *p = DEREF_PLAYER(w->window_number);
|
|
876 |
SET_DPARAM16(0, p->name_1);
|
|
877 |
SET_DPARAM32(1, p->name_2);
|
|
878 |
DrawWindowWidgets(w);
|
|
879 |
}
|
|
880 |
|
|
881 |
/* draw the aircraft */
|
|
882 |
{
|
|
883 |
Vehicle *v;
|
|
884 |
int pos = w->vscroll.pos;
|
|
885 |
byte owner = (byte)w->window_number;
|
|
886 |
int x = 2;
|
|
887 |
int y = 15;
|
|
888 |
|
|
889 |
FOR_ALL_VEHICLES(v) {
|
|
890 |
if (v->type == VEH_Aircraft && v->subtype <= 2 && v->owner == owner &&
|
|
891 |
--pos < 0 && pos >= -4) {
|
|
892 |
StringID str;
|
|
893 |
|
|
894 |
DrawAircraftImage(v, x + 19, y + 6, INVALID_VEHICLE);
|
|
895 |
DrawVehicleProfitButton(v, x, y+13);
|
|
896 |
|
|
897 |
SET_DPARAM16(0, v->unitnumber);
|
|
898 |
if (IsAircraftHangarTile(v->tile)) {
|
|
899 |
str = STR_021F;
|
|
900 |
} else {
|
|
901 |
str = v->age > v->max_age - 366 ? STR_00E3 : STR_00E2;
|
|
902 |
}
|
|
903 |
DrawString(x, y+2, str, 0);
|
|
904 |
|
|
905 |
SET_DPARAM32(0, v->profit_this_year);
|
|
906 |
SET_DPARAM32(1, v->profit_last_year);
|
|
907 |
DrawString(x+19, y + 28, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0);
|
|
908 |
|
|
909 |
if (v->string_id != STR_SV_AIRCRAFT_NAME) {
|
|
910 |
SET_DPARAM16(0, v->string_id);
|
|
911 |
DrawString(x+19, y, STR_01AB, 0);
|
|
912 |
}
|
|
913 |
|
|
914 |
DrawSmallSchedule(v, x+136, y);
|
|
915 |
|
|
916 |
y += 36;
|
|
917 |
}
|
|
918 |
}
|
|
919 |
}
|
|
920 |
break;
|
|
921 |
|
|
922 |
case WE_CLICK:
|
|
923 |
switch(e->click.widget) {
|
|
924 |
case 2: { /* click on aircraft */
|
|
925 |
int sel;
|
|
926 |
Vehicle *v;
|
|
927 |
byte owner;
|
|
928 |
|
|
929 |
sel = (e->click.pt.y - 14) / 36;
|
|
930 |
|
|
931 |
if ((uint)sel >= 4)
|
|
932 |
break;
|
|
933 |
sel += w->vscroll.pos;
|
|
934 |
owner = (byte)w->window_number;
|
|
935 |
FOR_ALL_VEHICLES(v) {
|
|
936 |
if (v->type == VEH_Aircraft && v->subtype <= 2 && v->owner == owner &&
|
|
937 |
--sel < 0) {
|
|
938 |
ShowAircraftViewWindow(v);
|
|
939 |
break;
|
|
940 |
}
|
|
941 |
}
|
|
942 |
break;
|
|
943 |
}
|
|
944 |
case 4: { /* build new */
|
|
945 |
uint tile;
|
|
946 |
|
|
947 |
tile = _last_built_aircraft_depot_tile;
|
|
948 |
do {
|
|
949 |
if (_map_owner[tile] == _local_player &&
|
|
950 |
IsAircraftHangarTile(tile)) {
|
|
951 |
ShowAircraftDepotWindow(tile);
|
|
952 |
ShowBuildAircraftWindow(tile);
|
|
953 |
return;
|
|
954 |
}
|
|
955 |
|
|
956 |
tile = TILE_MASK(tile + 1);
|
|
957 |
} while(tile != _last_built_aircraft_depot_tile);
|
|
958 |
ShowBuildAircraftWindow(0);
|
|
959 |
} break;
|
|
960 |
}
|
|
961 |
break;
|
|
962 |
}
|
|
963 |
}
|
|
964 |
|
|
965 |
static const Widget _player_aircraft_widgets[] = {
|
|
966 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
967 |
{ WWT_CAPTION, 14, 11, 259, 0, 13, STR_A009_AIRCRAFT, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
968 |
{ WWT_MATRIX, 14, 0, 248, 14, 157, 0x401, STR_A01F_AIRCRAFT_CLICK_ON_AIRCRAFT},
|
|
969 |
{ WWT_SCROLLBAR, 14, 249, 259, 14, 157, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
|
970 |
{ WWT_PUSHTXTBTN, 14, 0, 129, 158, 169, STR_A003_NEW_AIRCRAFT, STR_A020_BUILD_NEW_AIRCRAFT_REQUIRES},
|
|
971 |
{ WWT_IMGBTN, 14, 130, 259, 158, 169, 0x0, 0},
|
|
972 |
{ WWT_LAST},
|
|
973 |
};
|
|
974 |
|
|
975 |
static const WindowDesc _player_aircraft_desc = {
|
|
976 |
-1, -1, 260, 170,
|
|
977 |
WC_AIRCRAFT_LIST,0,
|
|
978 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
|
|
979 |
_player_aircraft_widgets,
|
|
980 |
PlayerAircraftWndProc
|
|
981 |
};
|
|
982 |
|
|
983 |
static const Widget _other_player_aircraft_widgets[] = {
|
|
984 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
985 |
{ WWT_CAPTION, 14, 11, 259, 0, 13, STR_A009_AIRCRAFT, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
986 |
{ WWT_MATRIX, 14, 0, 248, 14, 157, 0x401, STR_A01F_AIRCRAFT_CLICK_ON_AIRCRAFT},
|
|
987 |
{ WWT_SCROLLBAR, 14, 249, 259, 14, 157, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
|
988 |
{ WWT_LAST},
|
|
989 |
};
|
|
990 |
|
|
991 |
static const WindowDesc _other_player_aircraft_desc = {
|
|
992 |
-1, -1, 260, 158,
|
|
993 |
WC_AIRCRAFT_LIST,0,
|
|
994 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
|
|
995 |
_other_player_aircraft_widgets,
|
|
996 |
PlayerAircraftWndProc
|
|
997 |
};
|
|
998 |
|
|
999 |
void ShowPlayerAircraft(int player)
|
|
1000 |
{
|
|
1001 |
Window *w;
|
|
1002 |
|
|
1003 |
if ( player == _local_player) {
|
|
1004 |
w = AllocateWindowDescFront(&_player_aircraft_desc, player);
|
|
1005 |
} else {
|
|
1006 |
w = AllocateWindowDescFront(&_other_player_aircraft_desc, player);
|
|
1007 |
}
|
|
1008 |
|
|
1009 |
if (w) {
|
|
1010 |
w->caption_color = w->window_number;
|
|
1011 |
w->vscroll.cap = 4;
|
|
1012 |
}
|
|
1013 |
}
|