OpenTTD Source: src/rail_gui.cpp File Reference

OpenTTD Source 15.3

Data Structures | Functions | Variables
rail_gui.cpp File Reference

File for dealing with rail construction user interface More...

`#include "stdafx.h"`
`#include "gui.h"`
`#include "station_base.h"`
`#include "waypoint_base.h"`
`#include "window_gui.h"`
`#include "station_gui.h"`
`#include "terraform_gui.h"`
`#include "viewport_func.h"`
`#include "command_func.h"`
`#include "waypoint_func.h"`
`#include "newgrf_badge.h"`
`#include "newgrf_badge_gui.h"`
`#include "newgrf_station.h"`
`#include "company_base.h"`
`#include "strings_func.h"`
`#include "window_func.h"`
`#include "sound_func.h"`
`#include "company_func.h"`
`#include "dropdown_type.h"`
`#include "dropdown_func.h"`
`#include "tunnelbridge.h"`
`#include "tilehighlight_func.h"`
`#include "core/geometry_func.hpp"`
`#include "hotkeys.h"`
`#include "engine_base.h"`
`#include "vehicle_func.h"`
`#include "zoom_func.h"`
`#include "rail_gui.h"`
`#include "station_cmd.h"`
`#include "tunnelbridge_cmd.h"`
`#include "waypoint_cmd.h"`
`#include "rail_cmd.h"`
`#include "timer/timer.h"`
`#include "timer/timer_game_calendar.h"`
`#include "picker_gui.h"`
`#include "station_map.h"`
`#include "tunnelbridge_map.h"`
`#include "widgets/rail_widget.h"`
`#include "table/strings.h"`
`#include "safeguards.h"`

Go to the source code of this file.

## Data Structures
struct | WaypointPickerSelection
struct | StationPickerSelection
struct | BuildRailToolbarWindow
| Rail toolbar management class. More...
class | StationPickerCallbacks
struct | BuildRailStationWindow
struct | BuildSignalWindow
struct | BuildRailDepotWindow
class | WaypointPickerCallbacks
struct | BuildRailWaypointWindow

## Functions
static void | HandleStationPlacement (TileIndex start, TileIndex end)
static void | ShowBuildTrainDepotPicker (Window *parent)
static void | ShowBuildWaypointPicker (Window *parent)
static Window * | ShowStationBuilder (Window *parent)
| Open station build window.
static void | ShowSignalBuilder (Window *parent)
| Open the signal selection window.
static bool | IsStationAvailable (const StationSpec *statspec)
| Check whether a station type can be build.
void | CcPlaySound_CONSTRUCTION_RAIL (Commands, const CommandCost &result, TileIndex tile)
static void | GenericPlaceRail (TileIndex tile, Track track)
static void | PlaceExtraDepotRail (TileIndex tile, DiagDirection dir, Track track)
| Try to add an additional rail-track at the entrance of a depot.
void | CcRailDepot (Commands, const CommandCost &result, TileIndex tile, RailType, DiagDirection dir)
static void | PlaceRail_Waypoint (TileIndex tile)
| Place a rail waypoint.
void | CcStation (Commands, const CommandCost &result, TileIndex tile)
static void | PlaceRail_Station (TileIndex tile)
| Place a rail station.
static void | GenericPlaceSignals (TileIndex tile)
| Build a new signal or edit/remove a present signal, use CmdBuildSingleSignal() or CmdRemoveSingleSignal() in rail_cmd.cpp.
static void | PlaceRail_Bridge (TileIndex tile, Window *w)
| Start placing a rail bridge.
void | CcBuildRailTunnel (Commands, const CommandCost &result, TileIndex tile)
| Command callback for building a tunnel.
static void | ToggleRailButton_Remove (Window *w)
| Toggles state of the Remove button of Build rail toolbar.
static bool | RailToolbar_CtrlChanged (Window *w)
| Updates the Remove button because of Ctrl state change.
static void | BuildRailClick_Remove (Window *w)
| The "remove"-button click proc of the build-rail toolbar.
static void | DoRailroadTrack (Track track)
static void | HandleAutodirPlacement ()
static void | HandleAutoSignalPlacement ()
| Build new signals or remove signals or (if only one tile marked) edit a signal.
Window * | ShowBuildRailToolbar (RailType railtype)
| Open the build rail toolbar window for a specific rail type.
static bool | StationUsesDefaultType (const BaseStation *bst)
| Test if a station/waypoint uses the default graphics.
void | InitializeRailGui ()
| Initialize rail building GUI settings.
void | ReinitGuiAfterToggleElrail (bool disable)
| Re-initialize rail-build toolbar after toggling support for electric trains.
static void | SetDefaultRailGui ()
| Set the initial (default) railtype to use.
void | ResetSignalVariant (int32_t)
| Updates the current signal variant used in the signal GUI to the one adequate to current year.
void | InitializeRailGUI ()
| Resets the rail GUI - sets default railtype to build and resets the signal GUI.
DropDownList | GetRailTypeDropDownList (bool for_replacement, bool all_option)
| Create a drop down list for all the rail types of the local company.

