OpenTTD Source: src/dock_gui.cpp File Reference

OpenTTD Source 15.3

Data Structures | Functions | Variables
dock_gui.cpp File Reference

GUI to create amazing water objects. More...

`#include "stdafx.h"`
`#include "terraform_gui.h"`
`#include "window_gui.h"`
`#include "station_gui.h"`
`#include "command_func.h"`
`#include "water.h"`
`#include "window_func.h"`
`#include "vehicle_func.h"`
`#include "sound_func.h"`
`#include "viewport_func.h"`
`#include "gfx_func.h"`
`#include "company_func.h"`
`#include "slope_func.h"`
`#include "tilehighlight_func.h"`
`#include "company_base.h"`
`#include "hotkeys.h"`
`#include "gui.h"`
`#include "zoom_func.h"`
`#include "tunnelbridge_cmd.h"`
`#include "dock_cmd.h"`
`#include "station_cmd.h"`
`#include "water_cmd.h"`
`#include "waypoint_cmd.h"`
`#include "timer/timer.h"`
`#include "timer/timer_game_calendar.h"`
`#include "widgets/dock_widget.h"`
`#include "table/sprites.h"`
`#include "table/strings.h"`
`#include "safeguards.h"`

Go to the source code of this file.

## Data Structures
struct | BuildDocksToolbarWindow
| Toolbar window for constructing water infrastructure. More...
struct | BuildDocksStationWindow
struct | BuildDocksDepotWindow

## Functions
static void | ShowBuildDockStationPicker (Window *parent)
static void | ShowBuildDocksDepotPicker (Window *parent)
void | CcBuildDocks (Commands, const CommandCost &result, TileIndex tile)
void | CcPlaySound_CONSTRUCTION_WATER (Commands, const CommandCost &result, TileIndex tile)
static TileIndex | GetOtherAqueductEnd (TileIndex tile_from, TileIndex *tile_to=nullptr)
| Gets the other end of the aqueduct, if possible.
Window * | ShowBuildDocksToolbar ()
| Open the build water toolbar window.
Window * | ShowBuildDocksScenToolbar ()
| Open the build water toolbar window for the scenario editor.
void | InitializeDockGui ()

## Variables
static Axis | _ship_depot_direction
static constexpr std::initializer_list< NWidgetPart > | _nested_build_docks_toolbar_widgets
| Nested widget parts of docks toolbar, game version.
static WindowDesc | _build_docks_toolbar_desc (WDP_MANUAL, "toolbar_water", 0, 0, WC_BUILD_TOOLBAR, WC_NONE, WindowDefaultFlag::Construction, _nested_build_docks_toolbar_widgets, &BuildDocksToolbarWindow::hotkeys)
static constexpr std::initializer_list< NWidgetPart > | _nested_build_docks_scen_toolbar_widgets
| Nested widget parts of docks toolbar, scenario editor version.
static WindowDesc | _build_docks_scen_toolbar_desc (WDP_AUTO, "toolbar_water_scen", 0, 0, WC_SCEN_BUILD_TOOLBAR, WC_NONE, WindowDefaultFlag::Construction, _nested_build_docks_scen_toolbar_widgets)
| Window definition for the build docks in scenario editor window.
static constexpr std::initializer_list< NWidgetPart > | _nested_build_dock_station_widgets
| Nested widget parts of a build dock station window.
static WindowDesc | _build_dock_station_desc (WDP_AUTO, {}, 0, 0, WC_BUILD_STATION, WC_BUILD_TOOLBAR, WindowDefaultFlag::Construction, _nested_build_dock_station_widgets)
static constexpr std::initializer_list< NWidgetPart > | _nested_build_docks_depot_widgets
static WindowDesc | _build_docks_depot_desc (WDP_AUTO, {}, 0, 0, WC_BUILD_DEPOT, WC_BUILD_TOOLBAR, WindowDefaultFlag::Construction, _nested_build_docks_depot_widgets)

## Detailed Description

GUI to create amazing water objects.

Definition in file dock_gui.cpp.

## Function Documentation

## ◆ CcBuildDocks()

void CcBuildDocks | ( | Commands | ,
|  | const CommandCost & | result,
|  | TileIndex | tile
| ) |  |

Definition at line 48 of file dock_gui.cpp.

## ◆ CcPlaySound_CONSTRUCTION_WATER()

void CcPlaySound_CONSTRUCTION_WATER | ( | Commands | ,
|  | const CommandCost & | result,
|  | TileIndex | tile
| ) |  |

Definition at line 56 of file dock_gui.cpp.

