|
OpenTTD Source
14.0-beta3
|
Go to the documentation of this file.
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;
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", {
347 static WindowDesc _build_docks_toolbar_desc(__FILE__, __LINE__,
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
501 static WindowDesc _build_dock_station_desc(__FILE__, __LINE__,
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[] = {
596 static WindowDesc _build_docks_depot_desc(__FILE__, __LINE__,
600 std::begin(_nested_build_docks_depot_widgets), std::end(_nested_build_docks_depot_widgets)
604 static void ShowBuildDocksDepotPicker(
Window *parent)
610 void InitializeDockGui()
612 _ship_depot_direction =
AXIS_X;
static debug_inline uint TileY(TileIndex tile)
Get the Y component of a tile.
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
@ DDSP_DEMOLISH_AREA
Clear area.
@ CA_UNMODIFIED
Catchment for all stations with "modified catchment" disabled.
#define TILE_ADD(x, y)
Adds two tiles together.
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
int Height() const
Get height of Rect.
bool station_show_coverage
whether to highlight coverage area
@ WC_BUILD_TOOLBAR
Build toolbar; Window numbers:
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.
static constexpr NWidgetPart _nested_build_docks_toolbar_widgets[]
Nested widget parts of docks toolbar, game version.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
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 CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
@ WDP_ALIGN_TOOLBAR
Align toward the toolbar.
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
bool _ctrl_pressed
Is Ctrl pressed?
@ SND_15_BEEP
19 == 0x13 GUI button click
bool HandlePlacePushButton(Window *w, WidgetID widget, CursorID cursor, HighLightStyle mode)
This code is shared for the majority of the pushbuttons.
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.
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
@ WC_BUILD_STATION
Build station; Window numbers:
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
@ DDSP_CREATE_WATER
Create a canal.
static constexpr NWidgetPart _nested_build_dock_station_widgets[]
Nested widget parts of a build dock station window.
uint16_t max_bridge_length
maximum length of bridges
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
@ DDSP_CREATE_RIVER
Create rivers.
bool Succeeded() const
Did this command succeed?
@ DEPOT_PART_NORTH
Northern part of a depot.
High level window description.
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
@ WDP_AUTO
Find a place automatically.
ResizeInfo resize
Resize information.
Common return value for all commands.
SoundSettings sound
sound effect settings
int32_t WindowNumber
Number to differentiate different windows of the same class.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
static WindowDesc _build_docks_scen_toolbar_desc(__FILE__, __LINE__, WDP_AUTO, "toolbar_water_scen", 0, 0, WC_SCEN_BUILD_TOOLBAR, WC_NONE, WDF_CONSTRUCTION, std::begin(_nested_build_docks_scen_toolbar_widgets), std::end(_nested_build_docks_scen_toolbar_widgets))
Window definition for the build docks in scenario editor window.
static constexpr NWidgetPart _nested_build_docks_scen_toolbar_widgets[]
Nested widget parts of docks toolbar, scenario editor version.
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
highlighting tiles while only going over them with the mouse
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.
DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
@ ES_NOT_HANDLED
The passed event is not handled.
bool Failed() const
Did this command fail?
@ WATER_CLASS_CANAL
Canal.
void Close([[maybe_unused]] int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
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.
Window * parent
Parent window.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
@ 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 TileIndex GetOtherAqueductEnd(TileIndex tile_from, TileIndex *tile_to=nullptr)
Gets the other end of the aqueduct, if possible.
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.
int32_t TileIndexDiff
An offset value between two tiles.
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
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
@ 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:
bool IsValidTile(Tile tile)
Checks if a tile is valid.
TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
@ CA_DOCK
Catchment for docks with "modified catchment" enabled.
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)
void CcBuildBridge(Commands, const CommandCost &result, TileIndex end_tile, TileIndex tile_start, TransportType transport_type, BridgeType, byte)
Callback executed after a build Bridge CMD has been called.
@ DEPOT_PART_SOUTH
Southern part of a depot.
@ SCT_ALL
Draw all cargoes.
bool IsWidgetLowered(WidgetID widget_index) const
Gets the lowered state of a widget.
bool confirm
Play sound effect on successful constructions or other actions.
bool IsValidDiagDirection(DiagDirection d)
Checks if an integer value is a valid DiagDirection.
@ 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.
Class to backup a specific variable and restore it upon destruction of this object to prevent stack v...
int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
EventState
State of handling an event.
@ HT_RECT
rectangle (stations, depots, ...)
@ VPM_X_AND_Y
area of land in X and Y directions
@ 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 RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
bool click_beep
Beep on a random selection of buttons.
ConstructionSettings construction
construction of things in-game
Data structure for an opened window.
Commands
List of commands.
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.
static debug_inline uint TileX(TileIndex tile)
Get the X component of a tile.
int Width() const
Get width of Rect.
void OnRealtimeTick([[maybe_unused]] uint delta_ms) override
Called periodically.
@ VEH_SHIP
Ship vehicle type.
Specification of a rectangle with absolute coordinates of all edges.
void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
Sets the enabled/disabled status of a list of widgets.
TileIndex TileAddByDiagDir(TileIndex tile, DiagDirection dir)
Adds a DiagDir to a tile.
DiagDirection GetInclinedSlopeDirection(Slope s)
Returns the direction of an inclined slope.
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)
GUISettings gui
settings related to the GUI
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.