OpenTTD
Data Structures | Enumerations | 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 "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
 

Enumerations

enum  BuildDockStationWidgets { BDSW_BACKGROUND, BDSW_LT_OFF, BDSW_LT_ON, BDSW_INFO }
 Widget numbers of the build-dock GUI. More...
 

Functions

static void ShowBuildDockStationPicker (Window *parent)
 
static void ShowBuildDocksDepotPicker (Window *parent)
 
void CcBuildDocks (const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
 
void CcPlaySound_SPLAT_WATER (const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
 
static TileIndex GetOtherAqueductEnd (TileIndex tile_from, TileIndex *tile_to=NULL)
 Gets the other end of the aqueduct, if possible. More...
 
static EventState DockToolbarGlobalHotkeys (int hotkey)
 Handler for global hotkeys of the BuildDocksToolbarWindow. More...
 
WindowShowBuildDocksToolbar ()
 Open the build water toolbar window. More...
 
WindowShowBuildDocksScenToolbar ()
 Open the build water toolbar window for the scenario editor. More...
 
void InitializeDockGui ()
 

Variables

static Axis _ship_depot_direction
 
const uint16 _dockstoolbar_aqueduct_keys [] = {'B', '8', 0}
 
static Hotkey dockstoolbar_hotkeys []
 
static const NWidgetPart _nested_build_docks_toolbar_widgets []
 Nested widget parts of docks toolbar, game version. More...
 
static WindowDesc _build_docks_toolbar_desc (WDP_ALIGN_TOOLBAR, "toolbar_water", 0, 0, WC_BUILD_TOOLBAR, WC_NONE, WDF_CONSTRUCTION, _nested_build_docks_toolbar_widgets, lengthof(_nested_build_docks_toolbar_widgets), &BuildDocksToolbarWindow::hotkeys)
 
static const NWidgetPart _nested_build_docks_scen_toolbar_widgets []
 Nested widget parts of docks toolbar, scenario editor version. More...
 
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. More...
 
static const NWidgetPart _nested_build_dock_station_widgets []
 Nested widget parts of a build dock station window. More...
 
static WindowDesc _build_dock_station_desc (WDP_AUTO, NULL, 0, 0, WC_BUILD_STATION, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, _nested_build_dock_station_widgets, lengthof(_nested_build_dock_station_widgets))
 
static const NWidgetPart _nested_build_docks_depot_widgets []
 
static WindowDesc _build_docks_depot_desc (WDP_AUTO, NULL, 0, 0, WC_BUILD_DEPOT, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, _nested_build_docks_depot_widgets, lengthof(_nested_build_docks_depot_widgets))
 

Detailed Description

GUI to create amazing water objects.

Definition in file dock_gui.cpp.

Enumeration Type Documentation

◆ BuildDockStationWidgets

Widget numbers of the build-dock GUI.

Enumerator
BDSW_BACKGROUND 

Background panel.

BDSW_LT_OFF 

'Off' button of coverage high light.

BDSW_LT_ON 

'On' button of coverage high light.

BDSW_INFO 

'Coverage highlight' label.

Definition at line 393 of file dock_gui.cpp.

Function Documentation

◆ DockToolbarGlobalHotkeys()

static EventState DockToolbarGlobalHotkeys ( int  hotkey)
static

Handler for global hotkeys of the BuildDocksToolbarWindow.

Parameters
hotkeyHotkey
Returns
ES_HANDLED if hotkey was accepted.

Definition at line 286 of file dock_gui.cpp.

◆ GetOtherAqueductEnd()

static TileIndex GetOtherAqueductEnd ( TileIndex  tile_from,
TileIndex tile_to = NULL 
)
static

Gets the other end of the aqueduct, if possible.

Parameters
tile_fromThe begin tile for the aqueduct.
[out]tile_toThe 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 63 of file dock_gui.cpp.

References _settings_game, GameSettings::construction, DistanceFromEdgeDir(), GetInclinedSlopeDirection(), GetTileMaxZ(), GetTileSlope(), IsValidDiagDirection(), IsValidTile(), ConstructionSettings::max_bridge_length, min(), ReverseDiagDir(), TILE_ADD, TILE_ADDXY, TileOffsByDiagDir(), TileX(), and TileY().

Referenced by BuildDocksToolbarWindow::OnPlacePresize().

◆ ShowBuildDocksScenToolbar()

Window* ShowBuildDocksScenToolbar ( )

Open the build water toolbar window for the scenario editor.

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

Definition at line 387 of file dock_gui.cpp.

References _build_docks_scen_toolbar_desc, and TRANSPORT_WATER.

◆ 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 NULL if the toolbar could not be opened.

Definition at line 346 of file dock_gui.cpp.

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

Referenced by MenuClickBuildWater().

Variable Documentation

◆ _build_docks_scen_toolbar_desc

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))
static