## Variables
static RailType | _cur_railtype
| Rail type of the current build-rail toolbar.
static bool | _remove_button_clicked
| Flag whether 'remove' toggle-button is currently enabled.
static DiagDirection | _build_depot_direction
| Currently selected depot direction.
static bool | _convert_signal_button
| convert signal button in the signal GUI pressed
static SignalVariant | _cur_signal_variant
| set the signal variant (for signal GUI)
static SignalType | _cur_signal_type
| set the signal type (for signal GUI)
static WaypointPickerSelection | _waypoint_gui
| Settings of the waypoint picker.
static StationPickerSelection | _station_gui
| Settings of the station picker.
static const Track | _place_depot_extra_track [12]
| Additional pieces of track to add at the entrance of a depot.
static const DiagDirection | _place_depot_extra_dir [12]
| Direction to check for existing track pieces.
static constexpr std::initializer_list< NWidgetPart > | _nested_build_rail_widgets
static WindowDesc | _build_rail_desc (WDP_MANUAL, "toolbar_rail", 0, 0, WC_BUILD_TOOLBAR, WC_NONE, WindowDefaultFlag::Construction, _nested_build_rail_widgets, &BuildRailToolbarWindow::hotkeys)
static constexpr std::initializer_list< NWidgetPart > | _nested_station_builder_widgets
static WindowDesc | _station_builder_desc (WDP_AUTO, "build_station_rail", 0, 0, WC_BUILD_STATION, WC_BUILD_TOOLBAR, WindowDefaultFlag::Construction, _nested_station_builder_widgets, &BuildRailStationWindow::hotkeys)
| High level window description of the station-build window (default & newGRF)
static constexpr std::initializer_list< NWidgetPart > | _nested_signal_builder_widgets
| Nested widget definition of the build signal window.
static WindowDesc | _signal_builder_desc (WDP_AUTO, {}, 0, 0, WC_BUILD_SIGNAL, WC_BUILD_TOOLBAR, WindowDefaultFlag::Construction, _nested_signal_builder_widgets)
| Signal selection window description.
static constexpr std::initializer_list< NWidgetPart > | _nested_build_depot_widgets
| Nested widget definition of the build rail depot window.
static WindowDesc | _build_depot_desc (WDP_AUTO, {}, 0, 0, WC_BUILD_DEPOT, WC_BUILD_TOOLBAR, WindowDefaultFlag::Construction, _nested_build_depot_widgets)
static constexpr std::initializer_list< NWidgetPart > | _nested_build_waypoint_widgets
| Nested widget definition for the build NewGRF rail waypoint window.
static WindowDesc | _build_waypoint_desc (WDP_AUTO, "build_waypoint", 0, 0, WC_BUILD_WAYPOINT, WC_BUILD_TOOLBAR, WindowDefaultFlag::Construction, _nested_build_waypoint_widgets, &BuildRailWaypointWindow::hotkeys)
static const IntervalTimer< TimerGameCalendar > | _check_reset_signal ({TimerGameCalendar::YEAR, TimerGameCalendar::Priority::NONE}, [](auto) { if(TimerGameCalendar::year !=_settings_client.gui.semaphore_build_before) return;ResetSignalVariant();})

## Detailed Description

File for dealing with rail construction user interface

Definition in file rail_gui.cpp.

## Function Documentation

## ◆ BuildRailClick_Remove()

static void BuildRailClick_Remove | ( | Window * | w | ) |
| static

The "remove"-button click proc of the build-rail toolbar.

Parameters

  w | Build-rail toolbar window

See also
  BuildRailToolbarWindow::OnClick()