## ◆ GetOtherAqueductEnd()

static TileIndex GetOtherAqueductEnd | ( | TileIndex | tile_from,
|  | TileIndex * | tile_to = `nullptr`
| ) |  |
| static

Gets the other end of the aqueduct, if possible.

Parameters

  | tile_from | The begin tile for the aqueduct.
  [out] | tile_to | The tile till where to show a selection for the aqueduct.

Returns
  The other end of the aqueduct, or otherwise a tile in line with the aqueduct to cause the right error message.

Definition at line 68 of file dock_gui.cpp.

References _settings_game, GameSettings::construction, DistanceFromEdgeDir(), GetInclinedSlopeDirection(), GetTileMaxZ(), GetTileSlopeZ(), IsValidDiagDirection(), IsValidTile(), ConstructionSettings::max_bridge_length, ReverseDiagDir(), TileAdd(), TileAddXY(), TileOffsByDiagDir(), TileX(), and TileY().

Referenced by BuildDocksToolbarWindow::OnPlaceObject(), and BuildDocksToolbarWindow::OnPlacePresize().

## ◆ InitializeDockGui()

void InitializeDockGui | ( |  | ) |

Definition at line 614 of file dock_gui.cpp.

## ◆ ShowBuildDocksDepotPicker()

static void ShowBuildDocksDepotPicker | ( | Window * | parent | ) |
| static

Definition at line 608 of file dock_gui.cpp.

## ◆ ShowBuildDocksScenToolbar()

Window * ShowBuildDocksScenToolbar | ( |  | ) |

Open the build water toolbar window for the scenario editor.

Returns
  newly opened water toolbar, or nullptr if the toolbar could not be opened.

Definition at line 415 of file dock_gui.cpp.

References _build_docks_scen_toolbar_desc, and TRANSPORT_WATER.

## ◆ ShowBuildDockStationPicker()

static void ShowBuildDockStationPicker | ( | Window * | parent | ) |
| static

Definition at line 512 of file dock_gui.cpp.

## ◆ ShowBuildDocksToolbar()

Window * ShowBuildDocksToolbar | ( |  | ) |

Open the build water toolbar window.

If the terraform toolbar is linked to the toolbar, that window is also opened.

Returns
  newly opened water toolbar, or nullptr if the toolbar could not be opened.

Definition at line 374 of file dock_gui.cpp.

References _local_company, CloseWindowByClass(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::IsValidID(), TRANSPORT_WATER, and WC_BUILD_TOOLBAR.

Referenced by BuildDocksToolbarWindow::DockToolbarGlobalHotkeys(), MenuClickBuildWater(), and MainToolbarWindow::OnHotkey().

## Variable Documentation

## ◆ _nested_build_dock_station_widgets

constexpr std::initializer_list<NWidgetPart> _nested_build_dock_station_widgets
| staticconstexpr

Initial value:
= {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetStringTip(STR_STATION_BUILD_DOCK_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BDSW_BACKGROUND),
NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0), SetPadding(WidgetDimensions::unscaled.picker),
NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_picker, 0),
NWidget(WWT_LABEL, INVALID_COLOUR, WID_BDSW_INFO), SetStringTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE), SetFill(1, 0),
NWidget(NWID_HORIZONTAL, NWidContainerFlag::EqualSize), SetPIP(14, 0, 14),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BDSW_LT_OFF), SetMinimalSize(60, 12), SetFill(1, 0), SetStringTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BDSW_LT_ON), SetMinimalSize(60, 12), SetFill(1, 0), SetStringTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
EndContainer(),
EndContainer(),
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_BDSW_ACCEPTANCE), SetResize(0, 1), SetMinimalTextLines(2, WidgetDimensions::unscaled.vsep_normal),
EndContainer(),
EndContainer(),
}
WidgetDimensions::unscaled
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition window_gui.h:93
WID_BDSW_ACCEPTANCE
@ WID_BDSW_ACCEPTANCE
Acceptance info.
Definition dock_widget.h:26
WID_BDSW_LT_OFF
@ WID_BDSW_LT_OFF
'Off' button of coverage high light.
Definition dock_widget.h:23
WID_BDSW_INFO
@ WID_BDSW_INFO
'Coverage highlight' label.
Definition dock_widget.h:25
WID_BDSW_BACKGROUND
@ WID_BDSW_BACKGROUND
Background panel.
Definition dock_widget.h:22
WID_BDSW_LT_ON
@ WID_BDSW_LT_ON
'On' button of coverage high light.
Definition dock_widget.h:24
SetFill
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
Definition widget_type.h:1222
SetPIP
constexpr NWidgetPart SetPIP(uint8_t pre, uint8_t inter, uint8_t post)
Widget part function for setting a pre/inter/post spaces.
Definition widget_type.h:1378
SetPadding
constexpr NWidgetPart SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left)
Widget part function for setting additional space around a widget.
Definition widget_type.h:1335
SetStringTip
constexpr NWidgetPart SetStringTip(StringID string, StringID tip={})
Widget part function for setting the string and tooltip.
Definition widget_type.h:1243
SetMinimalSize
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
Definition widget_type.h:1159
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition widget_type.h:1232
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=INVALID_WIDGET)
Widget part function for starting a new 'real' widget.
Definition widget_type.h:1427
SetMinimalTextLines
constexpr NWidgetPart SetMinimalTextLines(uint8_t lines, uint8_t spacing, FontSize size=FS_NORMAL)
Widget part function for setting the minimal text lines.
Definition widget_type.h:1190
SetResize
constexpr NWidgetPart SetResize(int16_t dx, int16_t dy)
Widget part function for setting the resize step.
Definition widget_type.h:1148
WWT_LABEL
@ WWT_LABEL
Centered label.
Definition widget_type.h:48
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition widget_type.h:66
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition widget_type.h:44
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition widget_type.h:39
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition widget_type.h:52
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition widget_type.h:68
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition widget_type.h:60
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget tree.
Definition widget_type.h:37
EqualSize
@ EqualSize
Containers should keep all their (resizing) children equally large.
Definition widget_type.h:544

