2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file dock_gui.cpp GUI to create amazing water objects. */
|
2007-02-23 18:55:07 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "stdafx.h"
|
2005-06-02 19:30:21 +00:00
|
|
|
#include "openttd.h"
|
2007-12-19 23:26:02 +00:00
|
|
|
#include "tile_map.h"
|
2008-03-31 00:17:39 +00:00
|
|
|
#include "station_type.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "gui.h"
|
2008-01-06 18:56:43 +00:00
|
|
|
#include "terraform_gui.h"
|
2007-12-19 20:45:46 +00:00
|
|
|
#include "window_gui.h"
|
|
|
|
#include "station_gui.h"
|
2007-12-21 21:50:46 +00:00
|
|
|
#include "command_func.h"
|
2008-01-13 14:37:30 +00:00
|
|
|
#include "settings_type.h"
|
2007-11-24 08:45:04 +00:00
|
|
|
#include "water.h"
|
2007-12-25 11:26:07 +00:00
|
|
|
#include "window_func.h"
|
2007-12-27 13:35:39 +00:00
|
|
|
#include "vehicle_func.h"
|
2007-12-29 09:24:26 +00:00
|
|
|
#include "sound_func.h"
|
2008-01-09 09:45:45 +00:00
|
|
|
#include "viewport_func.h"
|
|
|
|
#include "gfx_func.h"
|
2008-01-12 14:10:35 +00:00
|
|
|
#include "player_func.h"
|
2008-01-25 15:47:58 +00:00
|
|
|
#include "slope_func.h"
|
2008-05-07 13:10:15 +00:00
|
|
|
#include "tilehighlight_func.h"
|
2008-07-18 16:40:29 +00:00
|
|
|
#include "player_base.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-01-13 01:21:35 +00:00
|
|
|
#include "table/sprites.h"
|
|
|
|
#include "table/strings.h"
|
|
|
|
|
2008-05-24 11:19:30 +00:00
|
|
|
static void ShowBuildDockStationPicker(Window *parent);
|
|
|
|
static void ShowBuildDocksDepotPicker(Window *parent);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-03-08 06:55:33 +00:00
|
|
|
static Axis _ship_depot_direction;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
void CcBuildDocks(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
if (success) {
|
2004-12-04 09:26:39 +00:00
|
|
|
SndPlayTileFx(SND_02_SPLAT, tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
ResetObjectToPlace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
void CcBuildCanal(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2004-12-04 09:26:39 +00:00
|
|
|
if (success) SndPlayTileFx(SND_02_SPLAT, tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void PlaceDocks_Dock(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2007-09-04 11:58:27 +00:00
|
|
|
DoCommandP(tile, _ctrl_pressed, 0, CcBuildDocks, CMD_BUILD_DOCK | CMD_MSG(STR_9802_CAN_T_BUILD_DOCK_HERE));
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void PlaceDocks_Depot(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2007-09-04 11:58:27 +00:00
|
|
|
DoCommandP(tile, _ship_depot_direction, 0, CcBuildDocks, CMD_BUILD_SHIP_DEPOT | CMD_MSG(STR_3802_CAN_T_BUILD_SHIP_DEPOT));
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void PlaceDocks_Buoy(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2007-09-04 11:58:27 +00:00
|
|
|
DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_BUOY | CMD_MSG(STR_9835_CAN_T_POSITION_BUOY_HERE));
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void PlaceDocks_BuildCanal(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2008-06-25 17:30:16 +00:00
|
|
|
VpStartPlaceSizing(tile, (_game_mode == GM_EDITOR) ? VPM_X_AND_Y : VPM_X_OR_Y, DDSP_CREATE_WATER);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void PlaceDocks_BuildLock(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2007-09-04 11:58:27 +00:00
|
|
|
DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_LOCK | CMD_MSG(STR_CANT_BUILD_LOCKS));
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2008-06-25 17:30:16 +00:00
|
|
|
static void PlaceDocks_BuildRiver(TileIndex tile)
|
|
|
|
{
|
|
|
|
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CREATE_RIVER);
|
|
|
|
}
|
|
|
|
|
2008-06-11 17:35:55 +00:00
|
|
|
static void PlaceDocks_Aqueduct(TileIndex tile)
|
2008-06-11 13:54:01 +00:00
|
|
|
{
|
|
|
|
VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_BUILD_BRIDGE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-22 20:37:14 +00:00
|
|
|
/** Enum referring to the widgets of the build dock toolbar */
|
|
|
|
enum DockToolbarWidgets {
|
|
|
|
DTW_BEGIN = 0, ///< Start of toolbar widgets
|
|
|
|
DTW_CLOSEBOX = DTW_BEGIN, ///< Close window button
|
|
|
|
DTW_CAPTION, ///< Window caption
|
|
|
|
DTW_STICKY, ///< Sticky window button
|
|
|
|
DTW_BUTTONS_BEGIN, ///< Begin of clickable buttons (except seperating panel)
|
|
|
|
DTW_CANAL = DTW_BUTTONS_BEGIN, ///< Build canal button
|
|
|
|
DTW_LOCK, ///< Build lock button
|
|
|
|
DTW_SEPERATOR, ///< Seperating panel between lock and demolish
|
|
|
|
DTW_DEMOLISH, ///< Demolish aka dynamite button
|
|
|
|
DTW_DEPOT, ///< Build depot button
|
|
|
|
DTW_STATION, ///< Build station button
|
|
|
|
DTW_BUOY, ///< Build buoy button
|
2008-06-25 17:30:16 +00:00
|
|
|
DTW_RIVER, ///< Build river button (in scenario editor)
|
2008-06-11 17:35:55 +00:00
|
|
|
DTW_BUILD_AQUEDUCT, ///< Build aqueduct button
|
2008-05-22 20:37:14 +00:00
|
|
|
DTW_END, ///< End of toolbar widgets
|
2006-11-22 16:08:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-12-12 17:42:04 +00:00
|
|
|
static void BuildDocksClick_Canal(Window *w)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2008-06-25 17:30:16 +00:00
|
|
|
|
2007-11-15 18:28:00 +00:00
|
|
|
HandlePlacePushButton(w, DTW_CANAL, SPR_CURSOR_CANAL, VHM_RECT, PlaceDocks_BuildCanal);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2004-12-12 17:42:04 +00:00
|
|
|
static void BuildDocksClick_Lock(Window *w)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2007-11-15 18:28:00 +00:00
|
|
|
HandlePlacePushButton(w, DTW_LOCK, SPR_CURSOR_LOCK, VHM_RECT, PlaceDocks_BuildLock);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void BuildDocksClick_Demolish(Window *w)
|
|
|
|
{
|
2008-05-07 00:04:40 +00:00
|
|
|
HandlePlacePushButton(w, DTW_DEMOLISH, ANIMCURSOR_DEMOLISH, VHM_RECT, PlaceProc_DemolishArea);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2004-12-12 17:42:04 +00:00
|
|
|
static void BuildDocksClick_Depot(Window *w)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2007-06-27 14:15:48 +00:00
|
|
|
if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return;
|
2008-05-24 11:19:30 +00:00
|
|
|
if (HandlePlacePushButton(w, DTW_DEPOT, SPR_CURSOR_SHIP_DEPOT, VHM_RECT, PlaceDocks_Depot)) ShowBuildDocksDepotPicker(w);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2004-12-12 17:42:04 +00:00
|
|
|
static void BuildDocksClick_Dock(Window *w)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2007-06-27 14:15:48 +00:00
|
|
|
if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return;
|
2008-05-24 11:19:30 +00:00
|
|
|
if (HandlePlacePushButton(w, DTW_STATION, SPR_CURSOR_DOCK, VHM_SPECIAL, PlaceDocks_Dock)) ShowBuildDockStationPicker(w);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2004-12-12 17:42:04 +00:00
|
|
|
static void BuildDocksClick_Buoy(Window *w)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2007-06-27 14:15:48 +00:00
|
|
|
if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return;
|
2007-11-15 18:28:00 +00:00
|
|
|
HandlePlacePushButton(w, DTW_BUOY, SPR_CURSOR_BOUY, VHM_RECT, PlaceDocks_Buoy);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2008-06-25 17:30:16 +00:00
|
|
|
static void BuildDocksClick_River(Window *w)
|
|
|
|
{
|
|
|
|
if (_game_mode != GM_EDITOR) return;
|
|
|
|
HandlePlacePushButton(w, DTW_RIVER, SPR_CURSOR_RIVER, VHM_RECT, PlaceDocks_BuildRiver);
|
|
|
|
}
|
|
|
|
|
2008-06-11 17:35:55 +00:00
|
|
|
static void BuildDocksClick_Aqueduct(Window *w)
|
2008-06-11 13:54:01 +00:00
|
|
|
{
|
2008-06-12 16:30:41 +00:00
|
|
|
HandlePlacePushButton(w, DTW_BUILD_AQUEDUCT, SPR_CURSOR_AQUEDUCT, VHM_RECT, PlaceDocks_Aqueduct);
|
2008-06-11 13:54:01 +00:00
|
|
|
}
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
typedef void OnButtonClick(Window *w);
|
|
|
|
static OnButtonClick * const _build_docks_button_proc[] = {
|
|
|
|
BuildDocksClick_Canal,
|
|
|
|
BuildDocksClick_Lock,
|
2005-10-22 06:39:32 +00:00
|
|
|
NULL,
|
2004-12-12 17:42:04 +00:00
|
|
|
BuildDocksClick_Demolish,
|
|
|
|
BuildDocksClick_Depot,
|
|
|
|
BuildDocksClick_Dock,
|
2008-06-11 13:54:01 +00:00
|
|
|
BuildDocksClick_Buoy,
|
2008-06-25 17:30:16 +00:00
|
|
|
BuildDocksClick_River,
|
2008-06-11 17:35:55 +00:00
|
|
|
BuildDocksClick_Aqueduct
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
2008-05-18 21:34:35 +00:00
|
|
|
struct BuildDocksToolbarWindow : Window {
|
|
|
|
BuildDocksToolbarWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
|
|
|
|
{
|
|
|
|
this->FindWindowPlacementAndResize(desc);
|
2008-05-29 15:13:28 +00:00
|
|
|
if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
|
2008-05-18 21:34:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
~BuildDocksToolbarWindow()
|
|
|
|
{
|
2008-05-29 15:13:28 +00:00
|
|
|
if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
|
2008-05-18 21:34:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void OnPaint()
|
|
|
|
{
|
2008-05-22 20:37:14 +00:00
|
|
|
this->SetWidgetsDisabledState(!CanBuildVehicleInfrastructure(VEH_SHIP), DTW_DEPOT, DTW_STATION, DTW_BUOY, WIDGET_LIST_END);
|
2008-05-18 21:34:35 +00:00
|
|
|
this->DrawWidgets();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void OnClick(Point pt, int widget)
|
|
|
|
{
|
2008-05-22 20:37:14 +00:00
|
|
|
if (widget >= DTW_BUTTONS_BEGIN && widget != DTW_SEPERATOR) _build_docks_button_proc[widget - DTW_BUTTONS_BEGIN](this);
|
2008-05-18 21:34:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
|
|
|
{
|
|
|
|
switch (keycode) {
|
|
|
|
case '1': BuildDocksClick_Canal(this); break;
|
|
|
|
case '2': BuildDocksClick_Lock(this); break;
|
|
|
|
case '3': BuildDocksClick_Demolish(this); break;
|
|
|
|
case '4': BuildDocksClick_Depot(this); break;
|
|
|
|
case '5': BuildDocksClick_Dock(this); break;
|
|
|
|
case '6': BuildDocksClick_Buoy(this); break;
|
2008-06-25 17:30:16 +00:00
|
|
|
case '7': BuildDocksClick_River(this); break;
|
2008-06-11 21:37:36 +00:00
|
|
|
case 'B':
|
2008-06-25 17:30:16 +00:00
|
|
|
case '8': BuildDocksClick_Aqueduct(this); break;
|
2008-05-18 21:34:35 +00:00
|
|
|
default: return ES_NOT_HANDLED;
|
2005-01-08 09:40:22 +00:00
|
|
|
}
|
2008-05-18 21:34:35 +00:00
|
|
|
return ES_HANDLED;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-18 21:34:35 +00:00
|
|
|
virtual void OnPlaceObject(Point pt, TileIndex tile)
|
|
|
|
{
|
|
|
|
_place_proc(tile);
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-18 21:34:35 +00:00
|
|
|
virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
|
|
|
|
{
|
|
|
|
VpSelectTilesWithMethod(pt.x, pt.y, select_method);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2008-05-18 21:34:35 +00:00
|
|
|
virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
|
|
|
|
{
|
|
|
|
if (pt.x != -1) {
|
|
|
|
switch (select_proc) {
|
2008-06-11 13:54:01 +00:00
|
|
|
case DDSP_BUILD_BRIDGE:
|
|
|
|
ResetObjectToPlace();
|
|
|
|
extern void CcBuildBridge(bool success, TileIndex tile, uint32 p1, uint32 p2);
|
2008-06-11 17:35:55 +00:00
|
|
|
DoCommandP(end_tile, start_tile, TRANSPORT_WATER << 15, CcBuildBridge, CMD_BUILD_BRIDGE | CMD_MSG(STR_CAN_T_BUILD_AQUEDUCT_HERE));
|
2008-06-11 13:54:01 +00:00
|
|
|
|
2007-05-23 13:52:10 +00:00
|
|
|
case DDSP_DEMOLISH_AREA:
|
2008-05-18 21:34:35 +00:00
|
|
|
GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
|
2007-05-23 12:45:56 +00:00
|
|
|
break;
|
2007-05-23 13:52:10 +00:00
|
|
|
case DDSP_CREATE_WATER:
|
2008-06-25 17:30:16 +00:00
|
|
|
DoCommandP(end_tile, start_tile, (_game_mode == GM_EDITOR ? _ctrl_pressed : 0), CcBuildCanal, CMD_BUILD_CANAL | CMD_MSG(STR_CANT_BUILD_CANALS));
|
|
|
|
break;
|
|
|
|
case DDSP_CREATE_RIVER:
|
|
|
|
DoCommandP(end_tile, start_tile, 2, CcBuildCanal, CMD_BUILD_CANAL | CMD_MSG(STR_CANT_PLACE_RIVERS));
|
2007-05-23 12:45:56 +00:00
|
|
|
break;
|
2008-05-18 21:34:35 +00:00
|
|
|
|
2007-05-23 12:45:56 +00:00
|
|
|
default: break;
|
2005-10-23 13:04:44 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2008-05-18 21:34:35 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-18 21:34:35 +00:00
|
|
|
virtual void OnPlaceObjectAbort()
|
|
|
|
{
|
|
|
|
this->RaiseButtons();
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-15 14:41:56 +00:00
|
|
|
delete FindWindowById(WC_BUILD_STATION, 0);
|
|
|
|
delete FindWindowById(WC_BUILD_DEPOT, 0);
|
2008-05-18 21:34:35 +00:00
|
|
|
}
|
2008-01-25 15:47:58 +00:00
|
|
|
|
2008-05-18 21:34:35 +00:00
|
|
|
virtual void OnPlacePresize(Point pt, TileIndex tile_from)
|
|
|
|
{
|
2008-01-25 15:47:58 +00:00
|
|
|
DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile_from, NULL));
|
2008-05-18 21:34:35 +00:00
|
|
|
TileIndex tile_to = (dir != INVALID_DIAGDIR ? TileAddByDiagDir(tile_from, ReverseDiagDir(dir)) : tile_from);
|
2008-01-25 15:47:58 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
VpSetPresizeRange(tile_from, tile_to);
|
|
|
|
}
|
2008-05-18 21:34:35 +00:00
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
static const Widget _build_docks_toolb_widgets[] = {
|
2008-07-31 02:36:01 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_DARK_GREEN, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // DTW_CLOSEBOX
|
|
|
|
{ WWT_CAPTION, RESIZE_NONE, COLOUR_DARK_GREEN, 11, 147, 0, 13, STR_9801_WATERWAYS_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // DTW_CAPTION
|
|
|
|
{ WWT_STICKYBOX, RESIZE_NONE, COLOUR_DARK_GREEN, 148, 159, 0, 13, 0x0, STR_STICKY_BUTTON}, // DTW_STICKY
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, COLOUR_DARK_GREEN, 0, 21, 14, 35, SPR_IMG_BUILD_CANAL, STR_BUILD_CANALS_TIP}, // DTW_CANAL
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, COLOUR_DARK_GREEN, 22, 43, 14, 35, SPR_IMG_BUILD_LOCK, STR_BUILD_LOCKS_TIP}, // DTW_LOCK
|
|
|
|
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, COLOUR_DARK_GREEN, 44, 48, 14, 35, 0x0, STR_NULL}, // DTW_SEPERATOR
|
|
|
|
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, COLOUR_DARK_GREEN, 49, 70, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC}, // DTW_DEMOLISH
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, COLOUR_DARK_GREEN, 71, 92, 14, 35, SPR_IMG_SHIP_DEPOT, STR_981E_BUILD_SHIP_DEPOT_FOR_BUILDING}, // DTW_DEPOT
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, COLOUR_DARK_GREEN, 93, 114, 14, 35, SPR_IMG_SHIP_DOCK, STR_981D_BUILD_SHIP_DOCK}, // DTW_STATION
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, COLOUR_DARK_GREEN, 115, 136, 14, 35, SPR_IMG_BOUY, STR_9834_POSITION_BUOY_WHICH_CAN}, // DTW_BUOY
|
|
|
|
{ WWT_EMPTY, RESIZE_NONE, COLOUR_DARK_GREEN, 0, 0, 0, 0, 0x0, STR_NULL}, // DTW_RIVER
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, COLOUR_DARK_GREEN, 137, 159, 14, 35, SPR_IMG_AQUEDUCT, STR_BUILD_AQUEDUCT}, // DTW_BUILD_AQUEDUCT
|
2004-09-07 21:48:09 +00:00
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const WindowDesc _build_docks_toolbar_desc = {
|
2008-06-25 17:30:16 +00:00
|
|
|
WDP_ALIGN_TBR, 22, 160, 36, 160, 36,
|
2007-02-01 15:49:12 +00:00
|
|
|
WC_BUILD_TOOLBAR, WC_NONE,
|
2004-12-22 00:18:40 +00:00
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
|
2004-08-09 17:04:08 +00:00
|
|
|
_build_docks_toolb_widgets,
|
|
|
|
};
|
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void ShowBuildDocksToolbar()
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2008-07-17 20:13:01 +00:00
|
|
|
if (!IsValidPlayerID(_current_player)) return;
|
2006-10-31 21:15:56 +00:00
|
|
|
|
2008-05-04 09:39:16 +00:00
|
|
|
DeleteWindowByClass(WC_BUILD_TOOLBAR);
|
2008-05-18 21:34:35 +00:00
|
|
|
AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_toolbar_desc, TRANSPORT_WATER);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2008-06-25 17:30:16 +00:00
|
|
|
/* Widget definition for the build docks in scenario editor window */
|
|
|
|
static const Widget _build_docks_scen_toolb_widgets[] = {
|
2008-07-31 02:36:01 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_DARK_GREEN, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // DTW_CLOSEBOX
|
|
|
|
{ WWT_CAPTION, RESIZE_NONE, COLOUR_DARK_GREEN, 11, 102, 0, 13, STR_9801_WATERWAYS_CONSTRUCTION_SE, STR_018C_WINDOW_TITLE_DRAG_THIS}, // DTW_CAPTION
|
|
|
|
{ WWT_STICKYBOX, RESIZE_NONE, COLOUR_DARK_GREEN, 103, 114, 0, 13, 0x0, STR_STICKY_BUTTON}, // DTW_STICKY
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, COLOUR_DARK_GREEN, 0, 21, 14, 35, SPR_IMG_BUILD_CANAL, STR_CREATE_LAKE}, // DTW_CANAL
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, COLOUR_DARK_GREEN, 22, 43, 14, 35, SPR_IMG_BUILD_LOCK, STR_BUILD_LOCKS_TIP}, // DTW_LOCK
|
|
|
|
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, COLOUR_DARK_GREEN, 44, 48, 14, 35, 0x0, STR_NULL}, // DTW_SEPERATOR
|
|
|
|
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, COLOUR_DARK_GREEN, 49, 70, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC}, // DTW_DEMOLISH
|
|
|
|
{ WWT_EMPTY, RESIZE_NONE, COLOUR_DARK_GREEN, 0, 0, 0, 0, 0x0, STR_NULL}, // DTW_DEPOT
|
|
|
|
{ WWT_EMPTY, RESIZE_NONE, COLOUR_DARK_GREEN, 0, 0, 0, 0, 0x0, STR_NULL}, // DTW_STATION
|
|
|
|
{ WWT_EMPTY, RESIZE_NONE, COLOUR_DARK_GREEN, 0, 0, 0, 0, 0x0, STR_NULL}, // DTW_BUOY
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, COLOUR_DARK_GREEN, 71, 92, 14, 35, SPR_IMG_BUILD_RIVER, STR_CREATE_RIVER}, // DTW_RIVER
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, COLOUR_DARK_GREEN, 93, 114, 14, 35, SPR_IMG_AQUEDUCT, STR_BUILD_AQUEDUCT}, // DTW_BUILD_AQUEDUCT
|
2008-06-25 17:30:16 +00:00
|
|
|
{ WIDGETS_END},
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Window definition for the build docks in scenario editor window */
|
|
|
|
static const WindowDesc _build_docks_scen_toolbar_desc = {
|
|
|
|
WDP_AUTO, WDP_AUTO, 115, 36, 115, 36,
|
|
|
|
WC_SCEN_BUILD_TOOLBAR, WC_NONE,
|
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
|
|
|
|
_build_docks_scen_toolb_widgets,
|
|
|
|
};
|
|
|
|
|
|
|
|
void ShowBuildDocksScenToolbar()
|
|
|
|
{
|
|
|
|
AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_scen_toolbar_desc, TRANSPORT_WATER);
|
|
|
|
}
|
|
|
|
|
2008-05-17 20:49:45 +00:00
|
|
|
struct BuildDocksStationWindow : public PickerWindowBase {
|
|
|
|
private:
|
|
|
|
enum BuildDockStationWidgets {
|
|
|
|
BDSW_CLOSE,
|
|
|
|
BDSW_CAPTION,
|
|
|
|
BDSW_BACKGROUND,
|
|
|
|
BDSW_LT_OFF,
|
|
|
|
BDSW_LT_ON,
|
|
|
|
BDSW_INFO,
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
2008-05-24 11:19:30 +00:00
|
|
|
BuildDocksStationWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
|
2008-05-17 20:49:45 +00:00
|
|
|
{
|
|
|
|
this->LowerWidget(_station_show_coverage + BDSW_LT_OFF);
|
|
|
|
this->FindWindowPlacementAndResize(desc);
|
|
|
|
}
|
2006-10-03 20:16:20 +00:00
|
|
|
|
2008-05-17 20:49:45 +00:00
|
|
|
virtual void OnPaint()
|
|
|
|
{
|
2008-05-29 15:13:28 +00:00
|
|
|
int rad = (_settings_game.station.modified_catchment) ? CA_DOCK : CA_UNMODIFIED;
|
2005-11-14 19:48:04 +00:00
|
|
|
|
2008-05-17 20:49:45 +00:00
|
|
|
this->DrawWidgets();
|
2005-11-13 14:54:09 +00:00
|
|
|
|
2007-06-08 18:15:11 +00:00
|
|
|
if (_station_show_coverage) {
|
|
|
|
SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
|
|
|
|
} else {
|
|
|
|
SetTileSelectSize(1, 1);
|
|
|
|
}
|
2004-12-19 09:31:35 +00:00
|
|
|
|
2008-04-06 22:32:20 +00:00
|
|
|
int text_end = DrawStationCoverageAreaText(4, 50, SCT_ALL, rad, false);
|
|
|
|
text_end = DrawStationCoverageAreaText(4, text_end + 4, SCT_ALL, rad, true) + 4;
|
2008-05-17 20:49:45 +00:00
|
|
|
if (text_end != this->widget[BDSW_BACKGROUND].bottom) {
|
|
|
|
this->SetDirty();
|
|
|
|
ResizeWindowForWidget(this, 2, 0, text_end - this->widget[BDSW_BACKGROUND].bottom);
|
|
|
|
this->SetDirty();
|
2008-01-27 11:01:10 +00:00
|
|
|
}
|
2005-11-14 19:48:04 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-17 20:49:45 +00:00
|
|
|
virtual void OnClick(Point pt, int widget)
|
|
|
|
{
|
|
|
|
switch (widget) {
|
|
|
|
case BDSW_LT_OFF:
|
|
|
|
case BDSW_LT_ON:
|
|
|
|
this->RaiseWidget(_station_show_coverage + BDSW_LT_OFF);
|
|
|
|
_station_show_coverage = (widget != BDSW_LT_OFF);
|
|
|
|
this->LowerWidget(_station_show_coverage + BDSW_LT_OFF);
|
2005-11-14 19:48:04 +00:00
|
|
|
SndPlayFx(SND_15_BEEP);
|
2008-05-17 20:49:45 +00:00
|
|
|
this->SetDirty();
|
2005-11-14 19:48:04 +00:00
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2008-05-17 20:49:45 +00:00
|
|
|
}
|
2005-01-20 08:36:15 +00:00
|
|
|
|
2008-05-17 20:49:45 +00:00
|
|
|
virtual void OnTick()
|
|
|
|
{
|
|
|
|
CheckRedrawStationCoverage(this);
|
2004-09-10 19:02:27 +00:00
|
|
|
}
|
2008-05-17 20:49:45 +00:00
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
static const Widget _build_dock_station_widgets[] = {
|
2008-07-31 02:36:01 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_DARK_GREEN, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // BDSW_CLOSE
|
|
|
|
{ WWT_CAPTION, RESIZE_NONE, COLOUR_DARK_GREEN, 11, 147, 0, 13, STR_3068_DOCK, STR_018C_WINDOW_TITLE_DRAG_THIS}, // BDSW_CAPTION
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, COLOUR_DARK_GREEN, 0, 147, 14, 74, 0x0, STR_NULL}, // BDSW_BACKGROUND
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 14, 73, 30, 40, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE}, // BDSW_LT_OFF
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 74, 133, 30, 40, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA}, // BDSW_LT_ON
|
|
|
|
{ WWT_LABEL, RESIZE_NONE, COLOUR_DARK_GREEN, 0, 147, 17, 30, STR_3066_COVERAGE_AREA_HIGHLIGHT, STR_NULL}, // BDSW_INFO
|
2004-09-07 21:48:09 +00:00
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const WindowDesc _build_dock_station_desc = {
|
2007-07-27 12:49:04 +00:00
|
|
|
WDP_AUTO, WDP_AUTO, 148, 75, 148, 75,
|
2006-11-10 19:24:14 +00:00
|
|
|
WC_BUILD_STATION, WC_BUILD_TOOLBAR,
|
2004-08-09 17:04:08 +00:00
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
|
|
|
|
_build_dock_station_widgets,
|
|
|
|
};
|
|
|
|
|
2008-05-24 11:19:30 +00:00
|
|
|
static void ShowBuildDockStationPicker(Window *parent)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2008-05-24 11:19:30 +00:00
|
|
|
new BuildDocksStationWindow(&_build_dock_station_desc, parent);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2008-05-17 20:49:45 +00:00
|
|
|
struct BuildDocksDepotWindow : public PickerWindowBase {
|
|
|
|
private:
|
|
|
|
enum BuildDockDepotWidgets {
|
|
|
|
BDDW_CLOSE,
|
|
|
|
BDDW_CAPTION,
|
|
|
|
BDDW_BACKGROUND,
|
|
|
|
BDDW_X,
|
|
|
|
BDDW_Y,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void UpdateDocksDirection()
|
|
|
|
{
|
|
|
|
if (_ship_depot_direction != AXIS_X) {
|
|
|
|
SetTileSelectSize(1, 2);
|
|
|
|
} else {
|
|
|
|
SetTileSelectSize(2, 1);
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2008-05-17 20:49:45 +00:00
|
|
|
public:
|
2008-05-24 11:19:30 +00:00
|
|
|
BuildDocksDepotWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
|
2008-05-17 20:49:45 +00:00
|
|
|
{
|
|
|
|
this->LowerWidget(_ship_depot_direction + BDDW_X);
|
|
|
|
UpdateDocksDirection();
|
|
|
|
this->FindWindowPlacementAndResize(desc);
|
|
|
|
}
|
2006-10-03 20:16:20 +00:00
|
|
|
|
2008-05-17 20:49:45 +00:00
|
|
|
virtual void OnPaint()
|
|
|
|
{
|
|
|
|
this->DrawWidgets();
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
DrawShipDepotSprite(67, 35, 0);
|
|
|
|
DrawShipDepotSprite(35, 51, 1);
|
|
|
|
DrawShipDepotSprite(135, 35, 2);
|
|
|
|
DrawShipDepotSprite(167, 51, 3);
|
2008-05-17 20:49:45 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-17 20:49:45 +00:00
|
|
|
virtual void OnClick(Point pt, int widget)
|
|
|
|
{
|
|
|
|
switch (widget) {
|
|
|
|
case BDDW_X:
|
|
|
|
case BDDW_Y:
|
|
|
|
this->RaiseWidget(_ship_depot_direction + BDDW_X);
|
|
|
|
_ship_depot_direction = (widget == BDDW_X ? AXIS_X : AXIS_Y);
|
|
|
|
this->LowerWidget(_ship_depot_direction + BDDW_X);
|
|
|
|
SndPlayFx(SND_15_BEEP);
|
|
|
|
UpdateDocksDirection();
|
|
|
|
this->SetDirty();
|
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
2008-05-17 20:49:45 +00:00
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
static const Widget _build_docks_depot_widgets[] = {
|
2008-07-31 02:36:01 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_DARK_GREEN, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // BDDW_CLOSE
|
|
|
|
{ WWT_CAPTION, RESIZE_NONE, COLOUR_DARK_GREEN, 11, 203, 0, 13, STR_3800_SHIP_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // BDDW_CAPTION
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, COLOUR_DARK_GREEN, 0, 203, 14, 85, 0x0, STR_NULL}, // BDDW_BACKGROUND
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 3, 100, 17, 82, 0x0, STR_3803_SELECT_SHIP_DEPOT_ORIENTATION}, // BDDW_X
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 103, 200, 17, 82, 0x0, STR_3803_SELECT_SHIP_DEPOT_ORIENTATION}, // BDDW_Y
|
2004-09-07 21:48:09 +00:00
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const WindowDesc _build_docks_depot_desc = {
|
2007-07-27 12:49:04 +00:00
|
|
|
WDP_AUTO, WDP_AUTO, 204, 86, 204, 86,
|
2006-11-10 19:24:14 +00:00
|
|
|
WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
|
2004-08-09 17:04:08 +00:00
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
|
|
|
|
_build_docks_depot_widgets,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-05-24 11:19:30 +00:00
|
|
|
static void ShowBuildDocksDepotPicker(Window *parent)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2008-05-24 11:19:30 +00:00
|
|
|
new BuildDocksDepotWindow(&_build_docks_depot_desc, parent);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void InitializeDockGui()
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2006-03-08 06:55:33 +00:00
|
|
|
_ship_depot_direction = AXIS_X;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|