OpenTTD Source
20241108-master-g80f628063a
|
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_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 "spritecache.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 "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. More... | |
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. More... | |
void | CcRailDepot (Commands, const CommandCost &result, TileIndex tile, RailType, DiagDirection dir) |
static void | PlaceRail_Waypoint (TileIndex tile) |
Place a rail waypoint. More... | |
void | CcStation (Commands, const CommandCost &result, TileIndex tile) |
static void | PlaceRail_Station (TileIndex tile) |
Place a rail station. More... | |
static void | GenericPlaceSignals (TileIndex tile) |
Build a new signal or edit/remove a present signal, use CmdBuildSingleSignal() or CmdRemoveSingleSignal() in rail_cmd.cpp. More... | |
static void | PlaceRail_Bridge (TileIndex tile, Window *w) |
Start placing a rail bridge. More... | |
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. More... | |
static bool | RailToolbar_CtrlChanged (Window *w) |
Updates the Remove button because of Ctrl state change. More... | |
static void | BuildRailClick_Remove (Window *w) |
The "remove"-button click proc of the build-rail toolbar. More... | |
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. More... | |
Window * | ShowBuildRailToolbar (RailType railtype) |
Open the build rail toolbar window for a specific rail type. More... | |
static bool | StationUsesDefaultType (const BaseStation *bst) |
Test if a station/waypoint uses the default graphics. More... | |
void | InitializeRailGui () |
Initialize rail building GUI settings. | |
void | ReinitGuiAfterToggleElrail (bool disable) |
Re-initialize rail-build toolbar after toggling support for electric trains. More... | |
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. More... | |
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. More... | |
static const DiagDirection | _place_depot_extra_dir [12] |
Direction to check for existing track pieces. More... | |
static constexpr NWidgetPart | _nested_build_rail_widgets [] |
static WindowDesc | _build_rail_desc (WDP_ALIGN_TOOLBAR, "toolbar_rail", 0, 0, WC_BUILD_TOOLBAR, WC_NONE, WDF_CONSTRUCTION, _nested_build_rail_widgets, &BuildRailToolbarWindow::hotkeys) |
static constexpr NWidgetPart | _nested_station_builder_widgets [] |
static WindowDesc | _station_builder_desc (WDP_AUTO, "build_station_rail", 0, 0, WC_BUILD_STATION, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, _nested_station_builder_widgets, &BuildRailStationWindow::hotkeys) |
High level window description of the station-build window (default & newGRF) | |
static constexpr NWidgetPart | _nested_signal_builder_widgets [] |
Nested widget definition of the build signal window. | |
static WindowDesc | _signal_builder_desc (WDP_AUTO, nullptr, 0, 0, WC_BUILD_SIGNAL, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, _nested_signal_builder_widgets) |
Signal selection window description. | |
static constexpr NWidgetPart | _nested_build_depot_widgets [] |
Nested widget definition of the build rail depot window. More... | |
static WindowDesc | _build_depot_desc (WDP_AUTO, nullptr, 0, 0, WC_BUILD_DEPOT, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, _nested_build_depot_widgets) |
static constexpr NWidgetPart | _nested_build_waypoint_widgets [] |
Nested widget definition for the build NewGRF rail waypoint window. More... | |
static WindowDesc | _build_waypoint_desc (WDP_AUTO, "build_waypoint", 0, 0, WC_BUILD_WAYPOINT, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, _nested_build_waypoint_widgets, &BuildRailWaypointWindow::hotkeys) |
static IntervalTimer< TimerGameCalendar > | _check_reset_signal ({TimerGameCalendar::YEAR, TimerGameCalendar::Priority::NONE}, [](auto) { if(TimerGameCalendar::year !=_settings_client.gui.semaphore_build_before) return;ResetSignalVariant();}) |
File for dealing with rail construction user interface
Definition in file rail_gui.cpp.
|
static |
The "remove"-button click proc of the build-rail toolbar.
w | Build-rail toolbar window |
Definition at line 352 of file rail_gui.cpp.
References _settings_client, SoundSettings::click_beep, Window::IsWidgetDisabled(), ClientSettings::sound, ToggleRailButton_Remove(), and WID_RAT_REMOVE.
|
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 233 of file rail_gui.cpp.
References GetTileTrackStatus(), TRACK_BIT_VERT, TrackStatusToTrackBits(), and TRANSPORT_RAIL.
DropDownList GetRailTypeDropDownList | ( | bool | for_replacement, |
bool | all_option | ||
) |
Create a drop down list for all the rail types of the local company.
for_replacement | Whether this list is for the replacement window. |
all_option | Whether to add an 'all types' item. |
Definition at line 2011 of file rail_gui.cpp.
References _local_company, Company::avail_railtypes, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), GetCompanyRailTypes(), GetRailTypes(), and Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index.
|
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 410 of file rail_gui.cpp.
References GB().
|
static |
Check whether a station type can be build.
Definition at line 84 of file rail_gui.cpp.
References StationSpec::callback_mask, CBM_STATION_AVAIL, and HasBit().
Referenced by StationPickerCallbacks::IsTypeAvailable(), and WaypointPickerCallbacks::IsTypeAvailable().
|
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 117 of file rail_gui.cpp.
References _cur_railtype, _settings_client, GUISettings::auto_remove_signals, DiagdirReachesTracks(), GetRailTileType(), GetTrackBits(), ClientSettings::gui, RAIL_TILE_DEPOT, and RAIL_TILE_SIGNALS.
Start placing a rail bridge.
tile | Position of the first tile of the bridge. |
w | Rail toolbar window. |
Definition at line 291 of file rail_gui.cpp.
References DDSP_BUILD_BRIDGE, GetOtherTunnelBridgeEnd(), IsBridgeTile(), Window::OnPlaceMouseUp(), VPM_X_OR_Y, and VpStartPlaceSizing().
|
static |
Place a rail station.
tile | Position to place or start dragging a station. |
Definition at line 197 of file rail_gui.cpp.
References _remove_button_clicked, DDSP_REMOVE_STATION, VPM_X_AND_Y_LIMITED, and VpStartPlaceSizing().
|
static |
Place a rail waypoint.
tile | Position to start dragging a waypoint. |
Definition at line 165 of file rail_gui.cpp.
References _remove_button_clicked, AXIS_X, DDSP_BUILD_STATION, DDSP_REMOVE_STATION, GetAxisForNewRailWaypoint(), IsValidAxis(), VPM_X_AND_Y, VPM_X_LIMITED, VPM_Y_LIMITED, and VpStartPlaceSizing().
|
static |
Updates the Remove button because of Ctrl state change.
w | window the button belongs to |
Definition at line 331 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::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 1908 of file rail_gui.cpp.
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 918 of file rail_gui.cpp.
References _cur_railtype, _local_company, _remove_button_clicked, CloseWindowByClass(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), ValParamRailType(), and WC_BUILD_TOOLBAR.
|
static |
Test if a station/waypoint uses the default graphics.
bst | Station to test. |
Definition at line 960 of file rail_gui.cpp.
References GetCustomStationSpecIndex(), HasStationRail(), BaseStation::TileBelongsToRailStation(), and BaseStation::train_station.
Referenced by StationPickerCallbacks::FillUsedItems(), and WaypointPickerCallbacks::FillUsedItems().
|
static |
Toggles state of the Remove button of Build rail toolbar.
w | window the button belongs to |
Definition at line 317 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(), and RailToolbar_CtrlChanged().
|
staticconstexpr |
Nested widget definition of the build rail depot window.
Definition at line 1748 of file rail_gui.cpp.
|
staticconstexpr |
Nested widget definition for the build NewGRF rail waypoint window.
Definition at line 1865 of file rail_gui.cpp.
|
static |
Direction to check for existing track pieces.
Definition at line 134 of file rail_gui.cpp.
|
static |
Additional pieces of track to add at the entrance of a depot.
Definition at line 127 of file rail_gui.cpp.