author | Darkvater |
Sun, 10 Dec 2006 00:20:26 +0000 | |
changeset 5305 | e07957fe871e |
parent 5147 | db717cde801d |
child 5542 | c719509fb0b7 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1784
diff
changeset
|
4 |
#include "openttd.h" |
1363
01d3de5d8039
(svn r1867) Include tables/sprites.h only in files which need it
tron
parents:
1313
diff
changeset
|
5 |
#include "table/sprites.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
337
diff
changeset
|
6 |
#include "table/strings.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
1977
diff
changeset
|
7 |
#include "functions.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
|
8 |
#include "map.h" |
0 | 9 |
#include "window.h" |
10 |
#include "gui.h" |
|
11 |
#include "viewport.h" |
|
12 |
#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
|
13 |
#include "sound.h" |
0 | 14 |
#include "command.h" |
15 |
#include "vehicle.h" |
|
16 |
#include "station.h" |
|
17 |
#include "airport.h" |
|
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1116
diff
changeset
|
18 |
#include "depot.h" |
0 | 19 |
|
20 |
static byte _selected_airport_type; |
|
21 |
||
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
|
22 |
static void ShowBuildAirportPicker(void); |
0 | 23 |
|
24 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
25 |
void CcBuildAirport(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 26 |
{ |
27 |
if (success) { |
|
541 | 28 |
SndPlayTileFx(SND_1F_SPLAT, tile); |
0 | 29 |
ResetObjectToPlace(); |
30 |
} |
|
31 |
} |
|
32 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
33 |
static void PlaceAirport(TileIndex tile) |
0 | 34 |
{ |
35 |
DoCommandP(tile, _selected_airport_type, 0, CcBuildAirport, CMD_BUILD_AIRPORT | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_A001_CAN_T_BUILD_AIRPORT_HERE)); |
|
36 |
} |
|
37 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
38 |
static void PlaceAir_DemolishArea(TileIndex tile) |
0 | 39 |
{ |
40 |
VpStartPlaceSizing(tile, 4); |
|
41 |
} |
|
42 |
||
43 |
||
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
44 |
enum { |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
45 |
ATW_AIRPORT = 3, |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
46 |
ATW_DEMOLISH = 4 |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
47 |
}; |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
48 |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
49 |
|
0 | 50 |
static void BuildAirClick_Airport(Window *w) |
51 |
{ |
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
52 |
if (HandlePlacePushButton(w, ATW_AIRPORT, SPR_CURSOR_AIRPORT, 1, PlaceAirport)) ShowBuildAirportPicker(); |
0 | 53 |
} |
54 |
||
55 |
static void BuildAirClick_Demolish(Window *w) |
|
56 |
{ |
|
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
57 |
HandlePlacePushButton(w, ATW_DEMOLISH, ANIMCURSOR_DEMOLISH, 1, PlaceAir_DemolishArea); |
0 | 58 |
} |
59 |
||
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
60 |
static void BuildAirClick_Landscaping(Window *w) |
0 | 61 |
{ |
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
62 |
ShowTerraformToolbar(); |
0 | 63 |
} |
64 |
||
65 |
typedef void OnButtonClick(Window *w); |
|
66 |
static OnButtonClick * const _build_air_button_proc[] = { |
|
67 |
BuildAirClick_Airport, |
|
68 |
BuildAirClick_Demolish, |
|
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
69 |
BuildAirClick_Landscaping, |
0 | 70 |
}; |
71 |
||
72 |
static void BuildAirToolbWndProc(Window *w, WindowEvent *e) |
|
73 |
{ |
|
2639 | 74 |
switch (e->event) { |
0 | 75 |
case WE_PAINT: |
76 |
DrawWindowWidgets(w); |
|
77 |
break; |
|
78 |
||
79 |
case WE_CLICK: |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4345
diff
changeset
|
80 |
if (e->we.click.widget - 3 >= 0) |
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4345
diff
changeset
|
81 |
_build_air_button_proc[e->we.click.widget - 3](w); |
0 | 82 |
break; |
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
946
diff
changeset
|
83 |
|
937
a8dfd3eb406f
(svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents:
867
diff
changeset
|
84 |
case WE_KEYPRESS: { |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4345
diff
changeset
|
85 |
switch (e->we.keypress.keycode) { |
937
a8dfd3eb406f
(svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents:
867
diff
changeset
|
86 |
case '1': BuildAirClick_Airport(w); break; |
a8dfd3eb406f
(svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents:
867
diff
changeset
|
87 |
case '2': BuildAirClick_Demolish(w); break; |
a8dfd3eb406f
(svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents:
867
diff
changeset
|
88 |
case 'l': BuildAirClick_Landscaping(w); break; |
2631
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2619
diff
changeset
|
89 |
default: return; |
937
a8dfd3eb406f
(svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents:
867
diff
changeset
|
90 |
} |
a8dfd3eb406f
(svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents:
867
diff
changeset
|
91 |
} break; |
0 | 92 |
|
93 |
case WE_PLACE_OBJ: |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4345
diff
changeset
|
94 |
_place_proc(e->we.place.tile); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
95 |
break; |
0 | 96 |
|
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
97 |
case WE_PLACE_DRAG: |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4345
diff
changeset
|
98 |
VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.userdata); |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
99 |
break; |
0 | 100 |
|
101 |
case WE_PLACE_MOUSEUP: |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4345
diff
changeset
|
102 |
if (e->we.place.pt.x != -1) { |
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4345
diff
changeset
|
103 |
DoCommandP(e->we.place.tile, e->we.place.starttile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA)); |
0 | 104 |
} |
105 |
break; |
|
106 |
||
107 |
case WE_ABORT_PLACE_OBJ: |
|
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
108 |
RaiseWindowButtons(w); |
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
109 |
|
0 | 110 |
w = FindWindowById(WC_BUILD_STATION, 0); |
111 |
if (w != 0) |
|
112 |
WP(w,def_d).close = true; |
|
113 |
break; |
|
2619
c2f488e400b1
(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:
2186
diff
changeset
|
114 |
|
c2f488e400b1
(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:
2186
diff
changeset
|
115 |
case WE_DESTROY: |
c2f488e400b1
(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:
2186
diff
changeset
|
116 |
if (_patches.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0); |
c2f488e400b1
(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:
2186
diff
changeset
|
117 |
break; |
0 | 118 |
} |
119 |
} |
|
120 |
||
121 |
static const Widget _air_toolbar_widgets[] = { |
|
4344
5d0e40cd67b9
(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:
4171
diff
changeset
|
122 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW }, |
5d0e40cd67b9
(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:
4171
diff
changeset
|
123 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 73, 0, 13, STR_A000_AIRPORTS, STR_018C_WINDOW_TITLE_DRAG_THIS }, |
5d0e40cd67b9
(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:
4171
diff
changeset
|
124 |
{ WWT_STICKYBOX, RESIZE_NONE, 7, 74, 85, 0, 13, 0x0, STR_STICKY_BUTTON }, |
4937
a525d56a8d40
(svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents:
4848
diff
changeset
|
125 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 41, 14, 35, SPR_IMG_AIRPORT, STR_A01E_BUILD_AIRPORT }, |
a525d56a8d40
(svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents:
4848
diff
changeset
|
126 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 42, 63, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC }, |
a525d56a8d40
(svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents:
4848
diff
changeset
|
127 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 64, 85, 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
|
128 |
{ WIDGETS_END}, |
0 | 129 |
}; |
130 |
||
131 |
||
132 |
static const WindowDesc _air_toolbar_desc = { |
|
5072
df5bde83a4bc
(svn r7130) -Codechange: Handle the positioning of windows through the desc->left/top settings with
Darkvater
parents:
5070
diff
changeset
|
133 |
WDP_ALIGN_TBR, 22, 86, 36, |
5070
0bbf5264bfb7
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
134 |
WC_BUILD_TOOLBAR, 0, |
756
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
751
diff
changeset
|
135 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, |
0 | 136 |
_air_toolbar_widgets, |
137 |
BuildAirToolbWndProc |
|
138 |
}; |
|
139 |
||
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
|
140 |
void ShowBuildAirToolbar(void) |
0 | 141 |
{ |
5005
21e84e53c732
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4968
diff
changeset
|
142 |
if (!IsValidPlayer(_current_player)) return; |
21e84e53c732
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4968
diff
changeset
|
143 |
|
0 | 144 |
DeleteWindowById(WC_BUILD_TOOLBAR, 0); |
145 |
AllocateWindowDescFront(&_air_toolbar_desc, 0); |
|
2619
c2f488e400b1
(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:
2186
diff
changeset
|
146 |
if (_patches.link_terraform_toolbar) ShowTerraformToolbar(); |
0 | 147 |
} |
148 |
||
149 |
static void BuildAirportPickerWndProc(Window *w, WindowEvent *e) |
|
150 |
{ |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1363
diff
changeset
|
151 |
switch (e->event) { |
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
152 |
case WE_CREATE: |
4727
ba5bae41b004
(svn r6639) -CodeChange : Conversion of SetWidgetLoweredState to SetWindowWidgetLoweredState, in order to follow pre-established standard
belugas
parents:
4719
diff
changeset
|
153 |
SetWindowWidgetLoweredState(w, 16, !_station_show_coverage); |
ba5bae41b004
(svn r6639) -CodeChange : Conversion of SetWidgetLoweredState to SetWindowWidgetLoweredState, in order to follow pre-established standard
belugas
parents:
4719
diff
changeset
|
154 |
SetWindowWidgetLoweredState(w, 17, _station_show_coverage); |
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
155 |
LowerWindowWidget(w, _selected_airport_type + 7); |
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
156 |
break; |
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
157 |
|
0 | 158 |
case WE_PAINT: { |
4709
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
159 |
int i; // airport enabling loop |
792
d8a4164fdb14
(svn r1262) -Fix: [1088996] kill some warnings for MinGW (luzi82)
darkvater
parents:
787
diff
changeset
|
160 |
int rad = 4; // default catchment radious |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1363
diff
changeset
|
161 |
uint32 avail_airports; |
4171 | 162 |
const AirportFTAClass *airport; |
0 | 163 |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1363
diff
changeset
|
164 |
if (WP(w,def_d).close) return; |
0 | 165 |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1363
diff
changeset
|
166 |
avail_airports = GetValidAirports(); |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1363
diff
changeset
|
167 |
|
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
168 |
RaiseWindowWidget(w, _selected_airport_type + 7); |
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
169 |
if (!HASBIT(avail_airports, 0) && _selected_airport_type == AT_SMALL) _selected_airport_type = AT_LARGE; |
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
170 |
if (!HASBIT(avail_airports, 1) && _selected_airport_type == AT_LARGE) _selected_airport_type = AT_SMALL; |
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
171 |
LowerWindowWidget(w, _selected_airport_type + 7); |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1363
diff
changeset
|
172 |
|
4709
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
173 |
/* 'Country Airport' starts at widget 7, and if its bit is set, it is |
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
174 |
* available, so take its opposite value to set the disabled state. |
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
175 |
* There are 9 buildable airports |
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
176 |
* XXX TODO : all airports should be held in arrays, with all relevant data. |
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
177 |
* This should be part of newgrf-airports, i suppose |
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
178 |
*/ |
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
179 |
for (i = 0; i < 9; i++) SetWindowWidgetDisabledState(w, i + 7, !HASBIT(avail_airports, i)); |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1363
diff
changeset
|
180 |
|
4059
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3884
diff
changeset
|
181 |
// select default the coverage area to 'Off' (16) |
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
182 |
airport = GetAirport(_selected_airport_type); |
3876
c0d426e78b56
(svn r4918) Move the information about the size of airports from an global array into the struct which describes an airport
tron
parents:
2725
diff
changeset
|
183 |
SetTileSelectSize(airport->size_x, airport->size_y); |
568
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
184 |
|
2631
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2619
diff
changeset
|
185 |
if (_patches.modified_catchment) { |
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
186 |
switch (_selected_airport_type) { |
2631
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2619
diff
changeset
|
187 |
case AT_OILRIG: rad = CA_AIR_OILPAD; break; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2619
diff
changeset
|
188 |
case AT_HELIPORT: rad = CA_AIR_HELIPORT; break; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2619
diff
changeset
|
189 |
case AT_SMALL: rad = CA_AIR_SMALL; break; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2619
diff
changeset
|
190 |
case AT_LARGE: rad = CA_AIR_LARGE; break; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2619
diff
changeset
|
191 |
case AT_METROPOLITAN: rad = CA_AIR_METRO; break; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2619
diff
changeset
|
192 |
case AT_INTERNATIONAL: rad = CA_AIR_INTER; break; |
4059
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3884
diff
changeset
|
193 |
case AT_COMMUTER: rad = CA_AIR_COMMUTER; break; |
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3884
diff
changeset
|
194 |
case AT_HELIDEPOT: rad = CA_AIR_HELIDEPOT; break; |
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3884
diff
changeset
|
195 |
case AT_INTERCON: rad = CA_AIR_INTERCON; break; |
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3884
diff
changeset
|
196 |
case AT_HELISTATION: rad = CA_AIR_HELISTATION; break; |
2631
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2619
diff
changeset
|
197 |
} |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2619
diff
changeset
|
198 |
} |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
792
diff
changeset
|
199 |
|
2639 | 200 |
if (_station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); |
0 | 201 |
|
202 |
DrawWindowWidgets(w); |
|
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
203 |
// strings such as 'Size' and 'Coverage Area' |
4345
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
204 |
// 'Coverage Area' |
4059
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3884
diff
changeset
|
205 |
DrawStationCoverageAreaText(2, 206, (uint)-1, rad); |
0 | 206 |
break; |
207 |
} |
|
208 |
||
209 |
case WE_CLICK: { |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4345
diff
changeset
|
210 |
switch (e->we.click.widget) { |
4059
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3884
diff
changeset
|
211 |
case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: |
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
212 |
RaiseWindowWidget(w, _selected_airport_type + 7); |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4345
diff
changeset
|
213 |
_selected_airport_type = e->we.click.widget - 7; |
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
214 |
LowerWindowWidget(w, _selected_airport_type + 7); |
541 | 215 |
SndPlayFx(SND_15_BEEP); |
0 | 216 |
SetWindowDirty(w); |
217 |
break; |
|
4059
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3884
diff
changeset
|
218 |
case 16: case 17: |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4345
diff
changeset
|
219 |
_station_show_coverage = e->we.click.widget - 16; |
4727
ba5bae41b004
(svn r6639) -CodeChange : Conversion of SetWidgetLoweredState to SetWindowWidgetLoweredState, in order to follow pre-established standard
belugas
parents:
4719
diff
changeset
|
220 |
SetWindowWidgetLoweredState(w, 16, !_station_show_coverage); |
ba5bae41b004
(svn r6639) -CodeChange : Conversion of SetWidgetLoweredState to SetWindowWidgetLoweredState, in order to follow pre-established standard
belugas
parents:
4719
diff
changeset
|
221 |
SetWindowWidgetLoweredState(w, 17, _station_show_coverage); |
541 | 222 |
SndPlayFx(SND_15_BEEP); |
0 | 223 |
SetWindowDirty(w); |
224 |
break; |
|
225 |
} |
|
226 |
} break; |
|
227 |
||
228 |
case WE_MOUSELOOP: { |
|
229 |
if (WP(w,def_d).close) { |
|
230 |
DeleteWindow(w); |
|
231 |
return; |
|
232 |
} |
|
233 |
||
234 |
CheckRedrawStationCoverage(w); |
|
235 |
} break; |
|
1109
1bab892228cd
(svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents:
1093
diff
changeset
|
236 |
|
1072
01bf9fc64236
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1019
diff
changeset
|
237 |
case WE_DESTROY: |
2639 | 238 |
if (!WP(w,def_d).close) ResetObjectToPlace(); |
1072
01bf9fc64236
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1019
diff
changeset
|
239 |
break; |
0 | 240 |
} |
241 |
} |
|
242 |
||
243 |
static const Widget _build_airport_picker_widgets[] = { |
|
4345
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
244 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
245 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_3001_AIRPORT_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
246 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 147, 14, 52, 0x0, STR_NULL}, |
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
247 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 147, 53, 89, 0x0, STR_NULL}, |
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
248 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 147, 90, 127, 0x0, STR_NULL}, |
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
249 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 147, 128, 177, 0x0, STR_NULL}, |
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
250 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 147, 178, 239, 0x0, STR_NULL}, |
4968
6cfec8858f17
(svn r6971) -Fix r6961: WWT_NODISTXTBTN buttons were normal buttons not push buttons
glx
parents:
4963
diff
changeset
|
251 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 27, 38, STR_SMALL_AIRPORT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
6cfec8858f17
(svn r6971) -Fix r6961: WWT_NODISTXTBTN buttons were normal buttons not push buttons
glx
parents:
4963
diff
changeset
|
252 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 65, 76, STR_CITY_AIRPORT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
6cfec8858f17
(svn r6971) -Fix r6961: WWT_NODISTXTBTN buttons were normal buttons not push buttons
glx
parents:
4963
diff
changeset
|
253 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 141, 152, STR_HELIPORT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
6cfec8858f17
(svn r6971) -Fix r6961: WWT_NODISTXTBTN buttons were normal buttons not push buttons
glx
parents:
4963
diff
changeset
|
254 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 77, 88, STR_METRO_AIRPORT , STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
6cfec8858f17
(svn r6971) -Fix r6961: WWT_NODISTXTBTN buttons were normal buttons not push buttons
glx
parents:
4963
diff
changeset
|
255 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 103, 114, STR_INTERNATIONAL_AIRPORT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
6cfec8858f17
(svn r6971) -Fix r6961: WWT_NODISTXTBTN buttons were normal buttons not push buttons
glx
parents:
4963
diff
changeset
|
256 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 39, 50, STR_COMMUTER_AIRPORT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
6cfec8858f17
(svn r6971) -Fix r6961: WWT_NODISTXTBTN buttons were normal buttons not push buttons
glx
parents:
4963
diff
changeset
|
257 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 165, 176, STR_HELIDEPOT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
6cfec8858f17
(svn r6971) -Fix r6961: WWT_NODISTXTBTN buttons were normal buttons not push buttons
glx
parents:
4963
diff
changeset
|
258 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 115, 126, STR_INTERCONTINENTAL_AIRPORT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
6cfec8858f17
(svn r6971) -Fix r6961: WWT_NODISTXTBTN buttons were normal buttons not push buttons
glx
parents:
4963
diff
changeset
|
259 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 153, 164, STR_HELISTATION, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
4345
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
260 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 14, 73, 191, 202, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE}, |
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
261 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 74, 133, 191, 202, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA}, |
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
262 |
{ WWT_LABEL, RESIZE_NONE, 7, 0, 147, 14, 27, STR_SMALL_AIRPORTS, STR_NULL}, |
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
263 |
{ WWT_LABEL, RESIZE_NONE, 7, 0, 147, 52, 65, STR_LARGE_AIRPORTS, STR_NULL}, |
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
264 |
{ WWT_LABEL, RESIZE_NONE, 7, 0, 147, 90, 103, STR_HUB_AIRPORTS, STR_NULL}, |
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
265 |
{ WWT_LABEL, RESIZE_NONE, 7, 0, 147, 128, 141, STR_HELIPORTS, STR_NULL}, |
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
266 |
{ WWT_LABEL, RESIZE_NONE, 7, 0, 147, 178, 191, 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
|
267 |
{ WIDGETS_END}, |
0 | 268 |
}; |
269 |
||
270 |
static const WindowDesc _build_airport_desc = { |
|
5070
0bbf5264bfb7
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
271 |
WDP_AUTO, WDP_AUTO, 148, 240, |
0bbf5264bfb7
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
272 |
WC_BUILD_STATION, WC_BUILD_TOOLBAR, |
0 | 273 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
274 |
_build_airport_picker_widgets, |
|
275 |
BuildAirportPickerWndProc |
|
276 |
}; |
|
277 |
||
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
|
278 |
static void ShowBuildAirportPicker(void) |
0 | 279 |
{ |
280 |
AllocateWindowDesc(&_build_airport_desc); |
|
281 |
} |
|
282 |
||
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
|
283 |
void InitializeAirportGui(void) |
0 | 284 |
{ |
285 |
_selected_airport_type = AT_SMALL; |
|
286 |
} |