OpenTTD Source: src/bridge_gui.cpp File Reference

OpenTTD Source 14.0-beta1

Data Structures | Typedefs | Functions | Variables
bridge_gui.cpp File Reference
`#include "stdafx.h"`
`#include "error.h"`
`#include "command_func.h"`
`#include "rail.h"`
`#include "road.h"`
`#include "strings_func.h"`
`#include "window_func.h"`
`#include "sound_func.h"`
`#include "gfx_func.h"`
`#include "tunnelbridge.h"`
`#include "sortlist_type.h"`
`#include "widgets/dropdown_func.h"`
`#include "core/geometry_func.hpp"`
`#include "tunnelbridge_map.h"`
`#include "road_gui.h"`
`#include "tunnelbridge_cmd.h"`
`#include "widgets/bridge_widget.h"`
`#include "table/strings.h"`
`#include "safeguards.h"`

Go to the source code of this file.

## Data Structures
struct | BuildBridgeData
| Carriage for the data we need if we want to build a bridge. More...
class | BuildBridgeWindow
| Window class for handling the bridge-build GUI. More...

## Typedefs
typedef GUIList< BuildBridgeData > | GUIBridgeList
| List of bridges, used in BuildBridgeWindow.

## Functions
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. More...
void | ShowBuildBridgeWindow (TileIndex start, TileIndex end, TransportType transport_type, byte road_rail_type)
| Prepare the data for the build a bridge window. More...

## Variables
static BridgeType | _last_railbridge_type = 0
| The type of the last built rail bridge.
static BridgeType | _last_roadbridge_type = 0
| The type of the last built road bridge.
static constexpr NWidgetPart | _nested_build_bridge_widgets []
| Widgets of the bridge gui. More...
static WindowDesc | _build_bridge_desc (__FILE__, __LINE__, WDP_AUTO, "build_bridge", 200, 114, WC_BUILD_BRIDGE, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, std::begin(_nested_build_bridge_widgets), std::end(_nested_build_bridge_widgets))
| Window definition for the rail bridge selection window.

## Detailed Description

Graphical user interface for bridge construction

Definition in file bridge_gui.cpp.

## Function Documentation

## ◆ CcBuildBridge()

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.

Parameters

  result | Whether the build succeeded
  end_tile | End tile of the bridge.
  tile_start | start tile
  transport_type | transport type.

Definition at line 57 of file bridge_gui.cpp.

Referenced by ShowBuildBridgeWindow().

## ◆ ShowBuildBridgeWindow()

void ShowBuildBridgeWindow | ( | TileIndex | start,
|  | TileIndex | end,
|  | TransportType | transport_type,
|  | byte | road_rail_type
| ) |  |

Prepare the data for the build a bridge window.

If we can't build a bridge under the given conditions show an error message.

Parameters

  start | The start tile of the bridge
  end | The end tile of the bridge
  transport_type | The transport type
  road_rail_type | The road/rail type

Definition at line 361 of file bridge_gui.cpp.

References _ctrl_pressed, _last_railbridge_type, _last_roadbridge_type, CalcBridgeLenCostFactor(), CcBuildBridge(), CheckBridgeAvailability(), CloseWindowByClass(), CommandFlagsToDCFlags(), DC_QUERY_COST, CommandCost::Failed(), CommandCost::GetErrorMessage(), GetTunnelBridgeLength(), INVALID_ROADTYPE, INVALID_STRING_ID, IsBridgeTile(), TRANSPORT_RAIL, TRANSPORT_ROAD, and WC_BUILD_BRIDGE.

## Variable Documentation

## ◆ _nested_build_bridge_widgets

constexpr NWidgetPart _nested_build_bridge_widgets[]
| staticconstexpr

Initial value:
= {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BBS_CAPTION), SetDataTip(STR_SELECT_RAIL_BRIDGE_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_DEFSIZEBOX, COLOUR_DARK_GREEN),
EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(NWID_VERTICAL),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_TEXTBTN, COLOUR_DARK_GREEN, WID_BBS_DROPDOWN_ORDER), SetFill(1, 0), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER),
NWidget(WWT_DROPDOWN, COLOUR_DARK_GREEN, WID_BBS_DROPDOWN_CRITERIA), SetFill(1, 0), SetDataTip(0x0, STR_TOOLTIP_SORT_CRITERIA),
EndContainer(),
NWidget(WWT_MATRIX, COLOUR_DARK_GREEN, WID_BBS_BRIDGE_LIST), SetFill(1, 0), SetResize(0, 22), SetMatrixDataTip(1, 0, STR_SELECT_BRIDGE_SELECTION_TOOLTIP), SetScrollbar(WID_BBS_SCROLLBAR),
EndContainer(),
NWidget(NWID_VERTICAL),
NWidget(NWID_VSCROLLBAR, COLOUR_DARK_GREEN, WID_BBS_SCROLLBAR),
NWidget(WWT_RESIZEBOX, COLOUR_DARK_GREEN),
EndContainer(),
EndContainer(),
}

Widgets of the bridge gui.

Definition at line 316 of file bridge_gui.cpp.

SetFill
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1141
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:63
WWT_DEFSIZEBOX
@ WWT_DEFSIZEBOX
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX)
Definition: widget_type.h:67
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:77
WWT_MATRIX
@ WWT_MATRIX
Grid of rows and columns.
Definition: widget_type.h:61
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1151
SetMatrixDataTip
constexpr NWidgetPart SetMatrixDataTip(uint8_t cols, uint8_t rows, StringID tip)
Widget part function for setting the data and tooltip of WWT_MATRIX widgets.
Definition: widget_type.h:1174
WID_BBS_DROPDOWN_ORDER
@ WID_BBS_DROPDOWN_ORDER
Direction of sort dropdown.
Definition: bridge_widget.h:16
SetResize
constexpr NWidgetPart SetResize(int16_t dx, int16_t dy)
Widget part function for setting the resize step.
Definition: widget_type.h:1086
SetScrollbar
constexpr NWidgetPart SetScrollbar(WidgetID index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1244
WID_BBS_BRIDGE_LIST
@ WID_BBS_BRIDGE_LIST
List of bridges.
Definition: bridge_widget.h:18
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1258
WID_BBS_SCROLLBAR
@ WID_BBS_SCROLLBAR
Scrollbar of the list.
Definition: bridge_widget.h:19
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:79
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:71
WWT_RESIZEBOX
@ WWT_RESIZEBOX
Resize box (normally at bottom-right of a window)
Definition: widget_type.h:70
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:86
WID_BBS_CAPTION
@ WID_BBS_CAPTION
Caption of the window.
Definition: bridge_widget.h:15
SetDataTip
constexpr NWidgetPart SetDataTip(uint32_t data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1162
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:57
WWT_DROPDOWN
@ WWT_DROPDOWN
Drop down list.
Definition: widget_type.h:72
WID_BBS_DROPDOWN_CRITERIA
@ WID_BBS_DROPDOWN_CRITERIA
Criteria of sort dropdown.
Definition: bridge_widget.h:17