39 #include "table/strings.h"
43 static void ShowBuildDockStationPicker(
Window *parent);
44 static void ShowBuildDocksDepotPicker(
Window *parent);
46 static Axis _ship_depot_direction;
50 if (result.
Failed())
return;
86 endtile =
TileAdd(endtile, offset);
88 if (length > max_length)
break;
91 if (tile_to !=
nullptr) *tile_to = endtile;
111 void Close([[maybe_unused]]
int data = 0)
override
123 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
125 if (!gui_scope)
return;
137 if (_game_mode != GM_EDITOR) {
140 this->GetWidget<NWidgetCore>(
WID_DT_DEPOT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
141 this->GetWidget<NWidgetCore>(
WID_DT_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
142 this->GetWidget<NWidgetCore>(
WID_DT_BUOY)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
144 this->GetWidget<NWidgetCore>(
WID_DT_DEPOT)->SetToolTip(STR_WATERWAYS_TOOLBAR_BUILD_DEPOT_TOOLTIP);
145 this->GetWidget<NWidgetCore>(
WID_DT_STATION)->SetToolTip(STR_WATERWAYS_TOOLBAR_BUILD_DOCK_TOOLTIP);
146 this->GetWidget<NWidgetCore>(
WID_DT_BUOY)->SetToolTip(STR_WATERWAYS_TOOLBAR_BUOY_TOOLTIP);
151 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
179 if (_game_mode != GM_EDITOR)
return;
192 void OnPlaceObject([[maybe_unused]]
Point pt,
TileIndex tile)
override
194 switch (this->last_clicked_widget) {
217 auto proc = [=](
bool test, StationID to_join) ->
bool {
241 default: NOT_REACHED();
253 switch (select_proc) {
281 void OnPlacePresize([[maybe_unused]]
Point pt,
TileIndex tile_from)
override
313 static inline HotkeyList hotkeys{
"dockstoolbar", {
352 &BuildDocksToolbarWindow::hotkeys
367 return AllocateWindowDescFront<BuildDocksToolbarWindow>(_build_docks_toolbar_desc,
TRANSPORT_WATER);
392 WDP_AUTO,
"toolbar_water_scen", 0, 0,
425 void Close([[maybe_unused]]
int data = 0)
override
438 SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
451 if (
top > r.bottom) {
456 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
508 static void ShowBuildDockStationPicker(
Window *parent)
515 static void UpdateDocksDirection()
517 if (_ship_depot_direction !=
AXIS_X) {
529 UpdateDocksDirection();
543 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
567 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
576 UpdateDocksDirection();
583 static constexpr
NWidgetPart _nested_build_docks_depot_widgets[] = {
600 _nested_build_docks_depot_widgets
604 static void ShowBuildDocksDepotPicker(
Window *parent)
610 void InitializeDockGui()
612 _ship_depot_direction =
AXIS_X;
void CcBuildBridge(Commands, const CommandCost &result, TileIndex end_tile, TileIndex tile_start, TransportType transport_type, BridgeType, uint8_t)
Callback executed after a build Bridge CMD has been called.
Common return value for all commands.
bool Succeeded() const
Did this command succeed?
bool Failed() const
Did this command fail?
Base class for windows opened from a toolbar.
void Close([[maybe_unused]] int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
Functions related to commands.
static constexpr DoCommandFlag CommandFlagsToDCFlags(CommandFlags cmd_flags)
Extracts the DC flags needed for DoCommand from the flags returned by GetCommandFlags.
Commands
List of commands.
Definition of stuff that is very close to a company, like the company struct itself.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Functions related to companies.
DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
bool IsValidDiagDirection(DiagDirection d)
Checks if an integer value is a valid DiagDirection.
Axis
Allow incrementing of DiagDirDiff variables.
DiagDirection
Enumeration for diagonal directions.
@ INVALID_DIAGDIR
Flag for an invalid DiagDirection.
Command definitions related to docks.
BuildDockStationWidgets
Widget numbers of the build-dock GUI.
@ BDSW_LT_OFF
'Off' button of coverage high light.
@ BDSW_BACKGROUND
Background panel.
@ BDSW_INFO
'Coverage highlight' label.
@ BDSW_ACCEPTANCE
Acceptance info.
@ BDSW_LT_ON
'On' button of coverage high light.
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)
Window definition for the build docks in scenario editor window.
static TileIndex GetOtherAqueductEnd(TileIndex tile_from, TileIndex *tile_to=nullptr)
Gets the other end of the aqueduct, if possible.
Window * ShowBuildDocksScenToolbar()
Open the build water toolbar window for the scenario editor.
static constexpr NWidgetPart _nested_build_docks_scen_toolbar_widgets[]
Nested widget parts of docks toolbar, scenario editor version.
static constexpr NWidgetPart _nested_build_docks_toolbar_widgets[]
Nested widget parts of docks toolbar, game version.
static constexpr NWidgetPart _nested_build_dock_station_widgets[]
Nested widget parts of a build dock station window.
Window * ShowBuildDocksToolbar()
Open the build water toolbar window.
bool _ctrl_pressed
Is Ctrl pressed?
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
Functions related to the gfx engine.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
GUI functions that shouldn't be here.
Hotkey related functions.
bool HandlePlacePushButton(Window *w, WidgetID widget, CursorID cursor, HighLightStyle mode)
This code is shared for the majority of the pushbuttons.
uint DistanceFromEdgeDir(TileIndex tile, DiagDirection dir)
Gets the distance to the edge of the map in given direction.
TileIndex TileAddXY(TileIndex tile, int x, int y)
Adds a given offset to a tile.
TileIndex TileAddByDiagDir(TileIndex tile, DiagDirection dir)
Adds a DiagDir to a tile.
constexpr TileIndex TileAdd(TileIndex tile, TileIndexDiff offset)
Adds a given offset to a tile.
static debug_inline uint TileY(TileIndex tile)
Get the Y component of a tile.
static debug_inline uint TileX(TileIndex tile)
Get the X component of a tile.
TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
int32_t TileIndexDiff
An offset value between two tiles.
A number of safeguards to prevent using unsafe methods.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
ClientSettings _settings_client
The current settings for this game.
Functions related to slopes.
DiagDirection GetInclinedSlopeDirection(Slope s)
Returns the direction of an inclined slope.
Functions related to sound.
@ SND_02_CONSTRUCTION_WATER
0 == 0x00 Construction: water infrastructure
@ SND_15_BEEP
19 == 0x13 GUI button click
This file contains all sprite-related enums and defines.
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
Command definitions related to stations.
void ShowSelectStationIfNeeded(TileArea ta, StationPickerCmdProc proc)
Show the station selection window when needed.
void CheckRedrawStationCoverage(const Window *w)
Check whether we need to redraw the station coverage text.
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)
Contains enums and function declarations connected with stations GUI.
@ SCT_ALL
Draw all cargoes.
static constexpr uint CA_DOCK
Catchment for docks with "modified catchment" enabled.
static constexpr uint CA_UNMODIFIED
Catchment for all stations with "modified catchment" disabled.
Definition of base types and functions in a cross-platform compatible way.
Class to backup a specific variable and restore it upon destruction of this object to prevent stack v...
void OnPaint() override
The window must be repainted.
void OnRealtimeTick([[maybe_unused]] uint delta_ms) override
Called periodically.
SoundSettings sound
sound effect settings
GUISettings gui
settings related to the GUI
uint16_t max_bridge_length
maximum length of bridges
Dimensions (a width and height) of a rectangle in 2D.
Data about how and where to blit pixels.
bool persistent_buildingtools
keep the building tools active after usage
bool station_show_coverage
whether to highlight coverage area
bool link_terraform_toolbar
display terraform toolbar when displaying rail, road, water and airport toolbars
ConstructionSettings construction
construction of things in-game
StationSettings station
settings related to station management
List of hotkeys for a window.
All data for a single hotkey.
Coordinates of a point in 2D.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Specification of a rectangle with absolute coordinates of all edges.
int Width() const
Get width of Rect.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
int Height() const
Get height of Rect.
bool click_beep
Beep on a random selection of buttons.
bool confirm
Play sound effect on successful constructions or other actions.
bool modified_catchment
different-size catchment areas
High level window description.
Data structure for an opened window.
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
void DrawWidgets() const
Paint all widgets of a window.
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
Window * parent
Parent window.
void RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
ResizeInfo resize
Resize information.
void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
Sets the enabled/disabled status of a list of widgets.
bool IsWidgetLowered(WidgetID widget_index) const
Gets the lowered state of a widget.
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
int top
y position of top edge of the window
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
WindowNumber window_number
Window number within the window class.
std::tuple< Slope, int > GetTileSlopeZ(TileIndex tile)
Return the slope of a given tile inside the map.
int GetTileMaxZ(TileIndex t)
Get top height of the tile inside the map.
bool IsValidTile(Tile tile)
Checks if a tile is valid.
Slope GetTileSlope(TileIndex tile)
Return the slope of a given tile inside the map.
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
Functions related to tile highlights.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
void VpSetPresizeRange(TileIndex from, TileIndex to)
Highlights all tiles between a set of two tiles.
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
highlighting tiles while only going over them with the mouse
@ HT_DIAGONAL
Also allow 'diagonal rectangles'. Only usable in combination with HT_RECT or HT_POINT.
@ HT_RECT
rectangle (stations, depots, ...)
@ HT_SPECIAL
special mode used for highlighting while dragging (and for tunnels/docks)
Definition of Interval and OneShot timers.
Definition of the game-calendar-timer.
@ TRANSPORT_WATER
Transport over water.
Command definitions related to tunnels and bridges.
bool CanBuildVehicleInfrastructure(VehicleType type, uint8_t subtype)
Check whether we can build infrastructure for the given vehicle type.
Functions related to vehicles.
@ VEH_SHIP
Ship vehicle type.
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
void SetViewportCatchmentStation(const Station *st, bool sel)
Select or deselect station for coverage area highlight.
Functions related to (drawing on) viewports.
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it.
@ DDSP_DEMOLISH_AREA
Clear area.
@ DDSP_CREATE_WATER
Create a canal.
@ DDSP_CREATE_RIVER
Create rivers.
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
@ VPM_X_AND_Y
area of land in X and Y directions
Functions related to water (management)
Command definitions related to water tiles.
@ DEPOT_PART_NORTH
Northern part of a depot.
@ DEPOT_PART_SOUTH
Southern part of a depot.
@ WATER_CLASS_CANAL
Canal.
@ WATER_CLASS_RIVER
River.
Command definitions related to waypoints.
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
void ResizeWindow(Window *w, int delta_x, int delta_y, bool clamp_to_screen, bool schedule_resize)
Resize the window.
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
Window functions not directly related to making/drawing windows.
Functions, definitions and such used only by the GUI.
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
@ WDP_AUTO
Find a place automatically.
@ WDP_ALIGN_TOOLBAR
Align toward the toolbar.
int32_t WindowNumber
Number to differentiate different windows of the same class.
EventState
State of handling an event.
@ ES_NOT_HANDLED
The passed event is not handled.
@ WC_BUILD_STATION
Build station; Window numbers:
@ WC_SCEN_BUILD_TOOLBAR
Scenario build toolbar; Window numbers:
@ WC_BUILD_TOOLBAR
Build toolbar; Window numbers:
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
@ WC_SCEN_LAND_GEN
Landscape generation (in Scenario Editor); Window numbers:
@ WC_SELECT_STATION
Select station (when joining stations); Window numbers:
@ WC_BUILD_DEPOT
Build depot; Window numbers:
@ WC_BUILD_BRIDGE
Build bridge; Window numbers:
Functions related to zooming.
int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.