OpenTTD Source: src/airport_gui.cpp File Reference

OpenTTD Source 15.3

Data Structures | Functions | Variables
airport_gui.cpp File Reference

The GUI for airports. More...

`#include "stdafx.h"`
`#include "economy_func.h"`
`#include "window_gui.h"`
`#include "station_gui.h"`
`#include "terraform_gui.h"`
`#include "sound_func.h"`
`#include "window_func.h"`
`#include "strings_func.h"`
`#include "viewport_func.h"`
`#include "company_func.h"`
`#include "tilehighlight_func.h"`
`#include "company_base.h"`
`#include "station_type.h"`
`#include "newgrf_airport.h"`
`#include "newgrf_badge_gui.h"`
`#include "newgrf_callbacks.h"`
`#include "dropdown_type.h"`
`#include "dropdown_func.h"`
`#include "core/geometry_func.hpp"`
`#include "hotkeys.h"`
`#include "vehicle_func.h"`
`#include "gui.h"`
`#include "command_func.h"`
`#include "airport_cmd.h"`
`#include "station_cmd.h"`
`#include "zoom_func.h"`
`#include "timer/timer.h"`
`#include "timer/timer_game_calendar.h"`
`#include "widgets/airport_widget.h"`
`#include "table/strings.h"`
`#include "safeguards.h"`

Go to the source code of this file.

## Data Structures
struct | BuildAirToolbarWindow
| Airport build toolbar window handler. More...
class | BuildAirportWindow

## Functions
static void | ShowBuildAirportPicker (Window *parent)
SpriteID | GetCustomAirportSprite (const AirportSpec *as, uint8_t layout)
void | CcBuildAirport (Commands, const CommandCost &result, TileIndex tile)
static void | PlaceAirport (TileIndex tile)
| Place an airport.
Window * | ShowBuildAirToolbar ()
| Open the build airport toolbar window.
void | InitializeAirportGui ()

## Variables
static AirportClassID | _selected_airport_class
| the currently visible airport class
static int | _selected_airport_index
| the index of the selected airport in the current class or -1
static uint8_t | _selected_airport_layout
| selected airport layout number.
static constexpr std::initializer_list< NWidgetPart > | _nested_air_toolbar_widgets
static WindowDesc | _air_toolbar_desc (WDP_MANUAL, "toolbar_air", 0, 0, WC_BUILD_TOOLBAR, WC_NONE, WindowDefaultFlag::Construction, _nested_air_toolbar_widgets, &BuildAirToolbarWindow::hotkeys)
static constexpr std::initializer_list< NWidgetPart > | _nested_build_airport_widgets
static WindowDesc | _build_airport_desc (WDP_AUTO, {}, 0, 0, WC_BUILD_STATION, WC_BUILD_TOOLBAR, WindowDefaultFlag::Construction, _nested_build_airport_widgets)

## Detailed Description

The GUI for airports.

Definition in file airport_gui.cpp.

## Function Documentation

## ◆ CcBuildAirport()

void CcBuildAirport | ( | Commands | ,
|  | const CommandCost & | result,
|  | TileIndex | tile
| ) |  |

Definition at line 54 of file airport_gui.cpp.

## ◆ GetCustomAirportSprite()

SpriteID GetCustomAirportSprite | ( | const AirportSpec * | as,
|  | uint8_t | layout
| ) |  |

Definition at line 258 of file newgrf_airport.cpp.

## ◆ InitializeAirportGui()

void InitializeAirportGui | ( |  | ) |

Definition at line 637 of file airport_gui.cpp.

## ◆ PlaceAirport()

static void PlaceAirport | ( | TileIndex | tile | ) |
| static

Place an airport.

Parameters

  tile | Position to put the new airport.

Definition at line 66 of file airport_gui.cpp.

References _ctrl_pressed, _selected_airport_class, _selected_airport_index, _selected_airport_layout, CommandFlagsToDCFlags(), NewGRFClass< Tspec, Tindex, Tmax >::Get(), NewGRFClass< Tspec, Tindex, Tmax >::GetSpec(), ShowSelectStationIfNeeded(), TileHighlightData::size, TILE_SIZE, Coord2D< T >::x, and Coord2D< T >::y.

Referenced by BuildAirToolbarWindow::OnPlaceObject().

## ◆ ShowBuildAirportPicker()

static void ShowBuildAirportPicker | ( | Window * | parent | ) |
| static