Definition at line 355 of file rail_gui.cpp.

References _remove_button_clicked, _settings_client, _settings_game, _station_gui, StationPickerSelection::axis, ClientSettings::gui, Window::IsWidgetDisabled(), Window::IsWidgetLowered(), SetTileSelectSize(), SndClickBeep(), GameSettings::station, GUISettings::station_dragdrop, GUISettings::station_numtracks, GUISettings::station_platlength, StationSettings::station_spread, ToggleRailButton_Remove(), WID_RAT_BUILD_STATION, and WID_RAT_REMOVE.

Referenced by BuildRailToolbarWindow::OnClick().

## ◆ CcBuildRailTunnel()

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

Command callback for building a tunnel.

Definition at line 306 of file rail_gui.cpp.

References _build_tunnel_endtile, _settings_client, SoundSettings::confirm, ClientSettings::gui, GUISettings::persistent_buildingtools, ResetObjectToPlace(), SetRedErrorSquare(), SND_20_CONSTRUCTION_RAIL, ClientSettings::sound, and CommandCost::Succeeded().

## ◆ CcPlaySound_CONSTRUCTION_RAIL()

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

Definition at line 97 of file rail_gui.cpp.

## ◆ CcRailDepot()

void CcRailDepot | ( | Commands | cmd,
|  | const CommandCost & | result,
|  | TileIndex | tile,
|  | RailType | rt,
|  | DiagDirection | dir
| ) |  |

Definition at line 143 of file rail_gui.cpp.

## ◆ CcStation()

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

Definition at line 187 of file rail_gui.cpp.

## ◆ DoRailroadTrack()

static void DoRailroadTrack | ( | Track | track | ) |
| static

Definition at line 384 of file rail_gui.cpp.

## ◆ GenericPlaceRail()

static void GenericPlaceRail | ( | TileIndex | tile,
|  | Track | track
| ) |  |
| static

Definition at line 102 of file rail_gui.cpp.

## ◆ GenericPlaceSignals()

static void GenericPlaceSignals | ( | TileIndex | tile | ) |
| static

Build a new signal or edit/remove a present signal, use CmdBuildSingleSignal() or CmdRemoveSingleSignal() in rail_cmd.cpp.

Parameters

  tile | The tile where the signal will build or edit

Definition at line 236 of file rail_gui.cpp.

References _convert_signal_button, _ctrl_pressed, _cur_signal_type, _cur_signal_variant, _remove_button_clicked, _settings_client, GUISettings::cycle_signal_types, GUISettings::default_signal_type, FindFirstTrack(), FindWindowById(), GetTileTrackStatus(), ClientSettings::gui, HasSignalOnTrack(), IsPlainRailTile(), IsValidTrack(), GUISettings::semaphore_build_before, SIG_ELECTRIC, SIG_SEMAPHORE, SIGNAL_CYCLE_ALL, SIGNAL_GUI_ALL, GUISettings::signal_gui_mode, SIGTYPE_BLOCK, SIGTYPE_PBS, TRACK_BIT_HORZ, TRACK_BIT_LEFT, TRACK_BIT_LOWER, TRACK_BIT_RIGHT, TRACK_BIT_UPPER, TRACK_BIT_VERT, TrackStatusToTrackBits(), TRANSPORT_RAIL, WC_BUILD_SIGNAL, Coord2D< T >::x, Coord2D< T >::y, and TimerGameCalendar::year.

Referenced by HandleAutoSignalPlacement().

## ◆ GetRailTypeDropDownList()

DropDownList GetRailTypeDropDownList | ( | bool | for_replacement,
|  | bool | all_option
| ) |  |

Create a drop down list for all the rail types of the local company.

Parameters

  for_replacement | Whether this list is for the replacement window.
  all_option | Whether to add an 'all types' item.

Returns
  The populated and sorted DropDownList.

Definition at line 2030 of file rail_gui.cpp.

References _local_company, _sorted_railtypes, Company::avail_railtypes, RailTypeInfo::build_x_rail, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::Get(), GetCompanyRailTypes(), GetRailTypeInfo(), GetRailTypes(), GetSpriteSize(), GetString(), RailTypeInfo::gui_sprites, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, RailTypeInfo::introduction_date, INVALID_RAILTYPE, RailTypeInfo::max_speed, maxdim(), RailTypeInfo::menu_text, RailBuildCost(), RailTypeInfo::replace_text, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Reset(), RailTypeInfo::strings, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

