author | Darkvater |
Mon, 06 Jun 2005 13:47:06 +0000 | |
changeset 1914 | 5ede46fd496f |
parent 1891 | 92a3b0aa0946 |
child 1977 | 4392ae3d8e31 |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1632
diff
changeset
|
2 |
#include "openttd.h" |
1363
01d3de5d8039
(svn r1867) Include tables/sprites.h only in files which need it
tron
parents:
1116
diff
changeset
|
3 |
#include "table/sprites.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
337
diff
changeset
|
4 |
#include "table/strings.h" |
679
e959706a3e4d
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
606
diff
changeset
|
5 |
#include "map.h" |
0 | 6 |
#include "window.h" |
568
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
7 |
#include "station.h" |
0 | 8 |
#include "gui.h" |
9 |
#include "viewport.h" |
|
10 |
#include "gfx.h" |
|
337
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
11 |
#include "sound.h" |
0 | 12 |
#include "command.h" |
13 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1072
diff
changeset
|
14 |
static void ShowBuildDockStationPicker(void); |
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1072
diff
changeset
|
15 |
static void ShowBuildDocksDepotPicker(void); |
0 | 16 |
|
17 |
static byte _ship_depot_direction; |
|
18 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
19 |
void CcBuildDocks(bool success, uint tile, uint32 p1, uint32 p2) |
0 | 20 |
{ |
21 |
if (success) { |
|
541 | 22 |
SndPlayTileFx(SND_02_SPLAT, tile); |
0 | 23 |
ResetObjectToPlace(); |
24 |
} |
|
25 |
} |
|
26 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
27 |
void CcBuildCanal(bool success, uint tile, uint32 p1, uint32 p2) |
0 | 28 |
{ |
541 | 29 |
if (success) SndPlayTileFx(SND_02_SPLAT, tile); |
0 | 30 |
} |
31 |
||
32 |
||
33 |
static void PlaceDocks_Dock(uint tile) |
|
34 |
{ |
|
35 |
DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_DOCK | CMD_AUTO | CMD_MSG(STR_9802_CAN_T_BUILD_DOCK_HERE)); |
|
36 |
} |
|
37 |
||
38 |
static void PlaceDocks_Depot(uint tile) |
|
39 |
{ |
|
40 |
DoCommandP(tile, _ship_depot_direction, 0, CcBuildDocks, CMD_BUILD_SHIP_DEPOT | CMD_AUTO | CMD_MSG(STR_3802_CAN_T_BUILD_SHIP_DEPOT)); |
|
41 |
} |
|
42 |
||
43 |
static void PlaceDocks_Buoy(uint tile) |
|
44 |
{ |
|
45 |
DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_BUOY | CMD_AUTO | CMD_MSG(STR_9835_CAN_T_POSITION_BUOY_HERE)); |
|
46 |
} |
|
47 |
||
48 |
static void PlaceDocks_DemolishArea(uint tile) |
|
49 |
{ |
|
1632
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
50 |
VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_DemolishArea); |
0 | 51 |
} |
52 |
||
53 |
static void PlaceDocks_BuildCanal(uint tile) |
|
54 |
{ |
|
55 |
VpStartPlaceSizing(tile, VPM_X_OR_Y); |
|
56 |
} |
|
57 |
||
58 |
static void PlaceDocks_BuildLock(uint tile) |
|
59 |
{ |
|
60 |
DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_LOCK | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_LOCKS)); |
|
61 |
} |
|
62 |
||
63 |
||
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
64 |
static void BuildDocksClick_Canal(Window *w) |
0 | 65 |
{ |
1914
5ede46fd496f
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
66 |
HandlePlacePushButton(w, 3, SPR_CURSOR_CANAL, 1, PlaceDocks_BuildCanal); |
0 | 67 |
} |
68 |
||
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
69 |
static void BuildDocksClick_Lock(Window *w) |
0 | 70 |
{ |
1914
5ede46fd496f
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
71 |
HandlePlacePushButton(w, 4, SPR_CURSOR_LOCK, 1, PlaceDocks_BuildLock); |
0 | 72 |
} |
73 |
||
74 |
static void BuildDocksClick_Demolish(Window *w) |
|
75 |
{ |
|
756
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
750
diff
changeset
|
76 |
HandlePlacePushButton(w, 6, ANIMCURSOR_DEMOLISH, 1, PlaceDocks_DemolishArea); |
0 | 77 |
} |
78 |
||
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
79 |
static void BuildDocksClick_Depot(Window *w) |
0 | 80 |
{ |
1914
5ede46fd496f
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
81 |
if (HandlePlacePushButton(w, 7, SPR_CURSOR_SHIP_DEPOT, 1, PlaceDocks_Depot)) ShowBuildDocksDepotPicker(); |
0 | 82 |
} |
83 |
||
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
84 |
static void BuildDocksClick_Dock(Window *w) |
0 | 85 |
{ |
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
86 |
|
1914
5ede46fd496f
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
87 |
if (HandlePlacePushButton(w, 8, SPR_CURSOR_DOCK, 3, PlaceDocks_Dock)) ShowBuildDockStationPicker(); |
0 | 88 |
} |
89 |
||
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
90 |
static void BuildDocksClick_Buoy(Window *w) |
0 | 91 |
{ |
1914
5ede46fd496f
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
92 |
HandlePlacePushButton(w, 9, SPR_CURSOR_BOUY, 1, PlaceDocks_Buoy); |
0 | 93 |
} |
94 |
||
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
95 |
static void BuildDocksClick_Landscaping(Window *w) |
0 | 96 |
{ |
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
97 |
ShowTerraformToolbar(); |
0 | 98 |
} |
99 |
||
100 |
typedef void OnButtonClick(Window *w); |
|
101 |
static OnButtonClick * const _build_docks_button_proc[] = { |
|
102 |
BuildDocksClick_Canal, |
|
103 |
BuildDocksClick_Lock, |
|
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
104 |
0, |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
105 |
BuildDocksClick_Demolish, |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
106 |
BuildDocksClick_Depot, |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
107 |
BuildDocksClick_Dock, |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
108 |
BuildDocksClick_Buoy, |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
109 |
BuildDocksClick_Landscaping, |
0 | 110 |
}; |
111 |
||
112 |
static void BuildDocksToolbWndProc(Window *w, WindowEvent *e) |
|
113 |
{ |
|
114 |
switch(e->event) { |
|
115 |
case WE_PAINT: |
|
116 |
DrawWindowWidgets(w); |
|
117 |
break; |
|
118 |
||
119 |
case WE_CLICK: { |
|
756
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
750
diff
changeset
|
120 |
if (e->click.widget - 3 >= 0 && e->click.widget != 5) _build_docks_button_proc[e->click.widget - 3](w); |
0 | 121 |
} break; |
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
946
diff
changeset
|
122 |
|
937
a8dfd3eb406f
(svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents:
867
diff
changeset
|
123 |
case WE_KEYPRESS: { |
a8dfd3eb406f
(svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents:
867
diff
changeset
|
124 |
switch(e->keypress.keycode) { |
a8dfd3eb406f
(svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents:
867
diff
changeset
|
125 |
case '1': BuildDocksClick_Canal(w); break; |
a8dfd3eb406f
(svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents:
867
diff
changeset
|
126 |
case '2': BuildDocksClick_Lock(w); break; |
a8dfd3eb406f
(svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents:
867
diff
changeset
|
127 |
case '3': BuildDocksClick_Demolish(w); break; |
a8dfd3eb406f
(svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents:
867
diff
changeset
|
128 |
case '4': BuildDocksClick_Depot(w); break; |
a8dfd3eb406f
(svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents:
867
diff
changeset
|
129 |
case '5': BuildDocksClick_Dock(w); break; |
a8dfd3eb406f
(svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents:
867
diff
changeset
|
130 |
case '6': BuildDocksClick_Buoy(w); break; |
a8dfd3eb406f
(svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents:
867
diff
changeset
|
131 |
case 'l': BuildDocksClick_Landscaping(w); break; |
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
946
diff
changeset
|
132 |
default: |
937
a8dfd3eb406f
(svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents:
867
diff
changeset
|
133 |
return; |
a8dfd3eb406f
(svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents:
867
diff
changeset
|
134 |
} |
a8dfd3eb406f
(svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents:
867
diff
changeset
|
135 |
} break; |
0 | 136 |
|
137 |
case WE_PLACE_OBJ: |
|
138 |
_place_proc(e->place.tile); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
139 |
break; |
0 | 140 |
|
141 |
case WE_PLACE_DRAG: { |
|
142 |
VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, e->place.userdata); |
|
143 |
return; |
|
144 |
} |
|
145 |
||
146 |
case WE_PLACE_MOUSEUP: |
|
147 |
if (e->click.pt.x != -1) { |
|
1632
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
148 |
if ((e->place.userdata & 0xF) == VPM_X_AND_Y) { // dragged actions |
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
149 |
GUIPlaceProcDragXY(e); |
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
150 |
} else if(e->place.userdata == VPM_X_OR_Y) |
0 | 151 |
DoCommandP(e->place.tile, e->place.starttile, 0, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS)); |
152 |
} |
|
153 |
break; |
|
154 |
||
155 |
case WE_ABORT_PLACE_OBJ: |
|
756
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
750
diff
changeset
|
156 |
UnclickWindowButtons(w); |
0 | 157 |
SetWindowDirty(w); |
158 |
||
159 |
w = FindWindowById(WC_BUILD_STATION, 0); |
|
160 |
if (w != NULL) WP(w,def_d).close=true; |
|
161 |
||
162 |
w = FindWindowById(WC_BUILD_DEPOT, 0); |
|
163 |
if (w != NULL) WP(w,def_d).close=true; |
|
164 |
break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
165 |
|
0 | 166 |
case WE_PLACE_PRESIZE: { |
167 |
uint tile_from, tile_to; |
|
168 |
||
169 |
tile_from = tile_to = e->place.tile; |
|
170 |
switch(GetTileSlope(tile_from, NULL)) { |
|
171 |
case 3: tile_to += TILE_XY(-1,0); break; |
|
172 |
case 6: tile_to += TILE_XY(0,-1); break; |
|
173 |
case 9: tile_to += TILE_XY(0,1); break; |
|
174 |
case 12:tile_to += TILE_XY(1,0); break; |
|
175 |
} |
|
176 |
VpSetPresizeRange(tile_from, tile_to); |
|
177 |
} break; |
|
178 |
} |
|
179 |
} |
|
180 |
||
181 |
static const Widget _build_docks_toolb_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
787
diff
changeset
|
182 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
787
diff
changeset
|
183 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 145, 0, 13, STR_9801_DOCK_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
787
diff
changeset
|
184 |
{ WWT_STICKYBOX, RESIZE_NONE, 7, 146, 157, 0, 13, 0x0, STR_STICKY_BUTTON}, |
1632
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
185 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_BUILD_CANAL, STR_BUILD_CANALS_TIP}, |
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
186 |
{ WWT_PANEL, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_BUILD_LOCK, STR_BUILD_LOCKS_TIP}, |
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
187 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
787
diff
changeset
|
188 |
{ WWT_PANEL, RESIZE_NONE, 7, 44, 47, 14, 35, 0x0, STR_NULL}, |
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
189 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
787
diff
changeset
|
190 |
{ WWT_PANEL, RESIZE_NONE, 7, 48, 69, 14, 35, 703, STR_018D_DEMOLISH_BUILDINGS_ETC}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
787
diff
changeset
|
191 |
{ WWT_PANEL, RESIZE_NONE, 7, 70, 91, 14, 35, 748, STR_981E_BUILD_SHIP_DEPOT_FOR_BUILDING}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
787
diff
changeset
|
192 |
{ WWT_PANEL, RESIZE_NONE, 7, 92, 113, 14, 35, 746, STR_981D_BUILD_SHIP_DOCK}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
787
diff
changeset
|
193 |
{ WWT_PANEL, RESIZE_NONE, 7, 114, 135, 14, 35, 693, STR_9834_POSITION_BUOY_WHICH_CAN}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
787
diff
changeset
|
194 |
{ 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
|
195 |
{ WIDGETS_END}, |
0 | 196 |
}; |
197 |
||
198 |
static const WindowDesc _build_docks_toolbar_desc = { |
|
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
199 |
640-158, 22, 158, 36, |
0 | 200 |
WC_BUILD_TOOLBAR,0, |
756
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
750
diff
changeset
|
201 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, |
0 | 202 |
_build_docks_toolb_widgets, |
203 |
BuildDocksToolbWndProc |
|
204 |
}; |
|
205 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1072
diff
changeset
|
206 |
void ShowBuildDocksToolbar(void) |
0 | 207 |
{ |
946
81cf624bbdc5
(svn r1435) Fix: [ 1094092 ] Toolbars accessible via keyboard in spectator mode
dominik
parents:
937
diff
changeset
|
208 |
if (_current_player == OWNER_SPECTATOR) return; |
0 | 209 |
DeleteWindowById(WC_BUILD_TOOLBAR, 0); |
210 |
AllocateWindowDesc(&_build_docks_toolbar_desc); |
|
211 |
} |
|
212 |
||
213 |
static void BuildDockStationWndProc(Window *w, WindowEvent *e) |
|
214 |
{ |
|
568
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
215 |
int rad; |
713
5b0be616ee1e
(svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents:
679
diff
changeset
|
216 |
|
0 | 217 |
switch(e->event) { |
218 |
case WE_PAINT: { |
|
219 |
if (WP(w,def_d).close) |
|
220 |
return; |
|
713
5b0be616ee1e
(svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents:
679
diff
changeset
|
221 |
w->click_state = (1<<3) << _station_show_coverage; |
0 | 222 |
DrawWindowWidgets(w); |
568
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
223 |
if (_patches.modified_catchment) { |
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
224 |
rad = CA_DOCK; |
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
225 |
} else { |
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
226 |
rad = 4; |
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
227 |
} |
713
5b0be616ee1e
(svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents:
679
diff
changeset
|
228 |
|
5b0be616ee1e
(svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents:
679
diff
changeset
|
229 |
if (_station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); |
5b0be616ee1e
(svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents:
679
diff
changeset
|
230 |
else SetTileSelectBigSize(0, 0, 0, 0); |
5b0be616ee1e
(svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents:
679
diff
changeset
|
231 |
|
750
f68f0af1dc53
(svn r1206) Fix: Polished build docks window a bit.
dominik
parents:
713
diff
changeset
|
232 |
DrawStringCentered(74, 17, STR_3066_COVERAGE_AREA_HIGHLIGHT, 0); |
f68f0af1dc53
(svn r1206) Fix: Polished build docks window a bit.
dominik
parents:
713
diff
changeset
|
233 |
DrawStationCoverageAreaText(4, 50, (uint)-1, rad); |
0 | 234 |
} break; |
235 |
||
236 |
case WE_CLICK: { |
|
713
5b0be616ee1e
(svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents:
679
diff
changeset
|
237 |
switch(e->click.widget) { |
5b0be616ee1e
(svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents:
679
diff
changeset
|
238 |
case 3: case 4: |
5b0be616ee1e
(svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents:
679
diff
changeset
|
239 |
_station_show_coverage = e->click.widget - 3; |
5b0be616ee1e
(svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents:
679
diff
changeset
|
240 |
SndPlayFx(SND_15_BEEP); |
5b0be616ee1e
(svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents:
679
diff
changeset
|
241 |
SetWindowDirty(w); |
5b0be616ee1e
(svn r1165) Fix: [ 1085255 ] Docks now have a button to display the catchment area
dominik
parents:
679
diff
changeset
|
242 |
break; |
0 | 243 |
} |
244 |
} break; |
|
245 |
||
246 |
case WE_MOUSELOOP: { |
|
247 |
if (WP(w,def_d).close) { |
|
248 |
DeleteWindow(w); |
|
249 |
return; |
|
250 |
} |
|
251 |
||
252 |
CheckRedrawStationCoverage(w); |
|
253 |
break; |
|
254 |
} |
|
1072
01bf9fc64236
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1019
diff
changeset
|
255 |
|
01bf9fc64236
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1019
diff
changeset
|
256 |
case WE_DESTROY: |
1116
a38aed715c95
(svn r1617) -Fix: Ugly hack to only call ResetObjectToPlaceon childwindows of build-toolbar if the window is closed manually (with 'X'); if not checked ResetObjectToPlace is called twice resulting in undesired actions (eg. clicked button is unclicked immediately).
darkvater
parents:
1093
diff
changeset
|
257 |
if (!WP(w,def_d).close) |
a38aed715c95
(svn r1617) -Fix: Ugly hack to only call ResetObjectToPlaceon childwindows of build-toolbar if the window is closed manually (with 'X'); if not checked ResetObjectToPlace is called twice resulting in undesired actions (eg. clicked button is unclicked immediately).
darkvater
parents:
1093
diff
changeset
|
258 |
ResetObjectToPlace(); |
1072
01bf9fc64236
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1019
diff
changeset
|
259 |
break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
260 |
} |
0 | 261 |
} |
262 |
||
263 |
static const Widget _build_dock_station_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
787
diff
changeset
|
264 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
787
diff
changeset
|
265 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_3068_DOCK, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
787
diff
changeset
|
266 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 147, 14, 74, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
787
diff
changeset
|
267 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 14, 73, 30, 40, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
787
diff
changeset
|
268 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 74, 133, 30, 40, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
0
diff
changeset
|
269 |
{ WIDGETS_END}, |
0 | 270 |
}; |
271 |
||
272 |
static const WindowDesc _build_dock_station_desc = { |
|
750
f68f0af1dc53
(svn r1206) Fix: Polished build docks window a bit.
dominik
parents:
713
diff
changeset
|
273 |
-1, -1, 148, 75, |
0 | 274 |
WC_BUILD_STATION,WC_BUILD_TOOLBAR, |
275 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
276 |
_build_dock_station_widgets, |
|
277 |
BuildDockStationWndProc |
|
278 |
}; |
|
279 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1072
diff
changeset
|
280 |
static void ShowBuildDockStationPicker(void) |
0 | 281 |
{ |
282 |
AllocateWindowDesc(&_build_dock_station_desc); |
|
283 |
} |
|
284 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1072
diff
changeset
|
285 |
static void UpdateDocksDirection(void) |
0 | 286 |
{ |
287 |
if (_ship_depot_direction != 0) { |
|
288 |
SetTileSelectSize(1, 2); |
|
289 |
} else { |
|
290 |
SetTileSelectSize(2, 1); |
|
291 |
} |
|
292 |
} |
|
293 |
||
294 |
static void BuildDocksDepotWndProc(Window *w, WindowEvent *e) |
|
295 |
{ |
|
296 |
switch(e->event) { |
|
297 |
case WE_PAINT: |
|
298 |
w->click_state = (1<<3) << _ship_depot_direction; |
|
299 |
DrawWindowWidgets(w); |
|
300 |
||
301 |
DrawShipDepotSprite(67, 35, 0); |
|
302 |
DrawShipDepotSprite(35, 51, 1); |
|
303 |
DrawShipDepotSprite(135, 35, 2); |
|
304 |
DrawShipDepotSprite(167, 51, 3); |
|
305 |
return; |
|
306 |
||
307 |
case WE_CLICK: { |
|
308 |
switch(e->click.widget) { |
|
309 |
case 3: |
|
310 |
case 4: |
|
311 |
_ship_depot_direction = e->click.widget - 3; |
|
541 | 312 |
SndPlayFx(SND_15_BEEP); |
0 | 313 |
UpdateDocksDirection(); |
314 |
SetWindowDirty(w); |
|
315 |
break; |
|
316 |
} |
|
317 |
} break; |
|
318 |
||
319 |
case WE_MOUSELOOP: |
|
320 |
if (WP(w,def_d).close) |
|
321 |
DeleteWindow(w); |
|
322 |
break; |
|
1072
01bf9fc64236
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1019
diff
changeset
|
323 |
|
01bf9fc64236
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1019
diff
changeset
|
324 |
case WE_DESTROY: |
1116
a38aed715c95
(svn r1617) -Fix: Ugly hack to only call ResetObjectToPlaceon childwindows of build-toolbar if the window is closed manually (with 'X'); if not checked ResetObjectToPlace is called twice resulting in undesired actions (eg. clicked button is unclicked immediately).
darkvater
parents:
1093
diff
changeset
|
325 |
if (!WP(w,def_d).close) |
a38aed715c95
(svn r1617) -Fix: Ugly hack to only call ResetObjectToPlaceon childwindows of build-toolbar if the window is closed manually (with 'X'); if not checked ResetObjectToPlace is called twice resulting in undesired actions (eg. clicked button is unclicked immediately).
darkvater
parents:
1093
diff
changeset
|
326 |
ResetObjectToPlace(); |
1072
01bf9fc64236
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1019
diff
changeset
|
327 |
break; |
0 | 328 |
} |
329 |
} |
|
330 |
||
331 |
static const Widget _build_docks_depot_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
787
diff
changeset
|
332 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
787
diff
changeset
|
333 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 203, 0, 13, STR_3800_SHIP_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
787
diff
changeset
|
334 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 203, 14, 85, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
787
diff
changeset
|
335 |
{ WWT_PANEL, RESIZE_NONE, 14, 3, 100, 17, 82, 0x0, STR_3803_SELECT_SHIP_DEPOT_ORIENTATION}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
787
diff
changeset
|
336 |
{ 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
|
337 |
{ WIDGETS_END}, |
0 | 338 |
}; |
339 |
||
340 |
static const WindowDesc _build_docks_depot_desc = { |
|
341 |
-1, -1, 204, 86, |
|
342 |
WC_BUILD_DEPOT,WC_BUILD_TOOLBAR, |
|
343 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
344 |
_build_docks_depot_widgets, |
|
345 |
BuildDocksDepotWndProc |
|
346 |
}; |
|
347 |
||
348 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1072
diff
changeset
|
349 |
static void ShowBuildDocksDepotPicker(void) |
0 | 350 |
{ |
351 |
AllocateWindowDesc(&_build_docks_depot_desc); |
|
352 |
UpdateDocksDirection(); |
|
353 |
} |
|
354 |
||
355 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1072
diff
changeset
|
356 |
void InitializeDockGui(void) |
0 | 357 |
{ |
358 |
_ship_depot_direction = 0; |
|
359 |
} |