41 static void ShowBuildAirportPicker(
Window *parent);
47 if (result.
Failed())
return;
61 SB(p2, 16, 16, INVALID_STATION);
92 if (!gui_scope)
return;
102 ShowBuildAirportPicker(
this);
103 this->last_user_action = widget;
109 this->last_user_action = widget;
119 switch (this->last_user_action) {
128 default: NOT_REACHED();
168 static Hotkey airtoolbar_hotkeys[] = {
175 static const NWidgetPart _nested_air_toolbar_widgets[] = {
192 _nested_air_toolbar_widgets,
lengthof(_nested_air_toolbar_widgets),
193 &BuildAirToolbarWindow::hotkeys
208 return AllocateWindowDescFront<BuildAirToolbarWindow>(&_air_toolbar_desc,
TRANSPORT_AIR);
221 for (uint i = 0; i < AirportClass::GetClassCount(); i++) {
252 bool selectFirstAirport =
true;
258 selectFirstAirport =
false;
259 this->UpdateSelectSize();
263 if (selectFirstAirport) this->SelectFirstAvailableAirport(
true);
283 if (
string != STR_UNDEFINED) {
286 SetDParam(0, STR_STATION_BUILD_AIRPORT_LAYOUT_NAME);
301 for (uint i = 0; i < AirportClass::GetClassCount(); i++) {
305 d.width += padding.width;
306 d.height += padding.height;
320 size->height = 5 * this->line_height;
328 for (byte layout = 0; layout < as->
num_table; layout++) {
329 SpriteID sprite = GetCustomAirportSprite(as, layout);
344 for (byte layout = 0; layout < as->
num_table; layout++) {
346 if (
string == STR_UNDEFINED)
continue;
372 y += this->line_height;
378 if (this->preview_sprite != 0) {
380 DrawSprite(this->preview_sprite, COMPANY_SPRITE_COLOUR(
_local_company), (r.left + r.right - d.width) / 2, (r.top + r.bottom - d.height) / 2);
388 if (
string != STR_UNDEFINED) {
432 void SelectOtherAirport(
int airport_index)
437 this->UpdateSelectSize();
441 void UpdateSelectSize()
474 if (num_clicked >= this->vscroll->
GetCount())
break;
476 if (as->
IsAvailable()) this->SelectOtherAirport(num_clicked);
486 this->UpdateSelectSize();
491 this->UpdateSelectSize();
497 this->UpdateSelectSize();
512 for (uint i = 0; i < sel_apclass->
GetSpecCount(); i++) {
515 this->SelectOtherAirport(i);
528 this->SelectOtherAirport(i);
535 this->SelectOtherAirport(-1);
543 this->SelectFirstAvailableAirport(
false);
552 static const NWidgetPart _nested_build_airport_widgets[] = {
579 SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
581 SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
590 WDP_AUTO,
"build_station_air", 0, 0,
593 _nested_build_airport_widgets,
lengthof(_nested_build_airport_widgets)
601 void InitializeAirportGui()
EventState
State of handling an event.
This callback is called from airport list.
Functions related to OTTD's strings.
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it...
static void Swap(T &a, T &b)
Type safe swap operation.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition of stuff that is very close to a company, like the company struct itself.
bool IsAvailable() const
Check whether this airport is available to build.
Select station (when joining stations); Window numbers:
bool link_terraform_toolbar
display terraform toolbar when displaying rail, road, water and airport toolbars
ResizeInfo resize
Resize information.
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
AirportClassID
List of default airport classes.
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...
void CheckRedrawStationCoverage(const Window *w)
Check whether we need to redraw the station coverage text.
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Offset at right of a matrix cell.
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
byte size_y
size of airport in y direction
Window * parent
Parent window.
All data for a single hotkey.
High level window description.
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
Landscape generation (in Scenario Editor); Window numbers:
EconomySettings economy
settings to change the economy
void DrawWidgets() const
Paint all widgets of a window.
bool station_show_coverage
whether to highlight coverage area
Hotkey related functions.
uint GetSpecCount() const
Get the number of allocated specs within the class.
void ShowSelectStationIfNeeded(const CommandContainer &cmd, TileArea ta)
Show the station selection window when needed.
Contains enums and function declarations connected with stations GUI.
Offset at top to draw the frame rectangular area.
Normal amount of vertical space between two paragraphs of text.
The passed event is not handled.
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
void ShowDropDownList(Window *w, const DropDownList *list, int selected, int button, uint width, bool auto_width, bool instant_close)
Show a drop down list.
Point size
Size, in tile "units", of the white/red selection area.
Functions related to vehicles.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
int top
y position of top edge of the window
static AirportClassID _selected_airport_class
the currently visible airport class
Offset at top of a matrix cell.
bool CanBuildVehicleInfrastructure(VehicleType type)
Check whether we can build infrastructure for the given vehicle type.
static byte _selected_airport_layout
selected airport layout number.
Lowest valid airport class id.
void DisableWidget(byte widget_index)
Sets a widget to disabled.
bool persistent_buildingtools
keep the building tools active after usage
virtual void OnTick()
Called once per (game) tick.
Common return value for all commands.
static T max(const T a, const T b)
Returns the maximum of two values.
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
Callbacks that NewGRFs could implement.
StationSettings station
settings related to station management
static const uint TILE_SIZE
Tile size in world coordinates.
static DropDownList * BuildAirportClassDropDown()
Build a dropdown list of available airport classes.
Direction
Defines the 8 directions on the map.
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.
Functions, definitions and such used only by the GUI.
NewGRF handling of airports.
T * Append(uint to_add=1)
Append an item and return it.
CompanyByte _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Functions related to (drawing on) viewports.
Data structure for an opened window.
bool _ctrl_pressed
Is Ctrl pressed?
virtual void SetStringParameters(int widget) const
Initialize string parameters for a widget.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
byte catchment
catchment area of this airport
Maximal number of airports in total.
byte noise_level
noise that this airport generates
Struct containing information relating to NewGRF classes for stations and airports.
Types related to stations.
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
NWidgetBase ** nested_array
Array of pointers into the tree. Do not access directly, use Window::GetWidget() instead.
Offset at bottom of a matrix cell.
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)
This window is used for construction; close it whenever changing company.
SoundSettings sound
sound effect settings
Number of the first newgrf airport.
const Direction * rotation
the rotation of each tiletable
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
Structure for buffering the build command when selecting a station to join.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Simple vector template class, with automatic delete.
ClientSettings _settings_client
The current settings for this game.
maximum number of airport classes
Definition of base types and functions in a cross-platform compatible way.
A number of safeguards to prevent using unsafe methods.
List of hotkeys for a window.
rectangle (stations, depots, ...)
byte num_table
number of elements in the table
Called to determine text to show as airport layout name.
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
Offset at left of a matrix cell.
static const AirportSpec * Get(byte type)
Retrieve airport spec for the given airport.
Offset at bottom to draw the frame rectangular area.
void SelectFirstAvailableAirport(bool change_class)
Select the first available airport.
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.
Build station; Window numbers:
Catchment for all stations with "modified catchment" disabled.
#define lengthof(x)
Return the length of an fixed size array.
Window * ShowBuildAirToolbar()
Open the build airport toolbar window.
Types related to the drop down widget.
static EventState AirportToolbarGlobalHotkeys(int hotkey)
Handler for global hotkeys of the BuildAirToolbarWindow.
Also allow 'diagonal rectangles'. Only usable in combination with HT_RECT or HT_POINT.
Functions related to sound.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
void DeleteWindowByClass(WindowClass cls)
Delete all windows of a given class.
bool Failed() const
Did this command fail?
static const uint8 PC_BLACK
Black palette colour.
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Build toolbar; Window numbers:
virtual void OnPaint()
The window must be repainted.
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion)
Calculate string bounding box for multi-line strings.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Draw only every second pixel, used for greying-out.
No window, redirects to WC_MAIN_WINDOW.
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
Functions related to companies.
GUISettings gui
settings related to the GUI
Align toward the toolbar.
bool station_noise_level
build new airports when the town noise level is still within accepted limits
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
uint32 TileIndex
The index/ID of a Tile.
bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, HighLightStyle mode)
This code is shared for the majority of the pushbuttons.
StringID name
name of this airport
bool modified_catchment
different-size catchment areas
byte size_x
size of airport in x direction
static NewGRFClass * Get(Tid cls_id)
Get a particular class.
bool confirm
Play sound effect on succesful constructions or other actions.
Non-water non-rail construction.
Coordinates of a point in 2D.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-NULL) Titem.
Offset at right to draw the frame rectangular area.
bool enabled
Entity still available (by default true). Newgrf can disable it, though.
#define CMD_MSG(x)
Used to combine a StringID with the command.
int32 WindowNumber
Number to differentiate different windows of the same class.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows)...
Specification of a rectangle with absolute coordinates of all edges.
WindowNumber window_number
Window number within the window class.
Functions related to tile highlights.
Window functions not directly related to making/drawing windows.
Defines the data structure for an airport.
Find a place automatically.
GUI functions that shouldn't be here.
static void PlaceAirport(TileIndex tile)
Place an airport.
StringID GetAirportTextCallback(const AirportSpec *as, byte layout, uint16 callback)
Get a custom text for the airport.
void ResizeWindow(Window *w, int delta_x, int delta_y, bool clamp_to_screen)
Resize the window.
SpriteID preview_sprite
Cached airport preview sprite.
Dimensions (a width and height) of a rectangle in 2D.
virtual void OnDropdownSelect(int widget, int index)
A dropdown option associated to this window has been selected.
bool click_beep
Beep on a random selection of buttons.
Offset at left to draw the frame rectangular area.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Base class for windows opened from a toolbar.
static int _selected_airport_index
the index of the selected airport in the current class or -1
AutoDeleteSmallVector< const DropDownListItem *, 4 > DropDownList
A drop down list is a collection of drop down list items.
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.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.