diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/airport_gui.cpp | 5 | ||||
-rw-r--r-- | src/dock_gui.cpp | 9 | ||||
-rw-r--r-- | src/lang/english.txt | 3 | ||||
-rw-r--r-- | src/road_gui.cpp | 12 | ||||
-rw-r--r-- | src/widget.cpp | 9 | ||||
-rw-r--r-- | src/widget_type.h | 1 |
6 files changed, 38 insertions, 1 deletions
diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index 62eca78f9..e12b8dccb 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -97,6 +97,11 @@ struct BuildAirToolbarWindow : Window { WIDGET_LIST_END); if (!can_build) { DeleteWindowById(WC_BUILD_STATION, TRANSPORT_AIR); + + /* Show in the tooltip why this button is disabled. */ + this->GetWidget<NWidgetCore>(WID_AT_AIRPORT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE); + } else { + this->GetWidget<NWidgetCore>(WID_AT_AIRPORT)->SetToolTip(STR_TOOLBAR_AIRCRAFT_BUILD_AIRPORT_TOOLTIP); } } diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index 7e2d61857..39237f5ca 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -125,6 +125,15 @@ struct BuildDocksToolbarWindow : Window { if (!can_build) { DeleteWindowById(WC_BUILD_STATION, TRANSPORT_WATER); DeleteWindowById(WC_BUILD_DEPOT, TRANSPORT_WATER); + + /* Show in the tooltip why this button is disabled. */ + this->GetWidget<NWidgetCore>(WID_DT_DEPOT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE); + this->GetWidget<NWidgetCore>(WID_DT_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE); + this->GetWidget<NWidgetCore>(WID_DT_BUOY)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE); + } else { + this->GetWidget<NWidgetCore>(WID_DT_DEPOT)->SetToolTip(STR_WATERWAYS_TOOLBAR_BUILD_DEPOT_TOOLTIP); + this->GetWidget<NWidgetCore>(WID_DT_STATION)->SetToolTip(STR_WATERWAYS_TOOLBAR_BUILD_DOCK_TOOLTIP); + this->GetWidget<NWidgetCore>(WID_DT_BUOY)->SetToolTip(STR_WATERWAYS_TOOLBAR_BUOY_TOOLTIP); } } diff --git a/src/lang/english.txt b/src/lang/english.txt index 52b75f413..a0cf2b9a0 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -2353,6 +2353,9 @@ STR_JOIN_STATION_CREATE_SPLITTED_STATION :{YELLOW}Build a STR_JOIN_WAYPOINT_CAPTION :{WHITE}Join waypoint STR_JOIN_WAYPOINT_CREATE_SPLITTED_WAYPOINT :{YELLOW}Build a separate waypoint +# Generic toolbar +STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE :{BLACK}Disabled as currently no vehicles are available for this infrastructure + # Rail construction toolbar STR_RAIL_TOOLBAR_RAILROAD_CONSTRUCTION_CAPTION :Railway Construction STR_RAIL_TOOLBAR_ELRAIL_CONSTRUCTION_CAPTION :Electrified Railway Construction 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); } } diff --git a/src/widget.cpp b/src/widget.cpp index 2be2f2b85..d1ba44679 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -895,6 +895,15 @@ void NWidgetCore::SetDataTip(uint32 widget_data, StringID tool_tip) this->tool_tip = tool_tip; } +/** + * Set the tool tip of the nested widget. + * @param tool_tip Tool tip string to use. + */ +void NWidgetCore::SetToolTip(StringID tool_tip) +{ + this->tool_tip = tool_tip; +} + void NWidgetCore::FillNestedArray(NWidgetBase **array, uint length) { if (this->index >= 0 && (uint)(this->index) < length) array[this->index] = this; diff --git a/src/widget_type.h b/src/widget_type.h index 1b1677039..d8841f9bd 100644 --- a/src/widget_type.h +++ b/src/widget_type.h @@ -285,6 +285,7 @@ public: void SetIndex(int index); void SetDataTip(uint32 widget_data, StringID tool_tip); + void SetToolTip(StringID tool_tip); inline void SetLowered(bool lowered); inline bool IsLowered() const; |