summaryrefslogtreecommitdiff
path: root/src/road_gui.cpp
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-01-07 22:28:08 +0100
committerPatric Stout <github@truebrain.nl>2021-01-08 16:43:51 +0100
commit85a49a0d3605b83b911c57c6e5cc9d8b79365131 (patch)
tree5c98121072bc62f49e89c1636fa675df404df6be /src/road_gui.cpp
parenta6aec252b1987d11e09f2778e481ae3d6fb916fa (diff)
downloadopenttd-85a49a0d3605b83b911c57c6e5cc9d8b79365131.tar.xz
Change: always allow to click on the toolbar icons for road/rail/dock/airport
This change allows a user to see what is available and what will become available before it is available, instead of only disabling the button with no further explanation. It also always allows building roads and canals, even if no vehicles are available for road / water. For rail/road/tram, a dropdown with available types is shown. If none are available, it reads "None". If the type is not yet available, it is greyed out. For dock/airport, this always open the toolbar, but building airports, docks, and depots buttons are disabled till vehicles are available for those. Road is the only exception, with the primary road always being available. Here too, stations and depots are disabled till vehicles become available. It does mean you can now always build roads to for example help towns grow.
Diffstat (limited to 'src/road_gui.cpp')
-rw-r--r--src/road_gui.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/road_gui.cpp b/src/road_gui.cpp
index 1e1f3e807..dff4d2bc1 100644
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -304,7 +304,17 @@ struct BuildRoadToolbarWindow : Window {
{
if (!gui_scope) return;
- if (_game_mode != GM_EDITOR && !CanBuildVehicleInfrastructure(VEH_ROAD, GetRoadTramType(this->roadtype))) delete this;
+ bool can_build = CanBuildVehicleInfrastructure(VEH_ROAD, GetRoadTramType(this->roadtype));
+ this->SetWidgetsDisabledState(!can_build,
+ WID_ROT_DEPOT,
+ WID_ROT_BUS_STATION,
+ WID_ROT_TRUCK_STATION,
+ WIDGET_LIST_END);
+ if (!can_build) {
+ DeleteWindowById(WC_BUS_STATION, TRANSPORT_ROAD);
+ DeleteWindowById(WC_TRUCK_STATION, TRANSPORT_ROAD);
+ DeleteWindowById(WC_BUILD_DEPOT, TRANSPORT_ROAD);
+ }
}
void Initialize(RoadType roadtype)
@@ -434,7 +444,6 @@ struct BuildRoadToolbarWindow : Window {
break;
case WID_ROT_DEPOT:
- if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD, GetRoadTramType(this->roadtype))) return;
if (HandlePlacePushButton(this, WID_ROT_DEPOT, this->rti->cursor.depot, HT_RECT)) {
ShowRoadDepotPicker(this);
this->last_started_action = widget;
@@ -442,7 +451,6 @@ struct BuildRoadToolbarWindow : Window {
break;
case WID_ROT_BUS_STATION:
- if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD, GetRoadTramType(this->roadtype))) return;
if (HandlePlacePushButton(this, WID_ROT_BUS_STATION, SPR_CURSOR_BUS_STATION, HT_RECT)) {
ShowRVStationPicker(this, ROADSTOP_BUS);
this->last_started_action = widget;
@@ -450,7 +458,6 @@ struct BuildRoadToolbarWindow : Window {
break;
case WID_ROT_TRUCK_STATION:
- if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD, GetRoadTramType(this->roadtype))) return;
if (HandlePlacePushButton(this, WID_ROT_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, HT_RECT)) {
ShowRVStationPicker(this, ROADSTOP_TRUCK);
this->last_started_action = widget;
@@ -711,7 +718,6 @@ static EventState RoadTramToolbarGlobalHotkeys(int hotkey, RoadType last_build,
Window* w = nullptr;
switch (_game_mode) {
case GM_NORMAL:
- if (!CanBuildVehicleInfrastructure(VEH_ROAD, rtt)) return ES_NOT_HANDLED;
w = ShowBuildRoadToolbar(last_build);
break;