# dock_gui.cpp

Go to the documentation of this file.

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