OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
39 static void ShowBuildAirportPicker(
Window *parent);
45 if (result.
Failed())
return;
59 SB(p2, 16, 16, INVALID_STATION);
93 if (!gui_scope)
return;
103 this->GetWidget<NWidgetCore>(
WID_AT_AIRPORT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
105 this->GetWidget<NWidgetCore>(
WID_AT_AIRPORT)->SetToolTip(STR_TOOLBAR_AIRCRAFT_BUILD_AIRPORT_TOOLTIP);
114 ShowBuildAirportPicker(
this);
115 this->last_user_action = widget;
121 this->last_user_action = widget;
131 switch (this->last_user_action) {
140 default: NOT_REACHED();
182 static Hotkey airtoolbar_hotkeys[] = {
189 static const NWidgetPart _nested_air_toolbar_widgets[] = {
206 _nested_air_toolbar_widgets,
lengthof(_nested_air_toolbar_widgets),
207 &BuildAirToolbarWindow::hotkeys
222 return AllocateWindowDescFront<BuildAirToolbarWindow>(&_air_toolbar_desc,
TRANSPORT_AIR);
235 for (uint i = 0; i < AirportClass::GetClassCount(); i++) {
266 bool selectFirstAirport =
true;
272 selectFirstAirport =
false;
273 this->UpdateSelectSize();
298 if (
string != STR_UNDEFINED) {
301 SetDParam(0, STR_STATION_BUILD_AIRPORT_LAYOUT_NAME);
316 for (uint i = 0; i < AirportClass::GetClassCount(); i++) {
320 d.width += padding.width;
321 d.height += padding.height;
335 size->height = 5 * this->line_height;
343 for (
byte layout = 0; layout < as->
num_table; layout++) {
344 SpriteID sprite = GetCustomAirportSprite(as, layout);
359 for (
byte layout = 0; layout < as->
num_table; layout++) {
361 if (
string == STR_UNDEFINED)
continue;
381 for (uint i = this->vscroll->
GetPosition(); this->vscroll->IsVisible(i) && i < apclass->GetSpecCount(); i++) {
387 y += this->line_height;
393 if (this->preview_sprite != 0) {
395 DrawSprite(this->preview_sprite, COMPANY_SPRITE_COLOUR(
_local_company), (r.left + r.right - d.width) / 2, (r.top + r.bottom - d.height) / 2);
403 if (
string != STR_UNDEFINED) {
447 void SelectOtherAirport(
int airport_index)
452 this->UpdateSelectSize();
456 void UpdateSelectSize()
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;
491 if (as->
IsAvailable()) this->SelectOtherAirport(num_clicked);
501 this->UpdateSelectSize();
507 this->UpdateSelectSize();
513 this->UpdateSelectSize();
528 for (uint i = 0; i < sel_apclass->
GetSpecCount(); i++) {
531 this->SelectOtherAirport(i);
544 this->SelectOtherAirport(i);
551 this->SelectOtherAirport(-1);
568 static const NWidgetPart _nested_build_airport_widgets[] = {
595 SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
597 SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
606 WDP_AUTO,
"build_station_air", 0, 0,
609 _nested_build_airport_widgets,
lengthof(_nested_build_airport_widgets)
612 static void ShowBuildAirportPicker(
Window *parent)
617 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.
@ WD_FRAMERECT_TOP
Offset at top to draw the frame rectangular area.
#define CMD_MSG(x)
Used to combine a StringID with the command.
uint32 TileIndex
The index/ID of a Tile.
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
@ WD_MATRIX_RIGHT
Offset at right of a matrix cell.
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.
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.
@ WD_MATRIX_TOP
Offset at top of a matrix cell.
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.
Structure for buffering the build command when selecting a station to join.
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.
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.
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
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)
@ WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
@ HT_DIAGONAL
Also allow 'diagonal rectangles'. Only usable in combination with HT_RECT or HT_POINT.
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.
@ WD_PAR_VSEP_NORMAL
Normal amount of vertical space between two paragraphs of text.
@ WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
@ ES_NOT_HANDLED
The passed event is not handled.
@ WD_FRAMERECT_BOTTOM
Offset at bottom to draw the frame rectangular area.
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.
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.
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.
void ShowSelectStationIfNeeded(const CommandContainer &cmd, TileArea ta)
Show the station selection window when needed.
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)
@ 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.
@ CMD_BUILD_AIRPORT
build an airport
@ 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.
@ WD_MATRIX_BOTTOM
Offset at bottom of a matrix cell.
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.
@ WD_MATRIX_LEFT
Offset at left of a matrix cell.
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.