airport_gui.cpp

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