# dock_gui.cpp

Go to the documentation of this file.

    00001 /* $Id: dock_gui.cpp 15723 2009-03-15 15:12:06Z rubidium $ */
    00002
    00005 #include "stdafx.h"
    00006 #include "openttd.h"
    00007 #include "tile_map.h"
    00008 #include "station_type.h"
    00009 #include "terraform_gui.h"
    00010 #include "window_gui.h"
    00011 #include "station_gui.h"
    00012 #include "command_func.h"
    00013 #include "water.h"
    00014 #include "window_func.h"
    00015 #include "vehicle_func.h"
    00016 #include "sound_func.h"
    00017 #include "viewport_func.h"
    00018 #include "gfx_func.h"
    00019 #include "company_func.h"
    00020 #include "slope_func.h"
    00021 #include "tilehighlight_func.h"
    00022 #include "company_base.h"
    00023 #include "settings_type.h"
    00024
    00025 #include "table/sprites.h"
    00026 #include "table/strings.h"
    00027
    00028 static void ShowBuildDockStationPicker(Window *parent);
    00029 static void ShowBuildDocksDepotPicker(Window *parent);
    00030
    00031 static Axis _ship_depot_direction;
    00032
    00033 void CcBuildDocks(bool success, TileIndex tile, uint32 p1, uint32 p2)
    00034 {
    00035   if (success) {
    00036     SndPlayTileFx(SND_02_SPLAT, tile);
    00037     if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
    00038   }
    00039 }
    00040
    00041 void CcBuildCanal(bool success, TileIndex tile, uint32 p1, uint32 p2)
    00042 {
    00043   if (success) SndPlayTileFx(SND_02_SPLAT, tile);
    00044 }
    00045
    00046
    00047 static void PlaceDocks_Dock(TileIndex tile)
    00048 {
    00049   uint32 p2 = INVALID_STATION << 16; // no station to join
    00050
    00051   /* tile is always the land tile, so need to evaluate _thd.pos */
    00052   CommandContainer cmdcont = { tile, _ctrl_pressed, p2, CMD_BUILD_DOCK | CMD_MSG(STR_9802_CAN_T_BUILD_DOCK_HERE), CcBuildDocks, "" };
    00053   ShowSelectStationIfNeeded(cmdcont, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE);
    00054 }
    00055
    00056 static void PlaceDocks_Depot(TileIndex tile)
    00057 {
    00058   DoCommandP(tile, _ship_depot_direction, 0, CMD_BUILD_SHIP_DEPOT | CMD_MSG(STR_3802_CAN_T_BUILD_SHIP_DEPOT), CcBuildDocks);
    00059 }
    00060
    00061 static void PlaceDocks_Buoy(TileIndex tile)
    00062 {
    00063   DoCommandP(tile, 0, 0, CMD_BUILD_BUOY | CMD_MSG(STR_9835_CAN_T_POSITION_BUOY_HERE), CcBuildDocks);
    00064 }
    00065
    00066 static void PlaceDocks_BuildCanal(TileIndex tile)
    00067 {
    00068   VpStartPlaceSizing(tile, (_game_mode == GM_EDITOR) ? VPM_X_AND_Y : VPM_X_OR_Y, DDSP_CREATE_WATER);
    00069 }
    00070
    00071 static void PlaceDocks_BuildLock(TileIndex tile)
    00072 {
    00073   DoCommandP(tile, 0, 0, CMD_BUILD_LOCK | CMD_MSG(STR_CANT_BUILD_LOCKS), CcBuildDocks);
    00074 }
    00075
    00076 static void PlaceDocks_BuildRiver(TileIndex tile)
    00077 {
    00078   VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CREATE_RIVER);
    00079 }
    00080
    00081 static void PlaceDocks_Aqueduct(TileIndex tile)
    00082 {
    00083   VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_BUILD_BRIDGE);
    00084 }
    00085
    00086
    00088 enum DockToolbarWidgets {
    00089   DTW_BEGIN = 0,
    00090   DTW_CLOSEBOX = DTW_BEGIN,
    00091   DTW_CAPTION,
    00092   DTW_STICKY,
    00093   DTW_BUTTONS_BEGIN,
    00094   DTW_CANAL = DTW_BUTTONS_BEGIN,
    00095   DTW_LOCK,
    00096   DTW_SEPERATOR,
    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, VHM_RECT, PlaceDocks_BuildCanal);
    00111 }
    00112
    00113 static void BuildDocksClick_Lock(Window *w)
    00114 {
    00115   HandlePlacePushButton(w, DTW_LOCK, SPR_CURSOR_LOCK, VHM_RECT, PlaceDocks_BuildLock);
    00116 }
    00117
    00118 static void BuildDocksClick_Demolish(Window *w)
    00119 {
    00120   HandlePlacePushButton(w, DTW_DEMOLISH, ANIMCURSOR_DEMOLISH, VHM_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, VHM_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, VHM_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, VHM_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, VHM_RECT, PlaceDocks_BuildRiver);
    00145 }
    00146
    00147 static void BuildDocksClick_Aqueduct(Window *w)
    00148 {
    00149   HandlePlacePushButton(w, DTW_BUILD_AQUEDUCT, SPR_CURSOR_AQUEDUCT, VHM_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   NULL,
    00158   BuildDocksClick_Demolish,
    00159   BuildDocksClick_Depot,
    00160   BuildDocksClick_Dock,
    00161   BuildDocksClick_Buoy,
    00162   BuildDocksClick_River,
    00163   BuildDocksClick_Aqueduct
    00164 };
    00165
    00166 struct BuildDocksToolbarWindow : Window {
    00167   BuildDocksToolbarWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
    00168   {
    00169     this->FindWindowPlacementAndResize(desc);
    00170     if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
    00171   }
    00172
    00173   ~BuildDocksToolbarWindow()
    00174   {
    00175     if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0, false);
    00176   }
    00177
    00178   virtual void OnPaint()
    00179   {
    00180     this->SetWidgetsDisabledState(!CanBuildVehicleInfrastructure(VEH_SHIP), DTW_DEPOT, DTW_STATION, DTW_BUOY, WIDGET_LIST_END);
    00181     this->DrawWidgets();
    00182   }
    00183
    00184   virtual void OnClick(Point pt, int widget)
    00185   {
    00186     if (widget >= DTW_BUTTONS_BEGIN && widget != DTW_SEPERATOR) _build_docks_button_proc[widget - DTW_BUTTONS_BEGIN](this);
    00187   }
    00188
    00189   virtual EventState OnKeyPress(uint16 key, uint16 keycode)
    00190   {
    00191     switch (keycode) {
    00192       case '1': BuildDocksClick_Canal(this); break;
    00193       case '2': BuildDocksClick_Lock(this); break;
    00194       case '3': BuildDocksClick_Demolish(this); break;
    00195       case '4': BuildDocksClick_Depot(this); break;
    00196       case '5': BuildDocksClick_Dock(this); break;
    00197       case '6': BuildDocksClick_Buoy(this); break;
    00198       case '7': BuildDocksClick_River(this); break;
    00199       case 'B':
    00200       case '8': BuildDocksClick_Aqueduct(this); break;
    00201       default:  return ES_NOT_HANDLED;
    00202     }
    00203     return ES_HANDLED;
    00204   }
    00205
    00206   virtual void OnPlaceObject(Point pt, TileIndex tile)
    00207   {
    00208     _place_proc(tile);
    00209   }
    00210
    00211   virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
    00212   {
    00213     VpSelectTilesWithMethod(pt.x, pt.y, select_method);
    00214   }
    00215
    00216   virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
    00217   {
    00218     if (pt.x != -1) {
    00219       switch (select_proc) {
    00220         case DDSP_BUILD_BRIDGE:
    00221           if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
    00222           extern void CcBuildBridge(bool success, TileIndex tile, uint32 p1, uint32 p2);
    00223           DoCommandP(end_tile, start_tile, TRANSPORT_WATER << 15, CMD_BUILD_BRIDGE | CMD_MSG(STR_CAN_T_BUILD_AQUEDUCT_HERE), CcBuildBridge);
    00224
    00225         case DDSP_DEMOLISH_AREA:
    00226           GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
    00227           break;
    00228         case DDSP_CREATE_WATER:
    00229           DoCommandP(end_tile, start_tile, (_game_mode == GM_EDITOR ? _ctrl_pressed : 0), CMD_BUILD_CANAL | CMD_MSG(STR_CANT_BUILD_CANALS), CcBuildCanal);
    00230           break;
    00231         case DDSP_CREATE_RIVER:
    00232           DoCommandP(end_tile, start_tile, 2, CMD_BUILD_CANAL | CMD_MSG(STR_CANT_PLACE_RIVERS), CcBuildCanal);
    00233           break;
    00234
    00235         default: break;
    00236       }
    00237     }
    00238   }
    00239
    00240   virtual void OnPlaceObjectAbort()
    00241   {
    00242     this->RaiseButtons();
    00243
    00244     DeleteWindowById(WC_BUILD_STATION, 0);
    00245     DeleteWindowById(WC_BUILD_DEPOT, 0);
    00246     DeleteWindowById(WC_SELECT_STATION, 0);
    00247     DeleteWindowById(WC_BUILD_BRIDGE, 0);
    00248   }
    00249
    00250   virtual void OnPlacePresize(Point pt, TileIndex tile_from)
    00251   {
    00252     DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile_from, NULL));
    00253     TileIndex tile_to = (dir != INVALID_DIAGDIR ? TileAddByDiagDir(tile_from, ReverseDiagDir(dir)) : tile_from);
    00254
    00255     VpSetPresizeRange(tile_from, tile_to);
    00256   }
    00257 };
    00258
    00259 static const Widget _build_docks_toolb_widgets[] = {
    00260 {   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_DARK_GREEN,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},                  // DTW_CLOSEBOX
    00261 {    WWT_CAPTION,   RESIZE_NONE,  COLOUR_DARK_GREEN,    11,   147,     0,    13, STR_9801_WATERWAYS_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},        // DTW_CAPTION
    00262 {  WWT_STICKYBOX,   RESIZE_NONE,  COLOUR_DARK_GREEN,   148,   159,     0,    13, 0x0,                             STR_STICKY_BUTTON},                      // DTW_STICKY
    00263 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,     0,    21,    14,    35, SPR_IMG_BUILD_CANAL,             STR_BUILD_CANALS_TIP},                   // DTW_CANAL
    00264 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,    22,    43,    14,    35, SPR_IMG_BUILD_LOCK,              STR_BUILD_LOCKS_TIP},                    // DTW_LOCK
    00265
    00266 {      WWT_PANEL,   RESIZE_NONE,  COLOUR_DARK_GREEN,    44,    48,    14,    35, 0x0,                             STR_NULL},                               // DTW_SEPERATOR
    00267
    00268 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,    49,    70,    14,    35, SPR_IMG_DYNAMITE,                STR_018D_DEMOLISH_BUILDINGS_ETC},        // DTW_DEMOLISH
    00269 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,    71,    92,    14,    35, SPR_IMG_SHIP_DEPOT,              STR_981E_BUILD_SHIP_DEPOT_FOR_BUILDING}, // DTW_DEPOT
    00270 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,    93,   114,    14,    35, SPR_IMG_SHIP_DOCK,               STR_981D_BUILD_SHIP_DOCK},               // DTW_STATION
    00271 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,   115,   136,    14,    35, SPR_IMG_BOUY,                    STR_9834_POSITION_BUOY_WHICH_CAN},       // DTW_BUOY
    00272 {     WWT_EMPTY,    RESIZE_NONE,  COLOUR_DARK_GREEN,     0,     0,     0,     0, 0x0,                             STR_NULL},                               // DTW_RIVER
    00273 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,   137,   159,    14,    35, SPR_IMG_AQUEDUCT,                STR_BUILD_AQUEDUCT},                     // DTW_BUILD_AQUEDUCT
    00274 {   WIDGETS_END},
    00275 };
    00276
    00277 static const WindowDesc _build_docks_toolbar_desc(
    00278   WDP_ALIGN_TBR, 22, 160, 36, 160, 36,
    00279   WC_BUILD_TOOLBAR, WC_NONE,
    00280   WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON | WDF_CONSTRUCTION,
    00281   _build_docks_toolb_widgets
    00282 );
    00283
    00284 void ShowBuildDocksToolbar()
    00285 {
    00286   if (!IsValidCompanyID(_local_company)) return;
    00287
    00288   DeleteWindowByClass(WC_BUILD_TOOLBAR);
    00289   AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_toolbar_desc, TRANSPORT_WATER);
    00290 }
    00291
    00292 /* Widget definition for the build docks in scenario editor window */
    00293 static const Widget _build_docks_scen_toolb_widgets[] = {
    00294 {   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_DARK_GREEN,     0,    10,     0,    13, STR_00C5,                           STR_018B_CLOSE_WINDOW},           // DTW_CLOSEBOX
    00295 {    WWT_CAPTION,   RESIZE_NONE,  COLOUR_DARK_GREEN,    11,   102,     0,    13, STR_9801_WATERWAYS_CONSTRUCTION_SE, STR_018C_WINDOW_TITLE_DRAG_THIS}, // DTW_CAPTION
    00296 {  WWT_STICKYBOX,   RESIZE_NONE,  COLOUR_DARK_GREEN,   103,   114,     0,    13, 0x0,                                STR_STICKY_BUTTON},               // DTW_STICKY
    00297 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,     0,    21,    14,    35, SPR_IMG_BUILD_CANAL,                STR_CREATE_LAKE},                 // DTW_CANAL
    00298 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,    22,    43,    14,    35, SPR_IMG_BUILD_LOCK,                 STR_BUILD_LOCKS_TIP},             // DTW_LOCK
    00299
    00300 {      WWT_PANEL,   RESIZE_NONE,  COLOUR_DARK_GREEN,    44,    48,    14,    35, 0x0,                                STR_NULL},                        // DTW_SEPERATOR
    00301
    00302 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,    49,    70,    14,    35, SPR_IMG_DYNAMITE,                   STR_018D_DEMOLISH_BUILDINGS_ETC}, // DTW_DEMOLISH
    00303 {     WWT_EMPTY,    RESIZE_NONE,  COLOUR_DARK_GREEN,     0,     0,     0,     0, 0x0,                                STR_NULL},                        // DTW_DEPOT
    00304 {     WWT_EMPTY,    RESIZE_NONE,  COLOUR_DARK_GREEN,     0,     0,     0,     0, 0x0,                                STR_NULL},                        // DTW_STATION
    00305 {     WWT_EMPTY,    RESIZE_NONE,  COLOUR_DARK_GREEN,     0,     0,     0,     0, 0x0,                                STR_NULL},                        // DTW_BUOY
    00306 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,    71,    92,    14,    35, SPR_IMG_BUILD_RIVER,                STR_CREATE_RIVER},                // DTW_RIVER
    00307 {     WWT_IMGBTN,   RESIZE_NONE,  COLOUR_DARK_GREEN,    93,   114,    14,    35, SPR_IMG_AQUEDUCT,                   STR_BUILD_AQUEDUCT},              // DTW_BUILD_AQUEDUCT
    00308 {   WIDGETS_END},
    00309 };
    00310
    00311 /* Window definition for the build docks in scenario editor window */
    00312 static const WindowDesc _build_docks_scen_toolbar_desc(
    00313   WDP_AUTO, WDP_AUTO, 115, 36, 115, 36,
    00314   WC_SCEN_BUILD_TOOLBAR, WC_NONE,
    00315   WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON | WDF_CONSTRUCTION,
    00316   _build_docks_scen_toolb_widgets
    00317 );
    00318
    00319 void ShowBuildDocksScenToolbar()
    00320 {
    00321   AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_scen_toolbar_desc, TRANSPORT_WATER);
    00322 }
    00323
    00324 struct BuildDocksStationWindow : public PickerWindowBase {
    00325 private:
    00326   enum BuildDockStationWidgets {
    00327     BDSW_CLOSE,
    00328     BDSW_CAPTION,
    00329     BDSW_BACKGROUND,
    00330     BDSW_LT_OFF,
    00331     BDSW_LT_ON,
    00332     BDSW_INFO,
    00333   };
    00334
    00335 public:
    00336   BuildDocksStationWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
    00337   {
    00338     this->LowerWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF);
    00339     this->FindWindowPlacementAndResize(desc);
    00340   }
    00341
    00342   virtual ~BuildDocksStationWindow()
    00343   {
    00344     DeleteWindowById(WC_SELECT_STATION, 0);
    00345   }
    00346
    00347   virtual void OnPaint()
    00348   {
    00349     int rad = (_settings_game.station.modified_catchment) ? CA_DOCK : CA_UNMODIFIED;
    00350
    00351     this->DrawWidgets();
    00352
    00353     if (_settings_client.gui.station_show_coverage) {
    00354       SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
    00355     } else {
    00356       SetTileSelectSize(1, 1);
    00357     }
    00358
    00359     int text_end = DrawStationCoverageAreaText(4, 50, SCT_ALL, rad, false);
    00360     text_end = DrawStationCoverageAreaText(4, text_end + 4, SCT_ALL, rad, true) + 4;
    00361     if (text_end != this->widget[BDSW_BACKGROUND].bottom) {
    00362       this->SetDirty();
    00363       ResizeWindowForWidget(this, 2, 0, text_end - this->widget[BDSW_BACKGROUND].bottom);
    00364       this->SetDirty();
    00365     }
    00366   }
    00367
    00368   virtual void OnClick(Point pt, int widget)
    00369   {
    00370     switch (widget) {
    00371       case BDSW_LT_OFF:
    00372       case BDSW_LT_ON:
    00373         this->RaiseWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF);
    00374         _settings_client.gui.station_show_coverage = (widget != BDSW_LT_OFF);
    00375         this->LowerWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF);
    00376         SndPlayFx(SND_15_BEEP);
    00377         this->SetDirty();
    00378         break;
    00379     }
    00380   }
    00381
    00382   virtual void OnTick()
    00383   {
    00384     CheckRedrawStationCoverage(this);
    00385   }
    00386 };
    00387
    00388 static const Widget _build_dock_station_widgets[] = {
    00389 {   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_DARK_GREEN,     0,    10,     0,    13, STR_00C5,                         STR_018B_CLOSE_WINDOW},             // BDSW_CLOSE
    00390 {    WWT_CAPTION,   RESIZE_NONE,  COLOUR_DARK_GREEN,    11,   147,     0,    13, STR_3068_DOCK,                    STR_018C_WINDOW_TITLE_DRAG_THIS},   // BDSW_CAPTION
    00391 {      WWT_PANEL,   RESIZE_NONE,  COLOUR_DARK_GREEN,     0,   147,    14,    74, 0x0,                              STR_NULL},                          // BDSW_BACKGROUND
    00392 {    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,          14,    73,    30,    40, STR_02DB_OFF,                     STR_3065_DON_T_HIGHLIGHT_COVERAGE}, // BDSW_LT_OFF
    00393 {    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,          74,   133,    30,    40, STR_02DA_ON,                      STR_3064_HIGHLIGHT_COVERAGE_AREA},  // BDSW_LT_ON
    00394 {      WWT_LABEL,   RESIZE_NONE,  COLOUR_DARK_GREEN,     0,   147,    17,    30, STR_3066_COVERAGE_AREA_HIGHLIGHT, STR_NULL},                          // BDSW_INFO
    00395 {   WIDGETS_END},
    00396 };
    00397
    00398 static const WindowDesc _build_dock_station_desc(
    00399   WDP_AUTO, WDP_AUTO, 148, 75, 148, 75,
    00400   WC_BUILD_STATION, WC_BUILD_TOOLBAR,
    00401   WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_CONSTRUCTION,
    00402   _build_dock_station_widgets
    00403 );
    00404
    00405 static void ShowBuildDockStationPicker(Window *parent)
    00406 {
    00407   new BuildDocksStationWindow(&_build_dock_station_desc, parent);
    00408 }
    00409
    00410 struct BuildDocksDepotWindow : public PickerWindowBase {
    00411 private:
    00412   enum BuildDockDepotWidgets {
    00413     BDDW_CLOSE,
    00414     BDDW_CAPTION,
    00415     BDDW_BACKGROUND,
    00416     BDDW_X,
    00417     BDDW_Y,
    00418   };
    00419
    00420   static void UpdateDocksDirection()
    00421   {
    00422     if (_ship_depot_direction != AXIS_X) {
    00423       SetTileSelectSize(1, 2);
    00424     } else {
    00425       SetTileSelectSize(2, 1);
    00426     }
    00427   }
    00428
    00429 public:
    00430   BuildDocksDepotWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
    00431   {
    00432     this->LowerWidget(_ship_depot_direction + BDDW_X);
    00433     UpdateDocksDirection();
    00434     this->FindWindowPlacementAndResize(desc);
    00435   }
    00436
    00437   virtual void OnPaint()
    00438   {
    00439     this->DrawWidgets();
    00440
    00441     DrawShipDepotSprite(67, 35, 0);
    00442     DrawShipDepotSprite(35, 51, 1);
    00443     DrawShipDepotSprite(135, 35, 2);
    00444     DrawShipDepotSprite(167, 51, 3);
    00445   }
    00446
    00447   virtual void OnClick(Point pt, int widget)
    00448   {
    00449     switch (widget) {
    00450       case BDDW_X:
    00451       case BDDW_Y:
    00452         this->RaiseWidget(_ship_depot_direction + BDDW_X);
    00453         _ship_depot_direction = (widget == BDDW_X ? AXIS_X : AXIS_Y);
    00454         this->LowerWidget(_ship_depot_direction + BDDW_X);
    00455         SndPlayFx(SND_15_BEEP);
    00456         UpdateDocksDirection();
    00457         this->SetDirty();
    00458         break;
    00459     }
    00460   }
    00461 };
    00462
    00463 static const Widget _build_docks_depot_widgets[] = {
    00464 {   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_DARK_GREEN,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},                  // BDDW_CLOSE
    00465 {    WWT_CAPTION,   RESIZE_NONE,  COLOUR_DARK_GREEN,    11,   203,     0,    13, STR_3800_SHIP_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS},        // BDDW_CAPTION
    00466 {      WWT_PANEL,   RESIZE_NONE,  COLOUR_DARK_GREEN,     0,   203,    14,    85, 0x0,                             STR_NULL},                               // BDDW_BACKGROUND
    00467 {      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,           3,   100,    17,    82, 0x0,                             STR_3803_SELECT_SHIP_DEPOT_ORIENTATION}, // BDDW_X
    00468 {      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,         103,   200,    17,    82, 0x0,                             STR_3803_SELECT_SHIP_DEPOT_ORIENTATION}, // BDDW_Y
    00469 {   WIDGETS_END},
    00470 };
    00471
    00472 static const WindowDesc _build_docks_depot_desc(
    00473   WDP_AUTO, WDP_AUTO, 204, 86, 204, 86,
    00474   WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
    00475   WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_CONSTRUCTION,
    00476   _build_docks_depot_widgets
    00477 );
    00478
    00479
    00480 static void ShowBuildDocksDepotPicker(Window *parent)
    00481 {
    00482   new BuildDocksDepotWindow(&_build_docks_depot_desc, parent);
    00483 }
    00484
    00485
    00486 void InitializeDockGui()
    00487 {
    00488   _ship_depot_direction = AXIS_X;
    00489 }