summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/airport_gui.cpp57
-rw-r--r--src/cheat_gui.cpp1
-rw-r--r--src/date.cpp1
3 files changed, 37 insertions, 22 deletions
diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp
index fa1389202..107c186a8 100644
--- a/src/airport_gui.cpp
+++ b/src/airport_gui.cpp
@@ -207,6 +207,7 @@ public:
this->SetWidgetLoweredState(BAW_BTN_DONTHILIGHT, !_settings_client.gui.station_show_coverage);
this->SetWidgetLoweredState(BAW_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage);
this->LowerWidget(_selected_airport_type + BAW_SMALL_AIRPORT);
+ this->OnInvalidateData();
if (_settings_game.economy.station_noise_level) {
ResizeWindowForWidget(this, BAW_BOTTOMPANEL, 0, 10);
@@ -222,27 +223,12 @@ public:
virtual void OnPaint()
{
- int i; // airport enabling loop
- uint16 y_noise_offset = 0;
- const AirportFTAClass *airport;
-
- this->RaiseWidget(_selected_airport_type + BAW_SMALL_AIRPORT);
- if (!GetAirport(AT_SMALL)->IsAvailable() && _selected_airport_type == AT_SMALL) _selected_airport_type = AT_LARGE;
- if (!GetAirport(AT_LARGE)->IsAvailable() && _selected_airport_type == AT_LARGE) _selected_airport_type = AT_SMALL;
- this->LowerWidget(_selected_airport_type + BAW_SMALL_AIRPORT);
-
- for (i = 0; i < BAW_AIRPORT_COUNT; i++) this->SetWidgetDisabledState(i + BAW_SMALL_AIRPORT, !GetAirport(i)->IsAvailable());
-
- /* select default the coverage area to 'Off' (16) */
- airport = GetAirport(_selected_airport_type);
- SetTileSelectSize(airport->size_x, airport->size_y);
+ this->DrawWidgets();
+ const AirportFTAClass *airport = GetAirport(_selected_airport_type);
int rad = _settings_game.station.modified_catchment ? airport->catchment : (uint)CA_UNMODIFIED;
- if (_settings_client.gui.station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
-
- this->DrawWidgets();
-
+ uint16 y_noise_offset = 0;
/* only show the station (airport) noise, if the noise option is activated */
if (_settings_game.economy.station_noise_level) {
/* show the noise of the selected airport */
@@ -261,17 +247,44 @@ public:
}
}
+ void SelectOtherAirport(byte airport_id)
+ {
+ this->RaiseWidget(_selected_airport_type + BAW_SMALL_AIRPORT);
+ _selected_airport_type = airport_id;
+ this->LowerWidget(airport_id + BAW_SMALL_AIRPORT);
+
+ const AirportFTAClass *airport = GetAirport(airport_id);
+ SetTileSelectSize(airport->size_x, airport->size_y);
+
+ int rad = _settings_game.station.modified_catchment ? airport->catchment : (uint)CA_UNMODIFIED;
+ if (_settings_client.gui.station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
+
+ this->SetDirty();
+ }
+
+ virtual void OnInvalidateData(int data = 0)
+ {
+ if (!GetAirport(_selected_airport_type)->IsAvailable()) {
+ for (int i = 0; i < BAW_AIRPORT_COUNT; i++) {
+ if (GetAirport(i)->IsAvailable()) {
+ this->SelectOtherAirport(i);
+ break;
+ }
+ }
+ }
+ for (int i = 0; i < BAW_AIRPORT_COUNT; i++) {
+ this->SetWidgetDisabledState(i + BAW_SMALL_AIRPORT, !GetAirport(i)->IsAvailable());
+ }
+ }
+
virtual void OnClick(Point pt, int widget)
{
switch (widget) {
case BAW_SMALL_AIRPORT: case BAW_CITY_AIRPORT: case BAW_HELIPORT: case BAW_METRO_AIRPORT:
case BAW_INTERNATIONAL_AIRPORT: case BAW_COMMUTER_AIRPORT: case BAW_HELIDEPOT:
case BAW_INTERCONTINENTAL_AIRPORT: case BAW_HELISTATION:
- this->RaiseWidget(_selected_airport_type + BAW_SMALL_AIRPORT);
- _selected_airport_type = widget - BAW_SMALL_AIRPORT;
- this->LowerWidget(_selected_airport_type + BAW_SMALL_AIRPORT);
+ this->SelectOtherAirport(widget - BAW_SMALL_AIRPORT);
SndPlayFx(SND_15_BEEP);
- this->SetDirty();
DeleteWindowById(WC_SELECT_STATION, 0);
break;
diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp
index f3ce7d0e1..de7eaec97 100644
--- a/src/cheat_gui.cpp
+++ b/src/cheat_gui.cpp
@@ -98,6 +98,7 @@ static int32 ClickChangeDateCheat(int32 p1, int32 p2)
SetDate(ConvertYMDToDate(_cur_year + p2, ymd.month, ymd.day));
EnginesMonthlyLoop();
SetWindowDirty(FindWindowById(WC_STATUS_BAR, 0));
+ InvalidateWindowClassesData(WC_BUILD_STATION, 0);
ResetSignalVariant();
return _cur_year;
}
diff --git a/src/date.cpp b/src/date.cpp
index 46cf23582..b0643701f 100644
--- a/src/date.cpp
+++ b/src/date.cpp
@@ -268,6 +268,7 @@ void IncreaseDate()
CompaniesYearlyLoop();
VehiclesYearlyLoop();
TownsYearlyLoop();
+ InvalidateWindowClassesData(WC_BUILD_STATION);
#ifdef ENABLE_NETWORK
if (_network_server) NetworkServerYearlyLoop();
#endif /* ENABLE_NETWORK */