Nested widget parts of a build dock station window.

Definition at line 486 of file dock_gui.cpp.

## ◆ _nested_build_docks_depot_widgets

constexpr std::initializer_list<NWidgetPart> _nested_build_docks_depot_widgets
| staticconstexpr

Initial value:
= {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetStringTip(STR_DEPOT_BUILD_SHIP_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BDD_BACKGROUND),
NWidget(NWID_HORIZONTAL_LTR), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1), SetPadding(WidgetDimensions::unscaled.picker),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BDD_X), SetToolTip(STR_DEPOT_BUILD_SHIP_ORIENTATION_TOOLTIP),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BDD_Y), SetToolTip(STR_DEPOT_BUILD_SHIP_ORIENTATION_TOOLTIP),
EndContainer(),
EndContainer(),
}
WID_BDD_X
@ WID_BDD_X
X-direction button.
Definition dock_widget.h:16
WID_BDD_Y
@ WID_BDD_Y
Y-direction button.
Definition dock_widget.h:17
WID_BDD_BACKGROUND
@ WID_BDD_BACKGROUND
Background of the window.
Definition dock_widget.h:15
SetToolTip
constexpr NWidgetPart SetToolTip(StringID tip)
Widget part function for setting tooltip and clearing the widget data.
Definition widget_type.h:1321
SetPIPRatio
constexpr NWidgetPart SetPIPRatio(uint8_t ratio_pre, uint8_t ratio_inter, uint8_t ratio_post)
Widget part function for setting a pre/inter/post ratio.
Definition widget_type.h:1390
NWID_HORIZONTAL_LTR
@ NWID_HORIZONTAL_LTR
Horizontal container that doesn't change the order of the widgets for RTL languages.
Definition widget_type.h:67

Definition at line 587 of file dock_gui.cpp.

## ◆ _nested_build_docks_scen_toolbar_widgets

constexpr std::initializer_list<NWidgetPart> _nested_build_docks_scen_toolbar_widgets
| staticconstexpr

