author | rubidium |
Fri, 18 Jul 2008 16:40:29 +0000 | |
changeset 9659 | 187142ff9b6c |
parent 9652 | 0405e98d8e96 |
child 9751 | 9e9c726170cc |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
9111
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
9080
diff
changeset
|
3 |
/** @file dock_gui.cpp GUI to create amazing water objects. */ |
6125
a6fff965707c
(svn r8862) -Cleanup: doxygen changes, again. Mostly @files missing tags and a few comments style.
belugas
parents:
5893
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1632
diff
changeset
|
6 |
#include "openttd.h" |
8108
b42a0e5c67ef
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents:
8107
diff
changeset
|
7 |
#include "tile_map.h" |
8786
1823ff88a054
(svn r12490) -Codechange: rename engine.h to engine_func.h and remove unneeded inclusions of engine.h and/or replace them with engine_type.h.
rubidium
parents:
8573
diff
changeset
|
8 |
#include "station_type.h" |
0 | 9 |
#include "gui.h" |
8205
2bde724f1b5d
(svn r11768) -Codechange: move some terraform related gui stuff from main_gui.cpp to terraform_gui.cpp (and introduce terraform_gui.h). Based on a patch by Roujin.
rubidium
parents:
8157
diff
changeset
|
10 |
#include "terraform_gui.h" |
8107
bb7deea89175
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8106
diff
changeset
|
11 |
#include "window_gui.h" |
bb7deea89175
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8106
diff
changeset
|
12 |
#include "station_gui.h" |
8116
8da76dcb3287
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
8108
diff
changeset
|
13 |
#include "command_func.h" |
8270
e7c342f6b14c
(svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents:
8264
diff
changeset
|
14 |
#include "settings_type.h" |
7948
e408508f5727
(svn r11504) -Fix [FS#1467]: removing docks/ship depots could result in non-canal water where canals should have been build.
rubidium
parents:
7889
diff
changeset
|
15 |
#include "water.h" |
8131
160939e24ed3
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8121
diff
changeset
|
16 |
#include "window_func.h" |
8144
65cec0877b78
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents:
8139
diff
changeset
|
17 |
#include "vehicle_func.h" |
8157
1505def01945
(svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium
parents:
8144
diff
changeset
|
18 |
#include "sound_func.h" |
8224
c5a64d87cc54
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8205
diff
changeset
|
19 |
#include "viewport_func.h" |
c5a64d87cc54
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8205
diff
changeset
|
20 |
#include "gfx_func.h" |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8237
diff
changeset
|
21 |
#include "player_func.h" |
8413
c7f3384330a3
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8270
diff
changeset
|
22 |
#include "slope_func.h" |
9127
14f21c5954ee
(svn r12987) -Codechange: split viewport and tile selection.
rubidium
parents:
9123
diff
changeset
|
23 |
#include "tilehighlight_func.h" |
9659
187142ff9b6c
(svn r13731) -Codechange: make a pool of the array of players.
rubidium
parents:
9652
diff
changeset
|
24 |
#include "player_base.h" |
0 | 25 |
|
8264
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
26 |
#include "table/sprites.h" |
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
27 |
#include "table/strings.h" |
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
28 |
|
9338
3d6f9ddd431d
(svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents:
9327
diff
changeset
|
29 |
static void ShowBuildDockStationPicker(Window *parent); |
3d6f9ddd431d
(svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents:
9327
diff
changeset
|
30 |
static void ShowBuildDocksDepotPicker(Window *parent); |
0 | 31 |
|
3157
3f35e2d9c8e3
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
2952
diff
changeset
|
32 |
static Axis _ship_depot_direction; |
0 | 33 |
|
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
34 |
void CcBuildDocks(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 35 |
{ |
36 |
if (success) { |
|
541 | 37 |
SndPlayTileFx(SND_02_SPLAT, tile); |
0 | 38 |
ResetObjectToPlace(); |
39 |
} |
|
40 |
} |
|
41 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
42 |
void CcBuildCanal(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 43 |
{ |
541 | 44 |
if (success) SndPlayTileFx(SND_02_SPLAT, tile); |
0 | 45 |
} |
46 |
||
47 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
48 |
static void PlaceDocks_Dock(TileIndex tile) |
0 | 49 |
{ |
7521
0da1e91510e4
(svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents:
7341
diff
changeset
|
50 |
DoCommandP(tile, _ctrl_pressed, 0, CcBuildDocks, CMD_BUILD_DOCK | CMD_MSG(STR_9802_CAN_T_BUILD_DOCK_HERE)); |
0 | 51 |
} |
52 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
53 |
static void PlaceDocks_Depot(TileIndex tile) |
0 | 54 |
{ |
7521
0da1e91510e4
(svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents:
7341
diff
changeset
|
55 |
DoCommandP(tile, _ship_depot_direction, 0, CcBuildDocks, CMD_BUILD_SHIP_DEPOT | CMD_MSG(STR_3802_CAN_T_BUILD_SHIP_DEPOT)); |
0 | 56 |
} |
57 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
58 |
static void PlaceDocks_Buoy(TileIndex tile) |
0 | 59 |
{ |
7521
0da1e91510e4
(svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents:
7341
diff
changeset
|
60 |
DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_BUOY | CMD_MSG(STR_9835_CAN_T_POSITION_BUOY_HERE)); |
0 | 61 |
} |
62 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
63 |
static void PlaceDocks_BuildCanal(TileIndex tile) |
0 | 64 |
{ |
9588
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
65 |
VpStartPlaceSizing(tile, (_game_mode == GM_EDITOR) ? VPM_X_AND_Y : VPM_X_OR_Y, DDSP_CREATE_WATER); |
0 | 66 |
} |
67 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
68 |
static void PlaceDocks_BuildLock(TileIndex tile) |
0 | 69 |
{ |
7521
0da1e91510e4
(svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents:
7341
diff
changeset
|
70 |
DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_LOCK | CMD_MSG(STR_CANT_BUILD_LOCKS)); |
0 | 71 |
} |
72 |
||
9588
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
73 |
static void PlaceDocks_BuildRiver(TileIndex tile) |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
74 |
{ |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
75 |
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CREATE_RIVER); |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
76 |
} |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
77 |
|
9499
a7d854f98d65
(svn r13479) -Codechange: don't use word 'bridge' for aqueducts that often
smatz
parents:
9490
diff
changeset
|
78 |
static void PlaceDocks_Aqueduct(TileIndex tile) |
9490
01c07bde5e84
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium
parents:
9413
diff
changeset
|
79 |
{ |
01c07bde5e84
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium
parents:
9413
diff
changeset
|
80 |
VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_BUILD_BRIDGE); |
01c07bde5e84
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium
parents:
9413
diff
changeset
|
81 |
} |
01c07bde5e84
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium
parents:
9413
diff
changeset
|
82 |
|
01c07bde5e84
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium
parents:
9413
diff
changeset
|
83 |
|
9327
d75ba36bc651
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
9317
diff
changeset
|
84 |
/** Enum referring to the widgets of the build dock toolbar */ |
d75ba36bc651
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
9317
diff
changeset
|
85 |
enum DockToolbarWidgets { |
d75ba36bc651
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
9317
diff
changeset
|
86 |
DTW_BEGIN = 0, ///< Start of toolbar widgets |
d75ba36bc651
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
9317
diff
changeset
|
87 |
DTW_CLOSEBOX = DTW_BEGIN, ///< Close window button |
d75ba36bc651
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
9317
diff
changeset
|
88 |
DTW_CAPTION, ///< Window caption |
d75ba36bc651
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
9317
diff
changeset
|
89 |
DTW_STICKY, ///< Sticky window button |
d75ba36bc651
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
9317
diff
changeset
|
90 |
DTW_BUTTONS_BEGIN, ///< Begin of clickable buttons (except seperating panel) |
d75ba36bc651
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
9317
diff
changeset
|
91 |
DTW_CANAL = DTW_BUTTONS_BEGIN, ///< Build canal button |
d75ba36bc651
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
9317
diff
changeset
|
92 |
DTW_LOCK, ///< Build lock button |
d75ba36bc651
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
9317
diff
changeset
|
93 |
DTW_SEPERATOR, ///< Seperating panel between lock and demolish |
d75ba36bc651
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
9317
diff
changeset
|
94 |
DTW_DEMOLISH, ///< Demolish aka dynamite button |
d75ba36bc651
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
9317
diff
changeset
|
95 |
DTW_DEPOT, ///< Build depot button |
d75ba36bc651
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
9317
diff
changeset
|
96 |
DTW_STATION, ///< Build station button |
d75ba36bc651
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
9317
diff
changeset
|
97 |
DTW_BUOY, ///< Build buoy button |
9588
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
98 |
DTW_RIVER, ///< Build river button (in scenario editor) |
9499
a7d854f98d65
(svn r13479) -Codechange: don't use word 'bridge' for aqueducts that often
smatz
parents:
9490
diff
changeset
|
99 |
DTW_BUILD_AQUEDUCT, ///< Build aqueduct button |
9327
d75ba36bc651
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
9317
diff
changeset
|
100 |
DTW_END, ///< End of toolbar widgets |
5147
866030c20f0a
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
101 |
}; |
866030c20f0a
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
102 |
|
866030c20f0a
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
103 |
|
606
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
104 |
static void BuildDocksClick_Canal(Window *w) |
0 | 105 |
{ |
9588
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
106 |
|
7889
e74ce8853ba7
(svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents:
7521
diff
changeset
|
107 |
HandlePlacePushButton(w, DTW_CANAL, SPR_CURSOR_CANAL, VHM_RECT, PlaceDocks_BuildCanal); |
0 | 108 |
} |
109 |
||
606
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
110 |
static void BuildDocksClick_Lock(Window *w) |
0 | 111 |
{ |
7889
e74ce8853ba7
(svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents:
7521
diff
changeset
|
112 |
HandlePlacePushButton(w, DTW_LOCK, SPR_CURSOR_LOCK, VHM_RECT, PlaceDocks_BuildLock); |
0 | 113 |
} |
114 |
||
115 |
static void BuildDocksClick_Demolish(Window *w) |
|
116 |
{ |
|
9123
d2a939cbdf1d
(svn r12983) -Codechange [FS#1987] : Unification of all dynamite tools calls to only one. Thanks to Roujin
belugas
parents:
9116
diff
changeset
|
117 |
HandlePlacePushButton(w, DTW_DEMOLISH, ANIMCURSOR_DEMOLISH, VHM_RECT, PlaceProc_DemolishArea); |
0 | 118 |
} |
119 |
||
606
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
120 |
static void BuildDocksClick_Depot(Window *w) |
0 | 121 |
{ |
7086
de7e83fb1602
(svn r10353) -Fix/Feature [FS#669]: disallow (in the GUI) the building of infrastructure you do not have available vehicles for. This means that the airport building button is disabled till you can actually build aircraft. The game itself will not disallow you to build the infrastructure and this "new" behaviour can be overriden with a patch setting.
rubidium
parents:
6829
diff
changeset
|
122 |
if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return; |
9338
3d6f9ddd431d
(svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents:
9327
diff
changeset
|
123 |
if (HandlePlacePushButton(w, DTW_DEPOT, SPR_CURSOR_SHIP_DEPOT, VHM_RECT, PlaceDocks_Depot)) ShowBuildDocksDepotPicker(w); |
0 | 124 |
} |
125 |
||
606
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
126 |
static void BuildDocksClick_Dock(Window *w) |
0 | 127 |
{ |
7086
de7e83fb1602
(svn r10353) -Fix/Feature [FS#669]: disallow (in the GUI) the building of infrastructure you do not have available vehicles for. This means that the airport building button is disabled till you can actually build aircraft. The game itself will not disallow you to build the infrastructure and this "new" behaviour can be overriden with a patch setting.
rubidium
parents:
6829
diff
changeset
|
128 |
if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return; |
9338
3d6f9ddd431d
(svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents:
9327
diff
changeset
|
129 |
if (HandlePlacePushButton(w, DTW_STATION, SPR_CURSOR_DOCK, VHM_SPECIAL, PlaceDocks_Dock)) ShowBuildDockStationPicker(w); |
0 | 130 |
} |
131 |
||
606
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
132 |
static void BuildDocksClick_Buoy(Window *w) |
0 | 133 |
{ |
7086
de7e83fb1602
(svn r10353) -Fix/Feature [FS#669]: disallow (in the GUI) the building of infrastructure you do not have available vehicles for. This means that the airport building button is disabled till you can actually build aircraft. The game itself will not disallow you to build the infrastructure and this "new" behaviour can be overriden with a patch setting.
rubidium
parents:
6829
diff
changeset
|
134 |
if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return; |
7889
e74ce8853ba7
(svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents:
7521
diff
changeset
|
135 |
HandlePlacePushButton(w, DTW_BUOY, SPR_CURSOR_BOUY, VHM_RECT, PlaceDocks_Buoy); |
0 | 136 |
} |
137 |
||
9588
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
138 |
static void BuildDocksClick_River(Window *w) |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
139 |
{ |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
140 |
if (_game_mode != GM_EDITOR) return; |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
141 |
HandlePlacePushButton(w, DTW_RIVER, SPR_CURSOR_RIVER, VHM_RECT, PlaceDocks_BuildRiver); |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
142 |
} |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
143 |
|
9499
a7d854f98d65
(svn r13479) -Codechange: don't use word 'bridge' for aqueducts that often
smatz
parents:
9490
diff
changeset
|
144 |
static void BuildDocksClick_Aqueduct(Window *w) |
9490
01c07bde5e84
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium
parents:
9413
diff
changeset
|
145 |
{ |
9506 | 146 |
HandlePlacePushButton(w, DTW_BUILD_AQUEDUCT, SPR_CURSOR_AQUEDUCT, VHM_RECT, PlaceDocks_Aqueduct); |
9490
01c07bde5e84
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium
parents:
9413
diff
changeset
|
147 |
} |
01c07bde5e84
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium
parents:
9413
diff
changeset
|
148 |
|
0 | 149 |
|
150 |
typedef void OnButtonClick(Window *w); |
|
151 |
static OnButtonClick * const _build_docks_button_proc[] = { |
|
152 |
BuildDocksClick_Canal, |
|
153 |
BuildDocksClick_Lock, |
|
2548
49c8a096033f
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2186
diff
changeset
|
154 |
NULL, |
606
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
155 |
BuildDocksClick_Demolish, |
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
156 |
BuildDocksClick_Depot, |
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
157 |
BuildDocksClick_Dock, |
9490
01c07bde5e84
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium
parents:
9413
diff
changeset
|
158 |
BuildDocksClick_Buoy, |
9588
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
159 |
BuildDocksClick_River, |
9499
a7d854f98d65
(svn r13479) -Codechange: don't use word 'bridge' for aqueducts that often
smatz
parents:
9490
diff
changeset
|
160 |
BuildDocksClick_Aqueduct |
0 | 161 |
}; |
162 |
||
9303
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
163 |
struct BuildDocksToolbarWindow : Window { |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
164 |
BuildDocksToolbarWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
165 |
{ |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
166 |
this->FindWindowPlacementAndResize(desc); |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9354
diff
changeset
|
167 |
if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this); |
0 | 168 |
} |
169 |
||
9303
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
170 |
~BuildDocksToolbarWindow() |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
171 |
{ |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9354
diff
changeset
|
172 |
if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0); |
9303
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
173 |
} |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
174 |
|
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
175 |
virtual void OnPaint() |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
176 |
{ |
9327
d75ba36bc651
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
9317
diff
changeset
|
177 |
this->SetWidgetsDisabledState(!CanBuildVehicleInfrastructure(VEH_SHIP), DTW_DEPOT, DTW_STATION, DTW_BUOY, WIDGET_LIST_END); |
9303
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
178 |
this->DrawWidgets(); |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
179 |
} |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
180 |
|
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
181 |
virtual void OnClick(Point pt, int widget) |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
182 |
{ |
9327
d75ba36bc651
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
9317
diff
changeset
|
183 |
if (widget >= DTW_BUTTONS_BEGIN && widget != DTW_SEPERATOR) _build_docks_button_proc[widget - DTW_BUTTONS_BEGIN](this); |
9303
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
184 |
} |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
185 |
|
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
186 |
virtual EventState OnKeyPress(uint16 key, uint16 keycode) |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
187 |
{ |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
188 |
switch (keycode) { |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
189 |
case '1': BuildDocksClick_Canal(this); break; |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
190 |
case '2': BuildDocksClick_Lock(this); break; |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
191 |
case '3': BuildDocksClick_Demolish(this); break; |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
192 |
case '4': BuildDocksClick_Depot(this); break; |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
193 |
case '5': BuildDocksClick_Dock(this); break; |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
194 |
case '6': BuildDocksClick_Buoy(this); break; |
9588
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
195 |
case '7': BuildDocksClick_River(this); break; |
9501
63fa54b5b9c4
(svn r13481) -Codechange: add 'B' keyboard shortcut to build aqueduct (planetmaker)
smatz
parents:
9499
diff
changeset
|
196 |
case 'B': |
9588
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
197 |
case '8': BuildDocksClick_Aqueduct(this); break; |
9303
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
198 |
default: return ES_NOT_HANDLED; |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
199 |
} |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
200 |
return ES_HANDLED; |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
201 |
} |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
202 |
|
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
203 |
virtual void OnPlaceObject(Point pt, TileIndex tile) |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
204 |
{ |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
205 |
_place_proc(tile); |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
206 |
} |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
207 |
|
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
208 |
virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
209 |
{ |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
210 |
VpSelectTilesWithMethod(pt.x, pt.y, select_method); |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
211 |
} |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
212 |
|
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
213 |
virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
214 |
{ |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
215 |
if (pt.x != -1) { |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
216 |
switch (select_proc) { |
9490
01c07bde5e84
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium
parents:
9413
diff
changeset
|
217 |
case DDSP_BUILD_BRIDGE: |
01c07bde5e84
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium
parents:
9413
diff
changeset
|
218 |
ResetObjectToPlace(); |
01c07bde5e84
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium
parents:
9413
diff
changeset
|
219 |
extern void CcBuildBridge(bool success, TileIndex tile, uint32 p1, uint32 p2); |
9499
a7d854f98d65
(svn r13479) -Codechange: don't use word 'bridge' for aqueducts that often
smatz
parents:
9490
diff
changeset
|
220 |
DoCommandP(end_tile, start_tile, TRANSPORT_WATER << 15, CcBuildBridge, CMD_BUILD_BRIDGE | CMD_MSG(STR_CAN_T_BUILD_AQUEDUCT_HERE)); |
9490
01c07bde5e84
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium
parents:
9413
diff
changeset
|
221 |
|
6670
f0300bf50643
(svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents:
6669
diff
changeset
|
222 |
case DDSP_DEMOLISH_AREA: |
9303
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
223 |
GUIPlaceProcDragXY(select_proc, start_tile, end_tile); |
6669
bb48a810a509
(svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents:
6491
diff
changeset
|
224 |
break; |
6670
f0300bf50643
(svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents:
6669
diff
changeset
|
225 |
case DDSP_CREATE_WATER: |
9588
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
226 |
DoCommandP(end_tile, start_tile, (_game_mode == GM_EDITOR ? _ctrl_pressed : 0), CcBuildCanal, CMD_BUILD_CANAL | CMD_MSG(STR_CANT_BUILD_CANALS)); |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
227 |
break; |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
228 |
case DDSP_CREATE_RIVER: |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
229 |
DoCommandP(end_tile, start_tile, 2, CcBuildCanal, CMD_BUILD_CANAL | CMD_MSG(STR_CANT_PLACE_RIVERS)); |
6669
bb48a810a509
(svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents:
6491
diff
changeset
|
230 |
break; |
9303
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
231 |
|
6669
bb48a810a509
(svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents:
6491
diff
changeset
|
232 |
default: break; |
2549 | 233 |
} |
0 | 234 |
} |
9303
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
235 |
} |
0 | 236 |
|
9303
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
237 |
virtual void OnPlaceObjectAbort() |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
238 |
{ |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
239 |
this->RaiseButtons(); |
0 | 240 |
|
9238
e2f586d12318
(svn r13104) -Codechange: make ResetObjectToPlace safe to be called recursively via the OnPlaceObjectAbort callback and use this knowledge to simplify closing some windows.
rubidium
parents:
9161
diff
changeset
|
241 |
delete FindWindowById(WC_BUILD_STATION, 0); |
e2f586d12318
(svn r13104) -Codechange: make ResetObjectToPlace safe to be called recursively via the OnPlaceObjectAbort callback and use this knowledge to simplify closing some windows.
rubidium
parents:
9161
diff
changeset
|
242 |
delete FindWindowById(WC_BUILD_DEPOT, 0); |
9303
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
243 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
244 |
|
9303
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
245 |
virtual void OnPlacePresize(Point pt, TileIndex tile_from) |
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
246 |
{ |
8413
c7f3384330a3
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8270
diff
changeset
|
247 |
DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile_from, NULL)); |
9303
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
248 |
TileIndex tile_to = (dir != INVALID_DIAGDIR ? TileAddByDiagDir(tile_from, ReverseDiagDir(dir)) : tile_from); |
8413
c7f3384330a3
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8270
diff
changeset
|
249 |
|
0 | 250 |
VpSetPresizeRange(tile_from, tile_to); |
251 |
} |
|
9303
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
252 |
}; |
0 | 253 |
|
254 |
static const Widget _build_docks_toolb_widgets[] = { |
|
9588
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
255 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // DTW_CLOSEBOX |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
256 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_9801_WATERWAYS_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // DTW_CAPTION |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
257 |
{ WWT_STICKYBOX, RESIZE_NONE, 7, 148, 159, 0, 13, 0x0, STR_STICKY_BUTTON}, // DTW_STICKY |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
258 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_BUILD_CANAL, STR_BUILD_CANALS_TIP}, // DTW_CANAL |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
259 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_BUILD_LOCK, STR_BUILD_LOCKS_TIP}, // DTW_LOCK |
606
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
260 |
|
9588
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
261 |
{ WWT_PANEL, RESIZE_NONE, 7, 44, 48, 14, 35, 0x0, STR_NULL}, // DTW_SEPERATOR |
606
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
262 |
|
9588
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
263 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 49, 70, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC}, // DTW_DEMOLISH |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
264 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 71, 92, 14, 35, SPR_IMG_SHIP_DEPOT, STR_981E_BUILD_SHIP_DEPOT_FOR_BUILDING}, // DTW_DEPOT |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
265 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 93, 114, 14, 35, SPR_IMG_SHIP_DOCK, STR_981D_BUILD_SHIP_DOCK}, // DTW_STATION |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
266 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 115, 136, 14, 35, SPR_IMG_BOUY, STR_9834_POSITION_BUOY_WHICH_CAN}, // DTW_BUOY |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
267 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, // DTW_RIVER |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
268 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 137, 159, 14, 35, SPR_IMG_AQUEDUCT, STR_BUILD_AQUEDUCT}, // DTW_BUILD_AQUEDUCT |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
0
diff
changeset
|
269 |
{ WIDGETS_END}, |
0 | 270 |
}; |
271 |
||
272 |
static const WindowDesc _build_docks_toolbar_desc = { |
|
9588
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
273 |
WDP_ALIGN_TBR, 22, 160, 36, 160, 36, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5860
diff
changeset
|
274 |
WC_BUILD_TOOLBAR, WC_NONE, |
756
b76998029c12
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
750
diff
changeset
|
275 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, |
0 | 276 |
_build_docks_toolb_widgets, |
277 |
}; |
|
278 |
||
6247 | 279 |
void ShowBuildDocksToolbar() |
0 | 280 |
{ |
9652
0405e98d8e96
(svn r13719) -Codechange: rename IsValidPlayer to IsValidPlayerID in line with all other structs/classes that are in a pool.
rubidium
parents:
9588
diff
changeset
|
281 |
if (!IsValidPlayerID(_current_player)) return; |
5005
f5086bd3945a
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4994
diff
changeset
|
282 |
|
9080
34bc7cbbb79a
(svn r12939) -Codechange: do not use the window proc to determine whether a toolbar is a rail toolbar, but use the window number.
rubidium
parents:
8846
diff
changeset
|
283 |
DeleteWindowByClass(WC_BUILD_TOOLBAR); |
9303
6b6b52069079
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
9293
diff
changeset
|
284 |
AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_toolbar_desc, TRANSPORT_WATER); |
0 | 285 |
} |
286 |
||
9588
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
287 |
/* Widget definition for the build docks in scenario editor window */ |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
288 |
static const Widget _build_docks_scen_toolb_widgets[] = { |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
289 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // DTW_CLOSEBOX |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
290 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 102, 0, 13, STR_9801_WATERWAYS_CONSTRUCTION_SE, STR_018C_WINDOW_TITLE_DRAG_THIS}, // DTW_CAPTION |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
291 |
{ WWT_STICKYBOX, RESIZE_NONE, 7, 103, 114, 0, 13, 0x0, STR_STICKY_BUTTON}, // DTW_STICKY |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
292 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_BUILD_CANAL, STR_CREATE_LAKE}, // DTW_CANAL |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
293 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_BUILD_LOCK, STR_BUILD_LOCKS_TIP}, // DTW_LOCK |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
294 |
|
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
295 |
{ WWT_PANEL, RESIZE_NONE, 7, 44, 48, 14, 35, 0x0, STR_NULL}, // DTW_SEPERATOR |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
296 |
|
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
297 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 49, 70, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC}, // DTW_DEMOLISH |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
298 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, // DTW_DEPOT |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
299 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, // DTW_STATION |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
300 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, // DTW_BUOY |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
301 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 71, 92, 14, 35, SPR_IMG_BUILD_RIVER, STR_CREATE_RIVER}, // DTW_RIVER |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
302 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 93, 114, 14, 35, SPR_IMG_AQUEDUCT, STR_BUILD_AQUEDUCT}, // DTW_BUILD_AQUEDUCT |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
303 |
{ WIDGETS_END}, |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
304 |
}; |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
305 |
|
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
306 |
/* Window definition for the build docks in scenario editor window */ |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
307 |
static const WindowDesc _build_docks_scen_toolbar_desc = { |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
308 |
WDP_AUTO, WDP_AUTO, 115, 36, 115, 36, |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
309 |
WC_SCEN_BUILD_TOOLBAR, WC_NONE, |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
310 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
311 |
_build_docks_scen_toolb_widgets, |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
312 |
}; |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
313 |
|
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
314 |
void ShowBuildDocksScenToolbar() |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
315 |
{ |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
316 |
AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_scen_toolbar_desc, TRANSPORT_WATER); |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
317 |
} |
620c97d8cee4
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
9506
diff
changeset
|
318 |
|
9279
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
319 |
struct BuildDocksStationWindow : public PickerWindowBase { |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
320 |
private: |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
321 |
enum BuildDockStationWidgets { |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
322 |
BDSW_CLOSE, |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
323 |
BDSW_CAPTION, |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
324 |
BDSW_BACKGROUND, |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
325 |
BDSW_LT_OFF, |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
326 |
BDSW_LT_ON, |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
327 |
BDSW_INFO, |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
328 |
}; |
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4634
diff
changeset
|
329 |
|
9279
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
330 |
public: |
9338
3d6f9ddd431d
(svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents:
9327
diff
changeset
|
331 |
BuildDocksStationWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) |
9279
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
332 |
{ |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
333 |
this->LowerWidget(_station_show_coverage + BDSW_LT_OFF); |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
334 |
this->FindWindowPlacementAndResize(desc); |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
335 |
} |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
336 |
|
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
337 |
virtual void OnPaint() |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
338 |
{ |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9354
diff
changeset
|
339 |
int rad = (_settings_game.station.modified_catchment) ? CA_DOCK : CA_UNMODIFIED; |
713
aeeebdfdaae0
(svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents:
679
diff
changeset
|
340 |
|
9279
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
341 |
this->DrawWidgets(); |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2619
diff
changeset
|
342 |
|
6829
baf24dad91c9
(svn r10068) -Fix [FS#835]: coverage area highlight was still show when it was turned off for docks.
rubidium
parents:
6674
diff
changeset
|
343 |
if (_station_show_coverage) { |
baf24dad91c9
(svn r10068) -Fix [FS#835]: coverage area highlight was still show when it was turned off for docks.
rubidium
parents:
6674
diff
changeset
|
344 |
SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); |
baf24dad91c9
(svn r10068) -Fix [FS#835]: coverage area highlight was still show when it was turned off for docks.
rubidium
parents:
6674
diff
changeset
|
345 |
} else { |
baf24dad91c9
(svn r10068) -Fix [FS#835]: coverage area highlight was still show when it was turned off for docks.
rubidium
parents:
6674
diff
changeset
|
346 |
SetTileSelectSize(1, 1); |
baf24dad91c9
(svn r10068) -Fix [FS#835]: coverage area highlight was still show when it was turned off for docks.
rubidium
parents:
6674
diff
changeset
|
347 |
} |
713
aeeebdfdaae0
(svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents:
679
diff
changeset
|
348 |
|
8846
1b90782b2c4e
(svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents:
8786
diff
changeset
|
349 |
int text_end = DrawStationCoverageAreaText(4, 50, SCT_ALL, rad, false); |
1b90782b2c4e
(svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents:
8786
diff
changeset
|
350 |
text_end = DrawStationCoverageAreaText(4, text_end + 4, SCT_ALL, rad, true) + 4; |
9279
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
351 |
if (text_end != this->widget[BDSW_BACKGROUND].bottom) { |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
352 |
this->SetDirty(); |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
353 |
ResizeWindowForWidget(this, 2, 0, text_end - this->widget[BDSW_BACKGROUND].bottom); |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
354 |
this->SetDirty(); |
8423
0c0f0370620b
(svn r11993) -Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long.
peter1138
parents:
8413
diff
changeset
|
355 |
} |
2639 | 356 |
} |
0 | 357 |
|
9279
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
358 |
virtual void OnClick(Point pt, int widget) |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
359 |
{ |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
360 |
switch (widget) { |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
361 |
case BDSW_LT_OFF: |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
362 |
case BDSW_LT_ON: |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
363 |
this->RaiseWidget(_station_show_coverage + BDSW_LT_OFF); |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
364 |
_station_show_coverage = (widget != BDSW_LT_OFF); |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
365 |
this->LowerWidget(_station_show_coverage + BDSW_LT_OFF); |
2639 | 366 |
SndPlayFx(SND_15_BEEP); |
9279
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
367 |
this->SetDirty(); |
2639 | 368 |
break; |
0 | 369 |
} |
9279
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
370 |
} |
0 | 371 |
|
9279
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
372 |
virtual void OnTick() |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
373 |
{ |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
374 |
CheckRedrawStationCoverage(this); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
375 |
} |
9279
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
376 |
}; |
0 | 377 |
|
378 |
static const Widget _build_dock_station_widgets[] = { |
|
9279
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
379 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // BDSW_CLOSE |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
380 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_3068_DOCK, STR_018C_WINDOW_TITLE_DRAG_THIS}, // BDSW_CAPTION |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
381 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 147, 14, 74, 0x0, STR_NULL}, // BDSW_BACKGROUND |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
382 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 14, 73, 30, 40, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE}, // BDSW_LT_OFF |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
383 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 74, 133, 30, 40, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA}, // BDSW_LT_ON |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
384 |
{ 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
|
385 |
{ WIDGETS_END}, |
0 | 386 |
}; |
387 |
||
388 |
static const WindowDesc _build_dock_station_desc = { |
|
7341
02515d0d4ced
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7241
diff
changeset
|
389 |
WDP_AUTO, WDP_AUTO, 148, 75, 148, 75, |
5070
7f5b13b7e728
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
390 |
WC_BUILD_STATION, WC_BUILD_TOOLBAR, |
0 | 391 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
392 |
_build_dock_station_widgets, |
|
393 |
}; |
|
394 |
||
9338
3d6f9ddd431d
(svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents:
9327
diff
changeset
|
395 |
static void ShowBuildDockStationPicker(Window *parent) |
0 | 396 |
{ |
9338
3d6f9ddd431d
(svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents:
9327
diff
changeset
|
397 |
new BuildDocksStationWindow(&_build_dock_station_desc, parent); |
0 | 398 |
} |
399 |
||
9279
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
400 |
struct BuildDocksDepotWindow : public PickerWindowBase { |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
401 |
private: |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
402 |
enum BuildDockDepotWidgets { |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
403 |
BDDW_CLOSE, |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
404 |
BDDW_CAPTION, |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
405 |
BDDW_BACKGROUND, |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
406 |
BDDW_X, |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
407 |
BDDW_Y, |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
408 |
}; |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
409 |
|
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
410 |
static void UpdateDocksDirection() |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
411 |
{ |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
412 |
if (_ship_depot_direction != AXIS_X) { |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
413 |
SetTileSelectSize(1, 2); |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
414 |
} else { |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
415 |
SetTileSelectSize(2, 1); |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
416 |
} |
0 | 417 |
} |
418 |
||
9279
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
419 |
public: |
9338
3d6f9ddd431d
(svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents:
9327
diff
changeset
|
420 |
BuildDocksDepotWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) |
9279
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
421 |
{ |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
422 |
this->LowerWidget(_ship_depot_direction + BDDW_X); |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
423 |
UpdateDocksDirection(); |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
424 |
this->FindWindowPlacementAndResize(desc); |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
425 |
} |
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4634
diff
changeset
|
426 |
|
9279
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
427 |
virtual void OnPaint() |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
428 |
{ |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
429 |
this->DrawWidgets(); |
0 | 430 |
|
431 |
DrawShipDepotSprite(67, 35, 0); |
|
432 |
DrawShipDepotSprite(35, 51, 1); |
|
433 |
DrawShipDepotSprite(135, 35, 2); |
|
434 |
DrawShipDepotSprite(167, 51, 3); |
|
9279
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
435 |
} |
0 | 436 |
|
9279
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
437 |
virtual void OnClick(Point pt, int widget) |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
438 |
{ |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
439 |
switch (widget) { |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
440 |
case BDDW_X: |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
441 |
case BDDW_Y: |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
442 |
this->RaiseWidget(_ship_depot_direction + BDDW_X); |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
443 |
_ship_depot_direction = (widget == BDDW_X ? AXIS_X : AXIS_Y); |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
444 |
this->LowerWidget(_ship_depot_direction + BDDW_X); |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
445 |
SndPlayFx(SND_15_BEEP); |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
446 |
UpdateDocksDirection(); |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
447 |
this->SetDirty(); |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
448 |
break; |
0 | 449 |
} |
450 |
} |
|
9279
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
451 |
}; |
0 | 452 |
|
453 |
static const Widget _build_docks_depot_widgets[] = { |
|
9279
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
454 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // BDDW_CLOSE |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
455 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 203, 0, 13, STR_3800_SHIP_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // BDDW_CAPTION |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
456 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 203, 14, 85, 0x0, STR_NULL}, // BDDW_BACKGROUND |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
457 |
{ WWT_PANEL, RESIZE_NONE, 14, 3, 100, 17, 82, 0x0, STR_3803_SELECT_SHIP_DEPOT_ORIENTATION}, // BDDW_X |
a21d6abb1f56
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
9273
diff
changeset
|
458 |
{ 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
|
459 |
{ WIDGETS_END}, |
0 | 460 |
}; |
461 |
||
462 |
static const WindowDesc _build_docks_depot_desc = { |
|
7341
02515d0d4ced
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7241
diff
changeset
|
463 |
WDP_AUTO, WDP_AUTO, 204, 86, 204, 86, |
5070
7f5b13b7e728
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
464 |
WC_BUILD_DEPOT, WC_BUILD_TOOLBAR, |
0 | 465 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
466 |
_build_docks_depot_widgets, |
|
467 |
}; |
|
468 |
||
469 |
||
9338
3d6f9ddd431d
(svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents:
9327
diff
changeset
|
470 |
static void ShowBuildDocksDepotPicker(Window *parent) |
0 | 471 |
{ |
9338
3d6f9ddd431d
(svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents:
9327
diff
changeset
|
472 |
new BuildDocksDepotWindow(&_build_docks_depot_desc, parent); |
0 | 473 |
} |
474 |
||
475 |
||
6247 | 476 |
void InitializeDockGui() |
0 | 477 |
{ |
3157
3f35e2d9c8e3
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
2952
diff
changeset
|
478 |
_ship_depot_direction = AXIS_X; |
0 | 479 |
} |