Referenced by ReplaceVehicleWindow::OnClick().

## ◆ HandleAutodirPlacement()

static void HandleAutodirPlacement | ( |  | ) |
| static

Definition at line 395 of file rail_gui.cpp.

## ◆ HandleAutoSignalPlacement()

static void HandleAutoSignalPlacement | ( |  | ) |
| static

Build new signals or remove signals or (if only one tile marked) edit a signal.

If one tile marked abort and use GenericPlaceSignals() else use CmdBuildSingleSignal() or CmdRemoveSingleSignal() in rail_cmd.cpp to build many signals

Definition at line 413 of file rail_gui.cpp.

References _ctrl_pressed, _cur_signal_type, _cur_signal_variant, _remove_button_clicked, _settings_client, GUISettings::default_signal_type, GUISettings::drag_signals_density, GUISettings::drag_signals_fixed_distance, TileHighlightData::drawstyle, FindWindowById(), GB(), GenericPlaceSignals(), ClientSettings::gui, HT_DRAG_MASK, HT_RECT, TileHighlightData::selend, TileHighlightData::selstart, GUISettings::semaphore_build_before, SIG_ELECTRIC, SIG_SEMAPHORE, TileVirtXY(), WC_BUILD_SIGNAL, Coord2D< T >::x, Coord2D< T >::y, and TimerGameCalendar::year.

Referenced by BuildRailToolbarWindow::OnPlaceMouseUp().

## ◆ HandleStationPlacement()

static void HandleStationPlacement | ( | TileIndex | start,
|  | TileIndex | end
| ) |  |
| static

Definition at line 937 of file rail_gui.cpp.

## ◆ InitializeRailGui()

void InitializeRailGui | ( |  | ) |

Initialize rail building GUI settings.

Definition at line 1915 of file rail_gui.cpp.

References _build_depot_direction, _station_gui, _waypoint_gui, DIAGDIR_NW, WaypointPickerSelection::sel_class, StationPickerSelection::sel_class, WaypointPickerSelection::sel_type, StationPickerSelection::sel_type, STAT_CLASS_DFLT, and STAT_CLASS_WAYP.

## ◆ InitializeRailGUI()

void InitializeRailGUI | ( |  | ) |

Resets the rail GUI - sets default railtype to build and resets the signal GUI.

Definition at line 2015 of file rail_gui.cpp.

References _convert_signal_button, _cur_signal_type, _settings_client, GUISettings::default_signal_type, ClientSettings::gui, ResetSignalVariant(), and SetDefaultRailGui().

Referenced by AfterLoadGame().

## ◆ IsStationAvailable()

static bool IsStationAvailable | ( | const StationSpec * | statspec | ) |
| static

Check whether a station type can be build.

Returns
  true if building is allowed.

Definition at line 87 of file rail_gui.cpp.

References Avail, CALLBACK_FAILED, StationSpec::callback_mask, CBID_STATION_AVAILABILITY, Convert8bitBooleanCallback(), StationSpec::grf_prop, GRFFilePropsBase::grffile, INVALID_TILE, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

Referenced by StationPickerCallbacks::IsTypeAvailable(), and WaypointPickerCallbacks::IsTypeAvailable().

## ◆ PlaceExtraDepotRail()

static void PlaceExtraDepotRail | ( | TileIndex | tile,
|  | DiagDirection | dir,
|  | Track | track
| ) |  |
| static

Try to add an additional rail-track at the entrance of a depot.

Parameters

  tile | Tile to use for adding the rail-track
  dir | Direction to check for already present tracks
  track | Track to add

See also
  CcRailDepot()

Definition at line 120 of file rail_gui.cpp.

References _cur_railtype, _settings_client, GUISettings::auto_remove_signals, Depot, DiagdirReachesTracks(), GetRailTileType(), GetTrackBits(), ClientSettings::gui, and Signals.

## ◆ PlaceRail_Bridge()

static void PlaceRail_Bridge | ( | TileIndex | tile,
|  | Window * | w
| ) |  |
| static

Start placing a rail bridge.

Parameters

  tile | Position of the first tile of the bridge.
  w | Rail toolbar window.

Definition at line 294 of file rail_gui.cpp.

