summaryrefslogtreecommitdiff
path: root/src/airport_gui.cpp
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2009-07-05 16:50:56 +0000
committeryexo <yexo@openttd.org>2009-07-05 16:50:56 +0000
commit96201f1a41ee091ec9a1556893f83b92e28de7a0 (patch)
tree5b0660717606536e513d06a25c0fb8dc0b44244c /src/airport_gui.cpp
parentb9f181afc9f9fc2751625176f0f6fc6d73d5ca29 (diff)
downloadopenttd-96201f1a41ee091ec9a1556893f83b92e28de7a0.tar.xz
(svn r16752) -Codechange: Remove most of the window-changing code from AirportPickerWindow::OnPaint
Diffstat (limited to 'src/airport_gui.cpp')
-rw-r--r--src/airport_gui.cpp57
1 files changed, 35 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;