Window definition for the build docks in scenario editor window.

Referenced by ShowBuildDocksScenToolbar().

◆ _nested_build_dock_station_widgets

const NWidgetPart _nested_build_dock_station_widgets[]
static
Initial value:
= {
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_DOCK_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BDSW_BACKGROUND),
NWidget(WWT_LABEL, COLOUR_DARK_GREEN, BDSW_INFO), SetMinimalSize(148, 14), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL),
NWidget(WWT_TEXTBTN, COLOUR_GREY, BDSW_LT_OFF), SetMinimalSize(40, 12), SetFill(1, 0), SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
NWidget(WWT_TEXTBTN, COLOUR_GREY, BDSW_LT_ON), SetMinimalSize(40, 12), SetFill(1, 0), SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
}
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:930
Centered label.
Definition: widget_type.h:57
&#39;Coverage highlight&#39; label.
Definition: dock_gui.cpp:397
Horizontal container.
Definition: widget_type.h:75
Close box (at top-left of a window)
Definition: widget_type.h:69
Invisible widget that takes some space.
Definition: widget_type.h:79
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1014
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:947
Background panel.
Definition: dock_gui.cpp:394
Simple depressed panel.
Definition: widget_type.h:50
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new &#39;real&#39; widget.
Definition: widget_type.h:1114
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:61
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME, WWT_INSET, or WWT_PANEL).
Definition: widget_type.h:999
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:983
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1076
&#39;Off&#39; button of coverage high light.
Definition: dock_gui.cpp:395
(Toggle) Button with text
Definition: widget_type.h:55
&#39;On&#39; button of coverage high light.
Definition: dock_gui.cpp:396

Nested widget parts of a build dock station window.

Definition at line 461 of file dock_gui.cpp.

◆ _nested_build_docks_depot_widgets

const NWidgetPart _nested_build_docks_depot_widgets[]
static
Initial value:
= {
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_DEPOT_BUILD_SHIP_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BDD_BACKGROUND),
NWidget(WWT_PANEL, COLOUR_GREY, WID_BDD_X), SetMinimalSize(98, 66), SetDataTip(0x0, STR_DEPOT_BUILD_SHIP_ORIENTATION_TOOLTIP),
NWidget(WWT_PANEL, COLOUR_GREY, WID_BDD_Y), SetMinimalSize(98, 66), SetDataTip(0x0, STR_DEPOT_BUILD_SHIP_ORIENTATION_TOOLTIP),
}
Horizontal container.
Definition: widget_type.h:75
Background of the window.
Definition: dock_widget.h:17
Y-direction button.
Definition: dock_widget.h:19
X-direction button.
Definition: dock_widget.h:18
Close box (at top-left of a window)
Definition: widget_type.h:69
Invisible widget that takes some space.
Definition: widget_type.h:79
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1014
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:947
Simple depressed panel.
Definition: widget_type.h:50
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new &#39;real&#39; widget.
Definition: widget_type.h:1114
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:61
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME, WWT_INSET, or WWT_PANEL).
Definition: widget_type.h:999
Horizontal container that doesn&#39;t change the order of the widgets for RTL languages.
Definition: widget_type.h:76

Definition at line 550 of file dock_gui.cpp.

◆ _nested_build_docks_scen_toolbar_widgets

const NWidgetPart _nested_build_docks_scen_toolbar_widgets[]
static
Initial value:
= {
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_WATERWAYS_TOOLBAR_CAPTION_SE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_CANAL), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_BUILD_CANAL, STR_WATERWAYS_TOOLBAR_CREATE_LAKE_TOOLTIP),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_LOCK), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_BUILD_LOCK, STR_WATERWAYS_TOOLBAR_BUILD_LOCKS_TOOLTIP),
NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetMinimalSize(5, 22), SetFill(1, 1), EndContainer(),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_DEMOLISH), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_RIVER), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_BUILD_RIVER, STR_WATERWAYS_TOOLBAR_CREATE_RIVER_TOOLTIP),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_BUILD_AQUEDUCT), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_AQUEDUCT, STR_WATERWAYS_TOOLBAR_BUILD_AQUEDUCT_TOOLTIP),
}
Build river button (in scenario editor).
Definition: dock_widget.h:30
Horizontal container.
Definition: widget_type.h:75
Close box (at top-left of a window)
Definition: widget_type.h:69
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1014
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:947
Simple depressed panel.
Definition: widget_type.h:50
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new &#39;real&#39; widget.
Definition: widget_type.h:1114
Demolish aka dynamite button.
Definition: dock_widget.h:26
Build aqueduct button.
Definition: dock_widget.h:31
Build lock button.
Definition: dock_widget.h:25
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:61
Build canal button.
Definition: dock_widget.h:24
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME, WWT_INSET, or WWT_PANEL).
Definition: widget_type.h:999
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:66
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:983
(Toggle) Button with image
Definition: widget_type.h:52

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 358 of file dock_gui.cpp.

