OpenTTD Source 20241224-master-gee860a5c8e
|
GUI for building roads. 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 "road_cmd.h"
#include "station_func.h"
#include "waypoint_func.h"
#include "window_func.h"
#include "vehicle_func.h"
#include "sound_func.h"
#include "company_func.h"
#include "tunnelbridge.h"
#include "tunnelbridge_map.h"
#include "tilehighlight_func.h"
#include "company_base.h"
#include "hotkeys.h"
#include "road_gui.h"
#include "zoom_func.h"
#include "dropdown_type.h"
#include "dropdown_func.h"
#include "engine_base.h"
#include "station_base.h"
#include "waypoint_base.h"
#include "strings_func.h"
#include "core/geometry_func.hpp"
#include "station_cmd.h"
#include "waypoint_cmd.h"
#include "tunnelbridge_cmd.h"
#include "newgrf_roadstop.h"
#include "picker_gui.h"
#include "timer/timer.h"
#include "timer/timer_game_calendar.h"
#include "widgets/road_widget.h"
#include "table/strings.h"
#include "safeguards.h"
Go to the source code of this file.
Data Structures | |
struct | RoadWaypointPickerSelection |
struct | RoadStopPickerSelection |
struct | BuildRoadToolbarWindow |
Road toolbar window handler. More... | |
struct | BuildRoadDepotWindow |
class | RoadStopPickerCallbacks< roadstoptype > |
struct | BuildRoadStationWindow |
class | RoadWaypointPickerCallbacks |
struct | BuildRoadWaypointWindow |
Typedefs | |
typedef void | OnButtonClick(Window *w) |
Functions | |
static void | ShowRVStationPicker (Window *parent, RoadStopType rs) |
static void | ShowRoadDepotPicker (Window *parent) |
static void | ShowBuildRoadWaypointPicker (Window *parent) |
static bool | IsRoadStopEverAvailable (const RoadStopSpec *spec, StationType type) |
static bool | IsRoadStopAvailable (const RoadStopSpec *spec, StationType type) |
Check whether a road stop type can be built. | |
void | CcPlaySound_CONSTRUCTION_OTHER (Commands, const CommandCost &result, TileIndex tile) |
static void | PlaceRoad_Bridge (TileIndex tile, Window *w) |
Callback to start placing a bridge. | |
void | CcBuildRoadTunnel (Commands, const CommandCost &result, TileIndex start_tile) |
Callback executed after a build road tunnel command has been called. | |
void | ConnectRoadToStructure (TileIndex tile, DiagDirection direction) |
If required, connects a new structure to an existing road or tram by building the missing roadbit. | |
void | CcRoadDepot (Commands, const CommandCost &result, TileIndex tile, RoadType, DiagDirection dir) |
void | CcRoadStop (Commands, const CommandCost &result, TileIndex tile, uint8_t width, uint8_t length, RoadStopType, bool is_drive_through, DiagDirection dir, RoadType, RoadStopClassID spec_class, uint16_t spec_index, StationID, bool) |
Command callback for building road stops. | |
static void | PlaceRoadStop (TileIndex start_tile, TileIndex end_tile, RoadStopType stop_type, bool adjacent, RoadType rt, StringID err_msg) |
Place a new road stop. | |
static void | PlaceRoad_Waypoint (TileIndex tile) |
Place a road waypoint. | |
static void | PlaceRoad_BusStation (TileIndex tile) |
Callback for placing a bus station. | |
static void | PlaceRoad_TruckStation (TileIndex tile) |
Callback for placing a truck station. | |
static void | ToggleRoadButton_Remove (Window *w) |
Toggles state of the Remove button of Build road toolbar. | |
static bool | RoadToolbar_CtrlChanged (Window *w) |
Updates the Remove button because of Ctrl state change. | |
Window * | ShowBuildRoadToolbar (RoadType roadtype) |
Open the build road toolbar window. | |
Window * | ShowBuildRoadScenToolbar (RoadType roadtype) |
Show the road building toolbar in the scenario editor. | |
static PickerCallbacks & | GetRoadStopPickerCallbacks (RoadStopType rs) |
void | InitializeRoadGui () |
void | InitializeRoadGUI () |
I really don't know why rail_gui.cpp has this too, shouldn't be included in the other one? | |
DropDownList | GetRoadTypeDropDownList (RoadTramTypes rtts, bool for_replacement, bool all_option) |
DropDownList | GetScenRoadTypeDropDownList (RoadTramTypes rtts) |
Variables | |
static bool | _remove_button_clicked |
static bool | _one_way_button_clicked |
static Axis | _place_road_dir |
static bool | _place_road_start_half_x |
static bool | _place_road_start_half_y |
static bool | _place_road_end_half |
static RoadType | _cur_roadtype |
static DiagDirection | _road_depot_orientation |
static RoadWaypointPickerSelection | _waypoint_gui |
Settings of the road waypoint picker. | |
static RoadStopPickerSelection | _roadstop_gui |
static constexpr NWidgetPart | _nested_build_road_widgets [] |
static WindowDesc | _build_road_desc (WDP_ALIGN_TOOLBAR, "toolbar_road", 0, 0, WC_BUILD_TOOLBAR, WC_NONE, WDF_CONSTRUCTION, _nested_build_road_widgets, &BuildRoadToolbarWindow::road_hotkeys) |
static constexpr NWidgetPart | _nested_build_tramway_widgets [] |
static WindowDesc | _build_tramway_desc (WDP_ALIGN_TOOLBAR, "toolbar_tramway", 0, 0, WC_BUILD_TOOLBAR, WC_NONE, WDF_CONSTRUCTION, _nested_build_tramway_widgets, &BuildRoadToolbarWindow::tram_hotkeys) |
static constexpr NWidgetPart | _nested_build_road_scen_widgets [] |
static WindowDesc | _build_road_scen_desc (WDP_AUTO, "toolbar_road_scen", 0, 0, WC_SCEN_BUILD_TOOLBAR, WC_NONE, WDF_CONSTRUCTION, _nested_build_road_scen_widgets, &BuildRoadToolbarWindow::road_hotkeys) |
static constexpr NWidgetPart | _nested_build_tramway_scen_widgets [] |
static WindowDesc | _build_tramway_scen_desc (WDP_AUTO, "toolbar_tram_scen", 0, 0, WC_SCEN_BUILD_TOOLBAR, WC_NONE, WDF_CONSTRUCTION, _nested_build_tramway_scen_widgets, &BuildRoadToolbarWindow::tram_hotkeys) |
static constexpr NWidgetPart | _nested_build_road_depot_widgets [] |
static WindowDesc | _build_road_depot_desc (WDP_AUTO, nullptr, 0, 0, WC_BUILD_DEPOT, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, _nested_build_road_depot_widgets) |
static RoadStopPickerCallbacks< ROADSTOP_BUS > | _bus_callback_instance ("fav_passenger_roadstops") |
static RoadStopPickerCallbacks< ROADSTOP_TRUCK > | _truck_callback_instance ("fav_freight_roadstops") |
static constexpr NWidgetPart | _nested_road_station_picker_widgets [] |
Widget definition of the build road station window. | |
static WindowDesc | _road_station_picker_desc (WDP_AUTO, "build_station_road", 0, 0, WC_BUS_STATION, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, _nested_road_station_picker_widgets, &BuildRoadStationWindow::road_hotkeys) |
static constexpr NWidgetPart | _nested_tram_station_picker_widgets [] |
Widget definition of the build tram station window. | |
static WindowDesc | _tram_station_picker_desc (WDP_AUTO, "build_station_tram", 0, 0, WC_BUS_STATION, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, _nested_tram_station_picker_widgets, &BuildRoadStationWindow::tram_hotkeys) |
static constexpr NWidgetPart | _nested_build_road_waypoint_widgets [] |
Nested widget definition for the build NewGRF road waypoint window. | |
static WindowDesc | _build_road_waypoint_desc (WDP_AUTO, "build_road_waypoint", 0, 0, WC_BUILD_WAYPOINT, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, _nested_build_road_waypoint_widgets, &BuildRoadWaypointWindow::hotkeys) |
GUI for building roads.
Definition in file road_gui.cpp.
typedef void OnButtonClick(Window *w) |
Definition at line 309 of file road_gui.cpp.
void CcBuildRoadTunnel | ( | Commands | , |
const CommandCost & | result, | ||
TileIndex | start_tile | ||
) |
Callback executed after a build road tunnel command has been called.
result | Whether the build succeeded. |
start_tile | Starting tile of the tunnel. |
Definition at line 140 of file road_gui.cpp.
References _build_tunnel_endtile, _settings_client, SoundSettings::confirm, ConnectRoadToStructure(), GetOtherTunnelBridgeEnd(), GetTunnelBridgeDirection(), ClientSettings::gui, GUISettings::persistent_buildingtools, ResetObjectToPlace(), ReverseDiagDir(), SetRedErrorSquare(), SND_1F_CONSTRUCTION_OTHER, ClientSettings::sound, and CommandCost::Succeeded().
void CcPlaySound_CONSTRUCTION_OTHER | ( | Commands | , |
const CommandCost & | result, | ||
TileIndex | tile | ||
) |
Definition at line 114 of file road_gui.cpp.
void CcRoadDepot | ( | Commands | cmd, |
const CommandCost & | result, | ||
TileIndex | tile, | ||
RoadType | rt, | ||
DiagDirection | dir | ||
) |
Definition at line 173 of file road_gui.cpp.
void CcRoadStop | ( | Commands | cmd, |
const CommandCost & | result, | ||
TileIndex | tile, | ||
uint8_t | width, | ||
uint8_t | length, | ||
RoadStopType | , | ||
bool | is_drive_through, | ||
DiagDirection | dir, | ||
RoadType | , | ||
RoadStopClassID | spec_class, | ||
uint16_t | spec_index, | ||
StationID | , | ||
bool | |||
) |
Command callback for building road stops.
result | Result of the build road stop command. |
tile | Start tile. |
width | Width of the road stop. |
length | Length of the road stop. |
is_drive_through | False for normal stops, true for drive-through. |
dir | Entrance direction (DiagDirection) for normal stops. Converted to the axis for drive-through stops. |
spec_class | Road stop spec class. |
spec_index | Road stop spec index. |
Definition at line 194 of file road_gui.cpp.
References _settings_client, SoundSettings::confirm, ConnectRoadToStructure(), CommandCost::Failed(), NewGRFClass< Tspec, Tindex, Tmax >::Get(), NewGRFClass< Tspec, Tindex, Tmax >::GetClassCount(), NewGRFClass< Tspec, Tindex, Tmax >::GetSpec(), ClientSettings::gui, HasBit(), GUISettings::persistent_buildingtools, ResetObjectToPlace(), ReverseDiagDir(), RSF_NO_AUTO_ROAD_CONNECTION, SND_1F_CONSTRUCTION_OTHER, and ClientSettings::sound.
Referenced by PlaceRoadStop().
void ConnectRoadToStructure | ( | TileIndex | tile, |
DiagDirection | direction | ||
) |
If required, connects a new structure to an existing road or tram by building the missing roadbit.
tile | Tile containing the structure to connect. |
direction | Direction to check. |
Definition at line 162 of file road_gui.cpp.
References DiagDirToRoadBits(), DRD_NONE, GetRoadBits(), IsNormalRoadTile(), ReverseDiagDir(), ROAD_NONE, and TileOffsByDiagDir().
Referenced by CcBuildBridge(), CcBuildRoadTunnel(), and CcRoadStop().
|
static |
Definition at line 1274 of file road_gui.cpp.
DropDownList GetRoadTypeDropDownList | ( | RoadTramTypes | rtts, |
bool | for_replacement, | ||
bool | all_option | ||
) |
Definition at line 1728 of file road_gui.cpp.
DropDownList GetScenRoadTypeDropDownList | ( | RoadTramTypes | rtts | ) |
Definition at line 1788 of file road_gui.cpp.
void InitializeRoadGui | ( | ) |
Definition at line 1711 of file road_gui.cpp.
void InitializeRoadGUI | ( | ) |
I really don't know why rail_gui.cpp has this too, shouldn't be included in the other one?
Definition at line 1722 of file road_gui.cpp.
References FindWindowById(), BuildRoadToolbarWindow::ModifyRoadType(), TRANSPORT_ROAD, and WC_BUILD_TOOLBAR.
|
static |
Check whether a road stop type can be built.
Definition at line 101 of file road_gui.cpp.
References CALLBACK_FAILED, CBID_STATION_AVAILABILITY, CBM_ROAD_STOP_AVAIL, Convert8bitBooleanCallback(), RoadStopSpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, HasBit(), and INVALID_TILE.
Referenced by RoadStopPickerCallbacks< roadstoptype >::IsTypeAvailable(), and RoadWaypointPickerCallbacks::IsTypeAvailable().
|
static |
Definition at line 82 of file road_gui.cpp.
Callback to start placing a bridge.
tile | Start tile of the bridge. |
Definition at line 123 of file road_gui.cpp.
References DDSP_BUILD_BRIDGE, GetOtherTunnelBridgeEnd(), IsBridgeTile(), Window::OnPlaceMouseUp(), VPM_X_OR_Y, and VpStartPlaceSizing().
Referenced by BuildRoadToolbarWindow::OnPlaceObject().
|
static |
Callback for placing a bus station.
tile | Position to place the station. |
Definition at line 277 of file road_gui.cpp.
References _settings_game, AXIS_X, DDSP_BUILD_BUSSTOP, DDSP_REMOVE_BUSSTOP, DIAGDIR_END, DiagDirToAxis(), RoadStopPickerSelection::orientation, GameSettings::station, StationSettings::station_spread, VPM_X_AND_Y, VPM_X_AND_Y_LIMITED, VPM_X_LIMITED, VPM_Y_LIMITED, and VpStartPlaceSizing().
Referenced by BuildRoadToolbarWindow::OnPlaceObject().
|
static |
Callback for placing a truck station.
tile | Position to place the station. |
Definition at line 295 of file road_gui.cpp.
References _settings_game, AXIS_X, DDSP_BUILD_TRUCKSTOP, DDSP_REMOVE_TRUCKSTOP, DIAGDIR_END, DiagDirToAxis(), RoadStopPickerSelection::orientation, GameSettings::station, StationSettings::station_spread, VPM_X_AND_Y, VPM_X_AND_Y_LIMITED, VPM_X_LIMITED, VPM_Y_LIMITED, and VpStartPlaceSizing().
Referenced by BuildRoadToolbarWindow::OnPlaceObject().
|
static |
Place a road waypoint.
tile | Position to start dragging a waypoint. |
Definition at line 254 of file road_gui.cpp.
References _settings_game, AXIS_X, DDSP_BUILD_ROAD_WAYPOINT, DDSP_REMOVE_ROAD_WAYPOINT, GetAxisForNewRoadWaypoint(), IsValidAxis(), ROADSTOP_CLASS_WAYP, GameSettings::station, StationSettings::station_spread, VPM_X_AND_Y, VPM_X_LIMITED, VPM_Y_LIMITED, and VpStartPlaceSizing().
Referenced by BuildRoadToolbarWindow::OnPlaceObject().
|
static |
Place a new road stop.
start_tile | First tile of the area. |
end_tile | Last tile of the area. |
stop_type | Type of stop (bus/truck). |
adjacent | Allow stations directly adjacent to other stations. |
rt | The roadtypes. |
err_msg | Error message to show. |
Definition at line 228 of file road_gui.cpp.
References CcRoadStop(), CommandFlagsToDCFlags(), DIAGDIR_END, OrthogonalTileArea::h, RoadStopPickerSelection::orientation, RoadStopPickerSelection::sel_class, RoadStopPickerSelection::sel_type, ShowSelectStationIfNeeded(), OrthogonalTileArea::tile, and OrthogonalTileArea::w.
Referenced by BuildRoadToolbarWindow::OnPlaceMouseUp().
|
static |
Updates the Remove button because of Ctrl state change.
w | window the button belongs to |
Definition at line 328 of file road_gui.cpp.
References Window::IsWidgetDisabled(), Window::IsWidgetLowered(), ToggleRoadButton_Remove(), WID_ROT_AUTOROAD, WID_ROT_REMOVE, and WID_ROT_ROAD_X.
Referenced by BuildRoadToolbarWindow::OnClick(), and BuildRoadToolbarWindow::OnCTRLStateChange().
Show the road building toolbar in the scenario editor.
nullptr
if the toolbar was already open. Definition at line 1081 of file road_gui.cpp.
References CloseWindowById(), TRANSPORT_ROAD, and WC_SCEN_BUILD_TOOLBAR.
Referenced by BuildRoadToolbarWindow::RoadTramToolbarGlobalHotkeys(), ToolbarScenBuildRoad(), and ToolbarScenBuildTram().
Open the build road toolbar window.
If the terraform toolbar is linked to the toolbar, that window is also opened.
Definition at line 994 of file road_gui.cpp.
References _local_company, CloseWindowByClass(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), TRANSPORT_ROAD, ValParamRoadType(), and WC_BUILD_TOOLBAR.
Referenced by MenuClickBuildRoad(), MenuClickBuildTram(), MainToolbarWindow::OnHotkey(), and BuildRoadToolbarWindow::RoadTramToolbarGlobalHotkeys().
|
static |
Definition at line 1705 of file road_gui.cpp.
|
static |
Definition at line 1173 of file road_gui.cpp.
|
static |
Definition at line 1592 of file road_gui.cpp.
|
static |
Toggles state of the Remove button of Build road toolbar.
w | window the button belongs to |
Definition at line 315 of file road_gui.cpp.
References Window::IsWidgetLowered(), Window::SetWidgetDirty(), Window::ToggleWidgetLoweredState(), and WID_ROT_REMOVE.
Referenced by BuildRoadToolbarWindow::OnClick(), and RoadToolbar_CtrlChanged().
|
static |
Definition at line 65 of file road_gui.cpp.
|
staticconstexpr |
Definition at line 1147 of file road_gui.cpp.
|
staticconstexpr |
Definition at line 1005 of file road_gui.cpp.
|
staticconstexpr |
Nested widget definition for the build NewGRF road waypoint window.
Definition at line 1684 of file road_gui.cpp.
|
staticconstexpr |
Definition at line 899 of file road_gui.cpp.
|
staticconstexpr |
Definition at line 1042 of file road_gui.cpp.
|
staticconstexpr |
Definition at line 944 of file road_gui.cpp.
|
staticconstexpr |
Widget definition of the build road station window.
Definition at line 1491 of file road_gui.cpp.
|
staticconstexpr |
Widget definition of the build tram station window.
Definition at line 1553 of file road_gui.cpp.
|
static |
Definition at line 58 of file road_gui.cpp.
|
static |
Definition at line 60 of file road_gui.cpp.
|
static |
Definition at line 63 of file road_gui.cpp.
|
static |
Definition at line 61 of file road_gui.cpp.
|
static |
Definition at line 62 of file road_gui.cpp.
|
static |
Definition at line 57 of file road_gui.cpp.
|
static |
Definition at line 67 of file road_gui.cpp.
|
static |
Definition at line 80 of file road_gui.cpp.
|
static |
Settings of the road waypoint picker.
Definition at line 73 of file road_gui.cpp.
Referenced by RoadWaypointPickerCallbacks::GetSelectedClass(), RoadWaypointPickerCallbacks::GetSelectedType(), BuildRoadToolbarWindow::OnPlaceMouseUp(), RoadWaypointPickerCallbacks::SetSelectedClass(), and RoadWaypointPickerCallbacks::SetSelectedType().