OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
32 #include "table/strings.h"
36 static void ShowBuildDockStationPicker(
Window *parent);
37 static void ShowBuildDocksDepotPicker(
Window *parent);
39 static Axis _ship_depot_direction;
43 if (result.
Failed())
return;
49 void CcPlaySound_CONSTRUCTION_WATER(
const CommandCost &result,
TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
81 if (length > max_length)
break;
84 if (tile_to !=
nullptr) *tile_to = endtile;
117 if (!gui_scope)
return;
130 if (_game_mode != GM_EDITOR) {
133 this->GetWidget<NWidgetCore>(
WID_DT_DEPOT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
134 this->GetWidget<NWidgetCore>(
WID_DT_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
135 this->GetWidget<NWidgetCore>(
WID_DT_BUOY)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
137 this->GetWidget<NWidgetCore>(
WID_DT_DEPOT)->SetToolTip(STR_WATERWAYS_TOOLBAR_BUILD_DEPOT_TOOLTIP);
138 this->GetWidget<NWidgetCore>(
WID_DT_STATION)->SetToolTip(STR_WATERWAYS_TOOLBAR_BUILD_DOCK_TOOLTIP);
139 this->GetWidget<NWidgetCore>(
WID_DT_BUOY)->SetToolTip(STR_WATERWAYS_TOOLBAR_BUOY_TOOLTIP);
172 if (_game_mode != GM_EDITOR)
return;
187 switch (this->last_clicked_widget) {
205 uint32 p2 = (uint32)INVALID_STATION << 16;
230 default: NOT_REACHED();
242 switch (select_proc) {
305 const uint16 _dockstoolbar_aqueduct_keys[] = {
'B',
'8', 0};
307 static Hotkey dockstoolbar_hotkeys[] = {
347 &BuildDocksToolbarWindow::hotkeys
362 return AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_toolbar_desc,
TRANSPORT_WATER);
387 WDP_AUTO,
"toolbar_water_scen", 0, 0,
431 SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
496 static void ShowBuildDockStationPicker(
Window *parent)
503 static void UpdateDocksDirection()
505 if (_ship_depot_direction !=
AXIS_X) {
517 UpdateDocksDirection();
555 UpdateDocksDirection();
562 static const NWidgetPart _nested_build_docks_depot_widgets[] = {
586 _nested_build_docks_depot_widgets,
lengthof(_nested_build_docks_depot_widgets)
590 static void ShowBuildDocksDepotPicker(
Window *parent)
596 void InitializeDockGui()
598 _ship_depot_direction =
AXIS_X;
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 CMD_MSG(x)
Used to combine a StringID with the command.
uint32 TileIndex
The index/ID of a Tile.
#define TILE_ADD(x, y)
Adds to tiles together.
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.
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it.
@ 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.
void OnPaint() override
The window must be repainted.
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.
@ CMD_BUILD_BRIDGE
build a bridge
Structure for buffering the build command when selecting a station to join.
ClientSettings _settings_client
The current settings for this game.
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
void DeleteWindowByClass(WindowClass cls)
Delete all windows of a given class.
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:
@ WATER_CLASS_RIVER
River.
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.
@ CMD_BUILD_SHIP_DEPOT
build a ship depot
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 CcBuildBridge(const CommandCost &result, TileIndex end_tile, uint32 p1, uint32 p2, uint32 cmd)
Callback executed after a build Bridge CMD has been called.
@ CMD_BUILD_DOCK
build a dock
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
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
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 to tiles.
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.
@ 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.
bool Failed() const
Did this command fail?
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
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.
@ CMD_BUILD_CANAL
build a canal
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.
DiagDirection
Enumeration for diagonal directions.
@ WATER_CLASS_CANAL
Canal.
WindowNumber window_number
Window number within the window class.
bool link_terraform_toolbar
display terraform toolbar when displaying rail, road, water and airport toolbars
@ 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.
@ 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:
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
Window * ShowBuildDocksScenToolbar()
Open the build water toolbar window for the scenario editor.
@ CMD_BUILD_LOCK
build a lock
@ WC_SCEN_LAND_GEN
Landscape generation (in Scenario Editor); Window numbers:
static int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
void OnPaint() override
The window must be repainted.
@ BDSW_LT_OFF
'Off' button of coverage high light.
@ TRANSPORT_WATER
Transport over water.
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.
bool click_beep
Beep on a random selection of buttons.
#define lengthof(x)
Return the length of an fixed size array.
Axis
Allow incrementing of DiagDirDiff variables.
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.
@ VEH_SHIP
Ship vehicle type.
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.
@ VPM_X_OR_Y
drag in X or Y direction
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.
@ CMD_BUILD_BUOY
build a buoy
GUISettings gui
settings related to the GUI
static DiagDirection GetInclinedSlopeDirection(Slope s)
Returns the direction of an inclined slope.
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.