OpenTTD Source: src/airport_gui.cpp Source File

OpenTTD Source 14.1

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 "economy_func.h"
12 #include "window_gui.h"
13 #include "station_gui.h"
14 #include "terraform_gui.h"
15 #include "sound_func.h"
16 #include "window_func.h"
17 #include "strings_func.h"
18 #include "viewport_func.h"
19 #include "company_func.h"
20 #include "tilehighlight_func.h"
21 #include "company_base.h"
22 #include "station_type.h"
23 #include "newgrf_airport.h"
24 #include "newgrf_callbacks.h"
25 #include "widgets/dropdown_type.h"
26 #include "core/geometry_func.hpp"
27 #include "hotkeys.h"
28 #include "vehicle_func.h"
29 #include "gui.h"
30 #include "command_func.h"
31 #include "airport_cmd.h"
32 #include "station_cmd.h"
33 #include "zoom_func.h"
34 #include "timer/timer.h"
35 #include "timer/timer_game_calendar.h"
36
37 #include "widgets/airport_widget.h"
38
39 #include "safeguards.h"
40
41
42 static AirportClassID _selected_airport_class;
43 static int _selected_airport_index;
44 static byte _selected_airport_layout;
45
46 static void ShowBuildAirportPicker(Window *parent);
47
48 SpriteID GetCustomAirportSprite(const AirportSpec *as, byte layout);
49
50 void CcBuildAirport(Commands, const CommandCost &result, TileIndex tile)
51 {
52 if (result.Failed()) return;
53
54 if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile);
55 if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
56 }
57
62 static void PlaceAirport(TileIndex tile)
63 {
64 if (_selected_airport_index == -1) return;
65
66 byte airport_type = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index)->GetIndex();
67 byte layout = _selected_airport_layout;
68 bool adjacent = _ctrl_pressed;
69
70 auto proc = [=](bool test, StationID to_join) -> bool {
71 if (test) {
72 return Command<CMD_BUILD_AIRPORT>::Do(CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_AIRPORT>()), tile, airport_type, layout, INVALID_STATION, adjacent).Succeeded();
73 } else {
74 return Command<CMD_BUILD_AIRPORT>::Post(STR_ERROR_CAN_T_BUILD_AIRPORT_HERE, CcBuildAirport, tile, airport_type, layout, to_join, adjacent);
75 }
76 };
77
78 ShowSelectStationIfNeeded(TileArea(tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE), proc);
79 }
80
82 struct BuildAirToolbarWindow : Window {
83 int last_user_action; // Last started user action.
84
85 BuildAirToolbarWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
86 {
87 this->InitNested(window_number);
88 this->OnInvalidateData();
89 if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
90 this->last_user_action = INVALID_WID_AT;
91 }
92
93 void Close([[maybe_unused]] int data = 0) override
94 {
95 if (this->IsWidgetLowered(WID_AT_AIRPORT)) SetViewportCatchmentStation(nullptr, true);
96 if (_settings_client.gui.link_terraform_toolbar) CloseWindowById(WC_SCEN_LAND_GEN, 0, false);
97 this->Window::Close();
98 }
99
105 void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
106 {
107 if (!gui_scope) return;
108
109 bool can_build = CanBuildVehicleInfrastructure(VEH_AIRCRAFT);
110 this->SetWidgetDisabledState(WID_AT_AIRPORT, !can_build);
111 if (!can_build) {
112 CloseWindowById(WC_BUILD_STATION, TRANSPORT_AIR);
113
114 /* Show in the tooltip why this button is disabled. */
115 this->GetWidget<NWidgetCore>(WID_AT_AIRPORT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
116 } else {
117 this->GetWidget<NWidgetCore>(WID_AT_AIRPORT)->SetToolTip(STR_TOOLBAR_AIRCRAFT_BUILD_AIRPORT_TOOLTIP);
118 }
119 }
120
121 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
122 {
123 switch (widget) {
124 case WID_AT_AIRPORT:
125 if (HandlePlacePushButton(this, WID_AT_AIRPORT, SPR_CURSOR_AIRPORT, HT_RECT)) {
126 ShowBuildAirportPicker(this);
127 this->last_user_action = widget;
128 }
129 break;
130
131 case WID_AT_DEMOLISH:
132 HandlePlacePushButton(this, WID_AT_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT | HT_DIAGONAL);
133 this->last_user_action = widget;
134 break;
135
136 default: break;
137 }
138 }
139
140
141 void OnPlaceObject([[maybe_unused]] Point pt, TileIndex tile) override
142 {
143 switch (this->last_user_action) {
144 case WID_AT_AIRPORT:
145 PlaceAirport(tile);
146 break;
147
148 case WID_AT_DEMOLISH:
149 PlaceProc_DemolishArea(tile);
150 break;
151
152 default: NOT_REACHED();
153 }
154 }
155
156 void OnPlaceDrag(ViewportPlaceMethod select_method, [[maybe_unused]] ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt) override
157 {
158 VpSelectTilesWithMethod(pt.x, pt.y, select_method);
159 }
160
161 void OnPlaceMouseUp([[maybe_unused]] ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt, TileIndex start_tile, TileIndex end_tile) override
162 {
163 if (pt.x != -1 && select_proc == DDSP_DEMOLISH_AREA) {
164 GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
165 }
166 }
167
168 void OnPlaceObjectAbort() override
169 {
170 if (this->IsWidgetLowered(WID_AT_AIRPORT)) SetViewportCatchmentStation(nullptr, true);
171
172 this->RaiseButtons();
173
174 CloseWindowById(WC_BUILD_STATION, TRANSPORT_AIR);
175 CloseWindowById(WC_SELECT_STATION, 0);
176 }
177
183 static EventState AirportToolbarGlobalHotkeys(int hotkey)
184 {
185 if (_game_mode != GM_NORMAL) return ES_NOT_HANDLED;
186 Window *w = ShowBuildAirToolbar();
187 if (w == nullptr) return ES_NOT_HANDLED;
188 return w->OnHotkey(hotkey);
189 }
190
191 static inline HotkeyList hotkeys{"airtoolbar", {
192 Hotkey('1', "airport", WID_AT_AIRPORT),
193 Hotkey('2', "demolish", WID_AT_DEMOLISH),
194 }, AirportToolbarGlobalHotkeys};
195 };
196
197 static constexpr NWidgetPart _nested_air_toolbar_widgets[] = {
198 NWidget(NWID_HORIZONTAL),
199 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
200 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_TOOLBAR_AIRCRAFT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
201 NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
202 EndContainer(),
203 NWidget(NWID_HORIZONTAL),
204 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),
205 NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetMinimalSize(4, 22), SetFill(1, 1), EndContainer(),
206 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_AT_DEMOLISH), SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
207 EndContainer(),
208 };
209
210 static WindowDesc _air_toolbar_desc(__FILE__, __LINE__,
211 WDP_ALIGN_TOOLBAR, "toolbar_air", 0, 0,
212 WC_BUILD_TOOLBAR, WC_NONE,
213 WDF_CONSTRUCTION,
214 std::begin(_nested_air_toolbar_widgets), std::end(_nested_air_toolbar_widgets),
215 &BuildAirToolbarWindow::hotkeys
216 );
217
225 Window *ShowBuildAirToolbar()
226 {
227 if (!Company::IsValidID(_local_company)) return nullptr;
228
229 CloseWindowByClass(WC_BUILD_TOOLBAR);
230 return AllocateWindowDescFront<BuildAirToolbarWindow>(&_air_toolbar_desc, TRANSPORT_AIR);
231 }
232
233 class BuildAirportWindow : public PickerWindowBase {
234 SpriteID preview_sprite;
235 int line_height;
236 Scrollbar *vscroll;
237
239 static DropDownList BuildAirportClassDropDown()
240 {
241 DropDownList list;
242
243 for (uint i = 0; i < AirportClass::GetClassCount(); i++) {
244 list.push_back(std::make_unique<DropDownListStringItem>(AirportClass::Get((AirportClassID)i)->name, i, false));
245 }
246
247 return list;
248 }
249
250 public:
251 BuildAirportWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
252 {
253 this->CreateNestedTree();
254
255 this->vscroll = this->GetScrollbar(WID_AP_SCROLLBAR);
256 this->vscroll->SetCapacity(5);
257 this->vscroll->SetPosition(0);
258
259 this->FinishInitNested(TRANSPORT_AIR);
260
261 this->SetWidgetLoweredState(WID_AP_BTN_DONTHILIGHT, !_settings_client.gui.station_show_coverage);
262 this->SetWidgetLoweredState(WID_AP_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage);
263 this->OnInvalidateData();
264
265 /* Ensure airport class is valid (changing NewGRFs). */
266 _selected_airport_class = Clamp(_selected_airport_class, APC_BEGIN, (AirportClassID)(AirportClass::GetClassCount() - 1));
267 const AirportClass *ac = AirportClass::Get(_selected_airport_class);
268 this->vscroll->SetCount(ac->GetSpecCount());
269
270 /* Ensure the airport index is valid for this class (changing NewGRFs). */
271 _selected_airport_index = Clamp(_selected_airport_index, -1, ac->GetSpecCount() - 1);
272
273 /* Only when no valid airport was selected, we want to select the first airport. */
274 bool selectFirstAirport = true;
275 if (_selected_airport_index != -1) {
276 const AirportSpec *as = ac->GetSpec(_selected_airport_index);
277 if (as->IsAvailable()) {
278 /* Ensure the airport layout is valid. */
279 _selected_airport_layout = Clamp(_selected_airport_layout, 0, as->num_table - 1);
280 selectFirstAirport = false;
281 this->UpdateSelectSize();
282 }
283 }
284
285 if (selectFirstAirport) this->SelectFirstAvailableAirport(true);
286 }
287
288 void Close([[maybe_unused]] int data = 0) override
289 {
290 CloseWindowById(WC_SELECT_STATION, 0);
291 this->PickerWindowBase::Close();
292 }
293
294 void SetStringParameters(WidgetID widget) const override
295 {
296 switch (widget) {
297 case WID_AP_CLASS_DROPDOWN:
298 SetDParam(0, AirportClass::Get(_selected_airport_class)->name);
299 break;
300
301 case WID_AP_LAYOUT_NUM:
302 SetDParam(0, STR_EMPTY);
303 if (_selected_airport_index != -1) {
304 const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index);
305 StringID string = GetAirportTextCallback(as, _selected_airport_layout, CBID_AIRPORT_LAYOUT_NAME);
306 if (string != STR_UNDEFINED) {
307 SetDParam(0, string);
308 } else if (as->num_table > 1) {
309 SetDParam(0, STR_STATION_BUILD_AIRPORT_LAYOUT_NAME);
310 SetDParam(1, _selected_airport_layout + 1);
311 }
312 }
313 break;
314
315 default: break;
316 }
317 }
318
319 void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
320 {
321 switch (widget) {
322 case WID_AP_CLASS_DROPDOWN: {
323 Dimension d = {0, 0};
324 for (uint i = 0; i < AirportClass::GetClassCount(); i++) {
325 d = maxdim(d, GetStringBoundingBox(AirportClass::Get((AirportClassID)i)->name));
326 }
327 d.width += padding.width;
328 d.height += padding.height;
329 *size = maxdim(*size, d);
330 break;
331 }
332
333 case WID_AP_AIRPORT_LIST: {
334 for (int i = 0; i < NUM_AIRPORTS; i++) {
335 const AirportSpec *as = AirportSpec::Get(i);
336 if (!as->enabled) continue;
337
338 size->width = std::max(size->width, GetStringBoundingBox(as->name).width + padding.width);
339 }
340
341 this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height;
342 size->height = 5 * this->line_height;
343 break;
344 }
345
346 case WID_AP_AIRPORT_SPRITE:
347 for (int i = 0; i < NUM_AIRPORTS; i++) {
348 const AirportSpec *as = AirportSpec::Get(i);
349 if (!as->enabled) continue;
350 for (byte layout = 0; layout < as->num_table; layout++) {
351 SpriteID sprite = GetCustomAirportSprite(as, layout);
352 if (sprite != 0) {
353 Dimension d = GetSpriteSize(sprite);
354 d.width += WidgetDimensions::scaled.framerect.Horizontal();
355 d.height += WidgetDimensions::scaled.framerect.Vertical();
356 *size = maxdim(d, *size);
357 }
358 }
359 }
360 break;
361
362 case WID_AP_EXTRA_TEXT:
363 for (int i = NEW_AIRPORT_OFFSET; i < NUM_AIRPORTS; i++) {
364 const AirportSpec *as = AirportSpec::Get(i);
365 if (!as->enabled) continue;
366 for (byte layout = 0; layout < as->num_table; layout++) {
367 StringID string = GetAirportTextCallback(as, layout, CBID_AIRPORT_ADDITIONAL_TEXT);
368 if (string == STR_UNDEFINED) continue;
369
370 Dimension d = GetStringMultiLineBoundingBox(string, *size);
371 *size = maxdim(d, *size);
372 }
373 }
374 break;
375
376 default: break;
377 }
378 }
379
380 void DrawWidget(const Rect &r, WidgetID widget) const override
381 {
382 switch (widget) {
383 case WID_AP_AIRPORT_LIST: {
384 Rect row = r.WithHeight(this->line_height).Shrink(WidgetDimensions::scaled.bevel);
385 Rect text = r.WithHeight(this->line_height).Shrink(WidgetDimensions::scaled.matrix);
386 AirportClass *apclass = AirportClass::Get(_selected_airport_class);
387 for (uint i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < apclass->GetSpecCount(); i++) {
388 const AirportSpec *as = apclass->GetSpec(i);
389 if (!as->IsAvailable()) {
390 GfxFillRect(row, PC_BLACK, FILLRECT_CHECKER);
391 }
392 DrawString(text, as->name, ((int)i == _selected_airport_index) ? TC_WHITE : TC_BLACK);
393 row = row.Translate(0, this->line_height);
394 text = text.Translate(0, this->line_height);
395 }
396 break;
397 }
398
399 case WID_AP_AIRPORT_SPRITE:
400 if (this->preview_sprite != 0) {
401 Dimension d = GetSpriteSize(this->preview_sprite);
402 DrawSprite(this->preview_sprite, COMPANY_SPRITE_COLOUR(_local_company), CenterBounds(r.left, r.right, d.width), CenterBounds(r.top, r.bottom, d.height));
403 }
404 break;
405
406 case WID_AP_EXTRA_TEXT:
407 if (_selected_airport_index != -1) {
408 const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index);
409 StringID string = GetAirportTextCallback(as, _selected_airport_layout, CBID_AIRPORT_ADDITIONAL_TEXT);
410 if (string != STR_UNDEFINED) {
411 DrawStringMultiLine(r.left, r.right, r.top, r.bottom, string, TC_BLACK);
412 }
413 }
414 break;
415 }
416 }
417
418 void OnPaint() override
419 {
420 this->DrawWidgets();
421
422 Rect r = this->GetWidget<NWidgetBase>(WID_AP_ACCEPTANCE)->GetCurrentRect();
423 int top = r.top;
424
425 if (_selected_airport_index != -1) {
426 const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index);
427 int rad = _settings_game.station.modified_catchment ? as->catchment : (uint)CA_UNMODIFIED;
428
429 /* only show the station (airport) noise, if the noise option is activated */
430 if (_settings_game.economy.station_noise_level) {
431 /* show the noise of the selected airport */
432 SetDParam(0, as->noise_level);
433 DrawString(r.left, r.right, top, STR_STATION_BUILD_NOISE);
434 top += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
435 }
436
437 if (_settings_game.economy.infrastructure_maintenance) {
438 Money monthly = _price[PR_INFRASTRUCTURE_AIRPORT] * as->maintenance_cost >> 3;
439 SetDParam(0, monthly * 12);
440 DrawString(r.left, r.right, top, TimerGameEconomy::UsingWallclockUnits() ? STR_STATION_BUILD_INFRASTRUCTURE_COST_PERIOD : STR_STATION_BUILD_INFRASTRUCTURE_COST_YEAR);
441 top += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
442 }
443
444 /* strings such as 'Size' and 'Coverage Area' */
445 top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, false) + WidgetDimensions::scaled.vsep_normal;
446 top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, true);
447 }
448
449 /* Resize background if the window is too small.
450 * Never make the window smaller to avoid oscillating if the size change affects the acceptance.
451 * (This is the case, if making the window bigger moves the mouse into the window.) */
452 if (top > r.bottom) {
453 ResizeWindow(this, 0, top - r.bottom, false);
454 }
455 }
456
457 void SelectOtherAirport(int airport_index)
458 {
459 _selected_airport_index = airport_index;
460 _selected_airport_layout = 0;
461
462 this->UpdateSelectSize();
463 this->SetDirty();
464 }
465
466 void UpdateSelectSize()
467 {
468 if (_selected_airport_index == -1) {
469 SetTileSelectSize(1, 1);
470 this->DisableWidget(WID_AP_LAYOUT_DECREASE);
471 this->DisableWidget(WID_AP_LAYOUT_INCREASE);
472 } else {
473 const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index);
474 int w = as->size_x;
475 int h = as->size_y;
476 Direction rotation = as->rotation[_selected_airport_layout];
477 if (rotation == DIR_E || rotation == DIR_W) Swap(w, h);
478 SetTileSelectSize(w, h);
479
480 this->preview_sprite = GetCustomAirportSprite(as, _selected_airport_layout);
481
482 this->SetWidgetDisabledState(WID_AP_LAYOUT_DECREASE, _selected_airport_layout == 0);
483 this->SetWidgetDisabledState(WID_AP_LAYOUT_INCREASE, _selected_airport_layout + 1 >= as->num_table);
484
485 int rad = _settings_game.station.modified_catchment ? as->catchment : (uint)CA_UNMODIFIED;
486 if (_settings_client.gui.station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
487 }
488 }
489
490 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
491 {
492 switch (widget) {
493 case WID_AP_CLASS_DROPDOWN:
494 ShowDropDownList(this, BuildAirportClassDropDown(), _selected_airport_class, WID_AP_CLASS_DROPDOWN);
495 break;
496
497 case WID_AP_AIRPORT_LIST: {
498 int num_clicked = this->vscroll->GetScrolledRowFromWidget(pt.y, this, widget, 0, this->line_height);
499 if (num_clicked == INT_MAX) break;
500 const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(num_clicked);
501 if (as->IsAvailable()) this->SelectOtherAirport(num_clicked);
502 break;
503 }
504
505 case WID_AP_BTN_DONTHILIGHT: case WID_AP_BTN_DOHILIGHT:
506 _settings_client.gui.station_show_coverage = (widget != WID_AP_BTN_DONTHILIGHT);
507 this->SetWidgetLoweredState(WID_AP_BTN_DONTHILIGHT, !_settings_client.gui.station_show_coverage);
508 this->SetWidgetLoweredState(WID_AP_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage);
509 this->SetDirty();
510 if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
511 this->UpdateSelectSize();
512 SetViewportCatchmentStation(nullptr, true);
513 break;
514
515 case WID_AP_LAYOUT_DECREASE:
516 _selected_airport_layout--;
517 this->UpdateSelectSize();
518 this->SetDirty();
519 break;
520
521 case WID_AP_LAYOUT_INCREASE:
522 _selected_airport_layout++;
523 this->UpdateSelectSize();
524 this->SetDirty();
525 break;
526 }
527 }
528
534 void SelectFirstAvailableAirport(bool change_class)
535 {
536 /* First try to select an airport in the selected class. */
537 AirportClass *sel_apclass = AirportClass::Get(_selected_airport_class);
538 for (uint i = 0; i < sel_apclass->GetSpecCount(); i++) {
539 const AirportSpec *as = sel_apclass->GetSpec(i);
540 if (as->IsAvailable()) {
541 this->SelectOtherAirport(i);
542 return;
543 }
544 }
545 if (change_class) {
546 /* If that fails, select the first available airport
547 * from the first class where airports are available. */
548 for (AirportClassID j = APC_BEGIN; j < APC_MAX; j++) {
549 AirportClass *apclass = AirportClass::Get(j);
550 for (uint i = 0; i < apclass->GetSpecCount(); i++) {
551 const AirportSpec *as = apclass->GetSpec(i);
552 if (as->IsAvailable()) {
553 _selected_airport_class = j;
554 this->vscroll->SetCount(apclass->GetSpecCount());
555 this->SelectOtherAirport(i);
556 return;
557 }
558 }
559 }
560 }
561 /* If all airports are unavailable, select nothing. */
562 this->SelectOtherAirport(-1);
563 }
564
565 void OnDropdownSelect(WidgetID widget, int index) override
566 {
567 if (widget == WID_AP_CLASS_DROPDOWN) {
568 _selected_airport_class = (AirportClassID)index;
569 this->vscroll->SetCount(AirportClass::Get(_selected_airport_class)->GetSpecCount());
570 this->SelectFirstAvailableAirport(false);
571 }
572 }
573
574 void OnRealtimeTick([[maybe_unused]] uint delta_ms) override
575 {
576 CheckRedrawStationCoverage(this);
577 }
578
579 IntervalTimer<TimerGameCalendar> yearly_interval = {{TimerGameCalendar::YEAR, TimerGameCalendar::Priority::NONE}, [this](auto) {
580 this->InvalidateData();
581 }};
582 };
583
584 static constexpr NWidgetPart _nested_build_airport_widgets[] = {
585 NWidget(NWID_HORIZONTAL),
586 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
587 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_AIRPORT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
588 EndContainer(),
589 NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
590 NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0), SetPadding(WidgetDimensions::unscaled.picker),
591 NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_picker, 0),
592 NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_AIRPORT_CLASS_LABEL, STR_NULL), SetFill(1, 0),
593 NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_AP_CLASS_DROPDOWN), SetFill(1, 0), SetDataTip(STR_JUST_STRING, STR_STATION_BUILD_AIRPORT_TOOLTIP),
594 NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_AP_AIRPORT_SPRITE), SetFill(1, 0),
595 NWidget(NWID_HORIZONTAL),
596 NWidget(WWT_MATRIX, COLOUR_GREY, WID_AP_AIRPORT_LIST), SetFill(1, 0), SetMatrixDataTip(1, 5, STR_STATION_BUILD_AIRPORT_TOOLTIP), SetScrollbar(WID_AP_SCROLLBAR),
597 NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_AP_SCROLLBAR),
598 EndContainer(),
599 NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_ORIENTATION, STR_NULL), SetFill(1, 0),
600 NWidget(NWID_HORIZONTAL),
601 NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_AP_LAYOUT_DECREASE), SetMinimalSize(12, 0), SetDataTip(AWV_DECREASE, STR_NULL),
602 NWidget(WWT_LABEL, COLOUR_GREY, WID_AP_LAYOUT_NUM), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_JUST_STRING1, STR_NULL),
603 NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_AP_LAYOUT_INCREASE), SetMinimalSize(12, 0), SetDataTip(AWV_INCREASE, STR_NULL),
604 EndContainer(),
605 NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_AP_EXTRA_TEXT), SetFill(1, 0), SetMinimalSize(150, 0),
606 NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0),
607 NWidget(NWID_HORIZONTAL), SetPIP(14, 0, 14), SetPIPRatio(1, 0, 1),
608 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
609 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_AP_BTN_DONTHILIGHT), SetMinimalSize(60, 12), SetFill(1, 0),
610 SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
611 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_AP_BTN_DOHILIGHT), SetMinimalSize(60, 12), SetFill(1, 0),
612 SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
613 EndContainer(),
614 EndContainer(),
615 EndContainer(),
616 NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_AP_ACCEPTANCE), SetResize(0, 1), SetFill(1, 0), SetMinimalTextLines(2, WidgetDimensions::unscaled.vsep_normal),
617 EndContainer(),
618 EndContainer(),
619 };
620
621 static WindowDesc _build_airport_desc(__FILE__, __LINE__,
622 WDP_AUTO, nullptr, 0, 0,
623 WC_BUILD_STATION, WC_BUILD_TOOLBAR,
624 WDF_CONSTRUCTION,
625 std::begin(_nested_build_airport_widgets), std::end(_nested_build_airport_widgets)
626 );
627
628 static void ShowBuildAirportPicker(Window *parent)
629 {
630 new BuildAirportWindow(&_build_airport_desc, parent);
631 }
632
633 void InitializeAirportGui()
634 {
635 _selected_airport_class = APC_BEGIN;
636 _selected_airport_index = -1;
637 }
VEH_AIRCRAFT
@ VEH_AIRCRAFT
Aircraft vehicle type.
Definition: vehicle_type.h:27
SetFill
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1143
SetTileSelectSize
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
Definition: viewport.cpp:2536
DDSP_DEMOLISH_AREA
@ DDSP_DEMOLISH_AREA
Clear area.
Definition: viewport_type.h:108
CA_UNMODIFIED
@ CA_UNMODIFIED
Catchment for all stations with "modified catchment" disabled.
Definition: station_type.h:82
CloseWindowByClass
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
Definition: window.cpp:1153
sound_func.h
TileHighlightData::size
Point size
Size, in tile "units", of the white/red selection area.
Definition: tilehighlight_type.h:48
GUISettings::station_show_coverage
bool station_show_coverage
whether to highlight coverage area
Definition: settings_type.h:189
WC_BUILD_TOOLBAR
@ WC_BUILD_TOOLBAR
Build toolbar; Window numbers:
Definition: window_type.h:73
Direction
Direction
Defines the 8 directions on the map.
Definition: direction_type.h:24
WID_AP_LAYOUT_NUM
@ WID_AP_LAYOUT_NUM
Current number of the layout.
Definition: airport_widget.h:26
GameSettings::station
StationSettings station
settings related to station management
Definition: settings_type.h:629
HotkeyList
List of hotkeys for a window.
Definition: hotkeys.h:37
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:30
command_func.h
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition: window_gui.h:68
airport_cmd.h
Swap
constexpr void Swap(T &a, T &b)
Type safe swap operation.
Definition: math_func.hpp:283
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:68
_selected_airport_layout
static byte _selected_airport_layout
selected airport layout number.
Definition: airport_gui.cpp:44
WDF_CONSTRUCTION
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Definition: window_gui.h:197
ShowBuildAirToolbar
Window * ShowBuildAirToolbar()
Open the build airport toolbar window.
Definition: airport_gui.cpp:225
Rect::Shrink
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Definition: geometry_type.hpp:98
_selected_airport_class
static AirportClassID _selected_airport_class
the currently visible airport class
Definition: airport_gui.cpp:42
company_base.h
WID_AP_LAYOUT_DECREASE
@ WID_AP_LAYOUT_DECREASE
Decrease the layout number.
Definition: airport_widget.h:27
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:107
CommandFlagsToDCFlags
static constexpr DoCommandFlag CommandFlagsToDCFlags(CommandFlags cmd_flags)
Extracts the DC flags needed for DoCommand from the flags returned by GetCommandFlags.
Definition: command_func.h:58
timer_game_calendar.h
AirportSpec::size_y
byte size_y
size of airport in y direction
Definition: newgrf_airport.h:108
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:63
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
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
WWT_IMGBTN
@ WWT_IMGBTN
(Toggle) Button with image
Definition: widget_type.h:54
AirportSpec::name
StringID name
name of this airport
Definition: newgrf_airport.h:113
WWT_LABEL
@ WWT_LABEL
Centered label.
Definition: widget_type.h:59
CloseWindowById
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
Definition: window.cpp:1141
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:210
IntervalTimer< TimerGameCalendar >
WDP_ALIGN_TOOLBAR
@ WDP_ALIGN_TOOLBAR
Align toward the toolbar.
Definition: window_gui.h:143
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:77
maxdim
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Definition: geometry_func.cpp:22
Window::Close
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
Definition: window.cpp:1048
WWT_MATRIX
@ WWT_MATRIX
Grid of rows and columns.
Definition: widget_type.h:61
AirportSpec::noise_level
byte noise_level
noise that this airport generates
Definition: newgrf_airport.h:109
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1153
PlaceProc_DemolishArea
void PlaceProc_DemolishArea(TileIndex tile)
Start a drag for demolishing an area.
Definition: terraform_gui.cpp:150
SetMatrixDataTip
constexpr NWidgetPart SetMatrixDataTip(uint8_t cols, uint8_t rows, StringID tip)
Widget part function for setting the data and tooltip of WWT_MATRIX widgets.
Definition: widget_type.h:1176
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:37
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:294
HandlePlacePushButton
bool HandlePlacePushButton(Window *w, WidgetID widget, CursorID cursor, HighLightStyle mode)
This code is shared for the majority of the pushbuttons.
Definition: main_gui.cpp:63
zoom_func.h
TILE_SIZE
static const uint TILE_SIZE
Tile size in world coordinates.
Definition: tile_type.h:15
Window::RaiseButtons
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
Definition: window.cpp:526
newgrf_airport.h
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:54
newgrf_callbacks.h
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget tree.
Definition: widget_type.h:50
ANIMCURSOR_DEMOLISH
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
Definition: sprites.h:1500
TimerGameEconomy::UsingWallclockUnits
static bool UsingWallclockUnits(bool newgame=false)
Check if we are using wallclock units.
Definition: timer_game_economy.cpp:97
RectPadding::Vertical
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Definition: geometry_type.hpp:69
WWT_PUSHARROWBTN
@ WWT_PUSHARROWBTN
Normal push-button (no toggle button) with arrow caption.
Definition: widget_type.h:112
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
_selected_airport_index
static int _selected_airport_index
the index of the selected airport in the current class or -1
Definition: airport_gui.cpp:43
DIR_W
@ DIR_W
West.
Definition: direction_type.h:32
WC_BUILD_STATION
@ WC_BUILD_STATION
Build station; Window numbers:
Definition: window_type.h:397
economy_func.h
ViewportPlaceMethod
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
Definition: viewport_type.h:88
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:680
Window::GetScrollbar
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
Definition: window.cpp:315
Window::OnHotkey
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
Definition: window.cpp:566
AirportSpec
Defines the data structure for an airport.
Definition: newgrf_airport.h:100
Rect::WithHeight
Rect WithHeight(int height, bool end=false) const
Copy Rect and set its height.
Definition: geometry_type.hpp:211
Window::Window
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition: window.cpp:1757
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:1040
ResizeWindow
void ResizeWindow(Window *w, int delta_x, int delta_y, bool clamp_to_screen, bool schedule_resize)
Resize the window.
Definition: window.cpp:2027
WID_AP_AIRPORT_SPRITE
@ WID_AP_AIRPORT_SPRITE
A visual display of the airport currently selected.
Definition: airport_widget.h:29
Scrollbar::GetPosition
uint16_t GetPosition() const
Gets the position of the first visible element in the list.
Definition: widget_type.h:722
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
WindowDesc
High level window description.
Definition: window_gui.h:153
WidgetID
int WidgetID
Widget ID.
Definition: window_type.h:18
RectPadding::Horizontal
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
Definition: geometry_type.hpp:63
WID_AP_BTN_DOHILIGHT
@ WID_AP_BTN_DOHILIGHT
Show the coverage button.
Definition: airport_widget.h:33
window_gui.h
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:510
SetPadding
constexpr NWidgetPart SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left)
Widget part function for setting additional space around a widget.
Definition: widget_type.h:1190
AirportSpec::rotation
const Direction * rotation
the rotation of each tiletable
Definition: newgrf_airport.h:103
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:556
SetResize
constexpr NWidgetPart SetResize(int16_t dx, int16_t dy)
Widget part function for setting the resize step.
Definition: widget_type.h:1088
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition: window_gui.h:141
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:308
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:54
WID_AP_SCROLLBAR
@ WID_AP_SCROLLBAR
Scrollbar of the list.
Definition: airport_widget.h:25
WID_AP_LAYOUT_INCREASE
@ WID_AP_LAYOUT_INCREASE
Increase the layout number.
Definition: airport_widget.h:28
tilehighlight_func.h
ClientSettings::sound
SoundSettings sound
sound effect settings
Definition: settings_type.h:638
WindowNumber
int32_t WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:732
FS_NORMAL
@ FS_NORMAL
Index of the normal font in the font tables.
Definition: gfx_type.h:203
Rect::Translate
Rect Translate(int x, int y) const
Copy and translate Rect by x,y pixels.
Definition: geometry_type.hpp:174
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1747
SetScrollbar
constexpr NWidgetPart SetScrollbar(WidgetID index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1246
AirportSpec::num_table
byte num_table
number of elements in the table
Definition: newgrf_airport.h:104
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:941
HT_DIAGONAL
@ HT_DIAGONAL
Also allow 'diagonal rectangles'. Only usable in combination with HT_RECT or HT_POINT.
Definition: tilehighlight_type.h:28
station_cmd.h
ES_NOT_HANDLED
@ ES_NOT_HANDLED
The passed event is not handled.
Definition: window_type.h:740
CommandCost::Failed
bool Failed() const
Did this command fail?
Definition: command_type.h:171
PickerWindowBase::Close
void Close([[maybe_unused]] int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
Definition: window.cpp:3504
VpSelectTilesWithMethod
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
Definition: viewport.cpp:3201
NewGRFClass
Struct containing information relating to NewGRF classes for stations and airports.
Definition: newgrf_class.h:20
dropdown_type.h
ShowSelectStationIfNeeded
void ShowSelectStationIfNeeded(TileArea ta, StationPickerCmdProc proc)
Show the station selection window when needed.
Definition: station_gui.cpp:2455
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:55
BuildAirportWindow::preview_sprite
SpriteID preview_sprite
Cached airport preview sprite.
Definition: airport_gui.cpp:234
GameSettings::economy
EconomySettings economy
settings to change the economy
Definition: settings_type.h:627
Window::parent
Window * parent
Parent window.
Definition: window_gui.h:322
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1260
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:50
safeguards.h
timer.h
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
AirportSpec::maintenance_cost
uint16_t maintenance_cost
maintenance cost multiplier
Definition: newgrf_airport.h:117
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:1003
GetStringMultiLineBoundingBox
Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion)
Calculate string bounding box for multi-line strings.
Definition: gfx.cpp:737
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
Scrollbar::SetCapacity
void SetCapacity(size_t capacity)
Set the capacity of visible elements.
Definition: widget_type.h:776
CenterBounds
int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
Definition: gfx_func.h:166
PlaceAirport
static void PlaceAirport(TileIndex tile)
Place an airport.
Definition: airport_gui.cpp:62
stdafx.h
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:296
GUISettings::link_terraform_toolbar
bool link_terraform_toolbar
display terraform toolbar when displaying rail, road, water and airport toolbars
Definition: settings_type.h:142
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:113
SpriteID
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition: gfx_type.h:17
Window::InvalidateData
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
Definition: window.cpp:3144
AirportSpec::IsAvailable
bool IsAvailable() const
Check whether this airport is available to build.
Definition: newgrf_airport.cpp:81
viewport_func.h
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:45
CanBuildVehicleInfrastructure
bool CanBuildVehicleInfrastructure(VehicleType type, byte subtype)
Check whether we can build infrastructure for the given vehicle type.
Definition: vehicle.cpp:1915
Window::SetWidgetLoweredState
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:441
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:79
WID_AP_CLASS_DROPDOWN
@ WID_AP_CLASS_DROPDOWN
Dropdown of airport classes.
Definition: airport_widget.h:23
Scrollbar::GetScrolledRowFromWidget
int GetScrolledRowFromWidget(int clickpos, const Window *const w, WidgetID widget, int padding=0, int line_height=-1) const
Compute the row of a scrolled widget that a user clicked in.
Definition: widget.cpp:2267
WID_AP_EXTRA_TEXT
@ WID_AP_EXTRA_TEXT
Additional text about the airport.
Definition: airport_widget.h:30
WidgetDimensions::unscaled
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition: window_gui.h:67
AirportSpec::size_x
byte size_x
size of airport in x direction
Definition: newgrf_airport.h:107
Window::SetWidgetDisabledState
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:381
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:937
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:71
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:52
EconomySettings::infrastructure_maintenance
bool infrastructure_maintenance
enable monthly maintenance fee for owner infrastructure
Definition: settings_type.h:559
SCT_ALL
@ SCT_ALL
Draw all cargoes.
Definition: station_gui.h:23
Window::IsWidgetLowered
bool IsWidgetLowered(WidgetID widget_index) const
Gets the lowered state of a widget.
Definition: window_gui.h:491
SoundSettings::confirm
bool confirm
Play sound effect on successful constructions or other actions.
Definition: settings_type.h:240
DrawStringMultiLine
int DrawStringMultiLine(int left, int right, int top, int bottom, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
Definition: gfx.cpp:771
WID_AP_ACCEPTANCE
@ WID_AP_ACCEPTANCE
Acceptance info.
Definition: airport_widget.h:34
vehicle_func.h
WC_SELECT_STATION
@ WC_SELECT_STATION
Select station (when joining stations); Window numbers:
Definition: window_type.h:242
Window::CreateNestedTree
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1724
strings_func.h
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:86
AirportSpec::enabled
bool enabled
Entity still available (by default true). Newgrf can disable it, though.
Definition: newgrf_airport.h:119
terraform_gui.h
WID_AT_AIRPORT
@ WID_AT_AIRPORT
Build airport button.
Definition: airport_widget.h:15
BuildAirportWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: airport_gui.cpp:418
NEW_AIRPORT_OFFSET
@ NEW_AIRPORT_OFFSET
Number of the first newgrf airport.
Definition: airport.h:39
AirportClassID
AirportClassID
List of default airport classes.
Definition: newgrf_airport.h:70
BuildAirportWindow::OnRealtimeTick
void OnRealtimeTick([[maybe_unused]] uint delta_ms) override
Called periodically.
Definition: airport_gui.cpp:574
BuildAirToolbarWindow::OnPlaceObjectAbort
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
Definition: airport_gui.cpp:168
Window::DisableWidget
void DisableWidget(WidgetID widget_index)
Sets a widget to disabled.
Definition: window_gui.h:391
SetPIP
constexpr NWidgetPart SetPIP(uint8_t pre, uint8_t inter, uint8_t post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1222
WC_SCEN_LAND_GEN
@ WC_SCEN_LAND_GEN
Landscape generation (in Scenario Editor); Window numbers:
Definition: window_type.h:449
SetDParam
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings.cpp:104
geometry_func.hpp
Window::OnInvalidateData
virtual void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true)
Some data on this window has become invalid.
Definition: window_gui.h:780
APC_MAX
@ APC_MAX
maximum number of airport classes
Definition: newgrf_airport.h:76
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:52
airport_widget.h
WidgetDimensions::vsep_normal
int vsep_normal
Normal vertical spacing.
Definition: window_gui.h:60
Scrollbar::SetCount
void SetCount(size_t num)
Sets the number of elements in the list.
Definition: widget_type.h:762
EventState
EventState
State of handling an event.
Definition: window_type.h:738
HT_RECT
@ HT_RECT
rectangle (stations, depots, ...)
Definition: tilehighlight_type.h:21
BuildAirportWindow::SelectFirstAvailableAirport
void SelectFirstAvailableAirport(bool change_class)
Select the first available airport.
Definition: airport_gui.cpp:534
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:1734
PC_BLACK
static const uint8_t PC_BLACK
Black palette colour.
Definition: palette_func.h:55
ShowDropDownList
void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, bool instant_close, bool persist)
Show a drop down list.
Definition: dropdown.cpp:374
company_func.h
PickerWindowBase
Base class for windows opened from a toolbar.
Definition: window_gui.h:980
SetViewportCatchmentStation
void SetViewportCatchmentStation(const Station *st, bool sel)
Select or deselect station for coverage area highlight.
Definition: viewport.cpp:3603
Window::top
int top
y position of top edge of the window
Definition: window_gui.h:304
TileArea
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
Definition: tilearea_type.h:102
CommandHelper
Definition: command_func.h:93
WID_AP_AIRPORT_LIST
@ WID_AP_AIRPORT_LIST
List of airports.
Definition: airport_widget.h:24
window_func.h
SoundSettings::click_beep
bool click_beep
Beep on a random selection of buttons.
Definition: settings_type.h:241
GetCharacterHeight
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition: fontcache.cpp:78
NewGRFClass::Get
static NewGRFClass * Get(Tid cls_id)
Get a particular class.
Definition: newgrf_class_func.h:98
ShowTerraformToolbar
Window * ShowTerraformToolbar(Window *link)
Show the toolbar for terraforming in the game.
Definition: terraform_gui.cpp:367
SetMinimalSize
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1099
SetPIPRatio
constexpr NWidgetPart SetPIPRatio(uint8_t ratio_pre, uint8_t ratio_inter, uint8_t ratio_post)
Widget part function for setting a pre/inter/post ratio.
Definition: widget_type.h:1234
SND_1F_CONSTRUCTION_OTHER
@ SND_1F_CONSTRUCTION_OTHER
29 == 0x1D Construction: other (non-water, non-rail, non-bridge)
Definition: sound_type.h:68
OverflowSafeInt< int64_t >
DrawString
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition: gfx.cpp:654
BuildAirToolbarWindow::OnInvalidateData
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
Definition: airport_gui.cpp:105
gui.h
BuildAirportWindow
Definition: airport_gui.cpp:233
BuildAirToolbarWindow::AirportToolbarGlobalHotkeys
static EventState AirportToolbarGlobalHotkeys(int hotkey)
Handler for global hotkeys of the BuildAirToolbarWindow.
Definition: airport_gui.cpp:183
Window
Data structure for an opened window.
Definition: window_gui.h:267
Commands
Commands
List of commands.
Definition: command_type.h:187
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:328
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:731
Clamp
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition: math_func.hpp:79
SetDataTip
constexpr NWidgetPart SetDataTip(uint32_t data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1164
SetMinimalTextLines
constexpr NWidgetPart SetMinimalTextLines(uint8_t lines, uint8_t spacing, FontSize size=FS_NORMAL)
Widget part function for setting the minimal text lines.
Definition: widget_type.h:1111
APC_BEGIN
@ APC_BEGIN
Lowest valid airport class id.
Definition: newgrf_airport.h:71
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:75
BuildAirportWindow::BuildAirportClassDropDown
static DropDownList BuildAirportClassDropDown()
Build a dropdown list of available airport classes.
Definition: airport_gui.cpp:239
AWV_INCREASE
@ AWV_INCREASE
Arrow to the right or in case of RTL to the left.
Definition: widget_type.h:34
GetAirportTextCallback
StringID GetAirportTextCallback(const AirportSpec *as, byte layout, uint16_t callback)
Get a custom text for the airport.
Definition: newgrf_airport.cpp:273
BuildAirToolbarWindow
Airport build toolbar window handler.
Definition: airport_gui.cpp:82
WidgetDimensions::framerect
RectPadding framerect
Standard padding inside many panels.
Definition: window_gui.h:42
ResetObjectToPlace
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
Definition: viewport.cpp:3483
AirportSpec::catchment
byte catchment
catchment area of this airport
Definition: newgrf_airport.h:110
station_gui.h
GetStringBoundingBox
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:848
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:57
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition: settings_type.h:635
WID_AP_BTN_DONTHILIGHT
@ WID_AP_BTN_DONTHILIGHT
Don't show the coverage button.
Definition: airport_widget.h:32
Scrollbar::SetPosition
bool SetPosition(int position)
Sets the position of the first visible element.
Definition: widget_type.h:792
AWV_DECREASE
@ AWV_DECREASE
Arrow to the left or in case of RTL to the right.
Definition: widget_type.h:33
WWT_DROPDOWN
@ WWT_DROPDOWN
Drop down list.
Definition: widget_type.h:72
GUISettings::persistent_buildingtools
bool persistent_buildingtools
keep the building tools active after usage
Definition: settings_type.h:190
station_type.h
StationSettings::modified_catchment
bool modified_catchment
different-size catchment areas
Definition: settings_type.h:589
Hotkey
All data for a single hotkey.
Definition: hotkeys.h:21
hotkeys.h
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:111