# bridge_gui.cpp File Reference

Graphical user interface for bridge construction. More...

`#include "stdafx.h"`
`#include "gui.h"`
`#include "window_gui.h"`
`#include "command_func.h"`
`#include "economy_func.h"`
`#include "bridge.h"`
`#include "strings_func.h"`
`#include "window_func.h"`
`#include "sound_func.h"`
`#include "map_func.h"`
`#include "gfx_func.h"`
`#include "tunnelbridge.h"`
`#include "sortlist_type.h"`
`#include "widgets/dropdown_func.h"`
`#include "table/strings.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
## Typedefs
typedef GUIList< BuildBridgeData > | GUIBridgeList
## Enumerations
enum | BuildBridgeSelectionWidgets { BBSW_CLOSEBOX = 0, BBSW_CAPTION, BBSW_DROPDOWN_ORDER, BBSW_DROPDOWN_CRITERIA, BBSW_BRIDGE_LIST, BBSW_SCROLLBAR, BBSW_RESIZEBOX }
## Functions
void | CcBuildBridge (bool success, TileIndex tile, uint32 p1, uint32 p2)
| Callback executed after a build Bridge CMD has been called.
void | ShowBuildBridgeWindow (TileIndex start, TileIndex end, TransportType transport_type, byte road_rail_type)
| Prepare the data for the build a bridge window.
## 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 const Widget | _build_bridge_widgets []
static const WindowDesc | _build_bridge_desc (WDP_AUTO, WDP_AUTO, 200, 114, 200, 114, WC_BUILD_BRIDGE, WC_BUILD_TOOLBAR, WDF_STD_TOOLTIPS|WDF_STD_BTN|WDF_DEF_WIDGET|WDF_RESIZABLE|WDF_CONSTRUCTION, _build_bridge_widgets)

## Detailed Description

Graphical user interface for bridge construction.

Definition in file bridge_gui.cpp.

## Function Documentation

void CcBuildBridge | ( | bool | success,
|  | TileIndex | tile,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Callback executed after a build Bridge CMD has been called.

Parameters:

  | scucess | True if the build succeded
  | tile | The tile where the command has been executed
  | p1 | not used
  | p2 | not used

Definition at line 46 of file bridge_gui.cpp.

Referenced by 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.

start The start tile of the bridge

Parameters:

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

Definition at line 288 of file bridge_gui.cpp.

References _ctrl_pressed, _last_railbridge_type, _last_roadbridge_type, CalcBridgeLenCostFactor(), CcBuildBridge(), CMD_BUILD_BRIDGE, CMD_MSG, CmdFailed(), BuildBridgeData::cost, DC_AUTO, DC_QUERY_COST, DeleteWindowById(), DoCommand(), DoCommandP(), CommandCost::GetCost(), GetTunnelBridgeLength(), BuildBridgeData::index, INVALID_STRING_ID, BridgeSpec::price, BuildBridgeData::spec, TILE_SIZE, TileX(), TileY(), TRANSPORT_RAIL, and TRANSPORT_ROAD.

Referenced by BuildRailToolbarWindow::OnPlaceMouseUp().

## Variable Documentation

const Widget _build_bridge_widgets[]`[static]`

Initial value:

     {
    {   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_DARK_GREEN,   0,  10,   0,  13, STR_00C5,                    STR_018B_CLOSE_WINDOW},
    {    WWT_CAPTION,   RESIZE_NONE,  COLOUR_DARK_GREEN,  11, 199,   0,  13, STR_100D_SELECT_RAIL_BRIDGE, STR_018C_WINDOW_TITLE_DRAG_THIS},

    {    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,   0,  80,  14,  25, STR_SORT_BY,                 STR_SORT_ORDER_TIP},
    {   WWT_DROPDOWN,   RESIZE_NONE,  COLOUR_DARK_GREEN,  81, 199,  14,  25, 0x0,                         STR_SORT_CRITERIA_TIP},

    {     WWT_MATRIX, RESIZE_BOTTOM,  COLOUR_DARK_GREEN,   0, 187,  26, 113, 0x401,                       STR_101F_BRIDGE_SELECTION_CLICK},
    {  WWT_SCROLLBAR, RESIZE_BOTTOM,  COLOUR_DARK_GREEN, 188, 199,  26, 101, 0x0,                         STR_0190_SCROLL_BAR_SCROLLS_LIST},
    {  WWT_RESIZEBOX,     RESIZE_TB,  COLOUR_DARK_GREEN, 188, 199, 102, 113, 0x0,                         STR_RESIZE_BUTTON},
    {   WIDGETS_END},
    }

Definition at line 257 of file bridge_gui.cpp.