References DDSP_BUILD_BRIDGE, GetOtherTunnelBridgeEnd(), IsBridgeTile(), Window::OnPlaceMouseUp(), VPM_X_OR_Y, and VpStartPlaceSizing().

Referenced by BuildRailToolbarWindow::OnPlaceObject().

## ◆ PlaceRail_Station()

static void PlaceRail_Station | ( | TileIndex | tile | ) |
| static

Place a rail station.

Parameters

  tile | Position to place or start dragging a station.

Definition at line 200 of file rail_gui.cpp.

References _ctrl_pressed, _cur_railtype, _remove_button_clicked, _settings_client, _settings_game, _station_gui, StationPickerSelection::axis, CommandFlagsToDCFlags(), DDSP_BUILD_STATION, DDSP_REMOVE_STATION, ClientSettings::gui, StationPickerSelection::sel_class, StationPickerSelection::sel_type, ShowSelectStationIfNeeded(), GameSettings::station, GUISettings::station_dragdrop, GUISettings::station_numtracks, GUISettings::station_platlength, StationSettings::station_spread, VPM_X_AND_Y_LIMITED, and VpStartPlaceSizing().

Referenced by BuildRailToolbarWindow::OnPlaceObject().

## ◆ PlaceRail_Waypoint()

static void PlaceRail_Waypoint | ( | TileIndex | tile | ) |
| static

Place a rail waypoint.

Parameters

  tile | Position to start dragging a waypoint.

Definition at line 168 of file rail_gui.cpp.

References _remove_button_clicked, _settings_game, AXIS_X, DDSP_BUILD_STATION, DDSP_REMOVE_STATION, GetAxisForNewRailWaypoint(), IsValidAxis(), STAT_CLASS_WAYP, GameSettings::station, StationSettings::station_spread, VPM_X_AND_Y, VPM_X_LIMITED, VPM_Y_LIMITED, and VpStartPlaceSizing().

Referenced by BuildRailToolbarWindow::OnPlaceObject().

## ◆ RailToolbar_CtrlChanged()

static bool RailToolbar_CtrlChanged | ( | Window * | w | ) |
| static

Updates the Remove button because of Ctrl state change.

Parameters

  w | window the button belongs to

Returns
  true iff the remove button was changed

Definition at line 334 of file rail_gui.cpp.

References Window::IsWidgetDisabled(), Window::IsWidgetLowered(), ToggleRailButton_Remove(), WID_RAT_BUILD_NS, WID_RAT_BUILD_STATION, WID_RAT_BUILD_WAYPOINT, and WID_RAT_REMOVE.

Referenced by BuildRailToolbarWindow::OnClick(), and BuildRailToolbarWindow::OnCTRLStateChange().

## ◆ ReinitGuiAfterToggleElrail()

void ReinitGuiAfterToggleElrail | ( | bool | disable | ) |

Re-initialize rail-build toolbar after toggling support for electric trains.

Parameters

  disable | Boolean whether electric trains are disabled (removed from the game)

Definition at line 1928 of file rail_gui.cpp.

References _cur_railtype, FindWindowById(), MarkWholeScreenDirty(), BuildRailToolbarWindow::ModifyRailType(), RAILTYPE_ELECTRIC, RAILTYPE_RAIL, TRANSPORT_RAIL, and WC_BUILD_TOOLBAR.

## ◆ ResetSignalVariant()

void ResetSignalVariant | ( | int32_t |  | ) |

Updates the current signal variant used in the signal GUI to the one adequate to current year.

Definition at line 1990 of file rail_gui.cpp.

References _cur_signal_type, _cur_signal_variant, _settings_client, FindWindowById(), ClientSettings::gui, Window::RaiseWidget(), GUISettings::semaphore_build_before, Window::SetDirty(), SIG_ELECTRIC, SIG_SEMAPHORE, WC_BUILD_SIGNAL, WID_BS_ELECTRIC_NORM, WID_BS_SEMAPHORE_NORM, and TimerGameCalendar::year.

Referenced by ClickChangeDateCheat(), and InitializeRailGUI().

## ◆ SetDefaultRailGui()

static void SetDefaultRailGui | ( |  | ) |
| static

Set the initial (default) railtype to use.

Definition at line 1940 of file rail_gui.cpp.

