summaryrefslogtreecommitdiff
path: root/src/road_gui.cpp
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-01-07 23:06:23 +0100
committerPatric Stout <github@truebrain.nl>2021-01-08 16:43:51 +0100
commitaf22a4f2cda86a7667578281a51ea1ec08a49af6 (patch)
treeef59fd78c7d3e2b68594bfbe22b43a6abaf0001e /src/road_gui.cpp
parent85a49a0d3605b83b911c57c6e5cc9d8b79365131 (diff)
downloadopenttd-af22a4f2cda86a7667578281a51ea1ec08a49af6.tar.xz
Add: show in the tooltip of disabled toolbar buttons why they are disabled
Diffstat (limited to 'src/road_gui.cpp')
-rw-r--r--src/road_gui.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/road_gui.cpp b/src/road_gui.cpp
index dff4d2bc1..b9f59333d 100644
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -303,8 +303,9 @@ struct BuildRoadToolbarWindow : Window {
void OnInvalidateData(int data = 0, bool gui_scope = true) override
{
if (!gui_scope) return;
+ RoadTramType rtt = GetRoadTramType(this->roadtype);
- bool can_build = CanBuildVehicleInfrastructure(VEH_ROAD, GetRoadTramType(this->roadtype));
+ bool can_build = CanBuildVehicleInfrastructure(VEH_ROAD, rtt);
this->SetWidgetsDisabledState(!can_build,
WID_ROT_DEPOT,
WID_ROT_BUS_STATION,
@@ -314,6 +315,15 @@ struct BuildRoadToolbarWindow : Window {
DeleteWindowById(WC_BUS_STATION, TRANSPORT_ROAD);
DeleteWindowById(WC_TRUCK_STATION, TRANSPORT_ROAD);
DeleteWindowById(WC_BUILD_DEPOT, TRANSPORT_ROAD);
+
+ /* Show in the tooltip why this button is disabled. */
+ this->GetWidget<NWidgetCore>(WID_ROT_DEPOT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
+ this->GetWidget<NWidgetCore>(WID_ROT_BUS_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
+ this->GetWidget<NWidgetCore>(WID_ROT_TRUCK_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
+ } else {
+ this->GetWidget<NWidgetCore>(WID_ROT_DEPOT)->SetToolTip(rtt == RTT_ROAD ? STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_VEHICLE_DEPOT : STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAM_VEHICLE_DEPOT);
+ this->GetWidget<NWidgetCore>(WID_ROT_BUS_STATION)->SetToolTip(rtt == RTT_ROAD ? STR_ROAD_TOOLBAR_TOOLTIP_BUILD_BUS_STATION : STR_ROAD_TOOLBAR_TOOLTIP_BUILD_PASSENGER_TRAM_STATION);
+ this->GetWidget<NWidgetCore>(WID_ROT_TRUCK_STATION)->SetToolTip(rtt == RTT_ROAD ? STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRUCK_LOADING_BAY : STR_ROAD_TOOLBAR_TOOLTIP_BUILD_CARGO_TRAM_STATION);
}
}