Changeset - r24609:ace2ce64471a
[Not reviewed]
master
0 6 0
Patric Stout - 4 years ago 2021-01-07 22:06:23
truebrain@openttd.org
Add: show in the tooltip of disabled toolbar buttons why they are disabled
6 files changed with 38 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/airport_gui.cpp
Show inline comments
 
@@ -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);
 
		}
 
	}
 

	
src/dock_gui.cpp
Show inline comments
 
@@ -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);
 
		}
 
	}
 

	
src/lang/english.txt
Show inline comments
 
@@ -2353,6 +2353,9 @@ STR_JOIN_STATION_CREATE_SPLITTED_STATION
 
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
src/road_gui.cpp
Show inline comments
 
@@ -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);
 
		}
 
	}
 

	
src/widget.cpp
Show inline comments
 
@@ -895,6 +895,15 @@ void NWidgetCore::SetDataTip(uint32 widg
 
	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;
src/widget_type.h
Show inline comments
 
@@ -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;
0 comments (0 inline, 0 general)