Index: src/airport_gui.cpp =================================================================== --- src/airport_gui.cpp (wersja 27117) +++ src/airport_gui.cpp (kopia robocza) @@ -82,6 +82,18 @@ if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0, false); } + /** + * Some data on this window has become invalid. + * @param data Information about the changed data. + * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details. + */ + virtual void OnInvalidateData(int data = 0, bool gui_scope = true) + { + if (!gui_scope) return; + + if (!CanBuildVehicleInfrastructure(VEH_AIRCRAFT)) delete this; + } + virtual void OnClick(Point pt, int widget, int click_count) { switch (widget) { Index: src/dock_gui.cpp =================================================================== --- src/dock_gui.cpp (wersja 27117) +++ src/dock_gui.cpp (kopia robocza) @@ -116,11 +116,17 @@ virtual void OnInvalidateData(int data = 0, bool gui_scope = true) { if (!gui_scope) return; - this->SetWidgetsDisabledState(!CanBuildVehicleInfrastructure(VEH_SHIP), + + bool can_build = CanBuildVehicleInfrastructure(VEH_SHIP); + this->SetWidgetsDisabledState(!can_build, WID_DT_DEPOT, WID_DT_STATION, WID_DT_BUOY, WIDGET_LIST_END); + if (!can_build) { + DeleteWindowById(WC_BUILD_STATION, TRANSPORT_WATER); + DeleteWindowById(WC_BUILD_DEPOT, TRANSPORT_WATER); + } } virtual void OnClick(Point pt, int widget, int click_count) Index: src/rail_gui.cpp =================================================================== --- src/rail_gui.cpp (wersja 27117) +++ src/rail_gui.cpp (kopia robocza) @@ -435,6 +435,18 @@ } /** + * Some data on this window has become invalid. + * @param data Information about the changed data. + * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details. + */ + virtual void OnInvalidateData(int data = 0, bool gui_scope = true) + { + if (!gui_scope) return; + + if (!CanBuildVehicleInfrastructure(VEH_TRAIN)) delete this; + } + + /** * Configures the rail toolbar for railtype given * @param railtype the railtype to display */ Index: src/road_gui.cpp =================================================================== --- src/road_gui.cpp (wersja 27117) +++ src/road_gui.cpp (kopia robocza) @@ -338,11 +338,18 @@ virtual void OnInvalidateData(int data = 0, bool gui_scope = true) { if (!gui_scope) return; - this->SetWidgetsDisabledState(!CanBuildVehicleInfrastructure(VEH_ROAD), + + bool can_build = CanBuildVehicleInfrastructure(VEH_ROAD); + this->SetWidgetsDisabledState(!can_build, WID_ROT_DEPOT, WID_ROT_BUS_STATION, WID_ROT_TRUCK_STATION, WIDGET_LIST_END); + if (!can_build) { + DeleteWindowById(WC_BUILD_DEPOT, TRANSPORT_ROAD); + DeleteWindowById(WC_BUS_STATION, TRANSPORT_ROAD); + DeleteWindowById(WC_TRUCK_STATION, TRANSPORT_ROAD); + } } /** Index: src/settings.cpp =================================================================== --- src/settings.cpp (wersja 27117) +++ src/settings.cpp (kopia robocza) @@ -1283,7 +1283,14 @@ return true; } +static bool MaxVehiclesChanged(int32 p1) +{ + InvalidateWindowClassesData(WC_BUILD_TOOLBAR); + MarkWholeScreenDirty(); + return true; +} + #ifdef ENABLE_NETWORK static bool UpdateClientName(int32 p1) Index: src/table/settings.ini =================================================================== --- src/table/settings.ini (wersja 27117) +++ src/table/settings.ini (kopia robocza) @@ -40,6 +40,7 @@ static bool InvalidateCompanyInfrastructureWindow(int32 p1); static bool InvalidateCompanyWindow(int32 p1); static bool ZoomMinMaxChanged(int32 p1); +static bool MaxVehiclesChanged(int32 p1); #ifdef ENABLE_NETWORK static bool UpdateClientName(int32 p1); @@ -959,7 +960,7 @@ str = STR_CONFIG_SETTING_MAX_TRAINS strhelp = STR_CONFIG_SETTING_MAX_TRAINS_HELPTEXT strval = STR_JUST_COMMA -proc = RedrawScreen +proc = MaxVehiclesChanged cat = SC_BASIC [SDT_VAR] @@ -972,7 +973,7 @@ str = STR_CONFIG_SETTING_MAX_ROAD_VEHICLES strhelp = STR_CONFIG_SETTING_MAX_ROAD_VEHICLES_HELPTEXT strval = STR_JUST_COMMA -proc = RedrawScreen +proc = MaxVehiclesChanged cat = SC_BASIC [SDT_VAR] @@ -985,7 +986,7 @@ str = STR_CONFIG_SETTING_MAX_AIRCRAFT strhelp = STR_CONFIG_SETTING_MAX_AIRCRAFT_HELPTEXT strval = STR_JUST_COMMA -proc = RedrawScreen +proc = MaxVehiclesChanged cat = SC_BASIC [SDT_VAR] @@ -998,7 +999,7 @@ str = STR_CONFIG_SETTING_MAX_SHIPS strhelp = STR_CONFIG_SETTING_MAX_SHIPS_HELPTEXT strval = STR_JUST_COMMA -proc = RedrawScreen +proc = MaxVehiclesChanged cat = SC_BASIC [SDTG_BOOL]