author | miham |
Tue, 15 Jul 2008 23:27:28 +0000 | |
changeset 11149 | f3ff534dded8 |
parent 11071 | 91ac7664ad1e |
child 11161 | 7d0fac8f14cd |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
10429
1b99254f9607
(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:
10397
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" |
8604
8afdd9877afd
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents:
8603
diff
changeset
|
7 |
#include "tile_map.h" |
9282
2bb9703aeb39
(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:
9069
diff
changeset
|
8 |
#include "station_type.h" |
0 | 9 |
#include "gui.h" |
8701
051036216675
(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:
8653
diff
changeset
|
10 |
#include "terraform_gui.h" |
8603
88c5ce6a5215
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8602
diff
changeset
|
11 |
#include "window_gui.h" |
88c5ce6a5215
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8602
diff
changeset
|
12 |
#include "station_gui.h" |
8612
6414fc21c2f3
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
8604
diff
changeset
|
13 |
#include "command_func.h" |
8766
c86cfa3a7580
(svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents:
8760
diff
changeset
|
14 |
#include "settings_type.h" |
8444
9317090e9c8c
(svn r11504) -Fix [FS#1467]: removing docks/ship depots could result in non-canal water where canals should have been build.
rubidium
parents:
8385
diff
changeset
|
15 |
#include "water.h" |
8627
448ebf3a8291
(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:
8617
diff
changeset
|
16 |
#include "window_func.h" |
8640
1e93b81e96d2
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents:
8635
diff
changeset
|
17 |
#include "vehicle_func.h" |
8653
a83f7a536919
(svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium
parents:
8640
diff
changeset
|
18 |
#include "sound_func.h" |
8720
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8701
diff
changeset
|
19 |
#include "viewport_func.h" |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8701
diff
changeset
|
20 |
#include "gfx_func.h" |
8750
fdd6054e7bae
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8733
diff
changeset
|
21 |
#include "player_func.h" |
8909
fa15e9afad2f
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8766
diff
changeset
|
22 |
#include "slope_func.h" |
10445
2dd7d9d0a957
(svn r12987) -Codechange: split viewport and tile selection.
rubidium
parents:
10441
diff
changeset
|
23 |
#include "tilehighlight_func.h" |
0 | 24 |
|
8760
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
25 |
#include "table/sprites.h" |
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
26 |
#include "table/strings.h" |
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
27 |
|
10686
8e02259158f3
(svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents:
10671
diff
changeset
|
28 |
static void ShowBuildDockStationPicker(Window *parent); |
8e02259158f3
(svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents:
10671
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 |
{ |
8017
8c46e61c510f
(svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents:
7837
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 |
{ |
8017
8c46e61c510f
(svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents:
7837
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 |
{ |
8017
8c46e61c510f
(svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents:
7837
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 |
{ |
11071
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
64 |
VpStartPlaceSizing(tile, (_game_mode == GM_EDITOR) ? VPM_X_AND_Y : 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 |
{ |
8017
8c46e61c510f
(svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents:
7837
diff
changeset
|
69 |
DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_LOCK | CMD_MSG(STR_CANT_BUILD_LOCKS)); |
0 | 70 |
} |
71 |
||
11071
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
72 |
static void PlaceDocks_BuildRiver(TileIndex tile) |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
73 |
{ |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
74 |
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CREATE_RIVER); |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
75 |
} |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
76 |
|
10926
e46c48440dbc
(svn r13479) -Codechange: don't use word 'bridge' for aqueducts that often
smatz
parents:
10913
diff
changeset
|
77 |
static void PlaceDocks_Aqueduct(TileIndex tile) |
10913
af60a6eda0a0
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium
parents:
10775
diff
changeset
|
78 |
{ |
af60a6eda0a0
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium
parents:
10775
diff
changeset
|
79 |
VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_BUILD_BRIDGE); |
af60a6eda0a0
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium
parents:
10775
diff
changeset
|
80 |
} |
af60a6eda0a0
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium
parents:
10775
diff
changeset
|
81 |
|
af60a6eda0a0
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium
parents:
10775
diff
changeset
|
82 |
|
10671
dec6e7c78066
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
10641
diff
changeset
|
83 |
/** Enum referring to the widgets of the build dock toolbar */ |
dec6e7c78066
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
10641
diff
changeset
|
84 |
enum DockToolbarWidgets { |
dec6e7c78066
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
10641
diff
changeset
|
85 |
DTW_BEGIN = 0, ///< Start of toolbar widgets |
dec6e7c78066
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
10641
diff
changeset
|
86 |
DTW_CLOSEBOX = DTW_BEGIN, ///< Close window button |
dec6e7c78066
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
10641
diff
changeset
|
87 |
DTW_CAPTION, ///< Window caption |
dec6e7c78066
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
10641
diff
changeset
|
88 |
DTW_STICKY, ///< Sticky window button |
dec6e7c78066
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
10641
diff
changeset
|
89 |
DTW_BUTTONS_BEGIN, ///< Begin of clickable buttons (except seperating panel) |
dec6e7c78066
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
10641
diff
changeset
|
90 |
DTW_CANAL = DTW_BUTTONS_BEGIN, ///< Build canal button |
dec6e7c78066
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
10641
diff
changeset
|
91 |
DTW_LOCK, ///< Build lock button |
dec6e7c78066
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
10641
diff
changeset
|
92 |
DTW_SEPERATOR, ///< Seperating panel between lock and demolish |
dec6e7c78066
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
10641
diff
changeset
|
93 |
DTW_DEMOLISH, ///< Demolish aka dynamite button |
dec6e7c78066
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
10641
diff
changeset
|
94 |
DTW_DEPOT, ///< Build depot button |
dec6e7c78066
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
10641
diff
changeset
|
95 |
DTW_STATION, ///< Build station button |
dec6e7c78066
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
10641
diff
changeset
|
96 |
DTW_BUOY, ///< Build buoy button |
11071
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
97 |
DTW_RIVER, ///< Build river button (in scenario editor) |
10926
e46c48440dbc
(svn r13479) -Codechange: don't use word 'bridge' for aqueducts that often
smatz
parents:
10913
diff
changeset
|
98 |
DTW_BUILD_AQUEDUCT, ///< Build aqueduct button |
10671
dec6e7c78066
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
10641
diff
changeset
|
99 |
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
|
100 |
}; |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
101 |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
102 |
|
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
103 |
static void BuildDocksClick_Canal(Window *w) |
0 | 104 |
{ |
11071
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
105 |
|
8385
aedd7656cfd1
(svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents:
8017
diff
changeset
|
106 |
HandlePlacePushButton(w, DTW_CANAL, SPR_CURSOR_CANAL, VHM_RECT, PlaceDocks_BuildCanal); |
0 | 107 |
} |
108 |
||
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
109 |
static void BuildDocksClick_Lock(Window *w) |
0 | 110 |
{ |
8385
aedd7656cfd1
(svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents:
8017
diff
changeset
|
111 |
HandlePlacePushButton(w, DTW_LOCK, SPR_CURSOR_LOCK, VHM_RECT, PlaceDocks_BuildLock); |
0 | 112 |
} |
113 |
||
114 |
static void BuildDocksClick_Demolish(Window *w) |
|
115 |
{ |
|
10441
09655ce4bfa3
(svn r12983) -Codechange [FS#1987] : Unification of all dynamite tools calls to only one. Thanks to Roujin
belugas
parents:
10434
diff
changeset
|
116 |
HandlePlacePushButton(w, DTW_DEMOLISH, ANIMCURSOR_DEMOLISH, VHM_RECT, PlaceProc_DemolishArea); |
0 | 117 |
} |
118 |
||
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
119 |
static void BuildDocksClick_Depot(Window *w) |
0 | 120 |
{ |
7582
9f23c01ae23d
(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:
7325
diff
changeset
|
121 |
if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return; |
10686
8e02259158f3
(svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents:
10671
diff
changeset
|
122 |
if (HandlePlacePushButton(w, DTW_DEPOT, SPR_CURSOR_SHIP_DEPOT, VHM_RECT, PlaceDocks_Depot)) ShowBuildDocksDepotPicker(w); |
0 | 123 |
} |
124 |
||
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
125 |
static void BuildDocksClick_Dock(Window *w) |
0 | 126 |
{ |
7582
9f23c01ae23d
(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:
7325
diff
changeset
|
127 |
if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return; |
10686
8e02259158f3
(svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents:
10671
diff
changeset
|
128 |
if (HandlePlacePushButton(w, DTW_STATION, SPR_CURSOR_DOCK, VHM_SPECIAL, PlaceDocks_Dock)) ShowBuildDockStationPicker(w); |
0 | 129 |
} |
130 |
||
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
131 |
static void BuildDocksClick_Buoy(Window *w) |
0 | 132 |
{ |
7582
9f23c01ae23d
(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:
7325
diff
changeset
|
133 |
if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return; |
8385
aedd7656cfd1
(svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents:
8017
diff
changeset
|
134 |
HandlePlacePushButton(w, DTW_BUOY, SPR_CURSOR_BOUY, VHM_RECT, PlaceDocks_Buoy); |
0 | 135 |
} |
136 |
||
11071
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
137 |
static void BuildDocksClick_River(Window *w) |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
138 |
{ |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
139 |
if (_game_mode != GM_EDITOR) return; |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
140 |
HandlePlacePushButton(w, DTW_RIVER, SPR_CURSOR_RIVER, VHM_RECT, PlaceDocks_BuildRiver); |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
141 |
} |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
142 |
|
10926
e46c48440dbc
(svn r13479) -Codechange: don't use word 'bridge' for aqueducts that often
smatz
parents:
10913
diff
changeset
|
143 |
static void BuildDocksClick_Aqueduct(Window *w) |
10913
af60a6eda0a0
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium
parents:
10775
diff
changeset
|
144 |
{ |
10937 | 145 |
HandlePlacePushButton(w, DTW_BUILD_AQUEDUCT, SPR_CURSOR_AQUEDUCT, VHM_RECT, PlaceDocks_Aqueduct); |
10913
af60a6eda0a0
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium
parents:
10775
diff
changeset
|
146 |
} |
af60a6eda0a0
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium
parents:
10775
diff
changeset
|
147 |
|
0 | 148 |
|
149 |
typedef void OnButtonClick(Window *w); |
|
150 |
static OnButtonClick * const _build_docks_button_proc[] = { |
|
151 |
BuildDocksClick_Canal, |
|
152 |
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
|
153 |
NULL, |
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
154 |
BuildDocksClick_Demolish, |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
155 |
BuildDocksClick_Depot, |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
156 |
BuildDocksClick_Dock, |
10913
af60a6eda0a0
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium
parents:
10775
diff
changeset
|
157 |
BuildDocksClick_Buoy, |
11071
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
158 |
BuildDocksClick_River, |
10926
e46c48440dbc
(svn r13479) -Codechange: don't use word 'bridge' for aqueducts that often
smatz
parents:
10913
diff
changeset
|
159 |
BuildDocksClick_Aqueduct |
0 | 160 |
}; |
161 |
||
10627
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
162 |
struct BuildDocksToolbarWindow : Window { |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
163 |
BuildDocksToolbarWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
164 |
{ |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
165 |
this->FindWindowPlacementAndResize(desc); |
10775
7061477bfbcf
(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:
10703
diff
changeset
|
166 |
if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this); |
0 | 167 |
} |
168 |
||
10627
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
169 |
~BuildDocksToolbarWindow() |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
170 |
{ |
10775
7061477bfbcf
(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:
10703
diff
changeset
|
171 |
if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0); |
10627
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
172 |
} |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
173 |
|
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
174 |
virtual void OnPaint() |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
175 |
{ |
10671
dec6e7c78066
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
10641
diff
changeset
|
176 |
this->SetWidgetsDisabledState(!CanBuildVehicleInfrastructure(VEH_SHIP), DTW_DEPOT, DTW_STATION, DTW_BUOY, WIDGET_LIST_END); |
10627
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
177 |
this->DrawWidgets(); |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
178 |
} |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
179 |
|
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
180 |
virtual void OnClick(Point pt, int widget) |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
181 |
{ |
10671
dec6e7c78066
(svn r13215) -Codechange [FS#2029]: enumify and comment Build Dock widgets (Roujin)
smatz
parents:
10641
diff
changeset
|
182 |
if (widget >= DTW_BUTTONS_BEGIN && widget != DTW_SEPERATOR) _build_docks_button_proc[widget - DTW_BUTTONS_BEGIN](this); |
10627
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
183 |
} |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
184 |
|
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
185 |
virtual EventState OnKeyPress(uint16 key, uint16 keycode) |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
186 |
{ |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
187 |
switch (keycode) { |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
188 |
case '1': BuildDocksClick_Canal(this); break; |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
189 |
case '2': BuildDocksClick_Lock(this); break; |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
190 |
case '3': BuildDocksClick_Demolish(this); break; |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
191 |
case '4': BuildDocksClick_Depot(this); break; |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
192 |
case '5': BuildDocksClick_Dock(this); break; |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
193 |
case '6': BuildDocksClick_Buoy(this); break; |
11071
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
194 |
case '7': BuildDocksClick_River(this); break; |
10928
e88d40758667
(svn r13481) -Codechange: add 'B' keyboard shortcut to build aqueduct (planetmaker)
smatz
parents:
10926
diff
changeset
|
195 |
case 'B': |
11071
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
196 |
case '8': BuildDocksClick_Aqueduct(this); break; |
10627
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
197 |
default: return ES_NOT_HANDLED; |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
198 |
} |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
199 |
return ES_HANDLED; |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
200 |
} |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
201 |
|
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
202 |
virtual void OnPlaceObject(Point pt, TileIndex tile) |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
203 |
{ |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
204 |
_place_proc(tile); |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
205 |
} |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
206 |
|
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
207 |
virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
208 |
{ |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
209 |
VpSelectTilesWithMethod(pt.x, pt.y, select_method); |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
210 |
} |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
211 |
|
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
212 |
virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
213 |
{ |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
214 |
if (pt.x != -1) { |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
215 |
switch (select_proc) { |
10913
af60a6eda0a0
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium
parents:
10775
diff
changeset
|
216 |
case DDSP_BUILD_BRIDGE: |
af60a6eda0a0
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium
parents:
10775
diff
changeset
|
217 |
ResetObjectToPlace(); |
af60a6eda0a0
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium
parents:
10775
diff
changeset
|
218 |
extern void CcBuildBridge(bool success, TileIndex tile, uint32 p1, uint32 p2); |
10926
e46c48440dbc
(svn r13479) -Codechange: don't use word 'bridge' for aqueducts that often
smatz
parents:
10913
diff
changeset
|
219 |
DoCommandP(end_tile, start_tile, TRANSPORT_WATER << 15, CcBuildBridge, CMD_BUILD_BRIDGE | CMD_MSG(STR_CAN_T_BUILD_AQUEDUCT_HERE)); |
10913
af60a6eda0a0
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium
parents:
10775
diff
changeset
|
220 |
|
7166
3937d5ea59df
(svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents:
7165
diff
changeset
|
221 |
case DDSP_DEMOLISH_AREA: |
10627
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
222 |
GUIPlaceProcDragXY(select_proc, start_tile, end_tile); |
7165
37eb253f3c06
(svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents:
6987
diff
changeset
|
223 |
break; |
7166
3937d5ea59df
(svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents:
7165
diff
changeset
|
224 |
case DDSP_CREATE_WATER: |
11071
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
225 |
DoCommandP(end_tile, start_tile, (_game_mode == GM_EDITOR ? _ctrl_pressed : 0), CcBuildCanal, CMD_BUILD_CANAL | CMD_MSG(STR_CANT_BUILD_CANALS)); |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
226 |
break; |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
227 |
case DDSP_CREATE_RIVER: |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
228 |
DoCommandP(end_tile, start_tile, 2, CcBuildCanal, CMD_BUILD_CANAL | CMD_MSG(STR_CANT_PLACE_RIVERS)); |
7165
37eb253f3c06
(svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents:
6987
diff
changeset
|
229 |
break; |
10627
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
230 |
|
7165
37eb253f3c06
(svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents:
6987
diff
changeset
|
231 |
default: break; |
2549 | 232 |
} |
0 | 233 |
} |
10627
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
234 |
} |
0 | 235 |
|
10627
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
236 |
virtual void OnPlaceObjectAbort() |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
237 |
{ |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
238 |
this->RaiseButtons(); |
0 | 239 |
|
10560
0cf0a95ebaf9
(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:
10481
diff
changeset
|
240 |
delete FindWindowById(WC_BUILD_STATION, 0); |
0cf0a95ebaf9
(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:
10481
diff
changeset
|
241 |
delete FindWindowById(WC_BUILD_DEPOT, 0); |
10627
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
242 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
243 |
|
10627
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
244 |
virtual void OnPlacePresize(Point pt, TileIndex tile_from) |
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
245 |
{ |
8909
fa15e9afad2f
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8766
diff
changeset
|
246 |
DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile_from, NULL)); |
10627
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
247 |
TileIndex tile_to = (dir != INVALID_DIAGDIR ? TileAddByDiagDir(tile_from, ReverseDiagDir(dir)) : tile_from); |
8909
fa15e9afad2f
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8766
diff
changeset
|
248 |
|
0 | 249 |
VpSetPresizeRange(tile_from, tile_to); |
250 |
} |
|
10627
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
251 |
}; |
0 | 252 |
|
253 |
static const Widget _build_docks_toolb_widgets[] = { |
|
11071
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
254 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // DTW_CLOSEBOX |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
255 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_9801_WATERWAYS_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // DTW_CAPTION |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
256 |
{ WWT_STICKYBOX, RESIZE_NONE, 7, 148, 159, 0, 13, 0x0, STR_STICKY_BUTTON}, // DTW_STICKY |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
257 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_BUILD_CANAL, STR_BUILD_CANALS_TIP}, // DTW_CANAL |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
258 |
{ 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
|
259 |
|
11071
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
260 |
{ WWT_PANEL, RESIZE_NONE, 7, 44, 48, 14, 35, 0x0, STR_NULL}, // DTW_SEPERATOR |
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
261 |
|
11071
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
262 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 49, 70, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC}, // DTW_DEMOLISH |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
263 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 71, 92, 14, 35, SPR_IMG_SHIP_DEPOT, STR_981E_BUILD_SHIP_DEPOT_FOR_BUILDING}, // DTW_DEPOT |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
264 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 93, 114, 14, 35, SPR_IMG_SHIP_DOCK, STR_981D_BUILD_SHIP_DOCK}, // DTW_STATION |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
265 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 115, 136, 14, 35, SPR_IMG_BOUY, STR_9834_POSITION_BUOY_WHICH_CAN}, // DTW_BUOY |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
266 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, // DTW_RIVER |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
267 |
{ 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
|
268 |
{ WIDGETS_END}, |
0 | 269 |
}; |
270 |
||
271 |
static const WindowDesc _build_docks_toolbar_desc = { |
|
11071
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
272 |
WDP_ALIGN_TBR, 22, 160, 36, 160, 36, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6111
diff
changeset
|
273 |
WC_BUILD_TOOLBAR, WC_NONE, |
756
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
750
diff
changeset
|
274 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, |
0 | 275 |
_build_docks_toolb_widgets, |
276 |
}; |
|
277 |
||
6573 | 278 |
void ShowBuildDocksToolbar() |
0 | 279 |
{ |
5005
21e84e53c732
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4994
diff
changeset
|
280 |
if (!IsValidPlayer(_current_player)) return; |
21e84e53c732
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4994
diff
changeset
|
281 |
|
10397
84e97769583b
(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:
9342
diff
changeset
|
282 |
DeleteWindowByClass(WC_BUILD_TOOLBAR); |
10627
641632e80093
(svn r13171) -Codechange: make a class of the Build[Air|Rail|Road|Dock]ToolbarWindows.
rubidium
parents:
10616
diff
changeset
|
283 |
AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_toolbar_desc, TRANSPORT_WATER); |
0 | 284 |
} |
285 |
||
11071
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
286 |
/* Widget definition for the build docks in scenario editor window */ |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
287 |
static const Widget _build_docks_scen_toolb_widgets[] = { |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
288 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // DTW_CLOSEBOX |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
289 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 102, 0, 13, STR_9801_WATERWAYS_CONSTRUCTION_SE, STR_018C_WINDOW_TITLE_DRAG_THIS}, // DTW_CAPTION |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
290 |
{ WWT_STICKYBOX, RESIZE_NONE, 7, 103, 114, 0, 13, 0x0, STR_STICKY_BUTTON}, // DTW_STICKY |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
291 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_BUILD_CANAL, STR_CREATE_LAKE}, // DTW_CANAL |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
292 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_BUILD_LOCK, STR_BUILD_LOCKS_TIP}, // DTW_LOCK |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
293 |
|
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
294 |
{ WWT_PANEL, RESIZE_NONE, 7, 44, 48, 14, 35, 0x0, STR_NULL}, // DTW_SEPERATOR |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
295 |
|
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
296 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 49, 70, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC}, // DTW_DEMOLISH |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
297 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, // DTW_DEPOT |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
298 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, // DTW_STATION |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
299 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, // DTW_BUOY |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
300 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 71, 92, 14, 35, SPR_IMG_BUILD_RIVER, STR_CREATE_RIVER}, // DTW_RIVER |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
301 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 93, 114, 14, 35, SPR_IMG_AQUEDUCT, STR_BUILD_AQUEDUCT}, // DTW_BUILD_AQUEDUCT |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
302 |
{ WIDGETS_END}, |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
303 |
}; |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
304 |
|
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
305 |
/* Window definition for the build docks in scenario editor window */ |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
306 |
static const WindowDesc _build_docks_scen_toolbar_desc = { |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
307 |
WDP_AUTO, WDP_AUTO, 115, 36, 115, 36, |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
308 |
WC_SCEN_BUILD_TOOLBAR, WC_NONE, |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
309 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
310 |
_build_docks_scen_toolb_widgets, |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
311 |
}; |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
312 |
|
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
313 |
void ShowBuildDocksScenToolbar() |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
314 |
{ |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
315 |
AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_scen_toolbar_desc, TRANSPORT_WATER); |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
316 |
} |
91ac7664ad1e
(svn r13628) -Feature: enable building of aqueducts in the scenario editor
skidd13
parents:
10937
diff
changeset
|
317 |
|
10601
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
318 |
struct BuildDocksStationWindow : public PickerWindowBase { |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
319 |
private: |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
320 |
enum BuildDockStationWidgets { |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
321 |
BDSW_CLOSE, |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
322 |
BDSW_CAPTION, |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
323 |
BDSW_BACKGROUND, |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
324 |
BDSW_LT_OFF, |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
325 |
BDSW_LT_ON, |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
326 |
BDSW_INFO, |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
327 |
}; |
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4634
diff
changeset
|
328 |
|
10601
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
329 |
public: |
10686
8e02259158f3
(svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents:
10671
diff
changeset
|
330 |
BuildDocksStationWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) |
10601
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
331 |
{ |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
332 |
this->LowerWidget(_station_show_coverage + BDSW_LT_OFF); |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
333 |
this->FindWindowPlacementAndResize(desc); |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
334 |
} |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
335 |
|
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
336 |
virtual void OnPaint() |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
337 |
{ |
10775
7061477bfbcf
(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:
10703
diff
changeset
|
338 |
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
|
339 |
|
10601
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
340 |
this->DrawWidgets(); |
2631
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2619
diff
changeset
|
341 |
|
7325
e49df6ba88e7
(svn r10068) -Fix [FS#835]: coverage area highlight was still show when it was turned off for docks.
rubidium
parents:
7170
diff
changeset
|
342 |
if (_station_show_coverage) { |
e49df6ba88e7
(svn r10068) -Fix [FS#835]: coverage area highlight was still show when it was turned off for docks.
rubidium
parents:
7170
diff
changeset
|
343 |
SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); |
e49df6ba88e7
(svn r10068) -Fix [FS#835]: coverage area highlight was still show when it was turned off for docks.
rubidium
parents:
7170
diff
changeset
|
344 |
} else { |
e49df6ba88e7
(svn r10068) -Fix [FS#835]: coverage area highlight was still show when it was turned off for docks.
rubidium
parents:
7170
diff
changeset
|
345 |
SetTileSelectSize(1, 1); |
e49df6ba88e7
(svn r10068) -Fix [FS#835]: coverage area highlight was still show when it was turned off for docks.
rubidium
parents:
7170
diff
changeset
|
346 |
} |
713
5b0be616ee1e
(svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents:
679
diff
changeset
|
347 |
|
9342
ca61cbfca47a
(svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents:
9282
diff
changeset
|
348 |
int text_end = DrawStationCoverageAreaText(4, 50, SCT_ALL, rad, false); |
ca61cbfca47a
(svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents:
9282
diff
changeset
|
349 |
text_end = DrawStationCoverageAreaText(4, text_end + 4, SCT_ALL, rad, true) + 4; |
10601
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
350 |
if (text_end != this->widget[BDSW_BACKGROUND].bottom) { |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
351 |
this->SetDirty(); |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
352 |
ResizeWindowForWidget(this, 2, 0, text_end - this->widget[BDSW_BACKGROUND].bottom); |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
353 |
this->SetDirty(); |
8919
b627c71f9cc3
(svn r11993) -Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long.
peter1138
parents:
8909
diff
changeset
|
354 |
} |
2639 | 355 |
} |
0 | 356 |
|
10601
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
357 |
virtual void OnClick(Point pt, int widget) |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
358 |
{ |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
359 |
switch (widget) { |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
360 |
case BDSW_LT_OFF: |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
361 |
case BDSW_LT_ON: |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
362 |
this->RaiseWidget(_station_show_coverage + BDSW_LT_OFF); |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
363 |
_station_show_coverage = (widget != BDSW_LT_OFF); |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
364 |
this->LowerWidget(_station_show_coverage + BDSW_LT_OFF); |
2639 | 365 |
SndPlayFx(SND_15_BEEP); |
10601
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
366 |
this->SetDirty(); |
2639 | 367 |
break; |
0 | 368 |
} |
10601
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
369 |
} |
0 | 370 |
|
10601
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
371 |
virtual void OnTick() |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
372 |
{ |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
373 |
CheckRedrawStationCoverage(this); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
374 |
} |
10601
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
375 |
}; |
0 | 376 |
|
377 |
static const Widget _build_dock_station_widgets[] = { |
|
10601
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
378 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // BDSW_CLOSE |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
379 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_3068_DOCK, STR_018C_WINDOW_TITLE_DRAG_THIS}, // BDSW_CAPTION |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
380 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 147, 14, 74, 0x0, STR_NULL}, // BDSW_BACKGROUND |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
381 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 14, 73, 30, 40, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE}, // BDSW_LT_OFF |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
382 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 74, 133, 30, 40, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA}, // BDSW_LT_ON |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
383 |
{ 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
|
384 |
{ WIDGETS_END}, |
0 | 385 |
}; |
386 |
||
387 |
static const WindowDesc _build_dock_station_desc = { |
|
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7737
diff
changeset
|
388 |
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
|
389 |
WC_BUILD_STATION, WC_BUILD_TOOLBAR, |
0 | 390 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
391 |
_build_dock_station_widgets, |
|
392 |
}; |
|
393 |
||
10686
8e02259158f3
(svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents:
10671
diff
changeset
|
394 |
static void ShowBuildDockStationPicker(Window *parent) |
0 | 395 |
{ |
10686
8e02259158f3
(svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents:
10671
diff
changeset
|
396 |
new BuildDocksStationWindow(&_build_dock_station_desc, parent); |
0 | 397 |
} |
398 |
||
10601
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
399 |
struct BuildDocksDepotWindow : public PickerWindowBase { |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
400 |
private: |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
401 |
enum BuildDockDepotWidgets { |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
402 |
BDDW_CLOSE, |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
403 |
BDDW_CAPTION, |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
404 |
BDDW_BACKGROUND, |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
405 |
BDDW_X, |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
406 |
BDDW_Y, |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
407 |
}; |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
408 |
|
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
409 |
static void UpdateDocksDirection() |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
410 |
{ |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
411 |
if (_ship_depot_direction != AXIS_X) { |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
412 |
SetTileSelectSize(1, 2); |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
413 |
} else { |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
414 |
SetTileSelectSize(2, 1); |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
415 |
} |
0 | 416 |
} |
417 |
||
10601
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
418 |
public: |
10686
8e02259158f3
(svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents:
10671
diff
changeset
|
419 |
BuildDocksDepotWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) |
10601
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
420 |
{ |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
421 |
this->LowerWidget(_ship_depot_direction + BDDW_X); |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
422 |
UpdateDocksDirection(); |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
423 |
this->FindWindowPlacementAndResize(desc); |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
424 |
} |
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4634
diff
changeset
|
425 |
|
10601
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
426 |
virtual void OnPaint() |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
427 |
{ |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
428 |
this->DrawWidgets(); |
0 | 429 |
|
430 |
DrawShipDepotSprite(67, 35, 0); |
|
431 |
DrawShipDepotSprite(35, 51, 1); |
|
432 |
DrawShipDepotSprite(135, 35, 2); |
|
433 |
DrawShipDepotSprite(167, 51, 3); |
|
10601
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
434 |
} |
0 | 435 |
|
10601
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
436 |
virtual void OnClick(Point pt, int widget) |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
437 |
{ |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
438 |
switch (widget) { |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
439 |
case BDDW_X: |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
440 |
case BDDW_Y: |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
441 |
this->RaiseWidget(_ship_depot_direction + BDDW_X); |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
442 |
_ship_depot_direction = (widget == BDDW_X ? AXIS_X : AXIS_Y); |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
443 |
this->LowerWidget(_ship_depot_direction + BDDW_X); |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
444 |
SndPlayFx(SND_15_BEEP); |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
445 |
UpdateDocksDirection(); |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
446 |
this->SetDirty(); |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
447 |
break; |
0 | 448 |
} |
449 |
} |
|
10601
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
450 |
}; |
0 | 451 |
|
452 |
static const Widget _build_docks_depot_widgets[] = { |
|
10601
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
453 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // BDDW_CLOSE |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
454 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 203, 0, 13, STR_3800_SHIP_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // BDDW_CAPTION |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
455 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 203, 14, 85, 0x0, STR_NULL}, // BDDW_BACKGROUND |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
456 |
{ WWT_PANEL, RESIZE_NONE, 14, 3, 100, 17, 82, 0x0, STR_3803_SELECT_SHIP_DEPOT_ORIENTATION}, // BDDW_X |
c843d0e06015
(svn r13145) -Codechange: make classes of the BuildDocks[Depot|Station]Window.
glx
parents:
10595
diff
changeset
|
457 |
{ 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
|
458 |
{ WIDGETS_END}, |
0 | 459 |
}; |
460 |
||
461 |
static const WindowDesc _build_docks_depot_desc = { |
|
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7737
diff
changeset
|
462 |
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
|
463 |
WC_BUILD_DEPOT, WC_BUILD_TOOLBAR, |
0 | 464 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
465 |
_build_docks_depot_widgets, |
|
466 |
}; |
|
467 |
||
468 |
||
10686
8e02259158f3
(svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents:
10671
diff
changeset
|
469 |
static void ShowBuildDocksDepotPicker(Window *parent) |
0 | 470 |
{ |
10686
8e02259158f3
(svn r13230) -Fix [FS#2030](r13171): When closing toolbars, also close their PickerWindows.
frosch
parents:
10671
diff
changeset
|
471 |
new BuildDocksDepotWindow(&_build_docks_depot_desc, parent); |
0 | 472 |
} |
473 |
||
474 |
||
6573 | 475 |
void InitializeDockGui() |
0 | 476 |
{ |
3157
40de8616c04c
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
2952
diff
changeset
|
477 |
_ship_depot_direction = AXIS_X; |
0 | 478 |
} |