References _cur_railtype, _local_company, _settings_client, _sorted_railtypes, COMPANY_SPECTATOR, GUISettings::default_rail_type, FindWindowById(), GetRailType(), GetTunnelBridgeTransportType(), ClientSettings::gui, HasStationTileRail(), IsLevelCrossingTile(), IsTileType(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::IsValidID(), Map::Iterate(), BuildRailToolbarWindow::ModifyRailType(), MP_RAILWAY, MP_TUNNELBRIDGE, RAILTYPE_BEGIN, TRANSPORT_RAIL, and WC_BUILD_TOOLBAR.

Referenced by InitializeRailGUI().

## ◆ ShowBuildRailToolbar()

Window * ShowBuildRailToolbar | ( | RailType | railtype | ) |

Open the build rail toolbar window for a specific rail type.

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

Parameters

  railtype | Rail type to open the window for

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

Definition at line 923 of file rail_gui.cpp.

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

Referenced by MenuClickBuildRail(), MainToolbarWindow::OnHotkey(), and BuildRailToolbarWindow::RailToolbarGlobalHotkeys().

## ◆ ShowBuildTrainDepotPicker()

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

Definition at line 1786 of file rail_gui.cpp.

## ◆ ShowBuildWaypointPicker()

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

Definition at line 1906 of file rail_gui.cpp.

## ◆ ShowSignalBuilder()

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

Open the signal selection window.

Definition at line 1708 of file rail_gui.cpp.

References _signal_builder_desc.

Referenced by BuildRailToolbarWindow::OnClick().

## ◆ ShowStationBuilder()

static Window * ShowStationBuilder | ( | Window * | parent | ) |
| static

Open station build window.

Definition at line 1454 of file rail_gui.cpp.

References _station_builder_desc.

Referenced by BuildRailStationWindow::BuildRailStationGlobalHotkeys(), and BuildRailToolbarWindow::OnClick().

## ◆ StationUsesDefaultType()

static bool StationUsesDefaultType | ( | const BaseStation * | bst | ) |
| static

Test if a station/waypoint uses the default graphics.

Parameters

  bst | Station to test.

Returns
  true if at least one of its rail station tiles uses the default graphics.

Definition at line 965 of file rail_gui.cpp.

References GetCustomStationSpecIndex(), HasStationRail(), BaseStation::TileBelongsToRailStation(), and BaseStation::train_station.

Referenced by StationPickerCallbacks::FillUsedItems(), and WaypointPickerCallbacks::FillUsedItems().

## ◆ ToggleRailButton_Remove()

static void ToggleRailButton_Remove | ( | Window * | w | ) |
| static

Toggles state of the Remove button of Build rail toolbar.

Parameters

  w | window the button belongs to

Definition at line 320 of file rail_gui.cpp.

References _remove_button_clicked, CloseWindowById(), Window::IsWidgetLowered(), Window::SetWidgetDirty(), Window::ToggleWidgetLoweredState(), WC_SELECT_STATION, and WID_RAT_REMOVE.

Referenced by BuildRailClick_Remove(), BuildSignalWindow::OnClick(), and RailToolbar_CtrlChanged().

## Variable Documentation

## ◆ _build_depot_direction

DiagDirection _build_depot_direction
| static

Currently selected depot direction.

Definition at line 58 of file rail_gui.cpp.

Referenced by InitializeRailGui(), BuildRailDepotWindow::OnClick(), and BuildRailToolbarWindow::OnPlaceObject().

## ◆ _convert_signal_button

bool _convert_signal_button
| static

convert signal button in the signal GUI pressed

Definition at line 59 of file rail_gui.cpp.

Referenced by BuildSignalWindow::Close(), GenericPlaceSignals(), InitializeRailGUI(), BuildSignalWindow::OnClick(), BuildSignalWindow::OnInvalidateData(), and BuildRailToolbarWindow::OnPlaceDrag().

## ◆ _cur_railtype

RailType _cur_railtype
| static

Rail type of the current build-rail toolbar.

Definition at line 56 of file rail_gui.cpp.

Referenced by StationPickerCallbacks::DrawType(), WaypointPickerCallbacks::DrawType(), BuildRailStationWindow::DrawWidget(), BuildSignalWindow::DrawWidget(), BuildRailDepotWindow::DrawWidget(), BuildRailToolbarWindow::OnClick(), BuildSignalWindow::OnInit(), BuildRailToolbarWindow::OnPlaceMouseUp(), BuildRailToolbarWindow::OnPlaceObject(), BuildRailToolbarWindow::OnPlacePresize(), PlaceExtraDepotRail(), PlaceRail_Station(), ReinitGuiAfterToggleElrail(), SetDefaultRailGui(), and ShowBuildRailToolbar().

## ◆ _cur_signal_type

SignalType _cur_signal_type
| static

set the signal type (for signal GUI)

Definition at line 61 of file rail_gui.cpp.

Referenced by GenericPlaceSignals(), HandleAutoSignalPlacement(), InitializeRailGUI(), BuildSignalWindow::OnClick(), BuildSignalWindow::OnInvalidateData(), and ResetSignalVariant().

## ◆ _cur_signal_variant

SignalVariant _cur_signal_variant
| static

set the signal variant (for signal GUI)

Definition at line 60 of file rail_gui.cpp.

Referenced by GenericPlaceSignals(), HandleAutoSignalPlacement(), BuildSignalWindow::OnClick(), BuildSignalWindow::OnInvalidateData(), and ResetSignalVariant().

## ◆ _nested_build_depot_widgets

constexpr std::initializer_list<NWidgetPart> _nested_build_depot_widgets
| staticconstexpr

Initial value:
= {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetStringTip(STR_BUILD_DEPOT_TRAIN_ORIENTATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
NWidget(NWID_HORIZONTAL_LTR), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1), SetPadding(WidgetDimensions::unscaled.picker),
NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAD_DEPOT_NW), SetToolTip(STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAD_DEPOT_SW), SetToolTip(STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP),
EndContainer(),
NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAD_DEPOT_NE), SetToolTip(STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAD_DEPOT_SE), SetToolTip(STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP),
EndContainer(),
EndContainer(),
EndContainer(),
}
WidgetDimensions::unscaled
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition window_gui.h:93
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
SetToolTip
constexpr NWidgetPart SetToolTip(StringID tip)
Widget part function for setting tooltip and clearing the widget data.
Definition widget_type.h:1321
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
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
WID_BRAD_DEPOT_SE
@ WID_BRAD_DEPOT_SE
Build a depot with the entrance in the south east.
Definition rail_widget.h:92
WID_BRAD_DEPOT_NE
@ WID_BRAD_DEPOT_NE
Build a depot with the entrance in the north east.
Definition rail_widget.h:91
WID_BRAD_DEPOT_SW
@ WID_BRAD_DEPOT_SW
Build a depot with the entrance in the south west.
Definition rail_widget.h:93
WID_BRAD_DEPOT_NW
@ WID_BRAD_DEPOT_NW
Build a depot with the entrance in the north west.
Definition rail_widget.h:94
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
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

