2 |
2 |
3 /** @file player_gui.cpp */ |
3 /** @file player_gui.cpp */ |
4 |
4 |
5 #include "stdafx.h" |
5 #include "stdafx.h" |
6 #include "openttd.h" |
6 #include "openttd.h" |
7 #include "table/sprites.h" |
|
8 #include "table/strings.h" |
|
9 #include "strings.h" |
|
10 #include "functions.h" |
|
11 #include "window.h" |
|
12 #include "gui.h" |
7 #include "gui.h" |
13 #include "viewport.h" |
8 #include "window_gui.h" |
14 #include "gfx.h" |
9 #include "textbuf_gui.h" |
15 #include "player.h" |
10 #include "viewport_func.h" |
16 #include "command.h" |
11 #include "gfx_func.h" |
17 #include "vehicle.h" |
12 #include "player_func.h" |
18 #include "economy.h" |
13 #include "player_base.h" |
|
14 #include "command_func.h" |
19 #include "network/network.h" |
15 #include "network/network.h" |
20 #include "variables.h" |
16 #include "variables.h" |
21 #include "roadveh.h" |
17 #include "roadveh.h" |
22 #include "train.h" |
18 #include "train.h" |
23 #include "aircraft.h" |
19 #include "aircraft.h" |
24 #include "date.h" |
|
25 #include "newgrf.h" |
20 #include "newgrf.h" |
26 #include "network/network_data.h" |
21 #include "network/network_data.h" |
27 #include "network/network_client.h" |
22 #include "network/network_client.h" |
28 #include "network/network_gui.h" |
23 #include "network/network_gui.h" |
29 #include "player_face.h" |
24 #include "player_face.h" |
|
25 #include "strings_func.h" |
|
26 #include "functions.h" |
|
27 #include "window_func.h" |
|
28 #include "date_func.h" |
|
29 #include "string_func.h" |
|
30 #include "settings_type.h" |
|
31 #include "widgets/dropdown_func.h" |
|
32 |
|
33 #include "table/sprites.h" |
|
34 #include "table/strings.h" |
|
35 |
|
36 /* player face selection window */ |
|
37 struct facesel_d { |
|
38 PlayerFace face; // player face bits |
|
39 bool advanced; // advance player face selection window |
|
40 }; |
|
41 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(facesel_d)); |
30 |
42 |
31 static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_stickied); |
43 static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_stickied); |
32 static void DoSelectPlayerFace(PlayerID player, bool show_big); |
44 static void DoSelectPlayerFace(PlayerID player, bool show_big); |
33 |
45 |
34 static void DrawPlayerEconomyStats(const Player *p, byte mode) |
46 static void DrawPlayerEconomyStats(const Player *p, byte mode) |
105 |
117 |
106 SetDParam(0, p->player_money - p->current_loan); |
118 SetDParam(0, p->player_money - p->current_loan); |
107 DrawStringRightAligned(182, y, STR_7028, TC_FROMSTRING); |
119 DrawStringRightAligned(182, y, STR_7028, TC_FROMSTRING); |
108 } |
120 } |
109 |
121 |
|
122 enum PlayerFinancesWindowWidgets { |
|
123 PFW_WIDGET_TOGGLE_SIZE = 2, |
|
124 PFW_WIDGET_INCREASE_LOAN = 6, |
|
125 PFW_WIDGET_REPAY_LOAN = 7, |
|
126 }; |
|
127 |
110 static const Widget _player_finances_widgets[] = { |
128 static const Widget _player_finances_widgets[] = { |
111 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
129 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
112 { WWT_CAPTION, RESIZE_NONE, 14, 11, 379, 0, 13, STR_700E_FINANCES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
130 { WWT_CAPTION, RESIZE_NONE, 14, 11, 379, 0, 13, STR_700E_FINANCES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
113 { WWT_IMGBTN, RESIZE_NONE, 14, 380, 394, 0, 13, SPR_LARGE_SMALL_WINDOW, STR_7075_TOGGLE_LARGE_SMALL_WINDOW}, |
131 { WWT_IMGBTN, RESIZE_NONE, 14, 380, 394, 0, 13, SPR_LARGE_SMALL_WINDOW, STR_7075_TOGGLE_LARGE_SMALL_WINDOW}, |
114 { WWT_STICKYBOX, RESIZE_NONE, 14, 395, 406, 0, 13, 0x0, STR_STICKY_BUTTON}, |
132 { WWT_STICKYBOX, RESIZE_NONE, 14, 395, 406, 0, 13, 0x0, STR_STICKY_BUTTON}, |
145 /* Make window dirty before and after resizing */ |
163 /* Make window dirty before and after resizing */ |
146 SetWindowDirty(w); |
164 SetWindowDirty(w); |
147 w->height = new_height; |
165 w->height = new_height; |
148 SetWindowDirty(w); |
166 SetWindowDirty(w); |
149 |
167 |
150 w->SetWidgetHiddenState(6, player != _local_player); |
168 w->SetWidgetHiddenState(PFW_WIDGET_INCREASE_LOAN, player != _local_player); |
151 w->SetWidgetHiddenState(7, player != _local_player); |
169 w->SetWidgetHiddenState(PFW_WIDGET_REPAY_LOAN, player != _local_player); |
152 } |
170 } |
153 |
171 |
154 /* Borrow button only shows when there is any more money to loan */ |
172 /* Borrow button only shows when there is any more money to loan */ |
155 w->SetWidgetDisabledState(6, p->current_loan == _economy.max_loan); |
173 w->SetWidgetDisabledState(PFW_WIDGET_INCREASE_LOAN, p->current_loan == _economy.max_loan); |
156 |
174 |
157 /* Repay button only shows when there is any more money to repay */ |
175 /* Repay button only shows when there is any more money to repay */ |
158 w->SetWidgetDisabledState(7, player != _local_player || p->current_loan == 0); |
176 w->SetWidgetDisabledState(PFW_WIDGET_REPAY_LOAN, player != _local_player || p->current_loan == 0); |
159 |
177 |
160 SetDParam(0, p->index); |
178 SetDParam(0, p->index); |
161 SetDParam(1, p->index); |
179 SetDParam(1, p->index); |
162 SetDParam(2, LOAN_INTERVAL); |
180 SetDParam(2, LOAN_INTERVAL); |
163 DrawWindowWidgets(w); |
181 DrawWindowWidgets(w); |
165 DrawPlayerEconomyStats(p, (byte)WP(w, def_d).data_1); |
183 DrawPlayerEconomyStats(p, (byte)WP(w, def_d).data_1); |
166 } break; |
184 } break; |
167 |
185 |
168 case WE_CLICK: |
186 case WE_CLICK: |
169 switch (e->we.click.widget) { |
187 switch (e->we.click.widget) { |
170 case 2: {/* toggle size */ |
188 case PFW_WIDGET_TOGGLE_SIZE: {/* toggle size */ |
171 byte mode = (byte)WP(w, def_d).data_1; |
189 byte mode = (byte)WP(w, def_d).data_1; |
172 bool stickied = !!(w->flags4 & WF_STICKY); |
190 bool stickied = !!(w->flags4 & WF_STICKY); |
173 PlayerID player = (PlayerID)w->window_number; |
191 PlayerID player = (PlayerID)w->window_number; |
174 DeleteWindow(w); |
192 DeleteWindow(w); |
175 DoShowPlayerFinances(player, !HasBit(mode, 0), stickied); |
193 DoShowPlayerFinances(player, !HasBit(mode, 0), stickied); |
176 } break; |
194 } break; |
177 |
195 |
178 case 6: /* increase loan */ |
196 case PFW_WIDGET_INCREASE_LOAN: /* increase loan */ |
179 DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_INCREASE_LOAN | CMD_MSG(STR_702C_CAN_T_BORROW_ANY_MORE_MONEY)); |
197 DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_INCREASE_LOAN | CMD_MSG(STR_702C_CAN_T_BORROW_ANY_MORE_MONEY)); |
180 break; |
198 break; |
181 |
199 |
182 case 7: /* repay loan */ |
200 case PFW_WIDGET_REPAY_LOAN: /* repay loan */ |
183 DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_DECREASE_LOAN | CMD_MSG(STR_702F_CAN_T_REPAY_LOAN)); |
201 DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_DECREASE_LOAN | CMD_MSG(STR_702F_CAN_T_REPAY_LOAN)); |
184 break; |
202 break; |
185 } |
203 } |
186 break; |
204 break; |
187 } |
205 } |
242 }; |
260 }; |
243 |
261 |
244 /* Association of liveries to livery classes */ |
262 /* Association of liveries to livery classes */ |
245 static const LiveryClass livery_class[LS_END] = { |
263 static const LiveryClass livery_class[LS_END] = { |
246 LC_OTHER, |
264 LC_OTHER, |
247 LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, |
265 LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, |
248 LC_ROAD, LC_ROAD, |
266 LC_ROAD, LC_ROAD, |
249 LC_SHIP, LC_SHIP, |
267 LC_SHIP, LC_SHIP, |
250 LC_AIRCRAFT, LC_AIRCRAFT, LC_AIRCRAFT, |
268 LC_AIRCRAFT, LC_AIRCRAFT, LC_AIRCRAFT, |
251 LC_ROAD, LC_ROAD, |
269 LC_ROAD, LC_ROAD, |
252 }; |
270 }; |
253 |
271 |
254 /* Number of liveries in each class, used to determine the height of the livery window */ |
272 /* Number of liveries in each class, used to determine the height of the livery window */ |
255 static const byte livery_height[] = { |
273 static const byte livery_height[] = { |
256 1, |
274 1, |
257 11, |
275 13, |
258 4, |
276 4, |
259 2, |
277 2, |
260 3, |
278 3, |
261 }; |
279 }; |
262 |
280 |
264 uint32 sel; |
282 uint32 sel; |
265 LiveryClass livery_class; |
283 LiveryClass livery_class; |
266 }; |
284 }; |
267 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(livery_d)); |
285 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(livery_d)); |
268 |
286 |
|
287 |
|
288 enum PlayerLiveryWindowWidgets { |
|
289 PLW_WIDGET_CLASS_GENERAL = 2, |
|
290 PLW_WIDGET_CLASS_RAIL, |
|
291 PLW_WIDGET_CLASS_ROAD, |
|
292 PLW_WIDGET_CLASS_SHIP, |
|
293 PLW_WIDGET_CLASS_AIRCRAFT, |
|
294 |
|
295 PLW_WIDGET_PRI_COL_DROPDOWN = 9, |
|
296 PLW_WIDGET_SEC_COL_DROPDOWN, |
|
297 PLW_WIDGET_MATRIX, |
|
298 }; |
|
299 |
269 static void ShowColourDropDownMenu(Window *w, uint32 widget) |
300 static void ShowColourDropDownMenu(Window *w, uint32 widget) |
270 { |
301 { |
271 uint32 used_colours = 0; |
302 uint32 used_colours = 0; |
272 const Livery *livery; |
303 const Livery *livery; |
273 LiveryScheme scheme; |
304 LiveryScheme scheme; |
274 |
305 |
275 /* Disallow other player colours for the primary colour */ |
306 /* Disallow other player colours for the primary colour */ |
276 if (HasBit(WP(w, livery_d).sel, LS_DEFAULT) && widget == 10) { |
307 if (HasBit(WP(w, livery_d).sel, LS_DEFAULT) && widget == PLW_WIDGET_PRI_COL_DROPDOWN) { |
277 const Player *p; |
308 const Player *p; |
278 FOR_ALL_PLAYERS(p) { |
309 FOR_ALL_PLAYERS(p) { |
279 if (p->is_active && p->index != _local_player) SetBit(used_colours, p->player_color); |
310 if (p->is_active && p->index != _local_player) SetBit(used_colours, p->player_color); |
280 } |
311 } |
281 } |
312 } |
285 if (HasBit(WP(w, livery_d).sel, scheme)) break; |
316 if (HasBit(WP(w, livery_d).sel, scheme)) break; |
286 } |
317 } |
287 if (scheme == LS_END) scheme = LS_DEFAULT; |
318 if (scheme == LS_END) scheme = LS_DEFAULT; |
288 livery = &GetPlayer((PlayerID)w->window_number)->livery[scheme]; |
319 livery = &GetPlayer((PlayerID)w->window_number)->livery[scheme]; |
289 |
320 |
290 ShowDropDownMenu(w, _colour_dropdown, widget == 10 ? livery->colour1 : livery->colour2, widget, used_colours, 0); |
321 ShowDropDownMenu(w, _colour_dropdown, widget == PLW_WIDGET_PRI_COL_DROPDOWN ? livery->colour1 : livery->colour2, widget, used_colours, 0); |
291 } |
322 } |
292 |
323 |
293 static void SelectPlayerLiveryWndProc(Window *w, WindowEvent *e) |
324 static void SelectPlayerLiveryWndProc(Window *w, WindowEvent *e) |
294 { |
325 { |
295 switch (e->event) { |
326 switch (e->event) { |
296 case WE_CREATE: |
327 case WE_CREATE: |
297 w->LowerWidget(WP(w, livery_d).livery_class + 2); |
328 w->LowerWidget(WP(w, livery_d).livery_class + PLW_WIDGET_CLASS_GENERAL); |
298 if (!_loaded_newgrf_features.has_2CC) { |
329 if (!_loaded_newgrf_features.has_2CC) { |
299 w->HideWidget(11); |
330 w->HideWidget(PLW_WIDGET_SEC_COL_DROPDOWN); |
300 w->HideWidget(12); |
|
301 } |
331 } |
302 break; |
332 break; |
303 |
333 |
304 case WE_PAINT: { |
334 case WE_PAINT: { |
305 const Player *p = GetPlayer((PlayerID)w->window_number); |
335 const Player *p = GetPlayer((PlayerID)w->window_number); |
306 LiveryScheme scheme = LS_DEFAULT; |
336 LiveryScheme scheme = LS_DEFAULT; |
307 int y = 51; |
337 int y = 51; |
308 |
338 |
309 /* Disable dropdown controls if no scheme is selected */ |
339 /* Disable dropdown controls if no scheme is selected */ |
310 w->SetWidgetDisabledState( 9, (WP(w, livery_d).sel == 0)); |
340 w->SetWidgetDisabledState(PLW_WIDGET_PRI_COL_DROPDOWN, (WP(w, livery_d).sel == 0)); |
311 w->SetWidgetDisabledState(10, (WP(w, livery_d).sel == 0)); |
341 w->SetWidgetDisabledState(PLW_WIDGET_SEC_COL_DROPDOWN, (WP(w, livery_d).sel == 0)); |
312 w->SetWidgetDisabledState(11, (WP(w, livery_d).sel == 0)); |
|
313 w->SetWidgetDisabledState(12, (WP(w, livery_d).sel == 0)); |
|
314 |
342 |
315 if (!(WP(w, livery_d).sel == 0)) { |
343 if (!(WP(w, livery_d).sel == 0)) { |
316 for (scheme = LS_BEGIN; scheme < LS_END; scheme++) { |
344 for (scheme = LS_BEGIN; scheme < LS_END; scheme++) { |
317 if (HasBit(WP(w, livery_d).sel, scheme)) break; |
345 if (HasBit(WP(w, livery_d).sel, scheme)) break; |
318 } |
346 } |
349 } |
377 } |
350 |
378 |
351 case WE_CLICK: { |
379 case WE_CLICK: { |
352 switch (e->we.click.widget) { |
380 switch (e->we.click.widget) { |
353 /* Livery Class buttons */ |
381 /* Livery Class buttons */ |
354 case 2: |
382 case PLW_WIDGET_CLASS_GENERAL: |
355 case 3: |
383 case PLW_WIDGET_CLASS_RAIL: |
356 case 4: |
384 case PLW_WIDGET_CLASS_ROAD: |
357 case 5: |
385 case PLW_WIDGET_CLASS_SHIP: |
358 case 6: { |
386 case PLW_WIDGET_CLASS_AIRCRAFT: { |
359 LiveryScheme scheme; |
387 LiveryScheme scheme; |
360 |
388 |
361 w->RaiseWidget(WP(w, livery_d).livery_class + 2); |
389 w->RaiseWidget(WP(w, livery_d).livery_class + PLW_WIDGET_CLASS_GENERAL); |
362 WP(w, livery_d).livery_class = (LiveryClass)(e->we.click.widget - 2); |
390 WP(w, livery_d).livery_class = (LiveryClass)(e->we.click.widget - PLW_WIDGET_CLASS_GENERAL); |
363 WP(w, livery_d).sel = 0; |
391 WP(w, livery_d).sel = 0; |
364 w->LowerWidget(WP(w, livery_d).livery_class + 2); |
392 w->LowerWidget(WP(w, livery_d).livery_class + PLW_WIDGET_CLASS_GENERAL); |
365 |
393 |
366 /* Select the first item in the list */ |
394 /* Select the first item in the list */ |
367 for (scheme = LS_DEFAULT; scheme < LS_END; scheme++) { |
395 for (scheme = LS_DEFAULT; scheme < LS_END; scheme++) { |
368 if (livery_class[scheme] == WP(w, livery_d).livery_class) { |
396 if (livery_class[scheme] == WP(w, livery_d).livery_class) { |
369 WP(w, livery_d).sel = 1 << scheme; |
397 WP(w, livery_d).sel = 1 << scheme; |
370 break; |
398 break; |
371 } |
399 } |
372 } |
400 } |
373 w->height = 49 + livery_height[WP(w, livery_d).livery_class] * 14; |
401 w->height = 49 + livery_height[WP(w, livery_d).livery_class] * 14; |
374 w->widget[13].bottom = w->height - 1; |
402 w->widget[PLW_WIDGET_MATRIX].bottom = w->height - 1; |
375 w->widget[13].data = livery_height[WP(w, livery_d).livery_class] << 8 | 1; |
403 w->widget[PLW_WIDGET_MATRIX].data = livery_height[WP(w, livery_d).livery_class] << 8 | 1; |
376 MarkWholeScreenDirty(); |
404 MarkWholeScreenDirty(); |
377 break; |
405 break; |
378 } |
406 } |
379 |
407 |
380 case 9: |
408 case PLW_WIDGET_PRI_COL_DROPDOWN: /* First colour dropdown */ |
381 case 10: /* First colour dropdown */ |
409 ShowColourDropDownMenu(w, PLW_WIDGET_PRI_COL_DROPDOWN); |
382 ShowColourDropDownMenu(w, 10); |
410 break; |
383 break; |
411 |
384 |
412 case PLW_WIDGET_SEC_COL_DROPDOWN: /* Second colour dropdown */ |
385 case 11: |
413 ShowColourDropDownMenu(w, PLW_WIDGET_SEC_COL_DROPDOWN); |
386 case 12: /* Second colour dropdown */ |
414 break; |
387 ShowColourDropDownMenu(w, 12); |
415 |
388 break; |
416 case PLW_WIDGET_MATRIX: { |
389 |
|
390 case 13: { |
|
391 LiveryScheme scheme; |
417 LiveryScheme scheme; |
392 LiveryScheme j = (LiveryScheme)((e->we.click.pt.y - 48) / 14); |
418 LiveryScheme j = (LiveryScheme)((e->we.click.pt.y - 48) / 14); |
393 |
419 |
394 for (scheme = LS_BEGIN; scheme <= j; scheme++) { |
420 for (scheme = LS_BEGIN; scheme <= j; scheme++) { |
395 if (livery_class[scheme] != WP(w, livery_d).livery_class) j++; |
421 if (livery_class[scheme] != WP(w, livery_d).livery_class) j++; |
435 { WWT_IMGBTN, RESIZE_NONE, 14, 44, 65, 14, 35, SPR_IMG_TRUCKLIST, STR_LIVERY_ROADVEH_TIP }, |
461 { WWT_IMGBTN, RESIZE_NONE, 14, 44, 65, 14, 35, SPR_IMG_TRUCKLIST, STR_LIVERY_ROADVEH_TIP }, |
436 { WWT_IMGBTN, RESIZE_NONE, 14, 66, 87, 14, 35, SPR_IMG_SHIPLIST, STR_LIVERY_SHIP_TIP }, |
462 { WWT_IMGBTN, RESIZE_NONE, 14, 66, 87, 14, 35, SPR_IMG_SHIPLIST, STR_LIVERY_SHIP_TIP }, |
437 { WWT_IMGBTN, RESIZE_NONE, 14, 88, 109, 14, 35, SPR_IMG_AIRPLANESLIST, STR_LIVERY_AIRCRAFT_TIP }, |
463 { WWT_IMGBTN, RESIZE_NONE, 14, 88, 109, 14, 35, SPR_IMG_AIRPLANESLIST, STR_LIVERY_AIRCRAFT_TIP }, |
438 { WWT_PANEL, RESIZE_NONE, 14, 110, 399, 14, 35, 0x0, STR_NULL }, |
464 { WWT_PANEL, RESIZE_NONE, 14, 110, 399, 14, 35, 0x0, STR_NULL }, |
439 { WWT_PANEL, RESIZE_NONE, 14, 0, 149, 36, 47, 0x0, STR_NULL }, |
465 { WWT_PANEL, RESIZE_NONE, 14, 0, 149, 36, 47, 0x0, STR_NULL }, |
440 { WWT_TEXTBTN, RESIZE_NONE, 14, 150, 262, 36, 47, STR_02BD, STR_LIVERY_PRIMARY_TIP }, |
466 { WWT_DROPDOWN, RESIZE_NONE, 14, 150, 274, 36, 47, STR_02BD, STR_LIVERY_PRIMARY_TIP }, |
441 { WWT_TEXTBTN, RESIZE_NONE, 14, 263, 274, 36, 47, STR_0225, STR_LIVERY_PRIMARY_TIP }, |
467 { WWT_DROPDOWN, RESIZE_NONE, 14, 275, 399, 36, 47, STR_02E1, STR_LIVERY_SECONDARY_TIP }, |
442 { WWT_TEXTBTN, RESIZE_NONE, 14, 275, 387, 36, 47, STR_02E1, STR_LIVERY_SECONDARY_TIP }, |
|
443 { WWT_TEXTBTN, RESIZE_NONE, 14, 388, 399, 36, 47, STR_0225, STR_LIVERY_SECONDARY_TIP }, |
|
444 { WWT_MATRIX, RESIZE_NONE, 14, 0, 399, 48, 48 + 1 * 14, (1 << 8) | 1, STR_LIVERY_PANEL_TIP }, |
468 { WWT_MATRIX, RESIZE_NONE, 14, 0, 399, 48, 48 + 1 * 14, (1 << 8) | 1, STR_LIVERY_PANEL_TIP }, |
445 { WIDGETS_END }, |
469 { WIDGETS_END }, |
446 }; |
470 }; |
447 |
471 |
448 static const WindowDesc _select_player_livery_2cc_desc = { |
472 static const WindowDesc _select_player_livery_2cc_desc = { |
462 { WWT_IMGBTN, RESIZE_NONE, 14, 44, 65, 14, 35, SPR_IMG_TRUCKLIST, STR_LIVERY_ROADVEH_TIP }, |
486 { WWT_IMGBTN, RESIZE_NONE, 14, 44, 65, 14, 35, SPR_IMG_TRUCKLIST, STR_LIVERY_ROADVEH_TIP }, |
463 { WWT_IMGBTN, RESIZE_NONE, 14, 66, 87, 14, 35, SPR_IMG_SHIPLIST, STR_LIVERY_SHIP_TIP }, |
487 { WWT_IMGBTN, RESIZE_NONE, 14, 66, 87, 14, 35, SPR_IMG_SHIPLIST, STR_LIVERY_SHIP_TIP }, |
464 { WWT_IMGBTN, RESIZE_NONE, 14, 88, 109, 14, 35, SPR_IMG_AIRPLANESLIST, STR_LIVERY_AIRCRAFT_TIP }, |
488 { WWT_IMGBTN, RESIZE_NONE, 14, 88, 109, 14, 35, SPR_IMG_AIRPLANESLIST, STR_LIVERY_AIRCRAFT_TIP }, |
465 { WWT_PANEL, RESIZE_NONE, 14, 110, 274, 14, 35, 0x0, STR_NULL }, |
489 { WWT_PANEL, RESIZE_NONE, 14, 110, 274, 14, 35, 0x0, STR_NULL }, |
466 { WWT_PANEL, RESIZE_NONE, 14, 0, 149, 36, 47, 0x0, STR_NULL }, |
490 { WWT_PANEL, RESIZE_NONE, 14, 0, 149, 36, 47, 0x0, STR_NULL }, |
467 { WWT_TEXTBTN, RESIZE_NONE, 14, 150, 262, 36, 47, STR_02BD, STR_LIVERY_PRIMARY_TIP }, |
491 { WWT_DROPDOWN, RESIZE_NONE, 14, 150, 274, 36, 47, STR_02BD, STR_LIVERY_PRIMARY_TIP }, |
468 { WWT_TEXTBTN, RESIZE_NONE, 14, 263, 274, 36, 47, STR_0225, STR_LIVERY_PRIMARY_TIP }, |
492 { WWT_DROPDOWN, RESIZE_NONE, 14, 275, 275, 36, 47, STR_02E1, STR_LIVERY_SECONDARY_TIP }, |
469 { WWT_TEXTBTN, RESIZE_NONE, 14, 275, 275, 36, 47, STR_02E1, STR_LIVERY_SECONDARY_TIP }, |
|
470 { WWT_TEXTBTN, RESIZE_NONE, 14, 275, 275, 36, 47, STR_0225, STR_LIVERY_SECONDARY_TIP }, |
|
471 { WWT_MATRIX, RESIZE_NONE, 14, 0, 274, 48, 48 + 1 * 14, (1 << 8) | 1, STR_LIVERY_PANEL_TIP }, |
493 { WWT_MATRIX, RESIZE_NONE, 14, 0, 274, 48, 48 + 1 * 14, (1 << 8) | 1, STR_LIVERY_PANEL_TIP }, |
472 { WIDGETS_END }, |
494 { WIDGETS_END }, |
473 }; |
495 }; |
474 |
496 |
475 static const WindowDesc _select_player_livery_desc = { |
497 static const WindowDesc _select_player_livery_desc = { |
1177 if ((byte)w->window_number != _local_player) |
1199 if ((byte)w->window_number != _local_player) |
1178 return; |
1200 return; |
1179 SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, w); |
1201 SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, w); |
1180 SetTileSelectSize(2, 2); |
1202 SetTileSelectSize(2, 2); |
1181 w->LowerWidget(PCW_WIDGET_BUILD_VIEW_HQ); |
1203 w->LowerWidget(PCW_WIDGET_BUILD_VIEW_HQ); |
1182 InvalidateWidget(w, PCW_WIDGET_BUILD_VIEW_HQ); |
1204 w->InvalidateWidget(PCW_WIDGET_BUILD_VIEW_HQ); |
1183 } else { |
1205 } else { |
1184 ScrollMainWindowToTile(tile); |
1206 ScrollMainWindowToTile(tile); |
1185 } |
1207 } |
1186 break; |
1208 break; |
1187 } |
1209 } |
1188 |
1210 |
1189 case PCW_WIDGET_RELOCATE_HQ: |
1211 case PCW_WIDGET_RELOCATE_HQ: |
1190 SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, w); |
1212 SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, w); |
1191 SetTileSelectSize(2, 2); |
1213 SetTileSelectSize(2, 2); |
1192 w->LowerWidget(PCW_WIDGET_RELOCATE_HQ); |
1214 w->LowerWidget(PCW_WIDGET_RELOCATE_HQ); |
1193 InvalidateWidget(w, PCW_WIDGET_RELOCATE_HQ); |
1215 w->InvalidateWidget(PCW_WIDGET_RELOCATE_HQ); |
1194 break; |
1216 break; |
1195 |
1217 |
1196 case PCW_WIDGET_BUY_SHARE: |
1218 case PCW_WIDGET_BUY_SHARE: |
1197 DoCommandP(0, w->window_number, 0, NULL, CMD_BUY_SHARE_IN_COMPANY | CMD_MSG(STR_707B_CAN_T_BUY_25_SHARE_IN_THIS)); |
1219 DoCommandP(0, w->window_number, 0, NULL, CMD_BUY_SHARE_IN_COMPANY | CMD_MSG(STR_707B_CAN_T_BUY_25_SHARE_IN_THIS)); |
1198 break; |
1220 break; |
1216 |
1238 |
1217 case WE_PLACE_OBJ: |
1239 case WE_PLACE_OBJ: |
1218 if (DoCommandP(e->we.place.tile, 0, 0, NULL, CMD_BUILD_COMPANY_HQ | CMD_NO_WATER | CMD_MSG(STR_7071_CAN_T_BUILD_COMPANY_HEADQUARTERS))) |
1240 if (DoCommandP(e->we.place.tile, 0, 0, NULL, CMD_BUILD_COMPANY_HQ | CMD_NO_WATER | CMD_MSG(STR_7071_CAN_T_BUILD_COMPANY_HEADQUARTERS))) |
1219 ResetObjectToPlace(); |
1241 ResetObjectToPlace(); |
1220 w->widget[PCW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; // this button can now behave as a normal push button |
1242 w->widget[PCW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; // this button can now behave as a normal push button |
1221 RaiseWindowButtons(w); |
1243 w->RaiseButtons(); |
1222 break; |
1244 break; |
1223 |
1245 |
1224 case WE_ABORT_PLACE_OBJ: |
1246 case WE_ABORT_PLACE_OBJ: |
1225 RaiseWindowButtons(w); |
1247 w->RaiseButtons(); |
1226 break; |
1248 break; |
1227 |
1249 |
1228 case WE_DESTROY: |
1250 case WE_DESTROY: |
1229 DeleteWindowById(WC_PLAYER_FACE, w->window_number); |
1251 DeleteWindowById(WC_PLAYER_FACE, w->window_number); |
1230 if (w->window_number == _local_player) DeleteWindowById(WC_COMPANY_PASSWORD_WINDOW, 0); |
1252 if (w->window_number == _local_player) DeleteWindowById(WC_COMPANY_PASSWORD_WINDOW, 0); |