Go to the documentation of this file.
44 static void ShowBuildAirportPicker(
Window *parent);
50 if (result.
Failed())
return;
68 auto proc = [=](
bool test, StationID to_join) ->
bool {
105 if (!gui_scope)
return;
115 this->GetWidget<NWidgetCore>(
WID_AT_AIRPORT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
117 this->GetWidget<NWidgetCore>(
WID_AT_AIRPORT)->SetToolTip(STR_TOOLBAR_AIRCRAFT_BUILD_AIRPORT_TOOLTIP);
126 ShowBuildAirportPicker(
this);
127 this->last_user_action = widget;
133 this->last_user_action = widget;
143 switch (this->last_user_action) {
152 default: NOT_REACHED();
194 static Hotkey airtoolbar_hotkeys[] = {
201 static const NWidgetPart _nested_air_toolbar_widgets[] = {
218 _nested_air_toolbar_widgets,
lengthof(_nested_air_toolbar_widgets),
219 &BuildAirToolbarWindow::hotkeys
234 return AllocateWindowDescFront<BuildAirToolbarWindow>(&_air_toolbar_desc,
TRANSPORT_AIR);
247 for (uint i = 0; i < AirportClass::GetClassCount(); i++) {
278 bool selectFirstAirport =
true;
284 selectFirstAirport =
false;
285 this->UpdateSelectSize();
310 if (
string != STR_UNDEFINED) {
313 SetDParam(0, STR_STATION_BUILD_AIRPORT_LAYOUT_NAME);
328 for (uint i = 0; i < AirportClass::GetClassCount(); i++) {
332 d.width += padding.width;
333 d.height += padding.height;
347 size->height = 5 * this->line_height;
355 for (
byte layout = 0; layout < as->
num_table; layout++) {
356 SpriteID sprite = GetCustomAirportSprite(as, layout);
371 for (
byte layout = 0; layout < as->
num_table; layout++) {
373 if (
string == STR_UNDEFINED)
continue;
394 for (uint i = this->vscroll->
GetPosition(); this->vscroll->IsVisible(i) && i < apclass->GetSpecCount(); i++) {
400 row = row.
Translate(0, this->line_height);
401 text = text.
Translate(0, this->line_height);
407 if (this->preview_sprite != 0) {
417 if (
string != STR_UNDEFINED) {
448 DrawString(r.left, r.right,
top, STR_STATION_BUILD_INFRASTRUCTURE_COST);
460 if (
top > r.bottom) {
465 void SelectOtherAirport(
int airport_index)
470 this->UpdateSelectSize();
474 void UpdateSelectSize()
506 int num_clicked = this->vscroll->
GetPosition() + (pt.y - this->GetWidget<NWidgetBase>(widget)->pos_y) / this->line_height;
507 if (num_clicked >= this->vscroll->
GetCount())
break;
509 if (as->
IsAvailable()) this->SelectOtherAirport(num_clicked);
519 this->UpdateSelectSize();
525 this->UpdateSelectSize();
531 this->UpdateSelectSize();
546 for (uint i = 0; i < sel_apclass->
GetSpecCount(); i++) {
549 this->SelectOtherAirport(i);
562 this->SelectOtherAirport(i);
569 this->SelectOtherAirport(-1);
586 static const NWidgetPart _nested_build_airport_widgets[] = {
613 SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
615 SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
624 WDP_AUTO,
"build_station_air", 0, 0,
627 _nested_build_airport_widgets,
lengthof(_nested_build_airport_widgets)
630 static void ShowBuildAirportPicker(
Window *parent)
635 void InitializeAirportGui()
@ VEH_AIRCRAFT
Aircraft vehicle type.
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
void Close() override
Hide the window and all its child windows, and mark them for a later deletion.
@ DDSP_DEMOLISH_AREA
Clear area.
@ CA_UNMODIFIED
Catchment for all stations with "modified catchment" disabled.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Point size
Size, in tile "units", of the white/red selection area.
bool station_show_coverage
whether to highlight coverage area
@ WC_BUILD_TOOLBAR
Build toolbar; Window numbers:
void Close() override
Hide the window and all its child windows, and mark them for a later deletion.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Direction
Defines the 8 directions on the map.
StationSettings station
settings related to station management
List of hotkeys for a window.
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.
Dimensions (a width and height) of a rectangle in 2D.
static byte _selected_airport_layout
selected airport layout number.
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Window * ShowBuildAirToolbar()
Open the build airport toolbar window.
Commands
List of commands.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
static AirportClassID _selected_airport_class
the currently visible airport class
static EventState AirportToolbarGlobalHotkeys(int hotkey)
Handler for global hotkeys of the BuildAirToolbarWindow.
StringID GetAirportTextCallback(const AirportSpec *as, byte layout, uint16 callback)
Get a custom text for the airport.
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it.
static constexpr DoCommandFlag CommandFlagsToDCFlags(CommandFlags cmd_flags)
Extracts the DC flags needed for DoCommand from the flags returned by GetCommandFlags.
byte size_y
size of airport in y direction
uint GetSpecCount() const
Get the number of allocated specs within the class.
void CheckRedrawStationCoverage(const Window *w)
Check whether we need to redraw the station coverage text.
StringID name
name of this airport
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
@ WDP_ALIGN_TOOLBAR
Align toward the toolbar.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
byte noise_level
noise that this airport generates
bool _ctrl_pressed
Is Ctrl pressed?
@ SND_15_BEEP
19 == 0x13 GUI button click
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
static const uint TILE_SIZE
Tile size in world coordinates.
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
ClientSettings _settings_client
The current settings for this game.
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.
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
int32 WindowNumber
Number to differentiate different windows of the same class.
static int _selected_airport_index
the index of the selected airport in the current class or -1
@ WC_BUILD_STATION
Build station; Window numbers:
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
Defines the data structure for an airport.
Rect WithHeight(int height, bool end=false) const
Copy Rect and set its height.
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
uint16 maintenance_cost
maintenance cost multiplier
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
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.
@ CBID_AIRPORT_ADDITIONAL_TEXT
This callback is called from airport list.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
High level window description.
const Direction * rotation
the rotation of each tiletable
bool station_noise_level
build new airports when the town noise level is still within accepted limits
@ WDP_AUTO
Find a place automatically.
ResizeInfo resize
Resize information.
Common return value for all commands.
static const AirportSpec * Get(byte type)
Retrieve airport spec for the given airport.
SoundSettings sound
sound effect settings
Rect Translate(int x, int y) const
Copy and translate Rect by x,y pixels.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
byte num_table
number of elements in the table
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
@ HT_DIAGONAL
Also allow 'diagonal rectangles'. Only usable in combination with HT_RECT or HT_POINT.
uint Horizontal() const
Get total horizontal padding of RectPadding.
@ ES_NOT_HANDLED
The passed event is not handled.
bool Failed() const
Did this command fail?
void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, uint width, bool auto_width, bool instant_close)
Show a drop down list.
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
void OnRealtimeTick(uint delta_ms) override
Called periodically.
Struct containing information relating to NewGRF classes for stations and airports.
void ShowSelectStationIfNeeded(TileArea ta, StationPickerCmdProc proc)
Show the station selection window when needed.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
SpriteID preview_sprite
Cached airport preview sprite.
EconomySettings economy
settings to change the economy
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Window * parent
Parent window.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, HighLightStyle mode)
This code is shared for the majority of the pushbuttons.
@ CBID_AIRPORT_LAYOUT_NAME
Called to determine text to show as airport layout name.
@ NUM_AIRPORTS
Maximal number of airports in total.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion)
Calculate string bounding box for multi-line strings.
Coordinates of a point in 2D.
static void PlaceAirport(TileIndex tile)
Place an airport.
static const uint8 PC_BLACK
Black palette colour.
WindowNumber window_number
Window number within the window class.
bool link_terraform_toolbar
display terraform toolbar when displaying rail, road, water and airport toolbars
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.
uint Vertical() const
Get total vertical padding of RectPadding.
bool IsAvailable() const
Check whether this airport is available to build.
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
bool CanBuildVehicleInfrastructure(VehicleType type, byte subtype)
Check whether we can build infrastructure for the given vehicle type.
byte size_x
size of airport in x direction
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
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)
bool infrastructure_maintenance
enable monthly maintenance fee for owner infrastructure
@ SCT_ALL
Draw all cargoes.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
bool confirm
Play sound effect on successful constructions or other actions.
@ WC_SELECT_STATION
Select station (when joining stations); Window numbers:
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
bool enabled
Entity still available (by default true). Newgrf can disable it, though.
void OnPaint() override
The window must be repainted.
@ NEW_AIRPORT_OFFSET
Number of the first newgrf airport.
AirportClassID
List of default airport classes.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
@ WC_SCEN_LAND_GEN
Landscape generation (in Scenario Editor); Window numbers:
void CloseWindowByClass(WindowClass cls)
Close all windows of a given class.
@ APC_MAX
maximum number of airport classes
void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets,...)
Sets the enabled/disabled status of a list of widgets.
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
EventState
State of handling an event.
@ HT_RECT
rectangle (stations, depots, ...)
void SelectFirstAvailableAirport(bool change_class)
Select the first available airport.
@ TRANSPORT_AIR
Transport through air.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Base class for windows opened from a toolbar.
void SetViewportCatchmentStation(const Station *st, bool sel)
Select or deselect station for coverage area highlight.
int top
y position of top edge of the window
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
static int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
bool click_beep
Beep on a random selection of buttons.
#define lengthof(x)
Return the length of an fixed size array.
static NewGRFClass * Get(Tid cls_id)
Get a particular class.
@ SND_1F_CONSTRUCTION_OTHER
29 == 0x1D Construction: other (non-water, non-rail, non-bridge)
void CloseWindowById(WindowClass cls, WindowNumber number, bool force)
Close a window by its class and window number (if it is open).
Data structure for an opened window.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
void DrawWidgets() const
Paint all widgets of a window.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
static void Swap(T &a, T &b)
Type safe swap operation.
@ APC_BEGIN
Lowest valid airport class id.
Specification of a rectangle with absolute coordinates of all edges.
static DropDownList BuildAirportClassDropDown()
Build a dropdown list of available airport classes.
void DisableWidget(byte widget_index)
Sets a widget to disabled.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
byte catchment
catchment area of this airport
GUISettings gui
settings related to the GUI
bool persistent_buildingtools
keep the building tools active after usage
bool modified_catchment
different-size catchment areas
All data for a single hotkey.
void ResizeWindow(Window *w, int delta_x, int delta_y, bool clamp_to_screen)
Resize the window.
virtual void Close()
Hide the window and all its child windows, and mark them for a later deletion.