Nested widget definition of the build rail depot window.

Definition at line 1760 of file rail_gui.cpp.

## ◆ _nested_build_rail_widgets

constexpr std::initializer_list<NWidgetPart> _nested_build_rail_widgets
| staticconstexpr

Definition at line 865 of file rail_gui.cpp.

## ◆ _nested_build_waypoint_widgets

constexpr std::initializer_list<NWidgetPart> _nested_build_waypoint_widgets
| staticconstexpr

Initial value:
= {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetStringTip(STR_WAYPOINT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_SHADEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_DEFSIZEBOX, COLOUR_DARK_GREEN),
EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidgetFunction(MakePickerClassWidgets),
NWidgetFunction(MakePickerTypeWidgets),
EndContainer(),
}
NWidgetFunction
constexpr NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr)
Obtain a nested widget (sub)tree from an external source.
Definition widget_type.h:1448
MakePickerClassWidgets
std::unique_ptr< NWidgetBase > MakePickerClassWidgets()
Create nested widgets for the class picker widgets.
Definition picker_gui.cpp:745
MakePickerTypeWidgets
std::unique_ptr< NWidgetBase > MakePickerTypeWidgets()
Create nested widgets for the type picker widgets.
Definition picker_gui.cpp:768
WWT_SHADEBOX
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition widget_type.h:55
WWT_DEFSIZEBOX
@ WWT_DEFSIZEBOX
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX)
Definition widget_type.h:56

Nested widget definition for the build NewGRF rail waypoint window.

Definition at line 1885 of file rail_gui.cpp.

## ◆ _nested_signal_builder_widgets

