Go to the documentation of this file.
37 #include "table/strings.h"
41 static void ShowBuildDockStationPicker(
Window *parent);
42 static void ShowBuildDocksDepotPicker(
Window *parent);
44 static Axis _ship_depot_direction;
48 if (result.
Failed())
return;
86 if (length > max_length)
break;
89 if (tile_to !=
nullptr) *tile_to = endtile;
123 if (!gui_scope)
return;
136 if (_game_mode != GM_EDITOR) {
139 this->GetWidget<NWidgetCore>(
WID_DT_DEPOT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
140 this->GetWidget<NWidgetCore>(
WID_DT_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
141 this->GetWidget<NWidgetCore>(
WID_DT_BUOY)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
143 this->GetWidget<NWidgetCore>(
WID_DT_DEPOT)->SetToolTip(STR_WATERWAYS_TOOLBAR_BUILD_DEPOT_TOOLTIP);
144 this->GetWidget<NWidgetCore>(
WID_DT_STATION)->SetToolTip(STR_WATERWAYS_TOOLBAR_BUILD_DOCK_TOOLTIP);
145 this->GetWidget<NWidgetCore>(
WID_DT_BUOY)->SetToolTip(STR_WATERWAYS_TOOLBAR_BUOY_TOOLTIP);
178 if (_game_mode != GM_EDITOR)
return;
193 switch (this->last_clicked_widget) {
216 auto proc = [=](
bool test, StationID to_join) ->
bool {
240 default: NOT_REACHED();
252 switch (select_proc) {
315 const uint16 _dockstoolbar_aqueduct_keys[] = {
'B',
'8', 0};
317 static Hotkey dockstoolbar_hotkeys[] = {
357 &BuildDocksToolbarWindow::hotkeys
372 return AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_toolbar_desc,
TRANSPORT_WATER);
397 WDP_AUTO,
"toolbar_water_scen", 0, 0,
443 SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
456 if (
top > r.bottom) {
505 static void ShowBuildDockStationPicker(
Window *parent)
512 static void UpdateDocksDirection()
514 if (_ship_depot_direction !=
AXIS_X) {
526 UpdateDocksDirection();
574 UpdateDocksDirection();
581 static const NWidgetPart _nested_build_docks_depot_widgets[] = {
602 _nested_build_docks_depot_widgets,
lengthof(_nested_build_docks_depot_widgets)
606 static void ShowBuildDocksDepotPicker(
Window *parent)
612 void InitializeDockGui()
614 _ship_depot_direction =
AXIS_X;
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.
#define TILE_ADD(x, y)
Adds two tiles together.
int Height() const
Get height of Rect.
bool station_show_coverage
whether to highlight coverage area
@ WC_BUILD_TOOLBAR
Build toolbar; Window numbers:
static TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
StationSettings station
settings related to station management
int GetTileMaxZ(TileIndex t)
Get top height of the tile inside the map.
List of hotkeys for a window.
void VpSetPresizeRange(TileIndex from, TileIndex to)
Highlights all tiles between a set of two tiles.
Dimensions (a width and height) of a rectangle in 2D.
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Commands
List of commands.
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.
Axis
Allow incrementing of DiagDirDiff variables.
@ WC_SCEN_BUILD_TOOLBAR
Scenario build toolbar; Window numbers:
void CheckRedrawStationCoverage(const Window *w)
Check whether we need to redraw the station coverage text.
void OnRealtimeTick(uint delta_ms) override
Called periodically.
@ WDP_ALIGN_TOOLBAR
Align toward the toolbar.
bool _ctrl_pressed
Is Ctrl pressed?
@ SND_15_BEEP
19 == 0x13 GUI button click
static bool IsValidDiagDirection(DiagDirection d)
Checks if an integer value is a valid DiagDirection.
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
ClientSettings _settings_client
The current settings for this game.
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
@ TRANSPORT_WATER
Transport over water.
static uint TileY(TileIndex tile)
Get the Y component of a tile.
int32 WindowNumber
Number to differentiate different windows of the same class.
@ WC_BUILD_STATION
Build station; Window numbers:
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
@ DDSP_CREATE_WATER
Create a canal.
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
@ DDSP_CREATE_RIVER
Create rivers.
static const NWidgetPart _nested_build_docks_scen_toolbar_widgets[]
Nested widget parts of docks toolbar, scenario editor version.
bool Succeeded() const
Did this command succeed?
static uint TileX(TileIndex tile)
Get the X component of a tile.
static EventState DockToolbarGlobalHotkeys(int hotkey)
Handler for global hotkeys of the BuildDocksToolbarWindow.
@ DEPOT_PART_NORTH
Northern part of a depot.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
High level window description.
@ WDP_AUTO
Find a place automatically.
ResizeInfo resize
Resize information.
Common return value for all commands.
SoundSettings sound
sound effect settings
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
highlighting tiles while only going over them with the mouse
int32 TileIndexDiff
An offset value between two tiles.
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 Close() override
Hide the window and all its child windows, and mark them for a later deletion.
@ WATER_CLASS_CANAL
Canal.
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
static int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
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.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
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.
@ WC_BUILD_BRIDGE
Build bridge; Window numbers:
uint DistanceFromEdgeDir(TileIndex tile, DiagDirection dir)
Gets the distance to the edge of the map in given direction.
static bool IsValidTile(TileIndex tile)
Checks if a tile is valid.
static TileIndex GetOtherAqueductEnd(TileIndex tile_from, TileIndex *tile_to=nullptr)
Gets the other end of the aqueduct, if possible.
static TileIndex TileAddByDiagDir(TileIndex tile, DiagDirection dir)
Adds a DiagDir to a tile.
static DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
Slope GetTileSlope(TileIndex tile, int *h)
Return the slope of a given tile inside the map.
@ INVALID_DIAGDIR
Flag for an invalid DiagDirection.
@ BDSW_INFO
'Coverage highlight' label.
Coordinates of a point in 2D.
@ BDSW_ACCEPTANCE
Acceptance info.
DiagDirection
Enumeration for diagonal directions.
@ WATER_CLASS_RIVER
River.
WindowNumber window_number
Window number within the window class.
bool link_terraform_toolbar
display terraform toolbar when displaying rail, road, water and airport toolbars
uint Vertical() const
Get total vertical padding of RectPadding.
@ 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.
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
@ WC_BUILD_DEPOT
Build depot; Window numbers:
static WindowDesc _build_docks_scen_toolbar_desc(WDP_AUTO, "toolbar_water_scen", 0, 0, WC_SCEN_BUILD_TOOLBAR, WC_NONE, WDF_CONSTRUCTION, _nested_build_docks_scen_toolbar_widgets, lengthof(_nested_build_docks_scen_toolbar_widgets))
Window definition for the build docks in scenario editor window.
@ CA_DOCK
Catchment for docks with "modified catchment" enabled.
uint16 max_bridge_length
maximum length of bridges
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)
@ DEPOT_PART_SOUTH
Southern part of a depot.
@ SCT_ALL
Draw all cargoes.
bool confirm
Play sound effect on successful constructions or other actions.
@ WC_SELECT_STATION
Select station (when joining stations); Window numbers:
Window * ShowBuildDocksScenToolbar()
Open the build water toolbar window for the scenario editor.
@ WC_SCEN_LAND_GEN
Landscape generation (in Scenario Editor); Window numbers:
void OnPaint() override
The window must be repainted.
@ BDSW_LT_OFF
'Off' button of coverage high light.
void CloseWindowByClass(WindowClass cls)
Close all windows of a given class.
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.
static const NWidgetPart _nested_build_dock_station_widgets[]
Nested widget parts of a build dock station window.
EventState
State of handling an event.
@ HT_RECT
rectangle (stations, depots, ...)
@ VPM_X_AND_Y
area of land in X and Y directions
static const NWidgetPart _nested_build_docks_toolbar_widgets[]
Nested widget parts of docks toolbar, game version.
@ BDSW_BACKGROUND
Background panel.
@ SND_02_CONSTRUCTION_WATER
0 == 0x00 Construction: water infrastructure
BuildDockStationWidgets
Widget numbers of the build-dock GUI.
Base class for windows opened from a toolbar.
void SetViewportCatchmentStation(const Station *st, bool sel)
Select or deselect station for coverage area highlight.
@ BDSW_LT_ON
'On' button of coverage high light.
int top
y position of top edge of the window
#define TILE_ADDXY(tile, x, y)
Adds a given offset to a tile.
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
void CcBuildBridge(Commands cmd, const CommandCost &result, TileIndex end_tile, TileIndex tile_start, TransportType transport_type, BridgeType, byte)
Callback executed after a build Bridge CMD has been called.
bool click_beep
Beep on a random selection of buttons.
#define lengthof(x)
Return the length of an fixed size array.
void CloseWindowById(WindowClass cls, WindowNumber number, bool force)
Close a window by its class and window number (if it is open).
ConstructionSettings construction
construction of things in-game
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 RaiseWidget(byte widget_index)
Marks a widget as raised.
void DrawWidgets() const
Paint all widgets of a window.
int Width() const
Get width of Rect.
@ VEH_SHIP
Ship vehicle type.
Specification of a rectangle with absolute coordinates of all edges.
void LowerWidget(byte widget_index)
Marks a widget as lowered.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
@ HT_SPECIAL
special mode used for highlighting while dragging (and for tunnels/docks)
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.
GUISettings gui
settings related to the GUI
static DiagDirection GetInclinedSlopeDirection(Slope s)
Returns the direction of an inclined slope.
Data about how and where to blit pixels.
bool persistent_buildingtools
keep the building tools active after usage
bool modified_catchment
different-size catchment areas
All data for a single hotkey.
Window * ShowBuildDocksToolbar()
Open the build water toolbar window.
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.