airport_gui.cpp

Go to the documentation of this file.
00001 /* $Id$ */
00002 
00003 /*
00004  * This file is part of OpenTTD.
00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
00008  */
00009 
00012 #include "stdafx.h"
00013 #include "window_gui.h"
00014 #include "station_gui.h"
00015 #include "terraform_gui.h"
00016 #include "sound_func.h"
00017 #include "window_func.h"
00018 #include "strings_func.h"
00019 #include "viewport_func.h"
00020 #include "company_func.h"
00021 #include "tilehighlight_func.h"
00022 #include "company_base.h"
00023 #include "station_type.h"
00024 #include "newgrf_airport.h"
00025 #include "newgrf_callbacks.h"
00026 #include "widgets/dropdown_type.h"
00027 #include "core/geometry_func.hpp"
00028 #include "hotkeys.h"
00029 #include "vehicle_func.h"
00030 #include "sprite.h"
00031 
00032 #include "widgets/airport_widget.h"
00033 
00034 #include "table/strings.h"
00035 
00036 static AirportClassID _selected_airport_class; 
00037 static int _selected_airport_index;            
00038 static byte _selected_airport_layout;          
00039 
00040 static void ShowBuildAirportPicker(Window *parent);
00041 
00042 SpriteID GetCustomAirportSprite(const AirportSpec *as, byte layout);
00043 
00044 void CcBuildAirport(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
00045 {
00046   if (result.Failed()) return;
00047 
00048   SndPlayTileFx(SND_1F_SPLAT, tile);
00049   if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
00050 }
00051 
00056 static void PlaceAirport(TileIndex tile)
00057 {
00058   if (_selected_airport_index == -1) return;
00059   uint32 p2 = _ctrl_pressed;
00060   SB(p2, 16, 16, INVALID_STATION); // no station to join
00061 
00062   uint32 p1 = AirportClass::Get(_selected_airport_class, _selected_airport_index)->GetIndex();
00063   p1 |= _selected_airport_layout << 8;
00064   CommandContainer cmdcont = { tile, p1, p2, CMD_BUILD_AIRPORT | CMD_MSG(STR_ERROR_CAN_T_BUILD_AIRPORT_HERE), CcBuildAirport, "" };
00065   ShowSelectStationIfNeeded(cmdcont, TileArea(tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE));
00066 }
00067 
00069 struct BuildAirToolbarWindow : Window {
00070   int last_user_action; // Last started user action.
00071 
00072   BuildAirToolbarWindow(const WindowDesc *desc, WindowNumber window_number) : Window()
00073   {
00074     this->InitNested(desc, window_number);
00075     if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
00076     this->last_user_action = WIDGET_LIST_END;
00077   }
00078 
00079   ~BuildAirToolbarWindow()
00080   {
00081     if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0, false);
00082   }
00083 
00084   virtual void OnClick(Point pt, int widget, int click_count)
00085   {
00086     switch (widget) {
00087       case WID_AT_AIRPORT:
00088         if (HandlePlacePushButton(this, WID_AT_AIRPORT, SPR_CURSOR_AIRPORT, HT_RECT)) {
00089           ShowBuildAirportPicker(this);
00090           this->last_user_action = widget;
00091         }
00092         break;
00093 
00094       case WID_AT_DEMOLISH:
00095         HandlePlacePushButton(this, WID_AT_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT | HT_DIAGONAL);
00096         this->last_user_action = widget;
00097         break;
00098 
00099       default: break;
00100     }
00101   }
00102 
00103 
00104   virtual EventState OnKeyPress(uint16 key, uint16 keycode)
00105   {
00106     int num = CheckHotkeyMatch(airtoolbar_hotkeys, keycode, this);
00107     if (num == -1) return ES_NOT_HANDLED;
00108     this->OnClick(Point(), num, 1);
00109     return ES_HANDLED;
00110   }
00111 
00112   virtual void OnPlaceObject(Point pt, TileIndex tile)
00113   {
00114     switch (this->last_user_action) {
00115       case WID_AT_AIRPORT:
00116         PlaceAirport(tile);
00117         break;
00118 
00119       case WID_AT_DEMOLISH:
00120         PlaceProc_DemolishArea(tile);
00121         break;
00122 
00123       default: NOT_REACHED();
00124     }
00125   }
00126 
00127   virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
00128   {
00129     VpSelectTilesWithMethod(pt.x, pt.y, select_method);
00130   }
00131 
00132   virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
00133   {
00134     if (pt.x != -1 && select_proc == DDSP_DEMOLISH_AREA) {
00135       GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
00136     }
00137   }
00138 
00139   virtual void OnPlaceObjectAbort()
00140   {
00141     this->RaiseButtons();
00142 
00143     DeleteWindowById(WC_BUILD_STATION, TRANSPORT_AIR);
00144     DeleteWindowById(WC_SELECT_STATION, 0);
00145   }
00146 
00147   static Hotkey<BuildAirToolbarWindow> airtoolbar_hotkeys[];
00148 };
00149 
00150 Hotkey<BuildAirToolbarWindow> BuildAirToolbarWindow::airtoolbar_hotkeys[] = {
00151   Hotkey<BuildAirToolbarWindow>('1', "airport", WID_AT_AIRPORT),
00152   Hotkey<BuildAirToolbarWindow>('2', "demolish", WID_AT_DEMOLISH),
00153   HOTKEY_LIST_END(BuildAirToolbarWindow)
00154 };
00155 Hotkey<BuildAirToolbarWindow> *_airtoolbar_hotkeys = BuildAirToolbarWindow::airtoolbar_hotkeys;
00156 
00157 static const NWidgetPart _nested_air_toolbar_widgets[] = {
00158   NWidget(NWID_HORIZONTAL),
00159     NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
00160     NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_TOOLBAR_AIRCRAFT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
00161     NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
00162   EndContainer(),
00163   NWidget(NWID_HORIZONTAL),
00164     NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_AT_AIRPORT), SetFill(0, 1), SetMinimalSize(42, 22), SetDataTip(SPR_IMG_AIRPORT, STR_TOOLBAR_AIRCRAFT_BUILD_AIRPORT_TOOLTIP),
00165     NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetMinimalSize(4, 22), SetFill(1, 1), EndContainer(),
00166     NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_AT_DEMOLISH), SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
00167   EndContainer(),
00168 };
00169 
00170 static const WindowDesc _air_toolbar_desc(
00171   WDP_ALIGN_TOOLBAR, 0, 0,
00172   WC_BUILD_TOOLBAR, WC_NONE,
00173   WDF_CONSTRUCTION,
00174   _nested_air_toolbar_widgets, lengthof(_nested_air_toolbar_widgets)
00175 );
00176 
00184 Window *ShowBuildAirToolbar()
00185 {
00186   if (!Company::IsValidID(_local_company)) return NULL;
00187 
00188   DeleteWindowByClass(WC_BUILD_TOOLBAR);
00189   return AllocateWindowDescFront<BuildAirToolbarWindow>(&_air_toolbar_desc, TRANSPORT_AIR);
00190 }
00191 
00192 EventState AirportToolbarGlobalHotkeys(uint16 key, uint16 keycode)
00193 {
00194   if (!CanBuildVehicleInfrastructure(VEH_AIRCRAFT)) return ES_NOT_HANDLED;
00195   int num = CheckHotkeyMatch<BuildAirToolbarWindow>(_airtoolbar_hotkeys, keycode, NULL, true);
00196   if (num == -1) return ES_NOT_HANDLED;
00197   Window *w = ShowBuildAirToolbar();
00198   if (w == NULL) return ES_NOT_HANDLED;
00199   return w->OnKeyPress(key, keycode);
00200 }
00201 
00202 class BuildAirportWindow : public PickerWindowBase {
00203   SpriteID preview_sprite; 
00204   int line_height;
00205   Scrollbar *vscroll;
00206 
00208   static DropDownList *BuildAirportClassDropDown()
00209   {
00210     DropDownList *list = new DropDownList();
00211 
00212     for (uint i = 0; i < AirportClass::GetCount(); i++) {
00213       list->push_back(new DropDownListStringItem(AirportClass::GetName((AirportClassID)i), i, false));
00214     }
00215 
00216     return list;
00217   }
00218 
00219 public:
00220   BuildAirportWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(parent)
00221   {
00222     this->CreateNestedTree(desc);
00223 
00224     this->vscroll = this->GetScrollbar(WID_AP_SCROLLBAR);
00225     this->vscroll->SetCapacity(5);
00226     this->vscroll->SetPosition(0);
00227 
00228     this->FinishInitNested(desc, TRANSPORT_AIR);
00229 
00230     this->SetWidgetLoweredState(WID_AP_BTN_DONTHILIGHT, !_settings_client.gui.station_show_coverage);
00231     this->SetWidgetLoweredState(WID_AP_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage);
00232     this->OnInvalidateData();
00233 
00234     this->vscroll->SetCount(AirportClass::GetCount(_selected_airport_class));
00235     this->SelectFirstAvailableAirport(true);
00236   }
00237 
00238   virtual ~BuildAirportWindow()
00239   {
00240     DeleteWindowById(WC_SELECT_STATION, 0);
00241   }
00242 
00243   virtual void SetStringParameters(int widget) const
00244   {
00245     switch (widget) {
00246       case WID_AP_CLASS_DROPDOWN:
00247         SetDParam(0, AirportClass::GetName(_selected_airport_class));
00248         break;
00249 
00250       case WID_AP_LAYOUT_NUM:
00251         SetDParam(0, STR_EMPTY);
00252         if (_selected_airport_index != -1) {
00253           const AirportSpec *as = AirportClass::Get(_selected_airport_class, _selected_airport_index);
00254           StringID string = GetAirportTextCallback(as, _selected_airport_layout, CBID_AIRPORT_LAYOUT_NAME);
00255           if (string != STR_UNDEFINED) {
00256             SetDParam(0, string);
00257           } else if (as->num_table > 1) {
00258             SetDParam(0, STR_STATION_BUILD_AIRPORT_LAYOUT_NAME);
00259             SetDParam(1, _selected_airport_layout + 1);
00260           }
00261         }
00262         break;
00263 
00264       default: break;
00265     }
00266   }
00267 
00268   virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
00269   {
00270     switch (widget) {
00271       case WID_AP_CLASS_DROPDOWN: {
00272         Dimension d = {0, 0};
00273         for (uint i = 0; i < AirportClass::GetCount(); i++) {
00274           SetDParam(0, AirportClass::GetName((AirportClassID)i));
00275           d = maxdim(d, GetStringBoundingBox(STR_BLACK_STRING));
00276         }
00277         d.width += padding.width;
00278         d.height += padding.height;
00279         *size = maxdim(*size, d);
00280         break;
00281       }
00282 
00283       case WID_AP_AIRPORT_LIST: {
00284         for (int i = 0; i < NUM_AIRPORTS; i++) {
00285           const AirportSpec *as = AirportSpec::Get(i);
00286           if (!as->enabled) continue;
00287 
00288           size->width = max(size->width, GetStringBoundingBox(as->name).width);
00289         }
00290 
00291         this->line_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM;
00292         size->height = this->vscroll->GetCapacity() * this->line_height;
00293         break;
00294       }
00295 
00296       case WID_AP_AIRPORT_SPRITE:
00297         for (int i = 0; i < NUM_AIRPORTS; i++) {
00298           const AirportSpec *as = AirportSpec::Get(i);
00299           if (!as->enabled) continue;
00300           for (byte layout = 0; layout < as->num_table; layout++) {
00301             SpriteID sprite = GetCustomAirportSprite(as, layout);
00302             if (sprite != 0) {
00303               Dimension d = GetSpriteSize(sprite);
00304               d.width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
00305               d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
00306               *size = maxdim(d, *size);
00307             }
00308           }
00309         }
00310         break;
00311 
00312       case WID_AP_EXTRA_TEXT:
00313         for (int i = NEW_AIRPORT_OFFSET; i < NUM_AIRPORTS; i++) {
00314           const AirportSpec *as = AirportSpec::Get(i);
00315           if (!as->enabled) continue;
00316           for (byte layout = 0; layout < as->num_table; layout++) {
00317             StringID string = GetAirportTextCallback(as, layout, CBID_AIRPORT_ADDITIONAL_TEXT);
00318             if (string == STR_UNDEFINED) continue;
00319 
00320             /* STR_BLACK_STRING is used to start the string with {BLACK} */
00321             SetDParam(0, string);
00322             Dimension d = GetStringMultiLineBoundingBox(STR_BLACK_STRING, *size);
00323             *size = maxdim(d, *size);
00324           }
00325         }
00326         break;
00327 
00328       default: break;
00329     }
00330   }
00331 
00332   virtual void DrawWidget(const Rect &r, int widget) const
00333   {
00334     switch (widget) {
00335       case WID_AP_AIRPORT_LIST: {
00336         int y = r.top;
00337         for (uint i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < AirportClass::GetCount(_selected_airport_class); i++) {
00338           const AirportSpec *as = AirportClass::Get(_selected_airport_class, i);
00339           if (!as->IsAvailable()) {
00340             GfxFillRect(r.left + 1, y + 1, r.right - 1, y + this->line_height - 2, PC_BLACK, FILLRECT_CHECKER);
00341           }
00342           DrawString(r.left + WD_MATRIX_LEFT, r.right + WD_MATRIX_RIGHT, y + WD_MATRIX_TOP, as->name, ((int)i == _selected_airport_index) ? TC_WHITE : TC_BLACK);
00343           y += this->line_height;
00344         }
00345         break;
00346       }
00347 
00348       case WID_AP_AIRPORT_SPRITE:
00349         if (this->preview_sprite != 0) {
00350           Dimension d = GetSpriteSize(this->preview_sprite);
00351           DrawSprite(this->preview_sprite, COMPANY_SPRITE_COLOUR(_local_company), (r.left + r.right - d.width) / 2, (r.top + r.bottom - d.height) / 2);
00352         }
00353         break;
00354 
00355       case WID_AP_EXTRA_TEXT:
00356         if (_selected_airport_index != -1) {
00357           const AirportSpec *as = AirportClass::Get(_selected_airport_class, _selected_airport_index);
00358           StringID string = GetAirportTextCallback(as, _selected_airport_layout, CBID_AIRPORT_ADDITIONAL_TEXT);
00359           if (string != STR_UNDEFINED) {
00360             SetDParam(0, string);
00361             DrawStringMultiLine(r.left, r.right, r.top, r.bottom, STR_BLACK_STRING);
00362           }
00363         }
00364         break;
00365     }
00366   }
00367 
00368   virtual void OnPaint()
00369   {
00370     this->DrawWidgets();
00371 
00372     uint16 top = this->GetWidget<NWidgetBase>(WID_AP_BTN_DOHILIGHT)->pos_y + this->GetWidget<NWidgetBase>(WID_AP_BTN_DOHILIGHT)->current_y + WD_PAR_VSEP_NORMAL;
00373     NWidgetBase *panel_nwi = this->GetWidget<NWidgetBase>(WID_AP_BOTTOMPANEL);
00374 
00375     int right = panel_nwi->pos_x +  panel_nwi->current_x;
00376     int bottom = panel_nwi->pos_y +  panel_nwi->current_y;
00377 
00378     if (_selected_airport_index != -1) {
00379       const AirportSpec *as = AirportClass::Get(_selected_airport_class, _selected_airport_index);
00380       int rad = _settings_game.station.modified_catchment ? as->catchment : (uint)CA_UNMODIFIED;
00381 
00382       /* only show the station (airport) noise, if the noise option is activated */
00383       if (_settings_game.economy.station_noise_level) {
00384         /* show the noise of the selected airport */
00385         SetDParam(0, as->noise_level);
00386         DrawString(panel_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, STR_STATION_BUILD_NOISE);
00387         top += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
00388       }
00389 
00390       /* strings such as 'Size' and 'Coverage Area' */
00391       top = DrawStationCoverageAreaText(panel_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, false) + WD_PAR_VSEP_NORMAL;
00392       top = DrawStationCoverageAreaText(panel_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, true) + WD_PAR_VSEP_NORMAL;
00393     }
00394 
00395     /* Resize background if the text is not equally long as the window. */
00396     if (top > bottom || (top < bottom && panel_nwi->current_y > panel_nwi->smallest_y)) {
00397       ResizeWindow(this, 0, top - bottom);
00398     }
00399   }
00400 
00401   void SelectOtherAirport(int airport_index)
00402   {
00403     _selected_airport_index = airport_index;
00404     _selected_airport_layout = 0;
00405 
00406     this->UpdateSelectSize();
00407     this->SetDirty();
00408   }
00409 
00410   void UpdateSelectSize()
00411   {
00412     if (_selected_airport_index == -1) {
00413       SetTileSelectSize(1, 1);
00414       this->DisableWidget(WID_AP_LAYOUT_DECREASE);
00415       this->DisableWidget(WID_AP_LAYOUT_INCREASE);
00416     } else {
00417       const AirportSpec *as = AirportClass::Get(_selected_airport_class, _selected_airport_index);
00418       int w = as->size_x;
00419       int h = as->size_y;
00420       Direction rotation = as->rotation[_selected_airport_layout];
00421       if (rotation == DIR_E || rotation == DIR_W) Swap(w, h);
00422       SetTileSelectSize(w, h);
00423 
00424       this->preview_sprite = GetCustomAirportSprite(as, _selected_airport_layout);
00425 
00426       this->SetWidgetDisabledState(WID_AP_LAYOUT_DECREASE, _selected_airport_layout == 0);
00427       this->SetWidgetDisabledState(WID_AP_LAYOUT_INCREASE, _selected_airport_layout + 1 >= as->num_table);
00428 
00429       int rad = _settings_game.station.modified_catchment ? as->catchment : (uint)CA_UNMODIFIED;
00430       if (_settings_client.gui.station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
00431     }
00432   }
00433 
00434   virtual void OnClick(Point pt, int widget, int click_count)
00435   {
00436     switch (widget) {
00437       case WID_AP_CLASS_DROPDOWN:
00438         ShowDropDownList(this, BuildAirportClassDropDown(), _selected_airport_class, WID_AP_CLASS_DROPDOWN);
00439         break;
00440 
00441       case WID_AP_AIRPORT_LIST: {
00442         int num_clicked = this->vscroll->GetPosition() + (pt.y - this->nested_array[widget]->pos_y) / this->line_height;
00443         if (num_clicked >= this->vscroll->GetCount()) break;
00444         const AirportSpec *as = AirportClass::Get(_selected_airport_class, num_clicked);
00445         if (as->IsAvailable()) this->SelectOtherAirport(num_clicked);
00446         break;
00447       }
00448 
00449       case WID_AP_BTN_DONTHILIGHT: case WID_AP_BTN_DOHILIGHT:
00450         _settings_client.gui.station_show_coverage = (widget != WID_AP_BTN_DONTHILIGHT);
00451         this->SetWidgetLoweredState(WID_AP_BTN_DONTHILIGHT, !_settings_client.gui.station_show_coverage);
00452         this->SetWidgetLoweredState(WID_AP_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage);
00453         this->SetDirty();
00454         SndPlayFx(SND_15_BEEP);
00455         this->UpdateSelectSize();
00456         break;
00457 
00458       case WID_AP_LAYOUT_DECREASE:
00459         _selected_airport_layout--;
00460         this->UpdateSelectSize();
00461         this->SetDirty();
00462         break;
00463 
00464       case WID_AP_LAYOUT_INCREASE:
00465         _selected_airport_layout++;
00466         this->UpdateSelectSize();
00467         this->SetDirty();
00468         break;
00469     }
00470   }
00471 
00477   void SelectFirstAvailableAirport(bool change_class)
00478   {
00479     /* First try to select an airport in the selected class. */
00480     for (uint i = 0; i < AirportClass::GetCount(_selected_airport_class); i++) {
00481       const AirportSpec *as = AirportClass::Get(_selected_airport_class, i);
00482       if (as->IsAvailable()) {
00483         this->SelectOtherAirport(i);
00484         return;
00485       }
00486     }
00487     if (change_class) {
00488       /* If that fails, select the first available airport
00489        * from a random class. */
00490       for (AirportClassID j = APC_BEGIN; j < APC_MAX; j++) {
00491         for (uint i = 0; i < AirportClass::GetCount(j); i++) {
00492           const AirportSpec *as = AirportClass::Get(j, i);
00493           if (as->IsAvailable()) {
00494             _selected_airport_class = j;
00495             this->SelectOtherAirport(i);
00496             return;
00497           }
00498         }
00499       }
00500     }
00501     /* If all airports are unavailable, select nothing. */
00502     this->SelectOtherAirport(-1);
00503   }
00504 
00505   virtual void OnDropdownSelect(int widget, int index)
00506   {
00507     assert(widget == WID_AP_CLASS_DROPDOWN);
00508     _selected_airport_class = (AirportClassID)index;
00509     this->vscroll->SetCount(AirportClass::GetCount(_selected_airport_class));
00510     this->SelectFirstAvailableAirport(false);
00511   }
00512 
00513   virtual void OnTick()
00514   {
00515     CheckRedrawStationCoverage(this);
00516   }
00517 };
00518 
00519 static const NWidgetPart _nested_build_airport_widgets[] = {
00520   NWidget(NWID_HORIZONTAL),
00521     NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
00522     NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_AIRPORT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
00523   EndContainer(),
00524   NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetFill(1, 0), SetPIP(2, 0, 2),
00525     NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_AIRPORT_CLASS_LABEL, STR_NULL), SetFill(1, 0),
00526     NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_AP_CLASS_DROPDOWN), SetFill(1, 0), SetDataTip(STR_BLACK_STRING, STR_STATION_BUILD_AIRPORT_TOOLTIP),
00527     NWidget(NWID_HORIZONTAL),
00528       NWidget(WWT_MATRIX, COLOUR_GREY, WID_AP_AIRPORT_LIST), SetFill(1, 0), SetDataTip(0x501, STR_STATION_BUILD_AIRPORT_TOOLTIP), SetScrollbar(WID_AP_SCROLLBAR),
00529       NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_AP_SCROLLBAR),
00530     EndContainer(),
00531     NWidget(NWID_HORIZONTAL),
00532       NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_AP_LAYOUT_DECREASE), SetMinimalSize(12, 0), SetDataTip(AWV_DECREASE, STR_NULL),
00533       NWidget(WWT_LABEL, COLOUR_GREY, WID_AP_LAYOUT_NUM), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_BLACK_STRING, STR_NULL),
00534       NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_AP_LAYOUT_INCREASE), SetMinimalSize(12, 0), SetDataTip(AWV_INCREASE, STR_NULL),
00535     EndContainer(),
00536     NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_AP_AIRPORT_SPRITE), SetFill(1, 0),
00537     NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_AP_EXTRA_TEXT), SetFill(1, 0), SetMinimalSize(150, 0),
00538   EndContainer(),
00539   /* Bottom panel. */
00540   NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_AP_BOTTOMPANEL), SetPIP(2, 2, 2),
00541     NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0),
00542     NWidget(NWID_HORIZONTAL),
00543       NWidget(NWID_SPACER), SetMinimalSize(14, 0), SetFill(1, 0),
00544       NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
00545         NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_AP_BTN_DONTHILIGHT), SetMinimalSize(60, 12), SetFill(1, 0),
00546                       SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
00547         NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_AP_BTN_DOHILIGHT), SetMinimalSize(60, 12), SetFill(1, 0),
00548                       SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
00549       EndContainer(),
00550       NWidget(NWID_SPACER), SetMinimalSize(14, 0), SetFill(1, 0),
00551     EndContainer(),
00552     NWidget(NWID_SPACER), SetMinimalSize(0, 10), SetResize(0, 1), SetFill(1, 0),
00553   EndContainer(),
00554 };
00555 
00556 static const WindowDesc _build_airport_desc(
00557   WDP_AUTO, 0, 0,
00558   WC_BUILD_STATION, WC_BUILD_TOOLBAR,
00559   WDF_CONSTRUCTION | WDF_UNCLICK_BUTTONS,
00560   _nested_build_airport_widgets, lengthof(_nested_build_airport_widgets)
00561 );
00562 
00563 static void ShowBuildAirportPicker(Window *parent)
00564 {
00565   new BuildAirportWindow(&_build_airport_desc, parent);
00566 }
00567 
00568 void InitializeAirportGui()
00569 {
00570   _selected_airport_class = APC_BEGIN;
00571   _selected_airport_index = -1;
00572 }