# dock_gui.cpp

Go to the documentation of this file.

    00001 /* $Id: dock_gui.cpp 20872 2010-10-02 14:51:33Z rubidium $ */
    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 "openttd.h"
    00014 #include "tile_map.h"
    00015 #include "terraform_gui.h"
    00016 #include "window_gui.h"
    00017 #include "station_gui.h"
    00018 #include "command_func.h"
    00019 #include "water.h"
    00020 #include "window_func.h"
    00021 #include "vehicle_func.h"
    00022 #include "sound_func.h"
    00023 #include "viewport_func.h"
    00024 #include "gfx_func.h"
    00025 #include "company_func.h"
    00026 #include "slope_func.h"
    00027 #include "tilehighlight_func.h"
    00028 #include "company_base.h"
    00029 #include "station_type.h"
    00030
    00031 #include "table/sprites.h"
    00032 #include "table/strings.h"
    00033
    00034 static void ShowBuildDockStationPicker(Window *parent);
    00035 static void ShowBuildDocksDepotPicker(Window *parent);
    00036
    00037 static Axis _ship_depot_direction;
    00038
    00039 void CcBuildDocks(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
    00040 {
    00041   if (result.Failed()) return;
    00042
    00043   SndPlayTileFx(SND_02_SPLAT, tile);
    00044   if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
    00045 }
    00046
    00047 void CcBuildCanal(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
    00048 {
    00049   if (result.Succeeded()) SndPlayTileFx(SND_02_SPLAT, tile);
    00050 }
    00051
    00052
    00053 static void PlaceDocks_Dock(TileIndex tile)
    00054 {
    00055   uint32 p2 = (uint32)INVALID_STATION << 16; // no station to join
    00056
    00057   /* tile is always the land tile, so need to evaluate _thd.pos */
    00058   CommandContainer cmdcont = { tile, _ctrl_pressed, p2, CMD_BUILD_DOCK | CMD_MSG(STR_ERROR_CAN_T_BUILD_DOCK_HERE), CcBuildDocks, "" };
    00059
    00060   /* Determine the watery part of the dock. */
    00061   DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile, NULL));
    00062   TileIndex tile_to = (dir != INVALID_DIAGDIR ? TileAddByDiagDir(tile, ReverseDiagDir(dir)) : tile);
    00063
    00064   ShowSelectStationIfNeeded(cmdcont, TileArea(tile, tile_to));
    00065 }
    00066
    00067 static void PlaceDocks_Depot(TileIndex tile)
    00068 {
    00069   DoCommandP(tile, _ship_depot_direction, 0, CMD_BUILD_SHIP_DEPOT | CMD_MSG(STR_ERROR_CAN_T_BUILD_SHIP_DEPOT), CcBuildDocks);
    00070 }
    00071
    00072 static void PlaceDocks_Buoy(TileIndex tile)
    00073 {
    00074   DoCommandP(tile, 0, 0, CMD_BUILD_BUOY | CMD_MSG(STR_ERROR_CAN_T_POSITION_BUOY_HERE), CcBuildDocks);
    00075 }
    00076
    00077 static void PlaceDocks_BuildCanal(TileIndex tile)
    00078 {
    00079   VpStartPlaceSizing(tile, (_game_mode == GM_EDITOR) ? VPM_X_AND_Y : VPM_X_OR_Y, DDSP_CREATE_WATER);
    00080 }
    00081
    00082 static void PlaceDocks_BuildLock(TileIndex tile)
    00083 {
    00084   DoCommandP(tile, 0, 0, CMD_BUILD_LOCK | CMD_MSG(STR_ERROR_CAN_T_BUILD_LOCKS), CcBuildDocks);
    00085 }
    00086
    00087 static void PlaceDocks_BuildRiver(TileIndex tile)
    00088 {
    00089   VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CREATE_RIVER);
    00090 }
    00091
    00092 static void PlaceDocks_Aqueduct(TileIndex tile)
    00093 {
    00094   VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_BUILD_BRIDGE);
    00095 }
    00096
    00097
    00099 enum DockToolbarWidgets {
    00100   DTW_BUTTONS_BEGIN,
    00101   DTW_CANAL = DTW_BUTTONS_BEGIN,
    00102   DTW_LOCK,
    00103   DTW_DEMOLISH,
    00104   DTW_DEPOT,
    00105   DTW_STATION,
    00106   DTW_BUOY,
    00107   DTW_RIVER,
    00108   DTW_BUILD_AQUEDUCT,
    00109   DTW_END,
    00110 };
    00111
    00112
    00113 static void BuildDocksClick_Canal(Window *w)
    00114 {
    00115
    00116   HandlePlacePushButton(w, DTW_CANAL, SPR_CURSOR_CANAL, HT_RECT, PlaceDocks_BuildCanal);
    00117 }
    00118
    00119 static void BuildDocksClick_Lock(Window *w)
    00120 {
    00121   HandlePlacePushButton(w, DTW_LOCK, SPR_CURSOR_LOCK, HT_RECT, PlaceDocks_BuildLock);
    00122 }
    00123
    00124 static void BuildDocksClick_Demolish(Window *w)
    00125 {
    00126   HandlePlacePushButton(w, DTW_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT, PlaceProc_DemolishArea);
    00127 }
    00128
    00129 static void BuildDocksClick_Depot(Window *w)
    00130 {
    00131   if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return;
    00132   if (HandlePlacePushButton(w, DTW_DEPOT, SPR_CURSOR_SHIP_DEPOT, HT_RECT, PlaceDocks_Depot)) ShowBuildDocksDepotPicker(w);
    00133 }
    00134
    00135 static void BuildDocksClick_Dock(Window *w)
    00136 {
    00137   if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return;
    00138   if (HandlePlacePushButton(w, DTW_STATION, SPR_CURSOR_DOCK, HT_SPECIAL, PlaceDocks_Dock)) ShowBuildDockStationPicker(w);
    00139 }
    00140
    00141 static void BuildDocksClick_Buoy(Window *w)
    00142 {
    00143   if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return;
    00144   HandlePlacePushButton(w, DTW_BUOY, SPR_CURSOR_BOUY, HT_RECT, PlaceDocks_Buoy);
    00145 }
    00146
    00147 static void BuildDocksClick_River(Window *w)
    00148 {
    00149   if (_game_mode != GM_EDITOR) return;
    00150   HandlePlacePushButton(w, DTW_RIVER, SPR_CURSOR_RIVER, HT_RECT, PlaceDocks_BuildRiver);
    00151 }
    00152
    00153 static void BuildDocksClick_Aqueduct(Window *w)
    00154 {
    00155   HandlePlacePushButton(w, DTW_BUILD_AQUEDUCT, SPR_CURSOR_AQUEDUCT, HT_RECT, PlaceDocks_Aqueduct);
    00156 }
    00157
    00158
    00159 typedef void OnButtonClick(Window *w);
    00160 static OnButtonClick * const _build_docks_button_proc[] = {
    00161   BuildDocksClick_Canal,
    00162   BuildDocksClick_Lock,
    00163   BuildDocksClick_Demolish,
    00164   BuildDocksClick_Depot,
    00165   BuildDocksClick_Dock,
    00166   BuildDocksClick_Buoy,
    00167   BuildDocksClick_River,
    00168   BuildDocksClick_Aqueduct
    00169 };
    00170
    00171 struct BuildDocksToolbarWindow : Window {
    00172   BuildDocksToolbarWindow(const WindowDesc *desc, WindowNumber window_number) : Window()
    00173   {
    00174     this->InitNested(desc, window_number);
    00175     this->OnInvalidateData();
    00176     if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
    00177   }
    00178
    00179   ~BuildDocksToolbarWindow()
    00180   {
    00181     if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0, false);
    00182   }
    00183
    00184   void OnInvalidateData(int data = 0)
    00185   {
    00186     this->SetWidgetsDisabledState(!CanBuildVehicleInfrastructure(VEH_SHIP),
    00187       DTW_DEPOT,
    00188       DTW_STATION,
    00189       DTW_BUOY,
    00190       WIDGET_LIST_END);
    00191   }
    00192
    00193   virtual void OnPaint()
    00194   {
    00195     this->DrawWidgets();
    00196   }
    00197
    00198   virtual void OnClick(Point pt, int widget, int click_count)
    00199   {
    00200     if (widget >= DTW_BUTTONS_BEGIN) _build_docks_button_proc[widget - DTW_BUTTONS_BEGIN](this);
    00201   }
    00202
    00203   virtual EventState OnKeyPress(uint16 key, uint16 keycode)
    00204   {
    00205     switch (keycode) {
    00206       case '1': BuildDocksClick_Canal(this); break;
    00207       case '2': BuildDocksClick_Lock(this); break;
    00208       case '3': BuildDocksClick_Demolish(this); break;
    00209       case '4': BuildDocksClick_Depot(this); break;
    00210       case '5': BuildDocksClick_Dock(this); break;
    00211       case '6': BuildDocksClick_Buoy(this); break;
    00212       case '7': BuildDocksClick_River(this); break;
    00213       case 'B':
    00214       case '8': BuildDocksClick_Aqueduct(this); break;
    00215       default:  return ES_NOT_HANDLED;
    00216     }
    00217     return ES_HANDLED;
    00218   }
    00219
    00220   virtual void OnPlaceObject(Point pt, TileIndex tile)
    00221   {
    00222     _place_proc(tile);
    00223   }
    00224
    00225   virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
    00226   {
    00227     VpSelectTilesWithMethod(pt.x, pt.y, select_method);
    00228   }
    00229
    00230   virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
    00231   {
    00232     if (pt.x != -1) {
    00233       switch (select_proc) {
    00234         case DDSP_BUILD_BRIDGE:
    00235           if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
    00236           DoCommandP(end_tile, start_tile, TRANSPORT_WATER << 15, CMD_BUILD_BRIDGE | CMD_MSG(STR_ERROR_CAN_T_BUILD_AQUEDUCT_HERE), CcBuildBridge);
    00237
    00238         case DDSP_DEMOLISH_AREA:
    00239           GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
    00240           break;
    00241         case DDSP_CREATE_WATER:
    00242           DoCommandP(end_tile, start_tile, (_game_mode == GM_EDITOR ? _ctrl_pressed : 0), CMD_BUILD_CANAL | CMD_MSG(STR_ERROR_CAN_T_BUILD_CANALS), CcBuildCanal);
    00243           break;
    00244         case DDSP_CREATE_RIVER:
    00245           DoCommandP(end_tile, start_tile, 2, CMD_BUILD_CANAL | CMD_MSG(STR_ERROR_CAN_T_PLACE_RIVERS), CcBuildCanal);
    00246           break;
    00247
    00248         default: break;
    00249       }
    00250     }
    00251   }
    00252
    00253   virtual void OnPlaceObjectAbort()
    00254   {
    00255     this->RaiseButtons();
    00256
    00257     DeleteWindowById(WC_BUILD_STATION, TRANSPORT_WATER);
    00258     DeleteWindowById(WC_BUILD_DEPOT, TRANSPORT_WATER);
    00259     DeleteWindowById(WC_SELECT_STATION, 0);
    00260     DeleteWindowByClass(WC_BUILD_BRIDGE);
    00261   }
    00262
    00263   virtual void OnPlacePresize(Point pt, TileIndex tile_from)
    00264   {
    00265     DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile_from, NULL));
    00266     TileIndex tile_to = (dir != INVALID_DIAGDIR ? TileAddByDiagDir(tile_from, ReverseDiagDir(dir)) : tile_from);
    00267
    00268     VpSetPresizeRange(tile_from, tile_to);
    00269   }
    00270 };
    00271
    00272
    00277 static const NWidgetPart _nested_build_docks_toolbar_widgets[] = {
    00278   NWidget(NWID_HORIZONTAL),
    00279     NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
    00280     NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_WATERWAYS_TOOLBAR_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
    00281     NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
    00282   EndContainer(),
    00283   NWidget(NWID_HORIZONTAL_LTR),
    00284     NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, DTW_CANAL), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_BUILD_CANAL, STR_WATERWAYS_TOOLBAR_BUILD_CANALS_TOOLTIP),
    00285     NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, DTW_LOCK), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_BUILD_LOCK, STR_WATERWAYS_TOOLBAR_BUILD_LOCKS_TOOLTIP),
    00286     NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetMinimalSize(5, 22), SetFill(1, 1), EndContainer(),
    00287     NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, DTW_DEMOLISH), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
    00288     NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, DTW_DEPOT), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_SHIP_DEPOT, STR_WATERWAYS_TOOLBAR_BUILD_DEPOT_TOOLTIP),
    00289     NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, DTW_STATION), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_SHIP_DOCK, STR_WATERWAYS_TOOLBAR_BUILD_DOCK_TOOLTIP),
    00290     NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, DTW_BUOY), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_BOUY, STR_WATERWAYS_TOOLBAR_BUOY_TOOLTIP),
    00291     NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, DTW_BUILD_AQUEDUCT), SetMinimalSize(23, 22), SetFill(0, 1), SetDataTip(SPR_IMG_AQUEDUCT, STR_WATERWAYS_TOOLBAR_BUILD_AQUEDUCT_TOOLTIP),
    00292   EndContainer(),
    00293 };
    00294
    00295 static const WindowDesc _build_docks_toolbar_desc(
    00296   WDP_ALIGN_TOOLBAR, 0, 0,
    00297   WC_BUILD_TOOLBAR, WC_NONE,
    00298   WDF_CONSTRUCTION,
    00299   _nested_build_docks_toolbar_widgets, lengthof(_nested_build_docks_toolbar_widgets)
    00300 );
    00301
    00302 void ShowBuildDocksToolbar()
    00303 {
    00304   if (!Company::IsValidID(_local_company)) return;
    00305
    00306   DeleteWindowByClass(WC_BUILD_TOOLBAR);
    00307   AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_toolbar_desc, TRANSPORT_WATER);
    00308 }
    00309
    00314 static const NWidgetPart _nested_build_docks_scen_toolbar_widgets[] = {
    00315   NWidget(NWID_HORIZONTAL),
    00316     NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
    00317     NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_WATERWAYS_TOOLBAR_CAPTION_SE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
    00318     NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
    00319   EndContainer(),
    00320   NWidget(NWID_HORIZONTAL),
    00321     NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, DTW_CANAL), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_BUILD_CANAL, STR_WATERWAYS_TOOLBAR_CREATE_LAKE_TOOLTIP),
    00322     NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, DTW_LOCK), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_BUILD_LOCK, STR_WATERWAYS_TOOLBAR_BUILD_LOCKS_TOOLTIP),
    00323     NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetMinimalSize(5, 22), SetFill(1, 1), EndContainer(),
    00324     NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, DTW_DEMOLISH), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
    00325     NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, DTW_RIVER), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_BUILD_RIVER, STR_WATERWAYS_TOOLBAR_CREATE_RIVER_TOOLTIP),
    00326     NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, DTW_BUILD_AQUEDUCT), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_AQUEDUCT, STR_WATERWAYS_TOOLBAR_BUILD_AQUEDUCT_TOOLTIP),
    00327   EndContainer(),
    00328 };
    00329
    00331 static const WindowDesc _build_docks_scen_toolbar_desc(
    00332   WDP_AUTO, 0, 0,
    00333   WC_SCEN_BUILD_TOOLBAR, WC_NONE,
    00334   WDF_CONSTRUCTION,
    00335   _nested_build_docks_scen_toolbar_widgets, lengthof(_nested_build_docks_scen_toolbar_widgets)
    00336 );
    00337
    00338 void ShowBuildDocksScenToolbar()
    00339 {
    00340   AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_scen_toolbar_desc, TRANSPORT_WATER);
    00341 }
    00342
    00344 enum BuildDockStationWidgets {
    00345   BDSW_BACKGROUND,
    00346   BDSW_LT_OFF,
    00347   BDSW_LT_ON,
    00348   BDSW_INFO,
    00349 };
    00350
    00351 struct BuildDocksStationWindow : public PickerWindowBase {
    00352 public:
    00353   BuildDocksStationWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(parent)
    00354   {
    00355     this->InitNested(desc, TRANSPORT_WATER);
    00356     this->LowerWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF);
    00357   }
    00358
    00359   virtual ~BuildDocksStationWindow()
    00360   {
    00361     DeleteWindowById(WC_SELECT_STATION, 0);
    00362   }
    00363
    00364   virtual void OnPaint()
    00365   {
    00366     int rad = (_settings_game.station.modified_catchment) ? CA_DOCK : CA_UNMODIFIED;
    00367
    00368     this->DrawWidgets();
    00369
    00370     if (_settings_client.gui.station_show_coverage) {
    00371       SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
    00372     } else {
    00373       SetTileSelectSize(1, 1);
    00374     }
    00375
    00376     /* strings such as 'Size' and 'Coverage Area' */
    00377     int top = this->GetWidget<NWidgetBase>(BDSW_LT_OFF)->pos_y + this->GetWidget<NWidgetBase>(BDSW_LT_OFF)->current_y + WD_PAR_VSEP_NORMAL;
    00378     NWidgetBase *back_nwi = this->GetWidget<NWidgetBase>(BDSW_BACKGROUND);
    00379     int right  = back_nwi->pos_x + back_nwi->current_x;
    00380     int bottom = back_nwi->pos_y + back_nwi->current_y;
    00381     top = DrawStationCoverageAreaText(back_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, false) + WD_PAR_VSEP_NORMAL;
    00382     top = DrawStationCoverageAreaText(back_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, true) + WD_PAR_VSEP_NORMAL;
    00383     /* Resize background if the text is not equally long as the window. */
    00384     if (top > bottom || (top < bottom && back_nwi->current_y > back_nwi->smallest_y)) {
    00385       ResizeWindow(this, 0, top - bottom);
    00386     }
    00387   }
    00388
    00389   virtual void OnClick(Point pt, int widget, int click_count)
    00390   {
    00391     switch (widget) {
    00392       case BDSW_LT_OFF:
    00393       case BDSW_LT_ON:
    00394         this->RaiseWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF);
    00395         _settings_client.gui.station_show_coverage = (widget != BDSW_LT_OFF);
    00396         this->LowerWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF);
    00397         SndPlayFx(SND_15_BEEP);
    00398         this->SetDirty();
    00399         break;
    00400     }
    00401   }
    00402
    00403   virtual void OnTick()
    00404   {
    00405     CheckRedrawStationCoverage(this);
    00406   }
    00407 };
    00408
    00410 static const NWidgetPart _nested_build_dock_station_widgets[] = {
    00411   NWidget(NWID_HORIZONTAL),
    00412     NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
    00413     NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_DOCK_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
    00414   EndContainer(),
    00415   NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BDSW_BACKGROUND),
    00416     NWidget(NWID_SPACER), SetMinimalSize(0, 3),
    00417     NWidget(WWT_LABEL, COLOUR_DARK_GREEN, BDSW_INFO), SetMinimalSize(148, 14), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL),
    00418     NWidget(NWID_HORIZONTAL), SetPIP(14, 0, 14),
    00419       NWidget(WWT_TEXTBTN, COLOUR_GREY, BDSW_LT_OFF), SetMinimalSize(40, 12), SetFill(1, 0), SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
    00420       NWidget(WWT_TEXTBTN, COLOUR_GREY, BDSW_LT_ON), SetMinimalSize(40, 12), SetFill(1, 0), SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
    00421     EndContainer(),
    00422     NWidget(NWID_SPACER), SetMinimalSize(0, 20), SetResize(0, 1),
    00423   EndContainer(),
    00424 };
    00425
    00426 static const WindowDesc _build_dock_station_desc(
    00427   WDP_AUTO, 0, 0,
    00428   WC_BUILD_STATION, WC_BUILD_TOOLBAR,
    00429   WDF_CONSTRUCTION,
    00430   _nested_build_dock_station_widgets, lengthof(_nested_build_dock_station_widgets)
    00431 );
    00432
    00433 static void ShowBuildDockStationPicker(Window *parent)
    00434 {
    00435   new BuildDocksStationWindow(&_build_dock_station_desc, parent);
    00436 }
    00437
    00439 enum BuildDockDepotWidgets {
    00440   BDDW_BACKGROUND,
    00441   BDDW_X,
    00442   BDDW_Y,
    00443 };
    00444
    00445 struct BuildDocksDepotWindow : public PickerWindowBase {
    00446 private:
    00447   static void UpdateDocksDirection()
    00448   {
    00449     if (_ship_depot_direction != AXIS_X) {
    00450       SetTileSelectSize(1, 2);
    00451     } else {
    00452       SetTileSelectSize(2, 1);
    00453     }
    00454   }
    00455
    00456 public:
    00457   BuildDocksDepotWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(parent)
    00458   {
    00459     this->InitNested(desc, TRANSPORT_WATER);
    00460     this->LowerWidget(_ship_depot_direction + BDDW_X);
    00461     UpdateDocksDirection();
    00462   }
    00463
    00464   virtual void OnPaint()
    00465   {
    00466     this->DrawWidgets();
    00467
    00468     DrawShipDepotSprite(this->GetWidget<NWidgetBase>(BDDW_X)->pos_x + 64, this->GetWidget<NWidgetBase>(BDDW_X)->pos_y + 18, 0);
    00469     DrawShipDepotSprite(this->GetWidget<NWidgetBase>(BDDW_X)->pos_x + 32, this->GetWidget<NWidgetBase>(BDDW_X)->pos_y + 34, 1);
    00470     DrawShipDepotSprite(this->GetWidget<NWidgetBase>(BDDW_Y)->pos_x + 32, this->GetWidget<NWidgetBase>(BDDW_Y)->pos_y + 18, 2);
    00471     DrawShipDepotSprite(this->GetWidget<NWidgetBase>(BDDW_Y)->pos_x + 64, this->GetWidget<NWidgetBase>(BDDW_Y)->pos_y + 34, 3);
    00472   }
    00473
    00474   virtual void OnClick(Point pt, int widget, int click_count)
    00475   {
    00476     switch (widget) {
    00477       case BDDW_X:
    00478       case BDDW_Y:
    00479         this->RaiseWidget(_ship_depot_direction + BDDW_X);
    00480         _ship_depot_direction = (widget == BDDW_X ? AXIS_X : AXIS_Y);
    00481         this->LowerWidget(_ship_depot_direction + BDDW_X);
    00482         SndPlayFx(SND_15_BEEP);
    00483         UpdateDocksDirection();
    00484         this->SetDirty();
    00485         break;
    00486     }
    00487   }
    00488 };
    00489
    00490 static const NWidgetPart _nested_build_docks_depot_widgets[] = {
    00491   NWidget(NWID_HORIZONTAL),
    00492     NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
    00493     NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_DEPOT_BUILD_SHIP_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
    00494   EndContainer(),
    00495   NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BDDW_BACKGROUND),
    00496     NWidget(NWID_SPACER), SetMinimalSize(0, 3),
    00497     NWidget(NWID_HORIZONTAL_LTR),
    00498       NWidget(NWID_SPACER), SetMinimalSize(3, 0),
    00499       NWidget(WWT_PANEL, COLOUR_GREY, BDDW_X), SetMinimalSize(98, 66), SetDataTip(0x0, STR_DEPOT_BUILD_SHIP_ORIENTATION_TOOLTIP),
    00500       EndContainer(),
    00501       NWidget(NWID_SPACER), SetMinimalSize(2, 0),
    00502       NWidget(WWT_PANEL, COLOUR_GREY, BDDW_Y), SetMinimalSize(98, 66), SetDataTip(0x0, STR_DEPOT_BUILD_SHIP_ORIENTATION_TOOLTIP),
    00503       EndContainer(),
    00504       NWidget(NWID_SPACER), SetMinimalSize(3, 0),
    00505     EndContainer(),
    00506     NWidget(NWID_SPACER), SetMinimalSize(0, 3),
    00507   EndContainer(),
    00508 };
    00509
    00510 static const WindowDesc _build_docks_depot_desc(
    00511   WDP_AUTO, 0, 0,
    00512   WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
    00513   WDF_CONSTRUCTION,
    00514   _nested_build_docks_depot_widgets, lengthof(_nested_build_docks_depot_widgets)
    00515 );
    00516
    00517
    00518 static void ShowBuildDocksDepotPicker(Window *parent)
    00519 {
    00520   new BuildDocksDepotWindow(&_build_docks_depot_desc, parent);
    00521 }
    00522
    00523
    00524 void InitializeDockGui()
    00525 {
    00526   _ship_depot_direction = AXIS_X;
    00527 }