constexpr std::initializer_list<NWidgetPart> _nested_signal_builder_widgets
| staticconstexpr

Nested widget definition of the build signal window.

Definition at line 1633 of file rail_gui.cpp.

## ◆ _nested_station_builder_widgets

constexpr std::initializer_list<NWidgetPart> _nested_station_builder_widgets
| staticconstexpr

Definition at line 1391 of file rail_gui.cpp.

## ◆ _place_depot_extra_dir

const DiagDirection _place_depot_extra_dir[12]
| static

Initial value:
= {
DIAGDIR_SE, DIAGDIR_SW, DIAGDIR_SE, DIAGDIR_SW,
DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_NE, DIAGDIR_SE,
DIAGDIR_NW, DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_NE,
}
DIAGDIR_NE
@ DIAGDIR_NE
Northeast, upper right on your monitor.
Definition direction_type.h:80
DIAGDIR_NW
@ DIAGDIR_NW
Northwest.
Definition direction_type.h:83
DIAGDIR_SE
@ DIAGDIR_SE
Southeast.
Definition direction_type.h:81
DIAGDIR_SW
@ DIAGDIR_SW
Southwest.
Definition direction_type.h:82

Direction to check for existing track pieces.

Definition at line 137 of file rail_gui.cpp.

## ◆ _place_depot_extra_track

const Track _place_depot_extra_track[12]
| static

Initial value:
= {
TRACK_LEFT, TRACK_UPPER, TRACK_UPPER, TRACK_RIGHT,
TRACK_X, TRACK_Y, TRACK_X, TRACK_Y,
TRACK_LOWER, TRACK_LEFT, TRACK_RIGHT, TRACK_LOWER,
}
TRACK_Y
@ TRACK_Y
Track along the y-axis (north-west to south-east)
Definition track_type.h:22
TRACK_LOWER
@ TRACK_LOWER
Track in the lower corner of the tile (south)
Definition track_type.h:24
TRACK_LEFT
@ TRACK_LEFT
Track in the left corner of the tile (west)
Definition track_type.h:25
TRACK_RIGHT
@ TRACK_RIGHT
Track in the right corner of the tile (east)
Definition track_type.h:26
TRACK_X
@ TRACK_X
Track along the x-axis (north-east to south-west)
Definition track_type.h:21
TRACK_UPPER
@ TRACK_UPPER
Track in the upper corner of the tile (north)
Definition track_type.h:23

Additional pieces of track to add at the entrance of a depot.

Definition at line 130 of file rail_gui.cpp.

## ◆ _remove_button_clicked

bool _remove_button_clicked
| static

Flag whether 'remove' toggle-button is currently enabled.

Definition at line 57 of file rail_gui.cpp.

Referenced by BuildRailClick_Remove(), GenericPlaceSignals(), HandleAutoSignalPlacement(), BuildRailToolbarWindow::OnClick(), BuildSignalWindow::OnClick(), BuildRailStationWindow::OnPaint(), BuildRailToolbarWindow::OnPlaceMouseUp(), PlaceRail_Station(), PlaceRail_Waypoint(), ShowBuildRailToolbar(), and ToggleRailButton_Remove().

## ◆ _station_gui

StationPickerSelection _station_gui
| static

Settings of the station picker.

Definition at line 74 of file rail_gui.cpp.

Referenced by BuildRailClick_Remove(), StationPickerCallbacks::DrawType(), BuildRailStationWindow::DrawWidget(), StationPickerCallbacks::GetSelectedClass(), StationPickerCallbacks::GetSelectedType(), InitializeRailGui(), BuildRailStationWindow::OnClick(), BuildRailStationWindow::OnInvalidateData(), BuildRailStationWindow::OnPaint(), PlaceRail_Station(), StationPickerCallbacks::SetSelectedClass(), and StationPickerCallbacks::SetSelectedType().

## ◆ _waypoint_gui

WaypointPickerSelection _waypoint_gui
| static

Settings of the waypoint picker.

Definition at line 67 of file rail_gui.cpp.

Referenced by WaypointPickerCallbacks::GetSelectedClass(), WaypointPickerCallbacks::GetSelectedType(), InitializeRailGui(), BuildRailToolbarWindow::OnPlaceMouseUp(), WaypointPickerCallbacks::SetSelectedClass(), and WaypointPickerCallbacks::SetSelectedType().