File for dealing with rail construction user interface. More...
#include "stdafx.h"#include "gui.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_station.h"#include "company_base.h"#include "strings_func.h"#include "functions.h"#include "window_func.h"#include "date_func.h"#include "sound_func.h"#include "company_func.h"#include "widgets/dropdown_type.h"#include "tunnelbridge.h"#include "tilehighlight_func.h"#include "spritecache.h"#include "core/geometry_func.hpp"#include "hotkeys.h"#include "station_map.h"#include "tunnelbridge_map.h"#include "table/strings.h"Go to the source code of this file.
Data Structures | |
| struct | RailStationGUISettings |
| struct | BuildRailToolbarWindow |
| Rail toolbar management class. More... | |
| struct | BuildRailStationWindow |
| struct | BuildSignalWindow |
| struct | BuildRailDepotWindow |
| struct | BuildRailWaypointWindow |
Enumerations | |
| enum | RailToolbarWidgets { RTW_CAPTION, RTW_BUILD_NS, RTW_BUILD_X, RTW_BUILD_EW, RTW_BUILD_Y, RTW_AUTORAIL, RTW_DEMOLISH, RTW_BUILD_DEPOT, RTW_BUILD_WAYPOINT, RTW_BUILD_STATION, RTW_BUILD_SIGNALS, RTW_BUILD_BRIDGE, RTW_BUILD_TUNNEL, RTW_REMOVE, RTW_CONVERT_RAIL } |
Enum referring to the widgets of the build rail toolbar. | |
| enum | BuildRailStationWidgets { BRSW_BACKGROUND, BRSW_PLATFORM_DIR_X, BRSW_PLATFORM_DIR_Y, BRSW_PLATFORM_NUM_1, BRSW_PLATFORM_NUM_2, BRSW_PLATFORM_NUM_3, BRSW_PLATFORM_NUM_4, BRSW_PLATFORM_NUM_5, BRSW_PLATFORM_NUM_6, BRSW_PLATFORM_NUM_7, BRSW_PLATFORM_LEN_1, BRSW_PLATFORM_LEN_2, BRSW_PLATFORM_LEN_3, BRSW_PLATFORM_LEN_4, BRSW_PLATFORM_LEN_5, BRSW_PLATFORM_LEN_6, BRSW_PLATFORM_LEN_7, BRSW_PLATFORM_DRAG_N_DROP, BRSW_HIGHLIGHT_OFF, BRSW_HIGHLIGHT_ON, BRSW_SHOW_NEWST_ADDITIONS, BRSW_NEWST_DROPDOWN, BRSW_NEWST_LIST, BRSW_NEWST_SCROLL, BRSW_PLATFORM_NUM_BEGIN = BRSW_PLATFORM_NUM_1 - 1, BRSW_PLATFORM_LEN_BEGIN = BRSW_PLATFORM_LEN_1 - 1 } |
Enum referring to the widgets of the rail stations window. | |
| enum | BuildSignalWidgets { BSW_SEMAPHORE_NORM, BSW_SEMAPHORE_ENTRY, BSW_SEMAPHORE_EXIT, BSW_SEMAPHORE_COMBO, BSW_SEMAPHORE_PBS, BSW_SEMAPHORE_PBS_OWAY, BSW_ELECTRIC_NORM, BSW_ELECTRIC_ENTRY, BSW_ELECTRIC_EXIT, BSW_ELECTRIC_COMBO, BSW_ELECTRIC_PBS, BSW_ELECTRIC_PBS_OWAY, BSW_CONVERT, BSW_DRAG_SIGNALS_DENSITY, BSW_DRAG_SIGNALS_DENSITY_LABEL, BSW_DRAG_SIGNALS_DENSITY_DECREASE, BSW_DRAG_SIGNALS_DENSITY_INCREASE } |
Enum referring to the widgets of the signal window. | |
| enum | BuildRailDepotWidgets { BRDW_DEPOT_NE, BRDW_DEPOT_SE, BRDW_DEPOT_SW, BRDW_DEPOT_NW } |
Enum referring to the widgets of the build rail depot window. | |
| enum | BuildRailWaypointWidgets { BRWW_WAYPOINT_MATRIX, BRWW_WAYPOINT, BRWW_SCROLL } |
Enum referring to the widgets of the build NewGRF rail waypoint window. | |
Functions | |
| static void | HandleStationPlacement (TileIndex start, TileIndex end) |
| static void | ShowBuildTrainDepotPicker (Window *parent) |
| static void | ShowBuildWaypointPicker (Window *parent) |
| static void | ShowStationBuilder (Window *parent) |
| Open station build window. | |
| static void | ShowSignalBuilder (Window *parent) |
| Open the signal selection window. | |
| void | CcPlaySound1E (const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2) |
| static void | GenericPlaceRail (TileIndex tile, int cmd) |
| static void | PlaceExtraDepotRail (TileIndex tile, DiagDirection dir, Track track) |
| Try to add an additional rail-track at the entrance of a depot. | |
| void | CcRailDepot (const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2) |
| static void | PlaceRail_Waypoint (TileIndex tile) |
| Place a rail waypoint. | |
| void | CcStation (const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2) |
| 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 (const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2) |
| 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 (int mode) |
| 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. | |
| EventState | RailToolbarGlobalHotkeys (uint16 key, uint16 keycode) |
| 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. | |
| bool | ResetSignalVariant (int32 p=0) |
| 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. | |
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 byte | _waypoint_count = 1 |
| Number of waypoint types. | |
| static byte | _cur_waypoint_type |
| Currently selected waypoint type. | |
| 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 const SignalType | _default_signal_type [] = {SIGTYPE_NORMAL, SIGTYPE_PBS, SIGTYPE_PBS_ONEWAY} |
| static RailStationGUISettings | _railstation |
| Settings of the station builder GUI. | |
| 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. | |
| const uint16 | _railtoolbar_autorail_keys [] = {'5', 'A' | WKC_GLOBAL_HOTKEY, 0} |
| Hotkey< BuildRailToolbarWindow > * | _railtoolbar_hotkeys = BuildRailToolbarWindow::railtoolbar_hotkeys |
| static const NWidgetPart | _nested_build_rail_widgets [] |
| static const WindowDesc | _build_rail_desc (WDP_ALIGN_TOOLBAR, 0, 0, WC_BUILD_TOOLBAR, WC_NONE, WDF_CONSTRUCTION, _nested_build_rail_widgets, lengthof(_nested_build_rail_widgets)) |
| static const NWidgetPart | _nested_station_builder_widgets [] |
| static const WindowDesc | _station_builder_desc (WDP_AUTO, 0, 0, WC_BUILD_STATION, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, _nested_station_builder_widgets, lengthof(_nested_station_builder_widgets)) |
| High level window description of the station-build window (default & newGRF). | |
| static const NWidgetPart | _nested_signal_builder_widgets [] |
| Nested widget definition of the build signal window. | |
| static const WindowDesc | _signal_builder_desc (WDP_AUTO, 0, 0, WC_BUILD_SIGNAL, WC_BUILD_TOOLBAR, WDF_UNCLICK_BUTTONS|WDF_CONSTRUCTION, _nested_signal_builder_widgets, lengthof(_nested_signal_builder_widgets)) |
| Signal selection window description. | |
| static const NWidgetPart | _nested_build_depot_widgets [] |
| Nested widget definition of the build rail depot window. | |
| static const WindowDesc | _build_depot_desc (WDP_AUTO, 0, 0, WC_BUILD_DEPOT, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, _nested_build_depot_widgets, lengthof(_nested_build_depot_widgets)) |
| static const NWidgetPart | _nested_build_waypoint_widgets [] |
| Nested widget definition for the build NewGRF rail waypoint window. | |
| static const WindowDesc | _build_waypoint_desc (WDP_AUTO, 0, 0, WC_BUILD_DEPOT, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, _nested_build_waypoint_widgets, lengthof(_nested_build_waypoint_widgets)) |
File for dealing with rail construction user interface.
Definition in file rail_gui.cpp.
| static void BuildRailClick_Remove | ( | Window * | w | ) | [static] |
The "remove"-button click proc of the build-rail toolbar.
| w | Build-rail toolbar window |
Definition at line 324 of file rail_gui.cpp.
References _remove_button_clicked, _settings_client, _settings_game, ClientSettings::gui, Window::IsWidgetDisabled(), Window::IsWidgetLowered(), RailStationGUISettings::orientation, SetTileSelectSize(), GameSettings::station, GUISettings::station_dragdrop, GUISettings::station_numtracks, GUISettings::station_platlength, StationSettings::station_spread, Swap(), and ToggleRailButton_Remove().
Referenced by BuildRailToolbarWindow::OnClick().
| static void GenericPlaceSignals | ( | TileIndex | tile | ) | [static] |
Build a new signal or edit/remove a present signal, use CmdBuildSingleSignal() or CmdRemoveSingleSignal() in rail_cmd.cpp.
| tile | The tile where the signal will build or edit |
Definition at line 191 of file rail_gui.cpp.
References _convert_signal_button, _ctrl_pressed, _cur_signal_type, _cur_signal_variant, _cur_year, _remove_button_clicked, _settings_client, CMD_BUILD_SIGNALS, CMD_MSG, CMD_REMOVE_SIGNALS, GUISettings::cycle_signal_types, GUISettings::default_signal_type, DoCommandP(), FindFirstTrack(), FindWindowById(), GetTileTrackStatus(), ClientSettings::gui, SB(), GUISettings::semaphore_build_before, SIG_ELECTRIC, SIG_SEMAPHORE, SIGTYPE_NORMAL, SIGTYPE_PBS, TRACK_BIT_HORZ, TRACK_BIT_LEFT, TRACK_BIT_LOWER, TRACK_BIT_RIGHT, TRACK_BIT_UPPER, TRACK_BIT_VERT, TrackStatusToTrackBits(), and TRANSPORT_RAIL.
Referenced by 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 380 of file rail_gui.cpp.
References _ctrl_pressed, _cur_signal_type, _cur_signal_variant, _cur_year, _remove_button_clicked, _settings_client, CMD_BUILD_SIGNAL_TRACK, CMD_MSG, CMD_REMOVE_SIGNAL_TRACK, GUISettings::default_signal_type, DoCommandP(), GUISettings::drag_signals_density, TileHighlightData::drawstyle, FindWindowById(), GB(), GenericPlaceSignals(), ClientSettings::gui, HT_RECT, SB(), TileHighlightData::selend, TileHighlightData::selstart, GUISettings::semaphore_build_before, SIG_ELECTRIC, and SIG_SEMAPHORE.
Referenced by BuildRailToolbarWindow::OnPlaceMouseUp().
| static void PlaceExtraDepotRail | ( | TileIndex | tile, | |
| DiagDirection | dir, | |||
| Track | track | |||
| ) | [static] |
Try to add an additional rail-track at the entrance of a depot.
| tile | Tile to use for adding the rail-track | |
| dir | Direction to check for already present tracks | |
| track | Track to add |
Definition at line 90 of file rail_gui.cpp.
References _cur_railtype, CMD_BUILD_SINGLE_RAIL, DiagdirReachesTracks(), DoCommandP(), GetRailTileType(), GetTrackBits(), and RAIL_TILE_NORMAL.
Start placing a rail bridge.
| tile | Position of the first tile of the bridge. | |
| w | Rail toolbar window. |
Definition at line 242 of file rail_gui.cpp.
References DDSP_BUILD_BRIDGE, GetOtherTunnelBridgeEnd(), IsBridgeTile(), Window::OnPlaceMouseUp(), VPM_X_OR_Y, and VpStartPlaceSizing().
Referenced by BuildRailToolbarWindow::OnPlaceObject().
| static void PlaceRail_Station | ( | TileIndex | tile | ) | [static] |
Place a rail station.
| tile | Position to place or start dragging a station. |
Definition at line 165 of file rail_gui.cpp.
References _ctrl_pressed, _cur_railtype, _remove_button_clicked, _settings_client, _settings_game, CMD_BUILD_RAIL_STATION, CMD_MSG, DDSP_BUILD_STATION, DDSP_REMOVE_STATION, ClientSettings::gui, RailStationGUISettings::orientation, ShowSelectStationIfNeeded(), GameSettings::station, RailStationGUISettings::station_class, GUISettings::station_dragdrop, GUISettings::station_numtracks, GUISettings::station_platlength, StationSettings::station_spread, RailStationGUISettings::station_type, Swap(), VPM_X_AND_Y_LIMITED, and VpStartPlaceSizing().
Referenced by BuildRailToolbarWindow::OnPlaceObject().
| static void PlaceRail_Waypoint | ( | TileIndex | tile | ) | [static] |
Place a rail waypoint.
| tile | Position to start dragging a waypoint. |
Definition at line 134 of file rail_gui.cpp.
References _remove_button_clicked, AXIS_X, CMD_BUILD_RAIL_WAYPOINT, CMD_MSG, DDSP_BUILD_STATION, DDSP_REMOVE_STATION, DoCommandP(), GetAxisForNewWaypoint(), IsValidAxis(), STAT_CLASS_WAYP, VPM_FIX_X, VPM_FIX_Y, VPM_X_AND_Y, and VpStartPlaceSizing().
Referenced by BuildRailToolbarWindow::OnPlaceObject().
| static bool RailToolbar_CtrlChanged | ( | Window * | w | ) | [static] |
Updates the Remove button because of Ctrl state change.
| w | window the button belongs to |
Definition at line 303 of file rail_gui.cpp.
References Window::IsWidgetDisabled(), Window::IsWidgetLowered(), and ToggleRailButton_Remove().
Referenced by BuildRailToolbarWindow::OnClick(), and BuildRailToolbarWindow::OnCTRLStateChange().
| void ReinitGuiAfterToggleElrail | ( | bool | disable | ) |
Re-initialize rail-build toolbar after toggling support for electric trains.
| disable | Boolean whether electric trains are disabled (removed from the game) |
Definition at line 1794 of file rail_gui.cpp.
References _cur_railtype, FindWindowById(), MarkWholeScreenDirty(), BuildRailToolbarWindow::ModifyRailType(), RAILTYPE_ELECTRIC, RAILTYPE_RAIL, and TRANSPORT_RAIL.
Referenced by SettingsDisableElrail().
| bool ResetSignalVariant | ( | int32 | p = 0 |
) |
Updates the current signal variant used in the signal GUI to the one adequate to current year.
| p | needed to be called when a setting changes |
Definition at line 1856 of file rail_gui.cpp.
References _cur_signal_type, _cur_signal_variant, _cur_year, _settings_client, FindWindowById(), ClientSettings::gui, Window::RaiseWidget(), GUISettings::semaphore_build_before, Window::SetDirty(), SIG_ELECTRIC, and SIG_SEMAPHORE.
Referenced by ClickChangeDateCheat(), InitializeRailGUI(), and OnNewYear().
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.
| railtype | Rail type to open the window for |
Definition at line 841 of file rail_gui.cpp.
References _cur_railtype, _local_company, _remove_button_clicked, DeleteWindowByClass(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), TRANSPORT_RAIL, and ValParamRailtype().
Referenced by MainToolbarWindow::OnKeyPress().
| static void ToggleRailButton_Remove | ( | Window * | w | ) | [static] |
Toggles state of the Remove button of Build rail toolbar.
| w | window the button belongs to |
Definition at line 289 of file rail_gui.cpp.
References _remove_button_clicked, DeleteWindowById(), Window::IsWidgetLowered(), Window::SetWidgetDirty(), and Window::ToggleWidgetLoweredState().
Referenced by BuildRailClick_Remove(), and RailToolbar_CtrlChanged().
const NWidgetPart _nested_build_depot_widgets[] [static] |
{
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_BUILD_DEPOT_TRAIN_ORIENTATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
NWidget(NWID_SPACER), SetMinimalSize(0, 3),
NWidget(NWID_HORIZONTAL_LTR),
NWidget(NWID_SPACER), SetMinimalSize(3, 0), SetFill(1, 0),
NWidget(NWID_VERTICAL),
NWidget(WWT_PANEL, COLOUR_GREY, BRDW_DEPOT_NW), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP),
EndContainer(),
NWidget(NWID_SPACER), SetMinimalSize(0, 2),
NWidget(WWT_PANEL, COLOUR_GREY, BRDW_DEPOT_SW), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP),
EndContainer(),
EndContainer(),
NWidget(NWID_SPACER), SetMinimalSize(2, 0),
NWidget(NWID_VERTICAL),
NWidget(WWT_PANEL, COLOUR_GREY, BRDW_DEPOT_NE), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP),
EndContainer(),
NWidget(NWID_SPACER), SetMinimalSize(0, 2),
NWidget(WWT_PANEL, COLOUR_GREY, BRDW_DEPOT_SE), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP),
EndContainer(),
EndContainer(),
NWidget(NWID_SPACER), SetMinimalSize(3, 0), SetFill(1, 0),
EndContainer(),
NWidget(NWID_SPACER), SetMinimalSize(0, 3),
EndContainer(),
}
Nested widget definition of the build rail depot window.
Definition at line 1636 of file rail_gui.cpp.
const NWidgetPart _nested_build_waypoint_widgets[] [static] |
{
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_WAYPOINT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(NWID_MATRIX, COLOUR_DARK_GREEN, BRWW_WAYPOINT_MATRIX), SetPIP(3, 2, 3), SetScrollbar(BRWW_SCROLL),
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BRWW_WAYPOINT), SetMinimalSize(66, 60), SetDataTip(0x0, STR_WAYPOINT_GRAPHICS_TOOLTIP), EndContainer(),
EndContainer(),
NWidget(NWID_VERTICAL),
NWidget(NWID_VSCROLLBAR, COLOUR_DARK_GREEN, BRWW_SCROLL),
NWidget(WWT_RESIZEBOX, COLOUR_DARK_GREEN),
EndContainer(),
EndContainer(),
}
Nested widget definition for the build NewGRF rail waypoint window.
Definition at line 1754 of file rail_gui.cpp.
const DiagDirection _place_depot_extra_dir[12] [static] |
{
DIAGDIR_SE, DIAGDIR_SW, DIAGDIR_SE, DIAGDIR_SW,
DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_NE, DIAGDIR_SE,
DIAGDIR_NW, DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_NE,
}
Direction to check for existing track pieces.
Definition at line 106 of file rail_gui.cpp.
const Track _place_depot_extra_track[12] [static] |
{
TRACK_LEFT, TRACK_UPPER, TRACK_UPPER, TRACK_RIGHT,
TRACK_X, TRACK_Y, TRACK_X, TRACK_Y,
TRACK_LOWER, TRACK_LEFT, TRACK_RIGHT, TRACK_LOWER,
}
Additional pieces of track to add at the entrance of a depot.
Definition at line 99 of file rail_gui.cpp.
1.6.1