author | glx |
Sun, 08 Oct 2006 19:31:01 +0000 | |
changeset 4777 | bab9aa91c186 |
parent 4719 | fc6e14219f72 |
child 4848 | 45f848b46222 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1632
diff
changeset
|
4 |
#include "openttd.h" |
1363
775a7ee52369
(svn r1867) Include tables/sprites.h only in files which need it
tron
parents:
1116
diff
changeset
|
5 |
#include "table/sprites.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
337
diff
changeset
|
6 |
#include "table/strings.h" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
7 |
#include "functions.h" |
679
04ca2cd69420
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
606
diff
changeset
|
8 |
#include "map.h" |
0 | 9 |
#include "window.h" |
568
b0d0df062880
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
10 |
#include "station.h" |
0 | 11 |
#include "gui.h" |
12 |
#include "viewport.h" |
|
13 |
#include "gfx.h" |
|
337
cbe0c766c947
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
14 |
#include "sound.h" |
0 | 15 |
#include "command.h" |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
1981
diff
changeset
|
16 |
#include "variables.h" |
0 | 17 |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1072
diff
changeset
|
18 |
static void ShowBuildDockStationPicker(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1072
diff
changeset
|
19 |
static void ShowBuildDocksDepotPicker(void); |
0 | 20 |
|
3157
3f35e2d9c8e3
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
2952
diff
changeset
|
21 |
static Axis _ship_depot_direction; |
0 | 22 |
|
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
23 |
void CcBuildDocks(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 24 |
{ |
25 |
if (success) { |
|
541 | 26 |
SndPlayTileFx(SND_02_SPLAT, tile); |
0 | 27 |
ResetObjectToPlace(); |
28 |
} |
|
29 |
} |
|
30 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
31 |
void CcBuildCanal(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 32 |
{ |
541 | 33 |
if (success) SndPlayTileFx(SND_02_SPLAT, tile); |
0 | 34 |
} |
35 |
||
36 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
37 |
static void PlaceDocks_Dock(TileIndex tile) |
0 | 38 |
{ |
39 |
DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_DOCK | CMD_AUTO | CMD_MSG(STR_9802_CAN_T_BUILD_DOCK_HERE)); |
|
40 |
} |
|
41 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
42 |
static void PlaceDocks_Depot(TileIndex tile) |
0 | 43 |
{ |
44 |
DoCommandP(tile, _ship_depot_direction, 0, CcBuildDocks, CMD_BUILD_SHIP_DEPOT | CMD_AUTO | CMD_MSG(STR_3802_CAN_T_BUILD_SHIP_DEPOT)); |
|
45 |
} |
|
46 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
47 |
static void PlaceDocks_Buoy(TileIndex tile) |
0 | 48 |
{ |
49 |
DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_BUOY | CMD_AUTO | CMD_MSG(STR_9835_CAN_T_POSITION_BUOY_HERE)); |
|
50 |
} |
|
51 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
52 |
static void PlaceDocks_DemolishArea(TileIndex tile) |
0 | 53 |
{ |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
54 |
VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_DemolishArea); |
0 | 55 |
} |
56 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
57 |
static void PlaceDocks_BuildCanal(TileIndex tile) |
0 | 58 |
{ |
59 |
VpStartPlaceSizing(tile, VPM_X_OR_Y); |
|
60 |
} |
|
61 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
62 |
static void PlaceDocks_BuildLock(TileIndex tile) |
0 | 63 |
{ |
64 |
DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_LOCK | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_LOCKS)); |
|
65 |
} |
|
66 |
||
67 |
||
606
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
68 |
static void BuildDocksClick_Canal(Window *w) |
0 | 69 |
{ |
1914
2b4b3c3a95b4
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
70 |
HandlePlacePushButton(w, 3, SPR_CURSOR_CANAL, 1, PlaceDocks_BuildCanal); |
0 | 71 |
} |
72 |
||
606
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
73 |
static void BuildDocksClick_Lock(Window *w) |
0 | 74 |
{ |
1914
2b4b3c3a95b4
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
75 |
HandlePlacePushButton(w, 4, SPR_CURSOR_LOCK, 1, PlaceDocks_BuildLock); |
0 | 76 |
} |
77 |
||
78 |
static void BuildDocksClick_Demolish(Window *w) |
|
79 |
{ |
|
756
b76998029c12
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
750
diff
changeset
|
80 |
HandlePlacePushButton(w, 6, ANIMCURSOR_DEMOLISH, 1, PlaceDocks_DemolishArea); |
0 | 81 |
} |
82 |
||
606
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
83 |
static void BuildDocksClick_Depot(Window *w) |
0 | 84 |
{ |
1914
2b4b3c3a95b4
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
85 |
if (HandlePlacePushButton(w, 7, SPR_CURSOR_SHIP_DEPOT, 1, PlaceDocks_Depot)) ShowBuildDocksDepotPicker(); |
0 | 86 |
} |
87 |
||
606
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
88 |
static void BuildDocksClick_Dock(Window *w) |
0 | 89 |
{ |
606
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
90 |
|
1914
2b4b3c3a95b4
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
91 |
if (HandlePlacePushButton(w, 8, SPR_CURSOR_DOCK, 3, PlaceDocks_Dock)) ShowBuildDockStationPicker(); |
0 | 92 |
} |
93 |
||
606
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
94 |
static void BuildDocksClick_Buoy(Window *w) |
0 | 95 |
{ |
1914
2b4b3c3a95b4
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
96 |
HandlePlacePushButton(w, 9, SPR_CURSOR_BOUY, 1, PlaceDocks_Buoy); |
0 | 97 |
} |
98 |
||
606
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
99 |
static void BuildDocksClick_Landscaping(Window *w) |
0 | 100 |
{ |
606
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
101 |
ShowTerraformToolbar(); |
0 | 102 |
} |
103 |
||
104 |
typedef void OnButtonClick(Window *w); |
|
105 |
static OnButtonClick * const _build_docks_button_proc[] = { |
|
106 |
BuildDocksClick_Canal, |
|
107 |
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
|
108 |
NULL, |
606
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
109 |
BuildDocksClick_Demolish, |
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
110 |
BuildDocksClick_Depot, |
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
111 |
BuildDocksClick_Dock, |
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
112 |
BuildDocksClick_Buoy, |
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
113 |
BuildDocksClick_Landscaping, |
0 | 114 |
}; |
115 |
||
116 |
static void BuildDocksToolbWndProc(Window *w, WindowEvent *e) |
|
117 |
{ |
|
2952 | 118 |
switch (e->event) { |
0 | 119 |
case WE_PAINT: |
120 |
DrawWindowWidgets(w); |
|
121 |
break; |
|
122 |
||
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
|
123 |
case WE_CLICK: |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4539
diff
changeset
|
124 |
if (e->we.click.widget - 3 >= 0 && e->we.click.widget != 5) _build_docks_button_proc[e->we.click.widget - 3](w); |
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
|
125 |
break; |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
946
diff
changeset
|
126 |
|
2549 | 127 |
case WE_KEYPRESS: |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4539
diff
changeset
|
128 |
switch (e->we.keypress.keycode) { |
937
883afa491049
(svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents:
867
diff
changeset
|
129 |
case '1': BuildDocksClick_Canal(w); break; |
883afa491049
(svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents:
867
diff
changeset
|
130 |
case '2': BuildDocksClick_Lock(w); break; |
883afa491049
(svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents:
867
diff
changeset
|
131 |
case '3': BuildDocksClick_Demolish(w); break; |
883afa491049
(svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents:
867
diff
changeset
|
132 |
case '4': BuildDocksClick_Depot(w); break; |
883afa491049
(svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents:
867
diff
changeset
|
133 |
case '5': BuildDocksClick_Dock(w); break; |
883afa491049
(svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents:
867
diff
changeset
|
134 |
case '6': BuildDocksClick_Buoy(w); break; |
883afa491049
(svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents:
867
diff
changeset
|
135 |
case 'l': BuildDocksClick_Landscaping(w); break; |
2549 | 136 |
default: return; |
937
883afa491049
(svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents:
867
diff
changeset
|
137 |
} |
2549 | 138 |
break; |
0 | 139 |
|
140 |
case WE_PLACE_OBJ: |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4539
diff
changeset
|
141 |
_place_proc(e->we.place.tile); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
142 |
break; |
0 | 143 |
|
144 |
case WE_PLACE_DRAG: { |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4539
diff
changeset
|
145 |
VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.userdata); |
0 | 146 |
return; |
147 |
} |
|
148 |
||
149 |
case WE_PLACE_MOUSEUP: |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4539
diff
changeset
|
150 |
if (e->we.click.pt.x != -1) { |
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4539
diff
changeset
|
151 |
if ((e->we.place.userdata & 0xF) == VPM_X_AND_Y) { // dragged actions |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
152 |
GUIPlaceProcDragXY(e); |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4539
diff
changeset
|
153 |
} else if (e->we.place.userdata == VPM_X_OR_Y) { |
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4539
diff
changeset
|
154 |
DoCommandP(e->we.place.tile, e->we.place.starttile, _ctrl_pressed, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS)); |
2549 | 155 |
} |
0 | 156 |
} |
157 |
break; |
|
158 |
||
159 |
case WE_ABORT_PLACE_OBJ: |
|
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4634
diff
changeset
|
160 |
RaiseWindowButtons(w); |
0 | 161 |
|
162 |
w = FindWindowById(WC_BUILD_STATION, 0); |
|
2549 | 163 |
if (w != NULL) WP(w,def_d).close = true; |
0 | 164 |
|
165 |
w = FindWindowById(WC_BUILD_DEPOT, 0); |
|
2549 | 166 |
if (w != NULL) WP(w,def_d).close = true; |
0 | 167 |
break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
168 |
|
0 | 169 |
case WE_PLACE_PRESIZE: { |
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
170 |
TileIndex tile_from; |
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
171 |
TileIndex tile_to; |
0 | 172 |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4539
diff
changeset
|
173 |
tile_from = tile_to = e->we.place.tile; |
1981 | 174 |
switch (GetTileSlope(tile_from, NULL)) { |
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3157
diff
changeset
|
175 |
case SLOPE_SW: tile_to += TileDiffXY(-1, 0); break; |
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3157
diff
changeset
|
176 |
case SLOPE_SE: tile_to += TileDiffXY( 0, -1); break; |
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3157
diff
changeset
|
177 |
case SLOPE_NW: tile_to += TileDiffXY( 0, 1); break; |
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3157
diff
changeset
|
178 |
case SLOPE_NE: tile_to += TileDiffXY( 1, 0); break; |
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3157
diff
changeset
|
179 |
default: break; |
0 | 180 |
} |
181 |
VpSetPresizeRange(tile_from, tile_to); |
|
182 |
} break; |
|
2619
1b20d578a660
(svn r3157) - Feature: Added patch option to link the terraform toolbar to the rail, road, water and airport toolbars. If enabled, the terraform toolbar will open and close with those toolbars.
peter1138
parents:
2549
diff
changeset
|
183 |
|
1b20d578a660
(svn r3157) - Feature: Added patch option to link the terraform toolbar to the rail, road, water and airport toolbars. If enabled, the terraform toolbar will open and close with those toolbars.
peter1138
parents:
2549
diff
changeset
|
184 |
case WE_DESTROY: |
1b20d578a660
(svn r3157) - Feature: Added patch option to link the terraform toolbar to the rail, road, water and airport toolbars. If enabled, the terraform toolbar will open and close with those toolbars.
peter1138
parents:
2549
diff
changeset
|
185 |
if (_patches.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0); |
1b20d578a660
(svn r3157) - Feature: Added patch option to link the terraform toolbar to the rail, road, water and airport toolbars. If enabled, the terraform toolbar will open and close with those toolbars.
peter1138
parents:
2549
diff
changeset
|
186 |
break; |
0 | 187 |
} |
188 |
} |
|
189 |
||
190 |
static const Widget _build_docks_toolb_widgets[] = { |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4087
diff
changeset
|
191 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4087
diff
changeset
|
192 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 145, 0, 13, STR_9801_DOCK_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4087
diff
changeset
|
193 |
{ WWT_STICKYBOX, RESIZE_NONE, 7, 146, 157, 0, 13, 0x0, STR_STICKY_BUTTON}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4087
diff
changeset
|
194 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_BUILD_CANAL, STR_BUILD_CANALS_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4087
diff
changeset
|
195 |
{ WWT_PANEL, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_BUILD_LOCK, STR_BUILD_LOCKS_TIP}, |
606
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
196 |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4087
diff
changeset
|
197 |
{ WWT_PANEL, RESIZE_NONE, 7, 44, 47, 14, 35, 0x0, STR_NULL}, |
606
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
198 |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4087
diff
changeset
|
199 |
{ WWT_PANEL, RESIZE_NONE, 7, 48, 69, 14, 35, 703, STR_018D_DEMOLISH_BUILDINGS_ETC}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4087
diff
changeset
|
200 |
{ WWT_PANEL, RESIZE_NONE, 7, 70, 91, 14, 35, 748, STR_981E_BUILD_SHIP_DEPOT_FOR_BUILDING}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4087
diff
changeset
|
201 |
{ WWT_PANEL, RESIZE_NONE, 7, 92, 113, 14, 35, 746, STR_981D_BUILD_SHIP_DOCK}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4087
diff
changeset
|
202 |
{ WWT_PANEL, RESIZE_NONE, 7, 114, 135, 14, 35, 693, STR_9834_POSITION_BUOY_WHICH_CAN}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4087
diff
changeset
|
203 |
{ WWT_PANEL, RESIZE_NONE, 7, 136, 157, 14, 35, SPR_IMG_LANDSCAPING, STR_LANDSCAPING_TOOLBAR_TIP}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
0
diff
changeset
|
204 |
{ WIDGETS_END}, |
0 | 205 |
}; |
206 |
||
207 |
static const WindowDesc _build_docks_toolbar_desc = { |
|
606
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
208 |
640-158, 22, 158, 36, |
0 | 209 |
WC_BUILD_TOOLBAR,0, |
756
b76998029c12
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
750
diff
changeset
|
210 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, |
0 | 211 |
_build_docks_toolb_widgets, |
212 |
BuildDocksToolbWndProc |
|
213 |
}; |
|
214 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1072
diff
changeset
|
215 |
void ShowBuildDocksToolbar(void) |
0 | 216 |
{ |
946
2468063f35a4
(svn r1435) Fix: [ 1094092 ] Toolbars accessible via keyboard in spectator mode
dominik
parents:
937
diff
changeset
|
217 |
if (_current_player == OWNER_SPECTATOR) return; |
0 | 218 |
DeleteWindowById(WC_BUILD_TOOLBAR, 0); |
219 |
AllocateWindowDesc(&_build_docks_toolbar_desc); |
|
2619
1b20d578a660
(svn r3157) - Feature: Added patch option to link the terraform toolbar to the rail, road, water and airport toolbars. If enabled, the terraform toolbar will open and close with those toolbars.
peter1138
parents:
2549
diff
changeset
|
220 |
if (_patches.link_terraform_toolbar) ShowTerraformToolbar(); |
0 | 221 |
} |
222 |
||
223 |
static void BuildDockStationWndProc(Window *w, WindowEvent *e) |
|
224 |
{ |
|
2639 | 225 |
switch (e->event) { |
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4634
diff
changeset
|
226 |
case WE_CREATE: LowerWindowWidget(w, _station_show_coverage + 3); break; |
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4634
diff
changeset
|
227 |
|
2639 | 228 |
case WE_PAINT: { |
229 |
int rad; |
|
713
aeeebdfdaae0
(svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents:
679
diff
changeset
|
230 |
|
2639 | 231 |
if (WP(w,def_d).close) return; |
0 | 232 |
DrawWindowWidgets(w); |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2619
diff
changeset
|
233 |
|
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2619
diff
changeset
|
234 |
rad = (_patches.modified_catchment) ? CA_DOCK : 4; |
713
aeeebdfdaae0
(svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents:
679
diff
changeset
|
235 |
|
4539
0004dc6c3777
(svn r6368) -Fix [FS#136]: Station catchment area persists after switching tools. The
Darkvater
parents:
4345
diff
changeset
|
236 |
if (_station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); |
713
aeeebdfdaae0
(svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents:
679
diff
changeset
|
237 |
|
750
d7bd2291c953
(svn r1206) Fix: Polished build docks window a bit.
dominik
parents:
713
diff
changeset
|
238 |
DrawStationCoverageAreaText(4, 50, (uint)-1, rad); |
2639 | 239 |
break; |
240 |
} |
|
0 | 241 |
|
2639 | 242 |
case WE_CLICK: |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4539
diff
changeset
|
243 |
switch (e->we.click.widget) { |
2639 | 244 |
case 3: |
245 |
case 4: |
|
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4634
diff
changeset
|
246 |
RaiseWindowWidget(w, _station_show_coverage + 3); |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4539
diff
changeset
|
247 |
_station_show_coverage = e->we.click.widget - 3; |
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4634
diff
changeset
|
248 |
LowerWindowWidget(w, _station_show_coverage + 3); |
2639 | 249 |
SndPlayFx(SND_15_BEEP); |
250 |
SetWindowDirty(w); |
|
251 |
break; |
|
0 | 252 |
} |
2639 | 253 |
break; |
0 | 254 |
|
2639 | 255 |
case WE_MOUSELOOP: |
0 | 256 |
if (WP(w,def_d).close) { |
257 |
DeleteWindow(w); |
|
258 |
return; |
|
259 |
} |
|
260 |
||
261 |
CheckRedrawStationCoverage(w); |
|
262 |
break; |
|
1072
74cd9150d473
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1019
diff
changeset
|
263 |
|
74cd9150d473
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1019
diff
changeset
|
264 |
case WE_DESTROY: |
2639 | 265 |
if (!WP(w,def_d).close) ResetObjectToPlace(); |
1072
74cd9150d473
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1019
diff
changeset
|
266 |
break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
267 |
} |
0 | 268 |
} |
269 |
||
270 |
static const Widget _build_dock_station_widgets[] = { |
|
4345
1da147230c79
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
271 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1da147230c79
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
272 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_3068_DOCK, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
1da147230c79
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
273 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 147, 14, 74, 0x0, STR_NULL}, |
1da147230c79
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
274 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 14, 73, 30, 40, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE}, |
1da147230c79
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
275 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 74, 133, 30, 40, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA}, |
1da147230c79
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
276 |
{ WWT_LABEL, RESIZE_NONE, 7, 0, 147, 17, 30, STR_3066_COVERAGE_AREA_HIGHLIGHT, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
0
diff
changeset
|
277 |
{ WIDGETS_END}, |
0 | 278 |
}; |
279 |
||
280 |
static const WindowDesc _build_dock_station_desc = { |
|
750
d7bd2291c953
(svn r1206) Fix: Polished build docks window a bit.
dominik
parents:
713
diff
changeset
|
281 |
-1, -1, 148, 75, |
0 | 282 |
WC_BUILD_STATION,WC_BUILD_TOOLBAR, |
283 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
284 |
_build_dock_station_widgets, |
|
285 |
BuildDockStationWndProc |
|
286 |
}; |
|
287 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1072
diff
changeset
|
288 |
static void ShowBuildDockStationPicker(void) |
0 | 289 |
{ |
290 |
AllocateWindowDesc(&_build_dock_station_desc); |
|
291 |
} |
|
292 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1072
diff
changeset
|
293 |
static void UpdateDocksDirection(void) |
0 | 294 |
{ |
3157
3f35e2d9c8e3
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
2952
diff
changeset
|
295 |
if (_ship_depot_direction != AXIS_X) { |
0 | 296 |
SetTileSelectSize(1, 2); |
297 |
} else { |
|
298 |
SetTileSelectSize(2, 1); |
|
299 |
} |
|
300 |
} |
|
301 |
||
302 |
static void BuildDocksDepotWndProc(Window *w, WindowEvent *e) |
|
303 |
{ |
|
2549 | 304 |
switch (e->event) { |
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4634
diff
changeset
|
305 |
case WE_CREATE: LowerWindowWidget(w, _ship_depot_direction + 3); break; |
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4634
diff
changeset
|
306 |
|
0 | 307 |
case WE_PAINT: |
308 |
DrawWindowWidgets(w); |
|
309 |
||
310 |
DrawShipDepotSprite(67, 35, 0); |
|
311 |
DrawShipDepotSprite(35, 51, 1); |
|
312 |
DrawShipDepotSprite(135, 35, 2); |
|
313 |
DrawShipDepotSprite(167, 51, 3); |
|
314 |
return; |
|
315 |
||
316 |
case WE_CLICK: { |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4539
diff
changeset
|
317 |
switch (e->we.click.widget) { |
0 | 318 |
case 3: |
319 |
case 4: |
|
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4634
diff
changeset
|
320 |
RaiseWindowWidget(w, _ship_depot_direction + 3); |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4539
diff
changeset
|
321 |
_ship_depot_direction = e->we.click.widget - 3; |
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4634
diff
changeset
|
322 |
LowerWindowWidget(w, _ship_depot_direction + 3); |
541 | 323 |
SndPlayFx(SND_15_BEEP); |
0 | 324 |
UpdateDocksDirection(); |
325 |
SetWindowDirty(w); |
|
326 |
break; |
|
327 |
} |
|
328 |
} break; |
|
329 |
||
330 |
case WE_MOUSELOOP: |
|
2639 | 331 |
if (WP(w,def_d).close) DeleteWindow(w); |
0 | 332 |
break; |
1072
74cd9150d473
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1019
diff
changeset
|
333 |
|
74cd9150d473
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1019
diff
changeset
|
334 |
case WE_DESTROY: |
2639 | 335 |
if (!WP(w,def_d).close) ResetObjectToPlace(); |
1072
74cd9150d473
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1019
diff
changeset
|
336 |
break; |
0 | 337 |
} |
338 |
} |
|
339 |
||
340 |
static const Widget _build_docks_depot_widgets[] = { |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4087
diff
changeset
|
341 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4087
diff
changeset
|
342 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 203, 0, 13, STR_3800_SHIP_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4087
diff
changeset
|
343 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 203, 14, 85, 0x0, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4087
diff
changeset
|
344 |
{ WWT_PANEL, RESIZE_NONE, 14, 3, 100, 17, 82, 0x0, STR_3803_SELECT_SHIP_DEPOT_ORIENTATION}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4087
diff
changeset
|
345 |
{ WWT_PANEL, RESIZE_NONE, 14, 103, 200, 17, 82, 0x0, STR_3803_SELECT_SHIP_DEPOT_ORIENTATION}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
0
diff
changeset
|
346 |
{ WIDGETS_END}, |
0 | 347 |
}; |
348 |
||
349 |
static const WindowDesc _build_docks_depot_desc = { |
|
350 |
-1, -1, 204, 86, |
|
351 |
WC_BUILD_DEPOT,WC_BUILD_TOOLBAR, |
|
352 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
353 |
_build_docks_depot_widgets, |
|
354 |
BuildDocksDepotWndProc |
|
355 |
}; |
|
356 |
||
357 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1072
diff
changeset
|
358 |
static void ShowBuildDocksDepotPicker(void) |
0 | 359 |
{ |
360 |
AllocateWindowDesc(&_build_docks_depot_desc); |
|
361 |
UpdateDocksDirection(); |
|
362 |
} |
|
363 |
||
364 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1072
diff
changeset
|
365 |
void InitializeDockGui(void) |
0 | 366 |
{ |
3157
3f35e2d9c8e3
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
2952
diff
changeset
|
367 |
_ship_depot_direction = AXIS_X; |
0 | 368 |
} |