OpenTTD Source: src/airport_gui.cpp Source File

OpenTTD Source 12.0-beta1

airport_gui.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10 #include "stdafx.h"
11 #include "window_gui.h"
12 #include "station_gui.h"
13 #include "terraform_gui.h"
14 #include "sound_func.h"
15 #include "window_func.h"
16 #include "strings_func.h"
17 #include "viewport_func.h"
18 #include "company_func.h"
19 #include "tilehighlight_func.h"
20 #include "company_base.h"
21 #include "station_type.h"
22 #include "newgrf_airport.h"
23 #include "newgrf_callbacks.h"
24 #include "widgets/dropdown_type.h"
25 #include "core/geometry_func.hpp"
26 #include "hotkeys.h"
27 #include "vehicle_func.h"
28 #include "gui.h"
29
30 #include "widgets/airport_widget.h"
31
32 #include "safeguards.h"
33
34
35 static AirportClassID _selected_airport_class;
36 static int _selected_airport_index;
37 static byte _selected_airport_layout;
38
39 static void ShowBuildAirportPicker(Window *parent);
40
41 SpriteID GetCustomAirportSprite(const AirportSpec *as, byte layout);
42
43 void CcBuildAirport(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
44 {
45 if (result.Failed()) return;
46
47 if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile);
48 if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
49 }
50
55 static void PlaceAirport(TileIndex tile)
56 {
57 if (_selected_airport_index == -1) return;
58 uint32 p2 = _ctrl_pressed;
59 SB(p2, 16, 16, INVALID_STATION); // no station to join
60
61 uint32 p1 = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index)->GetIndex();
62 p1 |= _selected_airport_layout << 8;
63 CommandContainer cmdcont = { tile, p1, p2, CMD_BUILD_AIRPORT | CMD_MSG(STR_ERROR_CAN_T_BUILD_AIRPORT_HERE), CcBuildAirport, "" };
64 ShowSelectStationIfNeeded(cmdcont, TileArea(tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE));
65 }
66
68 struct BuildAirToolbarWindow : Window {
69 int last_user_action; // Last started user action.
70
71 BuildAirToolbarWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
72 {
73 this->InitNested(window_number);
74 this->OnInvalidateData();
75 if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
76 this->last_user_action = WIDGET_LIST_END;
77 }
78
79 void Close() override
80 {
81 if (this->IsWidgetLowered(WID_AT_AIRPORT)) SetViewportCatchmentStation(nullptr, true);
82 if (_settings_client.gui.link_terraform_toolbar) CloseWindowById(WC_SCEN_LAND_GEN, 0, false);
83 this->Window::Close();
84 }
85
91 void OnInvalidateData(int data = 0, bool gui_scope = true) override
92 {
93 if (!gui_scope) return;
94
95 bool can_build = CanBuildVehicleInfrastructure(VEH_AIRCRAFT);
96 this->SetWidgetsDisabledState(!can_build,
97 WID_AT_AIRPORT,
98 WIDGET_LIST_END);
99 if (!can_build) {
100 CloseWindowById(WC_BUILD_STATION, TRANSPORT_AIR);
101
102 /* Show in the tooltip why this button is disabled. */
103 this->GetWidget<NWidgetCore>(WID_AT_AIRPORT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
104 } else {
105 this->GetWidget<NWidgetCore>(WID_AT_AIRPORT)->SetToolTip(STR_TOOLBAR_AIRCRAFT_BUILD_AIRPORT_TOOLTIP);
106 }
107 }
108
109 void OnClick(Point pt, int widget, int click_count) override
110 {
111 switch (widget) {
112 case WID_AT_AIRPORT:
113 if (HandlePlacePushButton(this, WID_AT_AIRPORT, SPR_CURSOR_AIRPORT, HT_RECT)) {
114 ShowBuildAirportPicker(this);
115 this->last_user_action = widget;
116 }
117 break;
118
119 case WID_AT_DEMOLISH:
120 HandlePlacePushButton(this, WID_AT_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT | HT_DIAGONAL);
121 this->last_user_action = widget;
122 break;
123
124 default: break;
125 }
126 }
127
128
129 void OnPlaceObject(Point pt, TileIndex tile) override
130 {
131 switch (this->last_user_action) {
132 case WID_AT_AIRPORT:
133 PlaceAirport(tile);
134 break;
135
136 case WID_AT_DEMOLISH:
137 PlaceProc_DemolishArea(tile);
138 break;
139
140 default: NOT_REACHED();
141 }
142 }
143
144 void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override
145 {
146 VpSelectTilesWithMethod(pt.x, pt.y, select_method);
147 }
148
149 void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) override
150 {
151 if (pt.x != -1 && select_proc == DDSP_DEMOLISH_AREA) {
152 GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
153 }
154 }
155
156 void OnPlaceObjectAbort() override
157 {
158 if (this->IsWidgetLowered(WID_AT_AIRPORT)) SetViewportCatchmentStation(nullptr, true);
159
160 this->RaiseButtons();
161
162 CloseWindowById(WC_BUILD_STATION, TRANSPORT_AIR);
163 CloseWindowById(WC_SELECT_STATION, 0);
164 }
165
166 static HotkeyList hotkeys;
167 };
168
174 static EventState AirportToolbarGlobalHotkeys(int hotkey)
175 {
176 if (_game_mode != GM_NORMAL) return ES_NOT_HANDLED;
177 Window *w = ShowBuildAirToolbar();
178 if (w == nullptr) return ES_NOT_HANDLED;
179 return w->OnHotkey(hotkey);
180 }
181
182 static Hotkey airtoolbar_hotkeys[] = {
183 Hotkey('1', "airport", WID_AT_AIRPORT),
184 Hotkey('2', "demolish", WID_AT_DEMOLISH),
185 HOTKEY_LIST_END
186 };
187 HotkeyList BuildAirToolbarWindow::hotkeys("airtoolbar", airtoolbar_hotkeys, AirportToolbarGlobalHotkeys);
188
189 static const NWidgetPart _nested_air_toolbar_widgets[] = {
190 NWidget(NWID_HORIZONTAL),
191 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
192 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_TOOLBAR_AIRCRAFT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
193 NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
194 EndContainer(),
195 NWidget(NWID_HORIZONTAL),
196 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_AT_AIRPORT), SetFill(0, 1), SetMinimalSize(42, 22), SetDataTip(SPR_IMG_AIRPORT, STR_TOOLBAR_AIRCRAFT_BUILD_AIRPORT_TOOLTIP),
197 NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetMinimalSize(4, 22), SetFill(1, 1), EndContainer(),
198 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_AT_DEMOLISH), SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
199 EndContainer(),
200 };
201
202 static WindowDesc _air_toolbar_desc(
203 WDP_ALIGN_TOOLBAR, "toolbar_air", 0, 0,
204 WC_BUILD_TOOLBAR, WC_NONE,
205 WDF_CONSTRUCTION,
206 _nested_air_toolbar_widgets, lengthof(_nested_air_toolbar_widgets),
207 &BuildAirToolbarWindow::hotkeys
208 );
209
217 Window *ShowBuildAirToolbar()
218 {
219 if (!Company::IsValidID(_local_company)) return nullptr;
220
221 CloseWindowByClass(WC_BUILD_TOOLBAR);
222 return AllocateWindowDescFront<BuildAirToolbarWindow>(&_air_toolbar_desc, TRANSPORT_AIR);
223 }
224
225 class BuildAirportWindow : public PickerWindowBase {
226 SpriteID preview_sprite;
227 int line_height;
228 Scrollbar *vscroll;
229
231 static DropDownList BuildAirportClassDropDown()
232 {
233 DropDownList list;
234
235 for (uint i = 0; i < AirportClass::GetClassCount(); i++) {
236 list.emplace_back(new DropDownListStringItem(AirportClass::Get((AirportClassID)i)->name, i, false));
237 }
238
239 return list;
240 }
241
242 public:
243 BuildAirportWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
244 {
245 this->CreateNestedTree();
246
247 this->vscroll = this->GetScrollbar(WID_AP_SCROLLBAR);
248 this->vscroll->SetCapacity(5);
249 this->vscroll->SetPosition(0);
250
251 this->FinishInitNested(TRANSPORT_AIR);
252
253 this->SetWidgetLoweredState(WID_AP_BTN_DONTHILIGHT, !_settings_client.gui.station_show_coverage);
254 this->SetWidgetLoweredState(WID_AP_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage);
255 this->OnInvalidateData();
256
257 /* Ensure airport class is valid (changing NewGRFs). */
258 _selected_airport_class = Clamp(_selected_airport_class, APC_BEGIN, (AirportClassID)(AirportClass::GetClassCount() - 1));
259 const AirportClass *ac = AirportClass::Get(_selected_airport_class);
260 this->vscroll->SetCount(ac->GetSpecCount());
261
262 /* Ensure the airport index is valid for this class (changing NewGRFs). */
263 _selected_airport_index = Clamp(_selected_airport_index, -1, ac->GetSpecCount() - 1);
264
265 /* Only when no valid airport was selected, we want to select the first airport. */
266 bool selectFirstAirport = true;
267 if (_selected_airport_index != -1) {
268 const AirportSpec *as = ac->GetSpec(_selected_airport_index);
269 if (as->IsAvailable()) {
270 /* Ensure the airport layout is valid. */
271 _selected_airport_layout = Clamp(_selected_airport_layout, 0, as->num_table - 1);
272 selectFirstAirport = false;
273 this->UpdateSelectSize();
274 }
275 }
276
277 if (selectFirstAirport) this->SelectFirstAvailableAirport(true);
278 }
279
280 void Close() override
281 {
282 CloseWindowById(WC_SELECT_STATION, 0);
283 this->PickerWindowBase::Close();
284 }
285
286 void SetStringParameters(int widget) const override
287 {
288 switch (widget) {
289 case WID_AP_CLASS_DROPDOWN:
290 SetDParam(0, AirportClass::Get(_selected_airport_class)->name);
291 break;
292
293 case WID_AP_LAYOUT_NUM:
294 SetDParam(0, STR_EMPTY);
295 if (_selected_airport_index != -1) {
296 const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index);
297 StringID string = GetAirportTextCallback(as, _selected_airport_layout, CBID_AIRPORT_LAYOUT_NAME);
298 if (string != STR_UNDEFINED) {
299 SetDParam(0, string);
300 } else if (as->num_table > 1) {
301 SetDParam(0, STR_STATION_BUILD_AIRPORT_LAYOUT_NAME);
302 SetDParam(1, _selected_airport_layout + 1);
303 }
304 }
305 break;
306
307 default: break;
308 }
309 }
310
311 void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
312 {
313 switch (widget) {
314 case WID_AP_CLASS_DROPDOWN: {
315 Dimension d = {0, 0};
316 for (uint i = 0; i < AirportClass::GetClassCount(); i++) {
317 SetDParam(0, AirportClass::Get((AirportClassID)i)->name);
318 d = maxdim(d, GetStringBoundingBox(STR_BLACK_STRING));
319 }
320 d.width += padding.width;
321 d.height += padding.height;
322 *size = maxdim(*size, d);
323 break;
324 }
325
326 case WID_AP_AIRPORT_LIST: {
327 for (int i = 0; i < NUM_AIRPORTS; i++) {
328 const AirportSpec *as = AirportSpec::Get(i);
329 if (!as->enabled) continue;
330
331 size->width = std::max(size->width, GetStringBoundingBox(as->name).width);
332 }
333
334 this->line_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM;
335 size->height = 5 * this->line_height;
336 break;
337 }
338
339 case WID_AP_AIRPORT_SPRITE:
340 for (int i = 0; i < NUM_AIRPORTS; i++) {
341 const AirportSpec *as = AirportSpec::Get(i);
342 if (!as->enabled) continue;
343 for (byte layout = 0; layout < as->num_table; layout++) {
344 SpriteID sprite = GetCustomAirportSprite(as, layout);
345 if (sprite != 0) {
346 Dimension d = GetSpriteSize(sprite);
347 d.width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
348 d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
349 *size = maxdim(d, *size);
350 }
351 }
352 }
353 break;
354
355 case WID_AP_EXTRA_TEXT:
356 for (int i = NEW_AIRPORT_OFFSET; i < NUM_AIRPORTS; i++) {
357 const AirportSpec *as = AirportSpec::Get(i);
358 if (!as->enabled) continue;
359 for (byte layout = 0; layout < as->num_table; layout++) {
360 StringID string = GetAirportTextCallback(as, layout, CBID_AIRPORT_ADDITIONAL_TEXT);
361 if (string == STR_UNDEFINED) continue;
362
363 /* STR_BLACK_STRING is used to start the string with {BLACK} */
364 SetDParam(0, string);
365 Dimension d = GetStringMultiLineBoundingBox(STR_BLACK_STRING, *size);
366 *size = maxdim(d, *size);
367 }
368 }
369 break;
370
371 default: break;
372 }
373 }
374
375 void DrawWidget(const Rect &r, int widget) const override
376 {
377 switch (widget) {
378 case WID_AP_AIRPORT_LIST: {
379 int y = r.top;
380 AirportClass *apclass = AirportClass::Get(_selected_airport_class);
381 for (uint i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < apclass->GetSpecCount(); i++) {
382 const AirportSpec *as = apclass->GetSpec(i);
383 if (!as->IsAvailable()) {
384 GfxFillRect(r.left + 1, y + 1, r.right - 1, y + this->line_height - 2, PC_BLACK, FILLRECT_CHECKER);
385 }
386 DrawString(r.left + WD_MATRIX_LEFT, r.right - WD_MATRIX_RIGHT, y + WD_MATRIX_TOP, as->name, ((int)i == _selected_airport_index) ? TC_WHITE : TC_BLACK);
387 y += this->line_height;
388 }
389 break;
390 }
391
392 case WID_AP_AIRPORT_SPRITE:
393 if (this->preview_sprite != 0) {
394 Dimension d = GetSpriteSize(this->preview_sprite);
395 DrawSprite(this->preview_sprite, COMPANY_SPRITE_COLOUR(_local_company), (r.left + r.right - d.width) / 2, (r.top + r.bottom - d.height) / 2);
396 }
397 break;
398
399 case WID_AP_EXTRA_TEXT:
400 if (_selected_airport_index != -1) {
401 const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index);
402 StringID string = GetAirportTextCallback(as, _selected_airport_layout, CBID_AIRPORT_ADDITIONAL_TEXT);
403 if (string != STR_UNDEFINED) {
404 SetDParam(0, string);
405 DrawStringMultiLine(r.left, r.right, r.top, r.bottom, STR_BLACK_STRING);
406 }
407 }
408 break;
409 }
410 }
411
412 void OnPaint() override
413 {
414 this->DrawWidgets();
415
416 uint16 top = this->GetWidget<NWidgetBase>(WID_AP_BTN_DOHILIGHT)->pos_y + this->GetWidget<NWidgetBase>(WID_AP_BTN_DOHILIGHT)->current_y + WD_PAR_VSEP_NORMAL;
417 NWidgetBase *panel_nwi = this->GetWidget<NWidgetBase>(WID_AP_BOTTOMPANEL);
418
419 int right = panel_nwi->pos_x + panel_nwi->current_x;
420 int bottom = panel_nwi->pos_y + panel_nwi->current_y;
421
422 if (_selected_airport_index != -1) {
423 const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index);
424 int rad = _settings_game.station.modified_catchment ? as->catchment : (uint)CA_UNMODIFIED;
425
426 /* only show the station (airport) noise, if the noise option is activated */
427 if (_settings_game.economy.station_noise_level) {
428 /* show the noise of the selected airport */
429 SetDParam(0, as->noise_level);
430 DrawString(panel_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, STR_STATION_BUILD_NOISE);
431 top += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
432 }
433
434 /* strings such as 'Size' and 'Coverage Area' */
435 top = DrawStationCoverageAreaText(panel_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, false) + WD_PAR_VSEP_NORMAL;
436 top = DrawStationCoverageAreaText(panel_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, true) + WD_PAR_VSEP_NORMAL;
437 }
438
439 /* Resize background if the window is too small.
440 * Never make the window smaller to avoid oscillating if the size change affects the acceptance.
441 * (This is the case, if making the window bigger moves the mouse into the window.) */
442 if (top > bottom) {
443 ResizeWindow(this, 0, top - bottom, false);
444 }
445 }
446
447 void SelectOtherAirport(int airport_index)
448 {
449 _selected_airport_index = airport_index;
450 _selected_airport_layout = 0;
451
452 this->UpdateSelectSize();
453 this->SetDirty();
454 }
455
456 void UpdateSelectSize()
457 {
458 if (_selected_airport_index == -1) {
459 SetTileSelectSize(1, 1);
460 this->DisableWidget(WID_AP_LAYOUT_DECREASE);
461 this->DisableWidget(WID_AP_LAYOUT_INCREASE);
462 } else {
463 const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index);
464 int w = as->size_x;
465 int h = as->size_y;
466 Direction rotation = as->rotation[_selected_airport_layout];
467 if (rotation == DIR_E || rotation == DIR_W) Swap(w, h);
468 SetTileSelectSize(w, h);
469
470 this->preview_sprite = GetCustomAirportSprite(as, _selected_airport_layout);
471
472 this->SetWidgetDisabledState(WID_AP_LAYOUT_DECREASE, _selected_airport_layout == 0);
473 this->SetWidgetDisabledState(WID_AP_LAYOUT_INCREASE, _selected_airport_layout + 1 >= as->num_table);
474
475 int rad = _settings_game.station.modified_catchment ? as->catchment : (uint)CA_UNMODIFIED;
476 if (_settings_client.gui.station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
477 }
478 }
479
480 void OnClick(Point pt, int widget, int click_count) override
481 {
482 switch (widget) {
483 case WID_AP_CLASS_DROPDOWN:
484 ShowDropDownList(this, BuildAirportClassDropDown(), _selected_airport_class, WID_AP_CLASS_DROPDOWN);
485 break;
486
487 case WID_AP_AIRPORT_LIST: {
488 int num_clicked = this->vscroll->GetPosition() + (pt.y - this->GetWidget<NWidgetBase>(widget)->pos_y) / this->line_height;
489 if (num_clicked >= this->vscroll->GetCount()) break;
490 const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(num_clicked);
491 if (as->IsAvailable()) this->SelectOtherAirport(num_clicked);
492 break;
493 }
494
495 case WID_AP_BTN_DONTHILIGHT: case WID_AP_BTN_DOHILIGHT:
496 _settings_client.gui.station_show_coverage = (widget != WID_AP_BTN_DONTHILIGHT);
497 this->SetWidgetLoweredState(WID_AP_BTN_DONTHILIGHT, !_settings_client.gui.station_show_coverage);
498 this->SetWidgetLoweredState(WID_AP_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage);
499 this->SetDirty();
500 if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
501 this->UpdateSelectSize();
502 SetViewportCatchmentStation(nullptr, true);
503 break;
504
505 case WID_AP_LAYOUT_DECREASE:
506 _selected_airport_layout--;
507 this->UpdateSelectSize();
508 this->SetDirty();
509 break;
510
511 case WID_AP_LAYOUT_INCREASE:
512 _selected_airport_layout++;
513 this->UpdateSelectSize();
514 this->SetDirty();
515 break;
516 }
517 }
518
524 void SelectFirstAvailableAirport(bool change_class)
525 {
526 /* First try to select an airport in the selected class. */
527 AirportClass *sel_apclass = AirportClass::Get(_selected_airport_class);
528 for (uint i = 0; i < sel_apclass->GetSpecCount(); i++) {
529 const AirportSpec *as = sel_apclass->GetSpec(i);
530 if (as->IsAvailable()) {
531 this->SelectOtherAirport(i);
532 return;
533 }
534 }
535 if (change_class) {
536 /* If that fails, select the first available airport
537 * from a random class. */
538 for (AirportClassID j = APC_BEGIN; j < APC_MAX; j++) {
539 AirportClass *apclass = AirportClass::Get(j);
540 for (uint i = 0; i < apclass->GetSpecCount(); i++) {
541 const AirportSpec *as = apclass->GetSpec(i);
542 if (as->IsAvailable()) {
543 _selected_airport_class = j;
544 this->SelectOtherAirport(i);
545 return;
546 }
547 }
548 }
549 }
550 /* If all airports are unavailable, select nothing. */
551 this->SelectOtherAirport(-1);
552 }
553
554 void OnDropdownSelect(int widget, int index) override
555 {
556 assert(widget == WID_AP_CLASS_DROPDOWN);
557 _selected_airport_class = (AirportClassID)index;
558 this->vscroll->SetCount(AirportClass::Get(_selected_airport_class)->GetSpecCount());
559 this->SelectFirstAvailableAirport(false);
560 }
561
562 void OnRealtimeTick(uint delta_ms) override
563 {
564 CheckRedrawStationCoverage(this);
565 }
566 };
567
568 static const NWidgetPart _nested_build_airport_widgets[] = {
569 NWidget(NWID_HORIZONTAL),
570 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
571 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_AIRPORT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
572 EndContainer(),
573 NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetFill(1, 0), SetPIP(2, 0, 2),
574 NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_AIRPORT_CLASS_LABEL, STR_NULL), SetFill(1, 0),
575 NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_AP_CLASS_DROPDOWN), SetFill(1, 0), SetDataTip(STR_BLACK_STRING, STR_STATION_BUILD_AIRPORT_TOOLTIP),
576 NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_AP_AIRPORT_SPRITE), SetFill(1, 0),
577 NWidget(NWID_HORIZONTAL),
578 NWidget(WWT_MATRIX, COLOUR_GREY, WID_AP_AIRPORT_LIST), SetFill(1, 0), SetMatrixDataTip(1, 5, STR_STATION_BUILD_AIRPORT_TOOLTIP), SetScrollbar(WID_AP_SCROLLBAR),
579 NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_AP_SCROLLBAR),
580 EndContainer(),
581 NWidget(NWID_HORIZONTAL),
582 NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_AP_LAYOUT_DECREASE), SetMinimalSize(12, 0), SetDataTip(AWV_DECREASE, STR_NULL),
583 NWidget(WWT_LABEL, COLOUR_GREY, WID_AP_LAYOUT_NUM), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_BLACK_STRING, STR_NULL),
584 NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_AP_LAYOUT_INCREASE), SetMinimalSize(12, 0), SetDataTip(AWV_INCREASE, STR_NULL),
585 EndContainer(),
586 NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_AP_EXTRA_TEXT), SetFill(1, 0), SetMinimalSize(150, 0),
587 EndContainer(),
588 /* Bottom panel. */
589 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_AP_BOTTOMPANEL), SetPIP(2, 2, 2),
590 NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0),
591 NWidget(NWID_HORIZONTAL),
592 NWidget(NWID_SPACER), SetMinimalSize(14, 0), SetFill(1, 0),
593 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
594 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_AP_BTN_DONTHILIGHT), SetMinimalSize(60, 12), SetFill(1, 0),
595 SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
596 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_AP_BTN_DOHILIGHT), SetMinimalSize(60, 12), SetFill(1, 0),
597 SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
598 EndContainer(),
599 NWidget(NWID_SPACER), SetMinimalSize(14, 0), SetFill(1, 0),
600 EndContainer(),
601 NWidget(NWID_SPACER), SetMinimalSize(0, 10), SetResize(0, 1), SetFill(1, 0),
602 EndContainer(),
603 };
604
605 static WindowDesc _build_airport_desc(
606 WDP_AUTO, "build_station_air", 0, 0,
607 WC_BUILD_STATION, WC_BUILD_TOOLBAR,
608 WDF_CONSTRUCTION,
609 _nested_build_airport_widgets, lengthof(_nested_build_airport_widgets)
610 );
611
612 static void ShowBuildAirportPicker(Window *parent)
613 {
614 new BuildAirportWindow(&_build_airport_desc, parent);
615 }
616
617 void InitializeAirportGui()
618 {
619 _selected_airport_class = APC_BEGIN;
620 _selected_airport_index = -1;
621 }
VEH_AIRCRAFT
@ VEH_AIRCRAFT
Aircraft vehicle type.
Definition: vehicle_type.h:27
WID_AP_BOTTOMPANEL
@ WID_AP_BOTTOMPANEL
Panel at the bottom.
Definition: airport_widget.h:29
SetTileSelectSize
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
Definition: viewport.cpp:2472
PickerWindowBase::Close
void Close() override
Hide the window and all its child windows, and mark them for a later deletion.
Definition: window.cpp:3512
DDSP_DEMOLISH_AREA
@ DDSP_DEMOLISH_AREA
Clear area.
Definition: viewport_type.h:116
CA_UNMODIFIED
@ CA_UNMODIFIED
Catchment for all stations with "modified catchment" disabled.
Definition: station_type.h:82
BuildAirportWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: airport_gui.cpp:480
WD_FRAMERECT_TOP
@ WD_FRAMERECT_TOP
Offset at top to draw the frame rectangular area.
Definition: window_gui.h:64
CMD_MSG
#define CMD_MSG(x)
Used to combine a StringID with the command.
Definition: command_type.h:372
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:83
sound_func.h
TileHighlightData::size
Point size
Size, in tile "units", of the white/red selection area.
Definition: tilehighlight_type.h:48
WID_AP_SCROLLBAR
@ WID_AP_SCROLLBAR
Scrollbar of the list.
Definition: airport_widget.h:23
GUISettings::station_show_coverage
bool station_show_coverage
whether to highlight coverage area
Definition: settings_type.h:161
WC_BUILD_TOOLBAR
@ WC_BUILD_TOOLBAR
Build toolbar; Window numbers:
Definition: window_type.h:65
BuildAirportWindow::Close
void Close() override
Hide the window and all its child windows, and mark them for a later deletion.
Definition: airport_gui.cpp:280
BuildAirportWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: airport_gui.cpp:286
WID_AP_CLASS_DROPDOWN
@ WID_AP_CLASS_DROPDOWN
Dropdown of airport classes.
Definition: airport_widget.h:21
Direction
Direction
Defines the 8 directions on the map.
Definition: direction_type.h:24
GameSettings::station
StationSettings station
settings related to station management
Definition: settings_type.h:587
WD_MATRIX_RIGHT
@ WD_MATRIX_RIGHT
Offset at right of a matrix cell.
Definition: window_gui.h:79
WID_AT_AIRPORT
@ WID_AT_AIRPORT
Build airport button.
Definition: airport_widget.h:15
SetScrollbar
static NWidgetPart SetScrollbar(int index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1188
HotkeyList
List of hotkeys for a window.
Definition: hotkeys.h:40
BuildAirportWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: airport_gui.cpp:311
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:64
_selected_airport_layout
static byte _selected_airport_layout
selected airport layout number.
Definition: airport_gui.cpp:37
Window::GetScrollbar
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
Definition: window.cpp:320
WDF_CONSTRUCTION
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Definition: window_gui.h:210
ShowBuildAirToolbar
Window * ShowBuildAirToolbar()
Open the build airport toolbar window.
Definition: airport_gui.cpp:217
_selected_airport_class
static AirportClassID _selected_airport_class
the currently visible airport class
Definition: airport_gui.cpp:35
AirportToolbarGlobalHotkeys
static EventState AirportToolbarGlobalHotkeys(int hotkey)
Handler for global hotkeys of the BuildAirToolbarWindow.
Definition: airport_gui.cpp:174
GetAirportTextCallback
StringID GetAirportTextCallback(const AirportSpec *as, byte layout, uint16 callback)
Get a custom text for the airport.
Definition: newgrf_airport.cpp:295
company_base.h
ViewportDragDropSelectionProcess
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it.
Definition: viewport_type.h:115
WD_MATRIX_TOP
@ WD_MATRIX_TOP
Offset at top of a matrix cell.
Definition: window_gui.h:80
AirportSpec::size_y
byte size_y
size of airport in y direction
Definition: newgrf_airport.h:106
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:59
NewGRFClass::GetSpecCount
uint GetSpecCount() const
Get the number of allocated specs within the class.
Definition: newgrf_class.h:44
CheckRedrawStationCoverage
void CheckRedrawStationCoverage(const Window *w)
Check whether we need to redraw the station coverage text.
Definition: station_gui.cpp:126
WWT_IMGBTN
@ WWT_IMGBTN
(Toggle) Button with image
Definition: widget_type.h:50
AirportSpec::name
StringID name
name of this airport
Definition: newgrf_airport.h:111
WWT_LABEL
@ WWT_LABEL
Centered label.
Definition: widget_type.h:55
DropDownList
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
Definition: dropdown_type.h:99
Window::CreateNestedTree
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1760
BuildAirToolbarWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: airport_gui.cpp:91
WDP_ALIGN_TOOLBAR
@ WDP_ALIGN_TOOLBAR
Align toward the toolbar.
Definition: window_gui.h:158
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
maxdim
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Definition: geometry_func.cpp:22
WWT_MATRIX
@ WWT_MATRIX
Grid of rows and columns.
Definition: widget_type.h:57
AirportSpec::noise_level
byte noise_level
noise that this airport generates
Definition: newgrf_airport.h:107
WID_AP_BTN_DOHILIGHT
@ WID_AP_BTN_DOHILIGHT
Show the coverage button.
Definition: airport_widget.h:32
PlaceProc_DemolishArea
void PlaceProc_DemolishArea(TileIndex tile)
Start a drag for demolishing an area.
Definition: terraform_gui.cpp:146
Scrollbar::SetCount
void SetCount(int num)
Sets the number of elements in the list.
Definition: widget_type.h:710
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:35
SND_15_BEEP
@ SND_15_BEEP
19 == 0x13 GUI button click
Definition: sound_type.h:58
FILLRECT_CHECKER
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
Definition: gfx_type.h:288
SetResize
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:993
Window::OnInvalidateData
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
Definition: window_gui.h:741
TILE_SIZE
static const uint TILE_SIZE
Tile size in world coordinates.
Definition: tile_type.h:13
Window::RaiseButtons
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
Definition: window.cpp:584
CommandContainer
Structure for buffering the build command when selecting a station to join.
Definition: command_type.h:479
newgrf_airport.h
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:52
newgrf_callbacks.h
DrawString
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition: gfx.cpp:642
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:46
ANIMCURSOR_DEMOLISH
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
Definition: sprites.h:1498
WWT_PUSHARROWBTN
@ WWT_PUSHARROWBTN
Normal push-button (no toggle button) with arrow caption.
Definition: widget_type.h:106
WindowNumber
int32 WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:711
_selected_airport_index
static int _selected_airport_index
the index of the selected airport in the current class or -1
Definition: airport_gui.cpp:36
DIR_W
@ DIR_W
West.
Definition: direction_type.h:32
WC_BUILD_STATION
@ WC_BUILD_STATION
Build station; Window numbers:
Definition: window_type.h:389
ViewportPlaceMethod
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
Definition: viewport_type.h:96
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:629
Window::OnHotkey
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
Definition: window.cpp:621
AirportSpec
Defines the data structure for an airport.
Definition: newgrf_airport.h:98
Window::Window
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition: window.cpp:1799
SetDParam
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings_func.h:196
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:971
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1107
WID_AP_AIRPORT_SPRITE
@ WID_AP_AIRPORT_SPRITE
A visual display of the airport currently selected.
Definition: airport_widget.h:27
GetStringBoundingBox
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:888
DrawStringMultiLine
int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
Definition: gfx.cpp:787
WID_AT_DEMOLISH
@ WID_AT_DEMOLISH
Demolish button.
Definition: airport_widget.h:16
CBID_AIRPORT_ADDITIONAL_TEXT
@ CBID_AIRPORT_ADDITIONAL_TEXT
This callback is called from airport list.
Definition: newgrf_callbacks.h:248
SpriteID
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition: gfx_type.h:17
WID_AP_LAYOUT_INCREASE
@ WID_AP_LAYOUT_INCREASE
Increase the layout number.
Definition: airport_widget.h:26
WindowDesc
High level window description.
Definition: window_gui.h:168
window_gui.h
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:463
AirportSpec::rotation
const Direction * rotation
the rotation of each tiletable
Definition: newgrf_airport.h:101
EconomySettings::station_noise_level
bool station_noise_level
build new airports when the town noise level is still within accepted limits
Definition: settings_type.h:519
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition: window_gui.h:156
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:317
CommandCost
Common return value for all commands.
Definition: command_type.h:23
AirportSpec::Get
static const AirportSpec * Get(byte type)
Retrieve airport spec for the given airport.
Definition: newgrf_airport.cpp:97
Scrollbar::GetCount
uint16 GetCount() const
Gets the number of elements in the list.
Definition: widget_type.h:653
tilehighlight_func.h
ClientSettings::sound
SoundSettings sound
sound effect settings
Definition: settings_type.h:596
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1789
AirportSpec::num_table
byte num_table
number of elements in the table
Definition: newgrf_airport.h:102
DIR_E
@ DIR_E
East.
Definition: direction_type.h:28
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:993
WD_FRAMERECT_LEFT
@ WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
Definition: window_gui.h:62
HT_DIAGONAL
@ HT_DIAGONAL
Also allow 'diagonal rectangles'. Only usable in combination with HT_RECT or HT_POINT.
Definition: tilehighlight_type.h:28
SB
static T SB(T &x, const uint8 s, const uint8 n, const U d)
Set n bits in x starting at bit s to d.
Definition: bitmath_func.hpp:58
WD_PAR_VSEP_NORMAL
@ WD_PAR_VSEP_NORMAL
Normal amount of vertical space between two paragraphs of text.
Definition: window_gui.h:139
WD_FRAMERECT_RIGHT
@ WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
Definition: window_gui.h:63
ES_NOT_HANDLED
@ ES_NOT_HANDLED
The passed event is not handled.
Definition: window_type.h:719
WD_FRAMERECT_BOTTOM
@ WD_FRAMERECT_BOTTOM
Offset at bottom to draw the frame rectangular area.
Definition: window_gui.h:65
CommandCost::Failed
bool Failed() const
Did this command fail?
Definition: command_type.h:159
NWidgetBase
Baseclass for nested widgets.
Definition: widget_type.h:126
ShowDropDownList
void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, uint width, bool auto_width, bool instant_close)
Show a drop down list.
Definition: dropdown.cpp:443
VpSelectTilesWithMethod
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
Definition: viewport.cpp:3139
BuildAirportWindow::OnRealtimeTick
void OnRealtimeTick(uint delta_ms) override
Called periodically.
Definition: airport_gui.cpp:562
SetMatrixDataTip
static NWidgetPart SetMatrixDataTip(uint8 cols, uint8 rows, StringID tip)
Widget part function for setting the data and tooltip of WWT_MATRIX widgets.
Definition: widget_type.h:1125
NewGRFClass
Struct containing information relating to NewGRF classes for stations and airports.
Definition: newgrf_class.h:19
dropdown_type.h
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:53
BuildAirportWindow::preview_sprite
SpriteID preview_sprite
Cached airport preview sprite.
Definition: airport_gui.cpp:226
GameSettings::economy
EconomySettings economy
settings to change the economy
Definition: settings_type.h:585
Window::SetWidgetDisabledState
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:386
Window::parent
Window * parent
Parent window.
Definition: window_gui.h:332
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:46
DropDownListStringItem
Common string list item.
Definition: dropdown_type.h:39
safeguards.h
HandlePlacePushButton
bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, HighLightStyle mode)
This code is shared for the majority of the pushbuttons.
Definition: main_gui.cpp:61
CBID_AIRPORT_LAYOUT_NAME
@ CBID_AIRPORT_LAYOUT_NAME
Called to determine text to show as airport layout name.
Definition: newgrf_callbacks.h:251
NUM_AIRPORTS
@ NUM_AIRPORTS
Maximal number of airports in total.
Definition: airport.h:41
DrawSprite
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Definition: gfx.cpp:1041
GetStringMultiLineBoundingBox
Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion)
Calculate string bounding box for multi-line strings.
Definition: gfx.cpp:753
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
PlaceAirport
static void PlaceAirport(TileIndex tile)
Place an airport.
Definition: airport_gui.cpp:55
stdafx.h
PC_BLACK
static const uint8 PC_BLACK
Black palette colour.
Definition: gfx_func.h:190
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:307
GUISettings::link_terraform_toolbar
bool link_terraform_toolbar
display terraform toolbar when displaying rail, road, water and airport toolbars
Definition: settings_type.h:115
GfxFillRect
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
Definition: gfx.cpp:116
AirportSpec::IsAvailable
bool IsAvailable() const
Check whether this airport is available to build.
Definition: newgrf_airport.cpp:124
viewport_func.h
NWidgetBase::current_y
uint current_y
Current vertical size (after resizing).
Definition: widget_type.h:187
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:37
CanBuildVehicleInfrastructure
bool CanBuildVehicleInfrastructure(VehicleType type, byte subtype)
Check whether we can build infrastructure for the given vehicle type.
Definition: vehicle.cpp:1821
ShowSelectStationIfNeeded
void ShowSelectStationIfNeeded(const CommandContainer &cmd, TileArea ta)
Show the station selection window when needed.
Definition: station_gui.cpp:2464
AirportSpec::size_x
byte size_x
size of airport in x direction
Definition: newgrf_airport.h:105
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:976
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:67
DrawStationCoverageAreaText
int DrawStationCoverageAreaText(int left, int right, int top, StationCoverageType sct, int rad, bool supplies)
Calculates and draws the accepted or supplied cargo around the selected tile(s)
Definition: station_gui.cpp:54
Scrollbar::SetCapacity
void SetCapacity(int capacity)
Set the capacity of visible elements.
Definition: widget_type.h:726
SCT_ALL
@ SCT_ALL
Draw all cargoes.
Definition: station_gui.h:22
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
BuildAirToolbarWindow::OnPlaceMouseUp
void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) override
The user has dragged over the map when the tile highlight mode has been set.
Definition: airport_gui.cpp:149
SoundSettings::confirm
bool confirm
Play sound effect on successful constructions or other actions.
Definition: settings_type.h:208
WID_AP_BTN_DONTHILIGHT
@ WID_AP_BTN_DONTHILIGHT
Don't show the coverage button.
Definition: airport_widget.h:31
vehicle_func.h
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1092
WC_SELECT_STATION
@ WC_SELECT_STATION
Select station (when joining stations); Window numbers:
Definition: window_type.h:234
Clamp
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition: math_func.hpp:77
strings_func.h
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:82
AirportSpec::enabled
bool enabled
Entity still available (by default true). Newgrf can disable it, though.
Definition: newgrf_airport.h:117
terraform_gui.h
BuildAirportWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: airport_gui.cpp:412
NEW_AIRPORT_OFFSET
@ NEW_AIRPORT_OFFSET
Number of the first newgrf airport.
Definition: airport.h:39
NWidgetBase::pos_x
int pos_x
Horizontal position of top-left corner of the widget in the window.
Definition: widget_type.h:189
AirportClassID
AirportClassID
List of default airport classes.
Definition: newgrf_airport.h:68
WIDGET_LIST_END
static const int WIDGET_LIST_END
indicate the end of widgets' list for vararg functions
Definition: widget_type.h:20
BuildAirToolbarWindow::OnPlaceObjectAbort
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
Definition: airport_gui.cpp:156
FONT_HEIGHT_NORMAL
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:165
WC_SCEN_LAND_GEN
@ WC_SCEN_LAND_GEN
Landscape generation (in Scenario Editor); Window numbers:
Definition: window_type.h:441
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1207
WID_AP_LAYOUT_DECREASE
@ WID_AP_LAYOUT_DECREASE
Decrease the layout number.
Definition: airport_widget.h:25
geometry_func.hpp
WID_AP_EXTRA_TEXT
@ WID_AP_EXTRA_TEXT
Additional text about the airport.
Definition: airport_widget.h:28
CloseWindowByClass
void CloseWindowByClass(WindowClass cls)
Close all windows of a given class.
Definition: window.cpp:1188
CMD_BUILD_AIRPORT
@ CMD_BUILD_AIRPORT
build an airport
Definition: command_type.h:205
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1010
APC_MAX
@ APC_MAX
maximum number of airport classes
Definition: newgrf_airport.h:74
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:48
airport_widget.h
BuildAirToolbarWindow::Close
void Close() override
Hide the window and all its child windows, and mark them for a later deletion.
Definition: airport_gui.cpp:79
Window::SetWidgetsDisabledState
void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets,...)
Sets the enabled/disabled status of a list of widgets.
Definition: window.cpp:547
Window::IsWidgetLowered
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
Definition: window_gui.h:487
EventState
EventState
State of handling an event.
Definition: window_type.h:717
HT_RECT
@ HT_RECT
rectangle (stations, depots, ...)
Definition: tilehighlight_type.h:21
Scrollbar::GetPosition
uint16 GetPosition() const
Gets the position of the first visible element in the list.
Definition: widget_type.h:671
BuildAirToolbarWindow::OnPlaceObject
void OnPlaceObject(Point pt, TileIndex tile) override
The user clicked some place on the map when a tile highlight mode has been set.
Definition: airport_gui.cpp:129
BuildAirportWindow::SelectFirstAvailableAirport
void SelectFirstAvailableAirport(bool change_class)
Select the first available airport.
Definition: airport_gui.cpp:524
TRANSPORT_AIR
@ TRANSPORT_AIR
Transport through air.
Definition: transport_type.h:30
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1776
NWID_SPACER
@ NWID_SPACER
Invisible widget that takes some space.
Definition: widget_type.h:77
company_func.h
PickerWindowBase
Base class for windows opened from a toolbar.
Definition: window_gui.h:917
SetViewportCatchmentStation
void SetViewportCatchmentStation(const Station *st, bool sel)
Select or deselect station for coverage area highlight.
Definition: viewport.cpp:3524
BuildAirToolbarWindow::OnPlaceDrag
void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override
The user is dragging over the map when the tile highlight mode has been set.
Definition: airport_gui.cpp:144
Window::top
int top
y position of top edge of the window
Definition: window_gui.h:313
TileArea
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
Definition: tilearea_type.h:102
BuildAirportWindow::OnDropdownSelect
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Definition: airport_gui.cpp:554
WD_MATRIX_BOTTOM
@ WD_MATRIX_BOTTOM
Offset at bottom of a matrix cell.
Definition: window_gui.h:81
window_func.h
SoundSettings::click_beep
bool click_beep
Beep on a random selection of buttons.
Definition: settings_type.h:209
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:378
NewGRFClass::Get
static NewGRFClass * Get(Tid cls_id)
Get a particular class.
Definition: newgrf_class_func.h:103
ShowTerraformToolbar
Window * ShowTerraformToolbar(Window *link)
Show the toolbar for terraforming in the game.
Definition: terraform_gui.cpp:357
SetPIP
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1169
SND_1F_CONSTRUCTION_OTHER
@ SND_1F_CONSTRUCTION_OTHER
29 == 0x1D Construction: other (non-water, non-rail, non-bridge)
Definition: sound_type.h:68
CloseWindowById
void CloseWindowById(WindowClass cls, WindowNumber number, bool force)
Close a window by its class and window number (if it is open).
Definition: window.cpp:1176
NWidgetBase::pos_y
int pos_y
Vertical position of top-left corner of the widget in the window.
Definition: widget_type.h:190
BuildAirToolbarWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: airport_gui.cpp:109
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1076
WID_AP_AIRPORT_LIST
@ WID_AP_AIRPORT_LIST
List of airports.
Definition: airport_widget.h:22
gui.h
BuildAirportWindow
Definition: airport_gui.cpp:225
Window
Data structure for an opened window.
Definition: window_gui.h:279
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition: pool_type.hpp:326
WD_MATRIX_LEFT
@ WD_MATRIX_LEFT
Offset at left of a matrix cell.
Definition: window_gui.h:78
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:636
BuildAirportWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: airport_gui.cpp:375
Swap
static void Swap(T &a, T &b)
Type safe swap operation.
Definition: math_func.hpp:215
APC_BEGIN
@ APC_BEGIN
Lowest valid airport class id.
Definition: newgrf_airport.h:69
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:47
BuildAirportWindow::BuildAirportClassDropDown
static DropDownList BuildAirportClassDropDown()
Build a dropdown list of available airport classes.
Definition: airport_gui.cpp:231
AWV_INCREASE
@ AWV_INCREASE
Arrow to the right or in case of RTL to the left.
Definition: widget_type.h:36
Window::DisableWidget
void DisableWidget(byte widget_index)
Sets a widget to disabled.
Definition: window_gui.h:396
NWidgetBase::current_x
uint current_x
Current horizontal size (after resizing).
Definition: widget_type.h:186
BuildAirToolbarWindow
Airport build toolbar window handler.
Definition: airport_gui.cpp:68
ResetObjectToPlace
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
Definition: viewport.cpp:3423
Window::SetWidgetLoweredState
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:447
AirportSpec::catchment
byte catchment
catchment area of this airport
Definition: newgrf_airport.h:108
station_gui.h
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:53
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition: settings_type.h:593
Scrollbar::SetPosition
bool SetPosition(int position)
Sets the position of the first visible element.
Definition: widget_type.h:742
AWV_DECREASE
@ AWV_DECREASE
Arrow to the left or in case of RTL to the right.
Definition: widget_type.h:35
WWT_DROPDOWN
@ WWT_DROPDOWN
Drop down list.
Definition: widget_type.h:68
GUISettings::persistent_buildingtools
bool persistent_buildingtools
keep the building tools active after usage
Definition: settings_type.h:162
station_type.h
StationSettings::modified_catchment
bool modified_catchment
different-size catchment areas
Definition: settings_type.h:547
Hotkey
All data for a single hotkey.
Definition: hotkeys.h:22
hotkeys.h
ResizeWindow
void ResizeWindow(Window *w, int delta_x, int delta_y, bool clamp_to_screen)
Resize the window.
Definition: window.cpp:2069
Window::Close
virtual void Close()
Hide the window and all its child windows, and mark them for a later deletion.
Definition: window.cpp:1092
WID_AP_LAYOUT_NUM
@ WID_AP_LAYOUT_NUM
Current number of the layout.
Definition: airport_widget.h:24
GUIPlaceProcDragXY
bool GUIPlaceProcDragXY(ViewportDragDropSelectionProcess proc, TileIndex start_tile, TileIndex end_tile)
A central place to handle all X_AND_Y dragged GUI functions.
Definition: terraform_gui.cpp:107