author | truebrain |
Thu, 12 Jun 2008 21:18:09 +0000 | |
branch | noai |
changeset 10944 | 588393239ac6 |
parent 10920 | e33442a2b239 |
child 10955 | 56b381e5253f |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
9869
diff
changeset
|
3 |
/** @file dock_gui.cpp GUI to create amazing water objects. */ |
6451
7baba06b4b85
(svn r8862) -Cleanup: doxygen changes, again. Mostly @files missing tags and a few comments style.
belugas
parents:
6144
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1632
diff
changeset
|
6 |
#include "openttd.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
7 |
#include "tile_map.h" |
9837
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9732
diff
changeset
|
8 |
#include "station_type.h" |
0 | 9 |
#include "gui.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
10 |
#include "terraform_gui.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
11 |
#include "window_gui.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
12 |
#include "station_gui.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
13 |
#include "command_func.h" |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
14 |
#include "settings_type.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
15 |
#include "water.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
16 |
#include "window_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
17 |
#include "vehicle_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
18 |
#include "sound_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
19 |
#include "viewport_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
20 |
#include "gfx_func.h" |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
21 |
#include "player_func.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
22 |
#include "slope_func.h" |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
9869
diff
changeset
|
23 |
#include "tilehighlight_func.h" |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
24 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
25 |
#include "table/sprites.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
26 |
#include "table/strings.h" |
0 | 27 |
|
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
28 |
static void ShowBuildDockStationPicker(Window *parent); |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
29 |
static void ShowBuildDocksDepotPicker(Window *parent); |
0 | 30 |
|
3157
40de8616c04c
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
2952
diff
changeset
|
31 |
static Axis _ship_depot_direction; |
0 | 32 |
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
33 |
void CcBuildDocks(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 34 |
{ |
35 |
if (success) { |
|
541 | 36 |
SndPlayTileFx(SND_02_SPLAT, tile); |
0 | 37 |
ResetObjectToPlace(); |
38 |
} |
|
39 |
} |
|
40 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
41 |
void CcBuildCanal(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 42 |
{ |
541 | 43 |
if (success) SndPlayTileFx(SND_02_SPLAT, tile); |
0 | 44 |
} |
45 |
||
46 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
47 |
static void PlaceDocks_Dock(TileIndex tile) |
0 | 48 |
{ |
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9694
diff
changeset
|
49 |
DoCommandP(tile, _ctrl_pressed, 0, CcBuildDocks, CMD_BUILD_DOCK | CMD_MSG(STR_9802_CAN_T_BUILD_DOCK_HERE)); |
0 | 50 |
} |
51 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
52 |
static void PlaceDocks_Depot(TileIndex tile) |
0 | 53 |
{ |
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9694
diff
changeset
|
54 |
DoCommandP(tile, _ship_depot_direction, 0, CcBuildDocks, CMD_BUILD_SHIP_DEPOT | CMD_MSG(STR_3802_CAN_T_BUILD_SHIP_DEPOT)); |
0 | 55 |
} |
56 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
57 |
static void PlaceDocks_Buoy(TileIndex tile) |
0 | 58 |
{ |
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9694
diff
changeset
|
59 |
DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_BUOY | CMD_MSG(STR_9835_CAN_T_POSITION_BUOY_HERE)); |
0 | 60 |
} |
61 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
62 |
static void PlaceDocks_BuildCanal(TileIndex tile) |
0 | 63 |
{ |
9624 | 64 |
VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_CREATE_WATER); |
0 | 65 |
} |
66 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
67 |
static void PlaceDocks_BuildLock(TileIndex tile) |
0 | 68 |
{ |
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9694
diff
changeset
|
69 |
DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_LOCK | CMD_MSG(STR_CANT_BUILD_LOCKS)); |
0 | 70 |
} |
71 |
||
10920 | 72 |
static void PlaceDocks_Bridge(TileIndex tile) |
73 |
{ |
|
74 |
VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_BUILD_BRIDGE); |
|
75 |
} |
|
76 |
||
77 |
||
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
78 |
/** Enum referring to the widgets of the build dock toolbar */ |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
79 |
enum DockToolbarWidgets { |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
80 |
DTW_BEGIN = 0, ///< Start of toolbar widgets |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
81 |
DTW_CLOSEBOX = DTW_BEGIN, ///< Close window button |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
82 |
DTW_CAPTION, ///< Window caption |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
83 |
DTW_STICKY, ///< Sticky window button |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
84 |
DTW_BUTTONS_BEGIN, ///< Begin of clickable buttons (except seperating panel) |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
85 |
DTW_CANAL = DTW_BUTTONS_BEGIN, ///< Build canal button |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
86 |
DTW_LOCK, ///< Build lock button |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
87 |
DTW_SEPERATOR, ///< Seperating panel between lock and demolish |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
88 |
DTW_DEMOLISH, ///< Demolish aka dynamite button |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
89 |
DTW_DEPOT, ///< Build depot button |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
90 |
DTW_STATION, ///< Build station button |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
91 |
DTW_BUOY, ///< Build buoy button |
10920 | 92 |
DTW_BUILD_BRIDGE, ///< Build bride button |
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
93 |
DTW_END, ///< End of toolbar widgets |
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
94 |
}; |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
95 |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
96 |
|
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
97 |
static void BuildDocksClick_Canal(Window *w) |
0 | 98 |
{ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
99 |
HandlePlacePushButton(w, DTW_CANAL, SPR_CURSOR_CANAL, VHM_RECT, PlaceDocks_BuildCanal); |
0 | 100 |
} |
101 |
||
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
102 |
static void BuildDocksClick_Lock(Window *w) |
0 | 103 |
{ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
104 |
HandlePlacePushButton(w, DTW_LOCK, SPR_CURSOR_LOCK, VHM_RECT, PlaceDocks_BuildLock); |
0 | 105 |
} |
106 |
||
107 |
static void BuildDocksClick_Demolish(Window *w) |
|
108 |
{ |
|
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
9869
diff
changeset
|
109 |
HandlePlacePushButton(w, DTW_DEMOLISH, ANIMCURSOR_DEMOLISH, VHM_RECT, PlaceProc_DemolishArea); |
0 | 110 |
} |
111 |
||
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
112 |
static void BuildDocksClick_Depot(Window *w) |
0 | 113 |
{ |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9626
diff
changeset
|
114 |
if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return; |
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
115 |
if (HandlePlacePushButton(w, DTW_DEPOT, SPR_CURSOR_SHIP_DEPOT, VHM_RECT, PlaceDocks_Depot)) ShowBuildDocksDepotPicker(w); |
0 | 116 |
} |
117 |
||
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
118 |
static void BuildDocksClick_Dock(Window *w) |
0 | 119 |
{ |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9626
diff
changeset
|
120 |
if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return; |
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
121 |
if (HandlePlacePushButton(w, DTW_STATION, SPR_CURSOR_DOCK, VHM_SPECIAL, PlaceDocks_Dock)) ShowBuildDockStationPicker(w); |
0 | 122 |
} |
123 |
||
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
124 |
static void BuildDocksClick_Buoy(Window *w) |
0 | 125 |
{ |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9626
diff
changeset
|
126 |
if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return; |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
127 |
HandlePlacePushButton(w, DTW_BUOY, SPR_CURSOR_BOUY, VHM_RECT, PlaceDocks_Buoy); |
0 | 128 |
} |
129 |
||
10920 | 130 |
static void BuildDocksClick_Bridge(Window *w) |
131 |
{ |
|
132 |
HandlePlacePushButton(w, DTW_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, VHM_RECT, PlaceDocks_Bridge); |
|
133 |
} |
|
134 |
||
0 | 135 |
|
136 |
typedef void OnButtonClick(Window *w); |
|
137 |
static OnButtonClick * const _build_docks_button_proc[] = { |
|
138 |
BuildDocksClick_Canal, |
|
139 |
BuildDocksClick_Lock, |
|
2548
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2186
diff
changeset
|
140 |
NULL, |
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
141 |
BuildDocksClick_Demolish, |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
142 |
BuildDocksClick_Depot, |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
143 |
BuildDocksClick_Dock, |
10920 | 144 |
BuildDocksClick_Buoy, |
145 |
BuildDocksClick_Bridge |
|
0 | 146 |
}; |
147 |
||
10645 | 148 |
struct BuildDocksToolbarWindow : Window { |
149 |
BuildDocksToolbarWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) |
|
150 |
{ |
|
151 |
this->FindWindowPlacementAndResize(desc); |
|
10776 | 152 |
if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this); |
0 | 153 |
} |
154 |
||
10645 | 155 |
~BuildDocksToolbarWindow() |
156 |
{ |
|
10776 | 157 |
if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0); |
10645 | 158 |
} |
159 |
||
160 |
virtual void OnPaint() |
|
161 |
{ |
|
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
162 |
this->SetWidgetsDisabledState(!CanBuildVehicleInfrastructure(VEH_SHIP), DTW_DEPOT, DTW_STATION, DTW_BUOY, WIDGET_LIST_END); |
10645 | 163 |
this->DrawWidgets(); |
164 |
} |
|
165 |
||
166 |
virtual void OnClick(Point pt, int widget) |
|
167 |
{ |
|
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
168 |
if (widget >= DTW_BUTTONS_BEGIN && widget != DTW_SEPERATOR) _build_docks_button_proc[widget - DTW_BUTTONS_BEGIN](this); |
10645 | 169 |
} |
170 |
||
171 |
virtual EventState OnKeyPress(uint16 key, uint16 keycode) |
|
172 |
{ |
|
173 |
switch (keycode) { |
|
174 |
case '1': BuildDocksClick_Canal(this); break; |
|
175 |
case '2': BuildDocksClick_Lock(this); break; |
|
176 |
case '3': BuildDocksClick_Demolish(this); break; |
|
177 |
case '4': BuildDocksClick_Depot(this); break; |
|
178 |
case '5': BuildDocksClick_Dock(this); break; |
|
179 |
case '6': BuildDocksClick_Buoy(this); break; |
|
10920 | 180 |
case '7': BuildDocksClick_Bridge(this); break; |
10645 | 181 |
default: return ES_NOT_HANDLED; |
182 |
} |
|
183 |
return ES_HANDLED; |
|
184 |
} |
|
185 |
||
186 |
virtual void OnPlaceObject(Point pt, TileIndex tile) |
|
187 |
{ |
|
188 |
_place_proc(tile); |
|
189 |
} |
|
190 |
||
191 |
virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) |
|
192 |
{ |
|
193 |
VpSelectTilesWithMethod(pt.x, pt.y, select_method); |
|
194 |
} |
|
195 |
||
196 |
virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) |
|
197 |
{ |
|
198 |
if (pt.x != -1) { |
|
199 |
switch (select_proc) { |
|
10920 | 200 |
case DDSP_BUILD_BRIDGE: |
201 |
ResetObjectToPlace(); |
|
202 |
extern void CcBuildBridge(bool success, TileIndex tile, uint32 p1, uint32 p2); |
|
203 |
DoCommandP(end_tile, start_tile, TRANSPORT_WATER << 15, CcBuildBridge, CMD_BUILD_BRIDGE | CMD_MSG(STR_5015_CAN_T_BUILD_BRIDGE_HERE)); |
|
204 |
||
9624 | 205 |
case DDSP_DEMOLISH_AREA: |
10645 | 206 |
GUIPlaceProcDragXY(select_proc, start_tile, end_tile); |
9624 | 207 |
break; |
208 |
case DDSP_CREATE_WATER: |
|
10645 | 209 |
DoCommandP(end_tile, start_tile, 0, CcBuildCanal, CMD_BUILD_CANAL | CMD_MSG(STR_CANT_BUILD_CANALS)); |
9624 | 210 |
break; |
10645 | 211 |
|
9624 | 212 |
default: break; |
2549 | 213 |
} |
0 | 214 |
} |
10645 | 215 |
} |
0 | 216 |
|
10645 | 217 |
virtual void OnPlaceObjectAbort() |
218 |
{ |
|
219 |
this->RaiseButtons(); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
220 |
|
10645 | 221 |
delete FindWindowById(WC_BUILD_STATION, 0); |
222 |
delete FindWindowById(WC_BUILD_DEPOT, 0); |
|
223 |
} |
|
0 | 224 |
|
10645 | 225 |
virtual void OnPlacePresize(Point pt, TileIndex tile_from) |
226 |
{ |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
227 |
DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile_from, NULL)); |
10645 | 228 |
TileIndex tile_to = (dir != INVALID_DIAGDIR ? TileAddByDiagDir(tile_from, ReverseDiagDir(dir)) : tile_from); |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
229 |
|
0 | 230 |
VpSetPresizeRange(tile_from, tile_to); |
231 |
} |
|
10645 | 232 |
}; |
0 | 233 |
|
234 |
static const Widget _build_docks_toolb_widgets[] = { |
|
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
235 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // DTW_CLOSEBOX |
10920 | 236 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 166, 0, 13, STR_9801_DOCK_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // DTW_CAPTION |
237 |
{ WWT_STICKYBOX, RESIZE_NONE, 7, 167, 178, 0, 13, 0x0, STR_STICKY_BUTTON}, // DTW_STICKY |
|
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
238 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_BUILD_CANAL, STR_BUILD_CANALS_TIP}, // DTW_CANAL |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
239 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_BUILD_LOCK, STR_BUILD_LOCKS_TIP}, // DTW_LOCK |
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
240 |
|
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
241 |
{ WWT_PANEL, RESIZE_NONE, 7, 44, 47, 14, 35, 0x0, STR_NULL}, // DTW_SEPERATOR |
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
242 |
|
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
243 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 48, 69, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC}, // DTW_DEMOLISH |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
244 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 70, 91, 14, 35, SPR_IMG_SHIP_DEPOT, STR_981E_BUILD_SHIP_DEPOT_FOR_BUILDING}, // DTW_DEPOT |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
245 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 92, 113, 14, 35, SPR_IMG_SHIP_DOCK, STR_981D_BUILD_SHIP_DOCK}, // DTW_STATION |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
246 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 114, 135, 14, 35, SPR_IMG_BOUY, STR_9834_POSITION_BUOY_WHICH_CAN}, // DTW_BUOY |
10920 | 247 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 136, 178, 14, 35, SPR_IMG_BRIDGE, STR_180F_BUILD_ROAD_BRIDGE}, // DTW_BUILD_BRIDGE |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
0
diff
changeset
|
248 |
{ WIDGETS_END}, |
0 | 249 |
}; |
250 |
||
251 |
static const WindowDesc _build_docks_toolbar_desc = { |
|
10920 | 252 |
WDP_ALIGN_TBR, 22, 179, 36, 179, 36, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6111
diff
changeset
|
253 |
WC_BUILD_TOOLBAR, WC_NONE, |
756
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
750
diff
changeset
|
254 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, |
0 | 255 |
_build_docks_toolb_widgets, |
256 |
}; |
|
257 |
||
6573 | 258 |
void ShowBuildDocksToolbar() |
0 | 259 |
{ |
5005
21e84e53c732
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4994
diff
changeset
|
260 |
if (!IsValidPlayer(_current_player)) return; |
21e84e53c732
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4994
diff
changeset
|
261 |
|
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
9869
diff
changeset
|
262 |
DeleteWindowByClass(WC_BUILD_TOOLBAR); |
10645 | 263 |
AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_toolbar_desc, TRANSPORT_WATER); |
0 | 264 |
} |
265 |
||
10645 | 266 |
struct BuildDocksStationWindow : public PickerWindowBase { |
267 |
private: |
|
268 |
enum BuildDockStationWidgets { |
|
269 |
BDSW_CLOSE, |
|
270 |
BDSW_CAPTION, |
|
271 |
BDSW_BACKGROUND, |
|
272 |
BDSW_LT_OFF, |
|
273 |
BDSW_LT_ON, |
|
274 |
BDSW_INFO, |
|
275 |
}; |
|
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4634
diff
changeset
|
276 |
|
10645 | 277 |
public: |
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
278 |
BuildDocksStationWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) |
10645 | 279 |
{ |
280 |
this->LowerWidget(_station_show_coverage + BDSW_LT_OFF); |
|
281 |
this->FindWindowPlacementAndResize(desc); |
|
282 |
} |
|
283 |
||
284 |
virtual void OnPaint() |
|
285 |
{ |
|
10776 | 286 |
int rad = (_settings_game.station.modified_catchment) ? CA_DOCK : CA_UNMODIFIED; |
713
5b0be616ee1e
(svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents:
679
diff
changeset
|
287 |
|
10645 | 288 |
this->DrawWidgets(); |
2631
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2619
diff
changeset
|
289 |
|
9626 | 290 |
if (_station_show_coverage) { |
291 |
SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); |
|
292 |
} else { |
|
293 |
SetTileSelectSize(1, 1); |
|
294 |
} |
|
713
5b0be616ee1e
(svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents:
679
diff
changeset
|
295 |
|
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
296 |
int text_end = DrawStationCoverageAreaText(4, 50, SCT_ALL, rad, false); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
297 |
text_end = DrawStationCoverageAreaText(4, text_end + 4, SCT_ALL, rad, true) + 4; |
10645 | 298 |
if (text_end != this->widget[BDSW_BACKGROUND].bottom) { |
299 |
this->SetDirty(); |
|
300 |
ResizeWindowForWidget(this, 2, 0, text_end - this->widget[BDSW_BACKGROUND].bottom); |
|
301 |
this->SetDirty(); |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
302 |
} |
2639 | 303 |
} |
0 | 304 |
|
10645 | 305 |
virtual void OnClick(Point pt, int widget) |
306 |
{ |
|
307 |
switch (widget) { |
|
308 |
case BDSW_LT_OFF: |
|
309 |
case BDSW_LT_ON: |
|
310 |
this->RaiseWidget(_station_show_coverage + BDSW_LT_OFF); |
|
311 |
_station_show_coverage = (widget != BDSW_LT_OFF); |
|
312 |
this->LowerWidget(_station_show_coverage + BDSW_LT_OFF); |
|
2639 | 313 |
SndPlayFx(SND_15_BEEP); |
10645 | 314 |
this->SetDirty(); |
2639 | 315 |
break; |
0 | 316 |
} |
10645 | 317 |
} |
0 | 318 |
|
10645 | 319 |
virtual void OnTick() |
320 |
{ |
|
321 |
CheckRedrawStationCoverage(this); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
322 |
} |
10645 | 323 |
}; |
0 | 324 |
|
325 |
static const Widget _build_dock_station_widgets[] = { |
|
10645 | 326 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // BDSW_CLOSE |
327 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_3068_DOCK, STR_018C_WINDOW_TITLE_DRAG_THIS}, // BDSW_CAPTION |
|
328 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 147, 14, 74, 0x0, STR_NULL}, // BDSW_BACKGROUND |
|
329 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 14, 73, 30, 40, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE}, // BDSW_LT_OFF |
|
330 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 74, 133, 30, 40, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA}, // BDSW_LT_ON |
|
331 |
{ WWT_LABEL, RESIZE_NONE, 7, 0, 147, 17, 30, STR_3066_COVERAGE_AREA_HIGHLIGHT, STR_NULL}, // BDSW_INFO |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
0
diff
changeset
|
332 |
{ WIDGETS_END}, |
0 | 333 |
}; |
334 |
||
335 |
static const WindowDesc _build_dock_station_desc = { |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9641
diff
changeset
|
336 |
WDP_AUTO, WDP_AUTO, 148, 75, 148, 75, |
5070
0bbf5264bfb7
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
337 |
WC_BUILD_STATION, WC_BUILD_TOOLBAR, |
0 | 338 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
339 |
_build_dock_station_widgets, |
|
340 |
}; |
|
341 |
||
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
342 |
static void ShowBuildDockStationPicker(Window *parent) |
0 | 343 |
{ |
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
344 |
new BuildDocksStationWindow(&_build_dock_station_desc, parent); |
0 | 345 |
} |
346 |
||
10645 | 347 |
struct BuildDocksDepotWindow : public PickerWindowBase { |
348 |
private: |
|
349 |
enum BuildDockDepotWidgets { |
|
350 |
BDDW_CLOSE, |
|
351 |
BDDW_CAPTION, |
|
352 |
BDDW_BACKGROUND, |
|
353 |
BDDW_X, |
|
354 |
BDDW_Y, |
|
355 |
}; |
|
356 |
||
357 |
static void UpdateDocksDirection() |
|
358 |
{ |
|
359 |
if (_ship_depot_direction != AXIS_X) { |
|
360 |
SetTileSelectSize(1, 2); |
|
361 |
} else { |
|
362 |
SetTileSelectSize(2, 1); |
|
363 |
} |
|
0 | 364 |
} |
365 |
||
10645 | 366 |
public: |
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
367 |
BuildDocksDepotWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) |
10645 | 368 |
{ |
369 |
this->LowerWidget(_ship_depot_direction + BDDW_X); |
|
370 |
UpdateDocksDirection(); |
|
371 |
this->FindWindowPlacementAndResize(desc); |
|
372 |
} |
|
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4634
diff
changeset
|
373 |
|
10645 | 374 |
virtual void OnPaint() |
375 |
{ |
|
376 |
this->DrawWidgets(); |
|
0 | 377 |
|
378 |
DrawShipDepotSprite(67, 35, 0); |
|
379 |
DrawShipDepotSprite(35, 51, 1); |
|
380 |
DrawShipDepotSprite(135, 35, 2); |
|
381 |
DrawShipDepotSprite(167, 51, 3); |
|
10645 | 382 |
} |
0 | 383 |
|
10645 | 384 |
virtual void OnClick(Point pt, int widget) |
385 |
{ |
|
386 |
switch (widget) { |
|
387 |
case BDDW_X: |
|
388 |
case BDDW_Y: |
|
389 |
this->RaiseWidget(_ship_depot_direction + BDDW_X); |
|
390 |
_ship_depot_direction = (widget == BDDW_X ? AXIS_X : AXIS_Y); |
|
391 |
this->LowerWidget(_ship_depot_direction + BDDW_X); |
|
392 |
SndPlayFx(SND_15_BEEP); |
|
393 |
UpdateDocksDirection(); |
|
394 |
this->SetDirty(); |
|
395 |
break; |
|
0 | 396 |
} |
397 |
} |
|
10645 | 398 |
}; |
0 | 399 |
|
400 |
static const Widget _build_docks_depot_widgets[] = { |
|
10645 | 401 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // BDDW_CLOSE |
402 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 203, 0, 13, STR_3800_SHIP_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // BDDW_CAPTION |
|
403 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 203, 14, 85, 0x0, STR_NULL}, // BDDW_BACKGROUND |
|
404 |
{ WWT_PANEL, RESIZE_NONE, 14, 3, 100, 17, 82, 0x0, STR_3803_SELECT_SHIP_DEPOT_ORIENTATION}, // BDDW_X |
|
405 |
{ WWT_PANEL, RESIZE_NONE, 14, 103, 200, 17, 82, 0x0, STR_3803_SELECT_SHIP_DEPOT_ORIENTATION}, // BDDW_Y |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
0
diff
changeset
|
406 |
{ WIDGETS_END}, |
0 | 407 |
}; |
408 |
||
409 |
static const WindowDesc _build_docks_depot_desc = { |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9641
diff
changeset
|
410 |
WDP_AUTO, WDP_AUTO, 204, 86, 204, 86, |
5070
0bbf5264bfb7
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
411 |
WC_BUILD_DEPOT, WC_BUILD_TOOLBAR, |
0 | 412 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
413 |
_build_docks_depot_widgets, |
|
414 |
}; |
|
415 |
||
416 |
||
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
417 |
static void ShowBuildDocksDepotPicker(Window *parent) |
0 | 418 |
{ |
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
419 |
new BuildDocksDepotWindow(&_build_docks_depot_desc, parent); |
0 | 420 |
} |
421 |
||
422 |
||
6573 | 423 |
void InitializeDockGui() |
0 | 424 |
{ |
3157
40de8616c04c
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
2952
diff
changeset
|
425 |
_ship_depot_direction = AXIS_X; |
0 | 426 |
} |