Definition at line 632 of file airport_gui.cpp.

## ◆ ShowBuildAirToolbar()

Window * ShowBuildAirToolbar | ( |  | ) |

Open the build airport toolbar window.

If the terraform toolbar is linked to the toolbar, that window is also opened.

Returns
  newly opened airport toolbar, or nullptr if the toolbar could not be opened.

Definition at line 233 of file airport_gui.cpp.

References _local_company, CloseWindowByClass(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::IsValidID(), TRANSPORT_AIR, and WC_BUILD_TOOLBAR.

Referenced by BuildAirToolbarWindow::AirportToolbarGlobalHotkeys(), MenuClickBuildAir(), and MainToolbarWindow::OnHotkey().

## Variable Documentation

## ◆ _nested_air_toolbar_widgets

constexpr std::initializer_list<NWidgetPart> _nested_air_toolbar_widgets
| staticconstexpr

Initial value:
= {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetStringTip(STR_TOOLBAR_AIRCRAFT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_AT_AIRPORT), SetFill(0, 1), SetToolbarMinimalSize(2), SetSpriteTip(SPR_IMG_AIRPORT, STR_TOOLBAR_AIRCRAFT_BUILD_AIRPORT_TOOLTIP),
NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetToolbarSpacerMinimalSize(), SetFill(1, 1), EndContainer(),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_AT_DEMOLISH), SetFill(0, 1), SetToolbarMinimalSize(1), SetSpriteTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
EndContainer(),
}
WID_AT_DEMOLISH
@ WID_AT_DEMOLISH
Demolish button.
Definition airport_widget.h:16
WID_AT_AIRPORT
@ WID_AT_AIRPORT
Build airport button.
Definition airport_widget.h:15
SetFill
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
Definition widget_type.h:1222
SetSpriteTip
constexpr NWidgetPart SetSpriteTip(SpriteID sprite, StringID tip={})
Widget part function for setting the sprite and tooltip.
Definition widget_type.h:1254
SetToolbarMinimalSize
constexpr NWidgetPart SetToolbarMinimalSize(int width)
Widget part function to setting the minimal size for a toolbar button.
Definition widget_type.h:1178
SetStringTip
constexpr NWidgetPart SetStringTip(StringID string, StringID tip={})
Widget part function for setting the string and tooltip.
Definition widget_type.h:1243
SetToolbarSpacerMinimalSize
constexpr NWidgetPart SetToolbarSpacerMinimalSize()
Widget part function to setting the minimal size for a toolbar spacer.
Definition widget_type.h:1168
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition widget_type.h:1232
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=INVALID_WIDGET)
Widget part function for starting a new 'real' widget.
Definition widget_type.h:1427
WWT_IMGBTN
@ WWT_IMGBTN
(Toggle) Button with image
Definition widget_type.h:41
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition widget_type.h:66
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition widget_type.h:39
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition widget_type.h:57
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition widget_type.h:52
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition widget_type.h:60

Definition at line 205 of file airport_gui.cpp.

## ◆ _nested_build_airport_widgets

constexpr std::initializer_list<NWidgetPart> _nested_build_airport_widgets
| staticconstexpr

Definition at line 588 of file airport_gui.cpp.

## ◆ _selected_airport_class

AirportClassID _selected_airport_class
| static

the currently visible airport class

Definition at line 46 of file airport_gui.cpp.

Referenced by BuildAirportWindow::DrawWidget(), BuildAirportWindow::GetWidgetString(), BuildAirportWindow::OnClick(), BuildAirportWindow::OnDropdownSelect(), BuildAirportWindow::OnPaint(), PlaceAirport(), and BuildAirportWindow::SelectFirstAvailableAirport().

## ◆ _selected_airport_index

int _selected_airport_index
| static

the index of the selected airport in the current class or -1

Definition at line 47 of file airport_gui.cpp.

Referenced by BuildAirportWindow::DrawWidget(), BuildAirportWindow::GetWidgetString(), BuildAirportWindow::OnPaint(), and PlaceAirport().

## ◆ _selected_airport_layout

uint8_t _selected_airport_layout
| static

selected airport layout number.

Definition at line 48 of file airport_gui.cpp.

Referenced by BuildAirportWindow::DrawWidget(), BuildAirportWindow::GetWidgetString(), BuildAirportWindow::OnClick(), and PlaceAirport().