◆ _nested_build_docks_toolbar_widgets

const NWidgetPart _nested_build_docks_toolbar_widgets[]
static
Initial value:
= {
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_WATERWAYS_TOOLBAR_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_CANAL), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_BUILD_CANAL, STR_WATERWAYS_TOOLBAR_BUILD_CANALS_TOOLTIP),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_LOCK), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_BUILD_LOCK, STR_WATERWAYS_TOOLBAR_BUILD_LOCKS_TOOLTIP),
NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetMinimalSize(5, 22), SetFill(1, 1), EndContainer(),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_DEMOLISH), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_DEPOT), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_SHIP_DEPOT, STR_WATERWAYS_TOOLBAR_BUILD_DEPOT_TOOLTIP),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_STATION), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_SHIP_DOCK, STR_WATERWAYS_TOOLBAR_BUILD_DOCK_TOOLTIP),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_BUOY), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_BUOY, STR_WATERWAYS_TOOLBAR_BUOY_TOOLTIP),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_DT_BUILD_AQUEDUCT), SetMinimalSize(23, 22), SetFill(0, 1), SetDataTip(SPR_IMG_AQUEDUCT, STR_WATERWAYS_TOOLBAR_BUILD_AQUEDUCT_TOOLTIP),
}
Build depot button.
Definition: dock_widget.h:27
Build station button.
Definition: dock_widget.h:28
Horizontal container.
Definition: widget_type.h:75
Close box (at top-left of a window)
Definition: widget_type.h:69
Build buoy button.
Definition: dock_widget.h:29
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1014
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:947
Simple depressed panel.
Definition: widget_type.h:50
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new &#39;real&#39; widget.
Definition: widget_type.h:1114
Demolish aka dynamite button.
Definition: dock_widget.h:26
Build aqueduct button.
Definition: dock_widget.h:31
Build lock button.
Definition: dock_widget.h:25
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:61
Build canal button.
Definition: dock_widget.h:24
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME, WWT_INSET, or WWT_PANEL).
Definition: widget_type.h:999
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:66
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:983
(Toggle) Button with image
Definition: widget_type.h:52
Horizontal container that doesn&#39;t change the order of the widgets for RTL languages.
Definition: widget_type.h:76

Nested widget parts of docks toolbar, game version.

Position of WID_DT_RIVER widget has changed.

Definition at line 313 of file dock_gui.cpp.

◆ dockstoolbar_hotkeys

Hotkey dockstoolbar_hotkeys[]
static
Initial value:
= {
Hotkey('1', "canal", WID_DT_CANAL),
Hotkey('2', "lock", WID_DT_LOCK),
Hotkey('3', "demolish", WID_DT_DEMOLISH),
Hotkey('4', "depot", WID_DT_DEPOT),
Hotkey('5', "dock", WID_DT_STATION),
Hotkey('6', "buoy", WID_DT_BUOY),
Hotkey('7', "river", WID_DT_RIVER),
Hotkey(_dockstoolbar_aqueduct_keys, "aqueduct", WID_DT_BUILD_AQUEDUCT),
HOTKEY_LIST_END
}
Build river button (in scenario editor).
Definition: dock_widget.h:30
All data for a single hotkey.
Definition: hotkeys.h:24
Build depot button.
Definition: dock_widget.h:27
Build station button.
Definition: dock_widget.h:28
Build buoy button.
Definition: dock_widget.h:29
Demolish aka dynamite button.
Definition: dock_widget.h:26
Build aqueduct button.
Definition: dock_widget.h:31
Build lock button.
Definition: dock_widget.h:25
Build canal button.
Definition: dock_widget.h:24

Definition at line 296 of file dock_gui.cpp.