summaryrefslogtreecommitdiff
path: root/src/airport_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/airport_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/airport_gui.cpp')
-rw-r--r--src/airport_gui.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp
index 8760e1f2a..62eca78f9 100644
--- a/src/airport_gui.cpp
+++ b/src/airport_gui.cpp
@@ -71,6 +71,7 @@ struct BuildAirToolbarWindow : Window {
BuildAirToolbarWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
{
this->InitNested(window_number);
+ this->OnInvalidateData();
if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
this->last_user_action = WIDGET_LIST_END;
}
@@ -90,7 +91,13 @@ struct BuildAirToolbarWindow : Window {
{
if (!gui_scope) return;
- if (!CanBuildVehicleInfrastructure(VEH_AIRCRAFT)) delete this;
+ bool can_build = CanBuildVehicleInfrastructure(VEH_AIRCRAFT);
+ this->SetWidgetsDisabledState(!can_build,
+ WID_AT_AIRPORT,
+ WIDGET_LIST_END);
+ if (!can_build) {
+ DeleteWindowById(WC_BUILD_STATION, TRANSPORT_AIR);
+ }
}
void OnClick(Point pt, int widget, int click_count) override
@@ -160,7 +167,6 @@ struct BuildAirToolbarWindow : Window {
*/
static EventState AirportToolbarGlobalHotkeys(int hotkey)
{
- if (_game_mode != GM_NORMAL || !CanBuildVehicleInfrastructure(VEH_AIRCRAFT)) return ES_NOT_HANDLED;
Window *w = ShowBuildAirToolbar();
if (w == nullptr) return ES_NOT_HANDLED;
return w->OnHotkey(hotkey);