author | belugas |
Sat, 10 May 2008 02:59:52 +0000 | |
changeset 9163 | c874bf1e0442 |
parent 9161 | fda175383e87 |
child 9238 | e2f586d12318 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
9111
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
9080
diff
changeset
|
3 |
/** @file airport_gui.cpp The GUI for airports. */ |
6117
6507b2a7e71d
(svn r8853) -Cleanup: doxygen changes. Correct forgotten c files to cpp files with the @file tag as well as a few general comments style
belugas
parents:
6042
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1784
diff
changeset
|
6 |
#include "openttd.h" |
8107
bb7deea89175
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8106
diff
changeset
|
7 |
#include "window_gui.h" |
0 | 8 |
#include "gui.h" |
8107
bb7deea89175
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8106
diff
changeset
|
9 |
#include "station_gui.h" |
8205
2bde724f1b5d
(svn r11768) -Codechange: move some terraform related gui stuff from main_gui.cpp to terraform_gui.cpp (and introduce terraform_gui.h). Based on a patch by Roujin.
rubidium
parents:
8157
diff
changeset
|
10 |
#include "terraform_gui.h" |
8116
8da76dcb3287
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
8107
diff
changeset
|
11 |
#include "command_func.h" |
0 | 12 |
#include "airport.h" |
8157
1505def01945
(svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium
parents:
8144
diff
changeset
|
13 |
#include "sound_func.h" |
8131
160939e24ed3
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8121
diff
changeset
|
14 |
#include "window_func.h" |
8270
e7c342f6b14c
(svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents:
8264
diff
changeset
|
15 |
#include "settings_type.h" |
8224
c5a64d87cc54
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8211
diff
changeset
|
16 |
#include "viewport_func.h" |
c5a64d87cc54
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8211
diff
changeset
|
17 |
#include "gfx_func.h" |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8237
diff
changeset
|
18 |
#include "player_func.h" |
8784
c2e9d649a9ce
(svn r12488) -Codechange: split order.h into order_base.h and order_func.h.
rubidium
parents:
8574
diff
changeset
|
19 |
#include "order_func.h" |
8962
1b263c69799d
(svn r12754) -Codechange: split depot.h into depot_map.h, depot_func.h and depot_base.h and remove quite a lot of unneeded (before this) includes of depot.h.
rubidium
parents:
8910
diff
changeset
|
20 |
#include "station_type.h" |
9127
14f21c5954ee
(svn r12987) -Codechange: split viewport and tile selection.
rubidium
parents:
9123
diff
changeset
|
21 |
#include "tilehighlight_func.h" |
0 | 22 |
|
8264
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
23 |
#include "table/sprites.h" |
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
24 |
#include "table/strings.h" |
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
25 |
|
0 | 26 |
static byte _selected_airport_type; |
27 |
||
6247 | 28 |
static void ShowBuildAirportPicker(); |
0 | 29 |
|
30 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
31 |
void CcBuildAirport(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 32 |
{ |
33 |
if (success) { |
|
541 | 34 |
SndPlayTileFx(SND_1F_SPLAT, tile); |
0 | 35 |
ResetObjectToPlace(); |
36 |
} |
|
37 |
} |
|
38 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
39 |
static void PlaceAirport(TileIndex tile) |
0 | 40 |
{ |
7521
0da1e91510e4
(svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents:
7341
diff
changeset
|
41 |
DoCommandP(tile, _selected_airport_type, _ctrl_pressed, CcBuildAirport, CMD_BUILD_AIRPORT | CMD_NO_WATER | CMD_MSG(STR_A001_CAN_T_BUILD_AIRPORT_HERE)); |
0 | 42 |
} |
43 |
||
44 |
||
5147
866030c20f0a
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
45 |
enum { |
866030c20f0a
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
46 |
ATW_AIRPORT = 3, |
866030c20f0a
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
47 |
ATW_DEMOLISH = 4 |
866030c20f0a
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
48 |
}; |
866030c20f0a
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
49 |
|
866030c20f0a
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
50 |
|
0 | 51 |
static void BuildAirClick_Airport(Window *w) |
52 |
{ |
|
7889
e74ce8853ba7
(svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents:
7521
diff
changeset
|
53 |
if (HandlePlacePushButton(w, ATW_AIRPORT, SPR_CURSOR_AIRPORT, VHM_RECT, PlaceAirport)) ShowBuildAirportPicker(); |
0 | 54 |
} |
55 |
||
56 |
static void BuildAirClick_Demolish(Window *w) |
|
57 |
{ |
|
9123
d2a939cbdf1d
(svn r12983) -Codechange [FS#1987] : Unification of all dynamite tools calls to only one. Thanks to Roujin
belugas
parents:
9116
diff
changeset
|
58 |
HandlePlacePushButton(w, ATW_DEMOLISH, ANIMCURSOR_DEMOLISH, VHM_RECT, PlaceProc_DemolishArea); |
0 | 59 |
} |
60 |
||
61 |
||
62 |
typedef void OnButtonClick(Window *w); |
|
63 |
static OnButtonClick * const _build_air_button_proc[] = { |
|
64 |
BuildAirClick_Airport, |
|
65 |
BuildAirClick_Demolish, |
|
66 |
}; |
|
67 |
||
68 |
static void BuildAirToolbWndProc(Window *w, WindowEvent *e) |
|
69 |
{ |
|
2639 | 70 |
switch (e->event) { |
8879
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
71 |
case WE_PAINT: |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
72 |
DrawWindowWidgets(w); |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
73 |
break; |
0 | 74 |
|
8879
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
75 |
case WE_CLICK: |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
76 |
if (e->we.click.widget - 3 >= 0) |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
77 |
_build_air_button_proc[e->we.click.widget - 3](w); |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
78 |
break; |
0 | 79 |
|
8879
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
80 |
case WE_KEYPRESS: { |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
81 |
switch (e->we.keypress.keycode) { |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
82 |
case '1': BuildAirClick_Airport(w); break; |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
83 |
case '2': BuildAirClick_Demolish(w); break; |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
84 |
default: return; |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
85 |
} |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
86 |
} break; |
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
87 |
|
8879
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
88 |
case WE_PLACE_OBJ: |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
89 |
_place_proc(e->we.place.tile); |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
90 |
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:
2186
diff
changeset
|
91 |
|
8879
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
92 |
case WE_PLACE_DRAG: |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
93 |
VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method); |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
94 |
break; |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
95 |
|
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
96 |
case WE_PLACE_MOUSEUP: |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
97 |
if (e->we.place.pt.x != -1 && e->we.place.select_proc == DDSP_DEMOLISH_AREA) { |
9163
c874bf1e0442
(svn r13026) -Codechange[FS#1999]: Further Dynamite Tool Unification.(Roujin)
belugas
parents:
9161
diff
changeset
|
98 |
GUIPlaceProcDragXY(e); |
8879
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
99 |
} |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
100 |
break; |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
101 |
|
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
102 |
case WE_ABORT_PLACE_OBJ: |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
103 |
w->RaiseButtons(); |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
104 |
|
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
105 |
w = FindWindowById(WC_BUILD_STATION, 0); |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
106 |
if (w != 0) |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
107 |
WP(w, def_d).close = true; |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
108 |
break; |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
109 |
|
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
110 |
case WE_DESTROY: |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
111 |
if (_patches.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0); |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
112 |
break; |
0 | 113 |
} |
114 |
} |
|
115 |
||
116 |
static const Widget _air_toolbar_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:
4171
diff
changeset
|
117 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW }, |
5682
f109e2e62af8
(svn r8143) Remove the landscaping button from the build toolbars.
tron
parents:
5587
diff
changeset
|
118 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 51, 0, 13, STR_A000_AIRPORTS, STR_018C_WINDOW_TITLE_DRAG_THIS }, |
f109e2e62af8
(svn r8143) Remove the landscaping button from the build toolbars.
tron
parents:
5587
diff
changeset
|
119 |
{ WWT_STICKYBOX, RESIZE_NONE, 7, 52, 63, 0, 13, 0x0, STR_STICKY_BUTTON }, |
4937
8cfdd86fd709
(svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents:
4848
diff
changeset
|
120 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 41, 14, 35, SPR_IMG_AIRPORT, STR_A01E_BUILD_AIRPORT }, |
8cfdd86fd709
(svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents:
4848
diff
changeset
|
121 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 42, 63, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC }, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
0
diff
changeset
|
122 |
{ WIDGETS_END}, |
0 | 123 |
}; |
124 |
||
125 |
||
126 |
static const WindowDesc _air_toolbar_desc = { |
|
7341
02515d0d4ced
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7241
diff
changeset
|
127 |
WDP_ALIGN_TBR, 22, 64, 36, 64, 36, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5860
diff
changeset
|
128 |
WC_BUILD_TOOLBAR, WC_NONE, |
756
b76998029c12
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
751
diff
changeset
|
129 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, |
0 | 130 |
_air_toolbar_widgets, |
131 |
BuildAirToolbWndProc |
|
132 |
}; |
|
133 |
||
6247 | 134 |
void ShowBuildAirToolbar() |
0 | 135 |
{ |
5005
f5086bd3945a
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4968
diff
changeset
|
136 |
if (!IsValidPlayer(_current_player)) return; |
f5086bd3945a
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4968
diff
changeset
|
137 |
|
9080
34bc7cbbb79a
(svn r12939) -Codechange: do not use the window proc to determine whether a toolbar is a rail toolbar, but use the window number.
rubidium
parents:
9066
diff
changeset
|
138 |
DeleteWindowByClass(WC_BUILD_TOOLBAR); |
9143
029e126e3439
(svn r13005) -Codechange: prepare AllocateWindowDescFront for subclassing of Window.
rubidium
parents:
9142
diff
changeset
|
139 |
Window *w = AllocateWindowDescFront<Window>(&_air_toolbar_desc, TRANSPORT_AIR); |
5860 | 140 |
if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w); |
0 | 141 |
} |
142 |
||
8910
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
143 |
enum { |
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
144 |
BAW_BOTTOMPANEL = 10, |
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
145 |
BAW_SMALL_AIRPORT, |
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
146 |
BAW_CITY_AIRPORT, |
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
147 |
BAW_HELIPORT, |
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
148 |
BAW_METRO_AIRPORT, |
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
149 |
BAW_STR_INTERNATIONAL_AIRPORT, |
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
150 |
BAW_COMMUTER_AIRPORT, |
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
151 |
BAW_HELIDEPOT, |
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
152 |
BAW_STR_INTERCONTINENTAL_AIRPORT, |
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
153 |
BAW_HELISTATION, |
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
154 |
BAW_LAST_AIRPORT = BAW_HELISTATION, |
9066
a58f0904ec02
(svn r12918) -Fix [FS#1963] (r12679): last airport would always be shown as buildable even when it was not.
rubidium
parents:
8962
diff
changeset
|
155 |
BAW_AIRPORT_COUNT = BAW_LAST_AIRPORT - BAW_SMALL_AIRPORT + 1, |
8910
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
156 |
BAW_BTN_DONTHILIGHT = BAW_LAST_AIRPORT + 1, |
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
157 |
BAW_BTN_DOHILIGHT, |
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
158 |
}; |
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
159 |
|
0 | 160 |
static void BuildAirportPickerWndProc(Window *w, WindowEvent *e) |
161 |
{ |
|
1784
d0698aac0c2e
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1363
diff
changeset
|
162 |
switch (e->event) { |
8879
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
163 |
case WE_CREATE: |
8910
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
164 |
w->SetWidgetLoweredState(BAW_BTN_DONTHILIGHT, !_station_show_coverage); |
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
165 |
w->SetWidgetLoweredState(BAW_BTN_DOHILIGHT, _station_show_coverage); |
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
166 |
w->LowerWidget(_selected_airport_type + BAW_SMALL_AIRPORT); |
8879
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
167 |
break; |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
168 |
|
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
169 |
case WE_PAINT: { |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
170 |
int i; // airport enabling loop |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
171 |
uint32 avail_airports; |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
172 |
const AirportFTAClass *airport; |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
173 |
|
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
174 |
if (WP(w, def_d).close) return; |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
175 |
|
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
176 |
avail_airports = GetValidAirports(); |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
177 |
|
8910
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
178 |
w->RaiseWidget(_selected_airport_type + BAW_SMALL_AIRPORT); |
8879
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
179 |
if (!HasBit(avail_airports, 0) && _selected_airport_type == AT_SMALL) _selected_airport_type = AT_LARGE; |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
180 |
if (!HasBit(avail_airports, 1) && _selected_airport_type == AT_LARGE) _selected_airport_type = AT_SMALL; |
8910
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
181 |
w->LowerWidget(_selected_airport_type + BAW_SMALL_AIRPORT); |
8879
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
182 |
|
8910
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
183 |
/* 'Country Airport' starts at widget BAW_SMALL_AIRPORT, and if its bit is set, it is |
8879
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
184 |
* available, so take its opposite value to set the disabled state. |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
185 |
* There are 9 buildable airports |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
186 |
* XXX TODO : all airports should be held in arrays, with all relevant data. |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
187 |
* This should be part of newgrf-airports, i suppose |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
188 |
*/ |
8910
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
189 |
for (i = 0; i < BAW_AIRPORT_COUNT; i++) w->SetWidgetDisabledState(i + BAW_SMALL_AIRPORT, !HasBit(avail_airports, i)); |
8879
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
190 |
|
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
191 |
/* select default the coverage area to 'Off' (16) */ |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
192 |
airport = GetAirport(_selected_airport_type); |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
193 |
SetTileSelectSize(airport->size_x, airport->size_y); |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
194 |
|
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
195 |
int rad = _patches.modified_catchment ? airport->catchment : (uint)CA_UNMODIFIED; |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
196 |
|
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
197 |
if (_station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
198 |
|
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
199 |
DrawWindowWidgets(w); |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
200 |
/* strings such as 'Size' and 'Coverage Area' */ |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
201 |
int text_end = DrawStationCoverageAreaText(2, 206, SCT_ALL, rad, false); |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
202 |
text_end = DrawStationCoverageAreaText(2, text_end + 4, SCT_ALL, rad, true) + 4; |
8910
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
203 |
if (text_end != w->widget[BAW_BOTTOMPANEL].bottom) { |
9116
f2491d3c321b
(svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents:
9115
diff
changeset
|
204 |
w->SetDirty(); |
8910
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
205 |
ResizeWindowForWidget(w, BAW_BOTTOMPANEL, 0, text_end - w->widget[BAW_BOTTOMPANEL].bottom); |
9116
f2491d3c321b
(svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents:
9115
diff
changeset
|
206 |
w->SetDirty(); |
8879
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
207 |
} |
0 | 208 |
break; |
209 |
} |
|
210 |
||
8879
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
211 |
case WE_CLICK: { |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
212 |
switch (e->we.click.widget) { |
8910
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
213 |
case BAW_SMALL_AIRPORT: case BAW_CITY_AIRPORT: case BAW_HELIPORT: case BAW_METRO_AIRPORT: |
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
214 |
case BAW_STR_INTERNATIONAL_AIRPORT: case BAW_COMMUTER_AIRPORT: case BAW_HELIDEPOT: |
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
215 |
case BAW_STR_INTERCONTINENTAL_AIRPORT: case BAW_HELISTATION: |
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
216 |
w->RaiseWidget(_selected_airport_type + BAW_SMALL_AIRPORT); |
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
217 |
_selected_airport_type = e->we.click.widget - BAW_SMALL_AIRPORT; |
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
218 |
w->LowerWidget(_selected_airport_type + BAW_SMALL_AIRPORT); |
8879
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
219 |
SndPlayFx(SND_15_BEEP); |
9116
f2491d3c321b
(svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents:
9115
diff
changeset
|
220 |
w->SetDirty(); |
8879
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
221 |
break; |
0 | 222 |
|
8910
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
223 |
case BAW_BTN_DONTHILIGHT: case BAW_BTN_DOHILIGHT: |
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
224 |
_station_show_coverage = (e->we.click.widget != BAW_BTN_DONTHILIGHT); |
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
225 |
w->SetWidgetLoweredState(BAW_BTN_DONTHILIGHT, !_station_show_coverage); |
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
226 |
w->SetWidgetLoweredState(BAW_BTN_DOHILIGHT, _station_show_coverage); |
8880
5b12cb0d9819
(svn r12647) -Codechange: Ooops... Too fast on the job... forgot to indent 3 lines
belugas
parents:
8879
diff
changeset
|
227 |
SndPlayFx(SND_15_BEEP); |
9116
f2491d3c321b
(svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents:
9115
diff
changeset
|
228 |
w->SetDirty(); |
8880
5b12cb0d9819
(svn r12647) -Codechange: Ooops... Too fast on the job... forgot to indent 3 lines
belugas
parents:
8879
diff
changeset
|
229 |
break; |
8879
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
230 |
} |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
231 |
} break; |
1109
ecb98f43ba2c
(svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents:
1093
diff
changeset
|
232 |
|
9161
fda175383e87
(svn r13024) -Codechange: do not use WE_MOUSELOOP when WE_TICK suffices, rename WE_4 to something more descriptive and correct some (completely incorrect) comments.
rubidium
parents:
9143
diff
changeset
|
233 |
case WE_TICK: { |
8879
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
234 |
if (WP(w, def_d).close) { |
9115
47ae980bace3
(svn r12975) -Codechange: replace DeleteWindow(w) with delete w.
rubidium
parents:
9111
diff
changeset
|
235 |
delete w; |
8879
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
236 |
return; |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
237 |
} |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
238 |
|
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
239 |
CheckRedrawStationCoverage(w); |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
240 |
} break; |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
241 |
|
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
242 |
case WE_DESTROY: |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
243 |
if (!WP(w, def_d).close) ResetObjectToPlace(); |
976ce196dddf
(svn r12646) -Codechange: another run of code-style cleanup
belugas
parents:
8878
diff
changeset
|
244 |
break; |
0 | 245 |
} |
246 |
} |
|
247 |
||
248 |
static const Widget _build_airport_picker_widgets[] = { |
|
4345
1da147230c79
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
249 |
{ 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
|
250 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_3001_AIRPORT_SELECTION, 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
|
251 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 147, 14, 52, 0x0, STR_NULL}, |
8910
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
252 |
{ WWT_LABEL, RESIZE_NONE, 7, 0, 147, 14, 27, STR_SMALL_AIRPORTS, STR_NULL}, |
4345
1da147230c79
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
253 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 147, 53, 89, 0x0, STR_NULL}, |
8910
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
254 |
{ WWT_LABEL, RESIZE_NONE, 7, 0, 147, 52, 65, STR_LARGE_AIRPORTS, STR_NULL}, |
4345
1da147230c79
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
255 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 147, 90, 127, 0x0, STR_NULL}, |
8910
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
256 |
{ WWT_LABEL, RESIZE_NONE, 7, 0, 147, 90, 103, STR_HUB_AIRPORTS, STR_NULL}, |
4345
1da147230c79
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
257 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 147, 128, 177, 0x0, STR_NULL}, |
8910
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
258 |
{ WWT_LABEL, RESIZE_NONE, 7, 0, 147, 128, 141, STR_HELIPORTS, STR_NULL}, |
d7e2e6246a52
(svn r12679) -Codechange : a little bit of widget enumification
belugas
parents:
8880
diff
changeset
|
259 |
{ WWT_PANEL, RESIZE_NONE, 7, 0, 147, 178, 239, 0x0, STR_NULL}, // bottom general box |
4968
59dcd41ce2d0
(svn r6971) -Fix r6961: WWT_NODISTXTBTN buttons were normal buttons not push buttons
glx
parents:
4963
diff
changeset
|
260 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 27, 38, STR_SMALL_AIRPORT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
59dcd41ce2d0
(svn r6971) -Fix r6961: WWT_NODISTXTBTN buttons were normal buttons not push buttons
glx
parents:
4963
diff
changeset
|
261 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 65, 76, STR_CITY_AIRPORT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
59dcd41ce2d0
(svn r6971) -Fix r6961: WWT_NODISTXTBTN buttons were normal buttons not push buttons
glx
parents:
4963
diff
changeset
|
262 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 141, 152, STR_HELIPORT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
59dcd41ce2d0
(svn r6971) -Fix r6961: WWT_NODISTXTBTN buttons were normal buttons not push buttons
glx
parents:
4963
diff
changeset
|
263 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 77, 88, STR_METRO_AIRPORT , STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
59dcd41ce2d0
(svn r6971) -Fix r6961: WWT_NODISTXTBTN buttons were normal buttons not push buttons
glx
parents:
4963
diff
changeset
|
264 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 103, 114, STR_INTERNATIONAL_AIRPORT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
59dcd41ce2d0
(svn r6971) -Fix r6961: WWT_NODISTXTBTN buttons were normal buttons not push buttons
glx
parents:
4963
diff
changeset
|
265 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 39, 50, STR_COMMUTER_AIRPORT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
59dcd41ce2d0
(svn r6971) -Fix r6961: WWT_NODISTXTBTN buttons were normal buttons not push buttons
glx
parents:
4963
diff
changeset
|
266 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 165, 176, STR_HELIDEPOT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
59dcd41ce2d0
(svn r6971) -Fix r6961: WWT_NODISTXTBTN buttons were normal buttons not push buttons
glx
parents:
4963
diff
changeset
|
267 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 115, 126, STR_INTERCONTINENTAL_AIRPORT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
59dcd41ce2d0
(svn r6971) -Fix r6961: WWT_NODISTXTBTN buttons were normal buttons not push buttons
glx
parents:
4963
diff
changeset
|
268 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 145, 153, 164, STR_HELISTATION, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
4345
1da147230c79
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
269 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 14, 73, 191, 202, 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
|
270 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 74, 133, 191, 202, 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
|
271 |
{ 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
|
272 |
{ WIDGETS_END}, |
0 | 273 |
}; |
274 |
||
275 |
static const WindowDesc _build_airport_desc = { |
|
7341
02515d0d4ced
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7241
diff
changeset
|
276 |
WDP_AUTO, WDP_AUTO, 148, 240, 148, 240, |
5070
7f5b13b7e728
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
277 |
WC_BUILD_STATION, WC_BUILD_TOOLBAR, |
0 | 278 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
279 |
_build_airport_picker_widgets, |
|
280 |
BuildAirportPickerWndProc |
|
281 |
}; |
|
282 |
||
6247 | 283 |
static void ShowBuildAirportPicker() |
0 | 284 |
{ |
9142
858a058aa730
(svn r13004) -Codechange: replace AllocateWindow and AllocateWindowDesc with a Window constructor.
rubidium
parents:
9127
diff
changeset
|
285 |
new Window(&_build_airport_desc); |
0 | 286 |
} |
287 |
||
6247 | 288 |
void InitializeAirportGui() |
0 | 289 |
{ |
290 |
_selected_airport_type = AT_SMALL; |
|
291 |
} |