Initial value:
= {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetStringTip(STR_WATERWAYS_TOOLBAR_CAPTION_SE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_CANAL), SetToolbarMinimalSize(1), SetFill(0, 1), SetSpriteTip(SPR_IMG_BUILD_CANAL, STR_WATERWAYS_TOOLBAR_CREATE_LAKE_TOOLTIP),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_LOCK), SetToolbarMinimalSize(1), SetFill(0, 1), SetSpriteTip(SPR_IMG_BUILD_LOCK, STR_WATERWAYS_TOOLBAR_BUILD_LOCKS_TOOLTIP),
NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetToolbarSpacerMinimalSize(), SetFill(1, 1), EndContainer(),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_DEMOLISH), SetToolbarMinimalSize(1), SetFill(0, 1), SetSpriteTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_RIVER), SetToolbarMinimalSize(1), SetFill(0, 1), SetSpriteTip(SPR_IMG_BUILD_RIVER, STR_WATERWAYS_TOOLBAR_CREATE_RIVER_TOOLTIP),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_BUILD_AQUEDUCT), SetToolbarMinimalSize(1), SetFill(0, 1), SetSpriteTip(SPR_IMG_AQUEDUCT, STR_WATERWAYS_TOOLBAR_BUILD_AQUEDUCT_TOOLTIP),
EndContainer(),
}
WID_DT_CANAL
@ WID_DT_CANAL
Build canal button.
Definition dock_widget.h:31
WID_DT_DEMOLISH
@ WID_DT_DEMOLISH
Demolish aka dynamite button.
Definition dock_widget.h:33
WID_DT_RIVER
@ WID_DT_RIVER
Build river button (in scenario editor).
Definition dock_widget.h:37
WID_DT_LOCK
@ WID_DT_LOCK
Build lock button.
Definition dock_widget.h:32
WID_DT_BUILD_AQUEDUCT
@ WID_DT_BUILD_AQUEDUCT
Build aqueduct button.
Definition dock_widget.h:38
SetSpriteTip
constexpr NWidgetPart SetSpriteTip(SpriteID sprite, StringID tip={})
Widget part function for setting the sprite and tooltip.
Definition widget_type.h:1254
SetToolbarMinimalSize
constexpr NWidgetPart SetToolbarMinimalSize(int width)
Widget part function to setting the minimal size for a toolbar button.
Definition widget_type.h:1178
SetToolbarSpacerMinimalSize
constexpr NWidgetPart SetToolbarSpacerMinimalSize()
Widget part function to setting the minimal size for a toolbar spacer.
Definition widget_type.h:1168
WWT_IMGBTN
@ WWT_IMGBTN
(Toggle) Button with image
Definition widget_type.h:41
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition widget_type.h:57

Nested widget parts of docks toolbar, scenario editor version.

Positions of WID_DT_DEPOT, WID_DT_STATION, and WID_DT_BUOY widgets have changed.

Definition at line 386 of file dock_gui.cpp.

## ◆ _nested_build_docks_toolbar_widgets

constexpr std::initializer_list<NWidgetPart> _nested_build_docks_toolbar_widgets
| staticconstexpr

Initial value:
= {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetStringTip(STR_WATERWAYS_TOOLBAR_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
EndContainer(),
NWidget(NWID_HORIZONTAL_LTR),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_CANAL), SetToolbarMinimalSize(1), SetFill(0, 1), SetSpriteTip(SPR_IMG_BUILD_CANAL, STR_WATERWAYS_TOOLBAR_BUILD_CANALS_TOOLTIP),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_LOCK), SetToolbarMinimalSize(1), SetFill(0, 1), SetSpriteTip(SPR_IMG_BUILD_LOCK, STR_WATERWAYS_TOOLBAR_BUILD_LOCKS_TOOLTIP),
NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetToolbarSpacerMinimalSize(), SetFill(1, 1), EndContainer(),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_DEMOLISH), SetToolbarMinimalSize(1), SetFill(0, 1), SetSpriteTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_DEPOT), SetToolbarMinimalSize(1), SetFill(0, 1), SetSpriteTip(SPR_IMG_SHIP_DEPOT, STR_WATERWAYS_TOOLBAR_BUILD_DEPOT_TOOLTIP),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_STATION), SetToolbarMinimalSize(1), SetFill(0, 1), SetSpriteTip(SPR_IMG_SHIP_DOCK, STR_WATERWAYS_TOOLBAR_BUILD_DOCK_TOOLTIP),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_BUOY), SetToolbarMinimalSize(1), SetFill(0, 1), SetSpriteTip(SPR_IMG_BUOY, STR_WATERWAYS_TOOLBAR_BUOY_TOOLTIP),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_BUILD_AQUEDUCT), SetToolbarMinimalSize(1), SetFill(0, 1), SetSpriteTip(SPR_IMG_AQUEDUCT, STR_WATERWAYS_TOOLBAR_BUILD_AQUEDUCT_TOOLTIP),
EndContainer(),
}
WID_DT_STATION
@ WID_DT_STATION
Build station button.
Definition dock_widget.h:35
WID_DT_DEPOT
@ WID_DT_DEPOT
Build depot button.
Definition dock_widget.h:34
WID_DT_BUOY
@ WID_DT_BUOY
Build buoy button.
Definition dock_widget.h:36

Nested widget parts of docks toolbar, game version.

Position of WID_DT_RIVER widget has changed.

Definition at line 341 of file dock_gui.cpp.

## ◆ _ship_depot_direction

Axis _ship_depot_direction
| static

Definition at line 46 of file dock_gui.cpp.