author | convert-repo |
Mon, 07 Apr 2008 16:21:55 +0000 | |
changeset 10076 | dfd70e42c4ae |
parent 9342 | ca61cbfca47a |
child 10114 | ceae65760994 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6443
b8f06d8eb7be
(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:
6368
diff
changeset
|
3 |
/** @file airport_gui.cpp */ |
b8f06d8eb7be
(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:
6368
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1784
diff
changeset
|
6 |
#include "openttd.h" |
8603
88c5ce6a5215
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8602
diff
changeset
|
7 |
#include "window_gui.h" |
0 | 8 |
#include "gui.h" |
8603
88c5ce6a5215
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8602
diff
changeset
|
9 |
#include "station_gui.h" |
8701
051036216675
(svn r11768) -Codechange: move some terraform related gui stuff from main_gui.cpp to terraform_gui.cpp (and introduce terraform_gui.h). Based on a patch by Roujin.
rubidium
parents:
8653
diff
changeset
|
10 |
#include "terraform_gui.h" |
8612
6414fc21c2f3
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
8603
diff
changeset
|
11 |
#include "command_func.h" |
0 | 12 |
#include "airport.h" |
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1116
diff
changeset
|
13 |
#include "depot.h" |
8653
a83f7a536919
(svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium
parents:
8640
diff
changeset
|
14 |
#include "sound_func.h" |
8627
448ebf3a8291
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8617
diff
changeset
|
15 |
#include "window_func.h" |
8766
c86cfa3a7580
(svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents:
8760
diff
changeset
|
16 |
#include "settings_type.h" |
8720
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8707
diff
changeset
|
17 |
#include "viewport_func.h" |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8707
diff
changeset
|
18 |
#include "gfx_func.h" |
8750
fdd6054e7bae
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8733
diff
changeset
|
19 |
#include "player_func.h" |
9280
9c03416d26b1
(svn r12488) -Codechange: split order.h into order_base.h and order_func.h.
rubidium
parents:
9070
diff
changeset
|
20 |
#include "order_func.h" |
0 | 21 |
|
8760
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
22 |
#include "table/sprites.h" |
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
23 |
#include "table/strings.h" |
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
24 |
|
0 | 25 |
static byte _selected_airport_type; |
26 |
||
6573 | 27 |
static void ShowBuildAirportPicker(); |
0 | 28 |
|
29 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
30 |
void CcBuildAirport(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 31 |
{ |
32 |
if (success) { |
|
541 | 33 |
SndPlayTileFx(SND_1F_SPLAT, tile); |
0 | 34 |
ResetObjectToPlace(); |
35 |
} |
|
36 |
} |
|
37 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
38 |
static void PlaceAirport(TileIndex tile) |
0 | 39 |
{ |
8017
8c46e61c510f
(svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents:
7837
diff
changeset
|
40 |
DoCommandP(tile, _selected_airport_type, _ctrl_pressed, CcBuildAirport, CMD_BUILD_AIRPORT | CMD_NO_WATER | CMD_MSG(STR_A001_CAN_T_BUILD_AIRPORT_HERE)); |
0 | 41 |
} |
42 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1914
diff
changeset
|
43 |
static void PlaceAir_DemolishArea(TileIndex tile) |
0 | 44 |
{ |
7166
3937d5ea59df
(svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents:
7165
diff
changeset
|
45 |
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_DEMOLISH_AREA); |
0 | 46 |
} |
47 |
||
48 |
||
5147
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
49 |
enum { |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
50 |
ATW_AIRPORT = 3, |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
51 |
ATW_DEMOLISH = 4 |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
52 |
}; |
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
53 |
|
db717cde801d
(svn r7239) Enumerate the widgets in the airport, dock, rail and road toolbars
tron
parents:
5072
diff
changeset
|
54 |
|
0 | 55 |
static void BuildAirClick_Airport(Window *w) |
56 |
{ |
|
8385
aedd7656cfd1
(svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents:
8017
diff
changeset
|
57 |
if (HandlePlacePushButton(w, ATW_AIRPORT, SPR_CURSOR_AIRPORT, VHM_RECT, PlaceAirport)) ShowBuildAirportPicker(); |
0 | 58 |
} |
59 |
||
60 |
static void BuildAirClick_Demolish(Window *w) |
|
61 |
{ |
|
8385
aedd7656cfd1
(svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents:
8017
diff
changeset
|
62 |
HandlePlacePushButton(w, ATW_DEMOLISH, ANIMCURSOR_DEMOLISH, VHM_RECT, PlaceAir_DemolishArea); |
0 | 63 |
} |
64 |
||
65 |
||
66 |
typedef void OnButtonClick(Window *w); |
|
67 |
static OnButtonClick * const _build_air_button_proc[] = { |
|
68 |
BuildAirClick_Airport, |
|
69 |
BuildAirClick_Demolish, |
|
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; |
2631
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2619
diff
changeset
|
88 |
default: return; |
937
a8dfd3eb406f
(svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents:
867
diff
changeset
|
89 |
} |
a8dfd3eb406f
(svn r1425) Added hotkeys for dock and airport toolbar
celestar
parents:
867
diff
changeset
|
90 |
} break; |
0 | 91 |
|
92 |
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
|
93 |
_place_proc(e->we.place.tile); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
94 |
break; |
0 | 95 |
|
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
96 |
case WE_PLACE_DRAG: |
7165
37eb253f3c06
(svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents:
6987
diff
changeset
|
97 |
VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method); |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
98 |
break; |
0 | 99 |
|
100 |
case WE_PLACE_MOUSEUP: |
|
7166
3937d5ea59df
(svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents:
7165
diff
changeset
|
101 |
if (e->we.place.pt.x != -1 && e->we.place.select_proc == DDSP_DEMOLISH_AREA) { |
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 |
DoCommandP(e->we.place.tile, e->we.place.starttile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA)); |
0 | 103 |
} |
104 |
break; |
|
105 |
||
106 |
case WE_ABORT_PLACE_OBJ: |
|
8528
04b4ef9abd9b
(svn r11592) -Codechange: Use the Window member RaiseButtons and remove the now useless RaiseWindowButtons function
belugas
parents:
8493
diff
changeset
|
107 |
w->RaiseButtons(); |
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
108 |
|
0 | 109 |
w = FindWindowById(WC_BUILD_STATION, 0); |
110 |
if (w != 0) |
|
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6573
diff
changeset
|
111 |
WP(w, def_d).close = true; |
0 | 112 |
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
|
113 |
|
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 |
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
|
115 |
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
|
116 |
break; |
0 | 117 |
} |
118 |
} |
|
119 |
||
120 |
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
|
121 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW }, |
5933
0835f3342b79
(svn r8143) Remove the landscaping button from the build toolbars.
tron
parents:
5838
diff
changeset
|
122 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 51, 0, 13, STR_A000_AIRPORTS, STR_018C_WINDOW_TITLE_DRAG_THIS }, |
0835f3342b79
(svn r8143) Remove the landscaping button from the build toolbars.
tron
parents:
5838
diff
changeset
|
123 |
{ WWT_STICKYBOX, RESIZE_NONE, 7, 52, 63, 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
|
124 |
{ 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
|
125 |
{ 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
|
126 |
{ WIDGETS_END}, |
0 | 127 |
}; |
128 |
||
129 |
||
130 |
static const WindowDesc _air_toolbar_desc = { |
|
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7737
diff
changeset
|
131 |
WDP_ALIGN_TBR, 22, 64, 36, 64, 36, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6111
diff
changeset
|
132 |
WC_BUILD_TOOLBAR, WC_NONE, |
756
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
751
diff
changeset
|
133 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, |
0 | 134 |
_air_toolbar_widgets, |
135 |
BuildAirToolbWndProc |
|
136 |
}; |
|
137 |
||
6573 | 138 |
void ShowBuildAirToolbar() |
0 | 139 |
{ |
5005
21e84e53c732
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4968
diff
changeset
|
140 |
if (!IsValidPlayer(_current_player)) return; |
21e84e53c732
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4968
diff
changeset
|
141 |
|
0 | 142 |
DeleteWindowById(WC_BUILD_TOOLBAR, 0); |
6111 | 143 |
Window *w = AllocateWindowDescFront(&_air_toolbar_desc, 0); |
144 |
if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w); |
|
0 | 145 |
} |
146 |
||
147 |
static void BuildAirportPickerWndProc(Window *w, WindowEvent *e) |
|
148 |
{ |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1363
diff
changeset
|
149 |
switch (e->event) { |
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
150 |
case WE_CREATE: |
8493
3ab458f7cff4
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
8424
diff
changeset
|
151 |
w->SetWidgetLoweredState(16, !_station_show_coverage); |
3ab458f7cff4
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
8424
diff
changeset
|
152 |
w->SetWidgetLoweredState(17, _station_show_coverage); |
3ab458f7cff4
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
8424
diff
changeset
|
153 |
w->LowerWidget(_selected_airport_type + 7); |
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
154 |
break; |
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
155 |
|
0 | 156 |
case WE_PAINT: { |
4709
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
157 |
int i; // airport enabling loop |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1363
diff
changeset
|
158 |
uint32 avail_airports; |
4171 | 159 |
const AirportFTAClass *airport; |
0 | 160 |
|
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6573
diff
changeset
|
161 |
if (WP(w, def_d).close) return; |
0 | 162 |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1363
diff
changeset
|
163 |
avail_airports = GetValidAirports(); |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1363
diff
changeset
|
164 |
|
8493
3ab458f7cff4
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
8424
diff
changeset
|
165 |
w->RaiseWidget(_selected_airport_type + 7); |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8385
diff
changeset
|
166 |
if (!HasBit(avail_airports, 0) && _selected_airport_type == AT_SMALL) _selected_airport_type = AT_LARGE; |
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8385
diff
changeset
|
167 |
if (!HasBit(avail_airports, 1) && _selected_airport_type == AT_LARGE) _selected_airport_type = AT_SMALL; |
8493
3ab458f7cff4
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
8424
diff
changeset
|
168 |
w->LowerWidget(_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
|
169 |
|
4709
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
170 |
/* '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
|
171 |
* 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
|
172 |
* There are 9 buildable airports |
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
173 |
* 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
|
174 |
* This should be part of newgrf-airports, i suppose |
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
175 |
*/ |
8493
3ab458f7cff4
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
8424
diff
changeset
|
176 |
for (i = 0; i < 9; i++) w->SetWidgetDisabledState(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
|
177 |
|
4059
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3884
diff
changeset
|
178 |
// select default the coverage area to 'Off' (16) |
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
179 |
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
|
180 |
SetTileSelectSize(airport->size_x, airport->size_y); |
568
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
181 |
|
9070
e83a2f017f3d
(svn r12155) -Fix (r12154): some warnings (always compile before commit)
glx
parents:
9069
diff
changeset
|
182 |
int rad = _patches.modified_catchment ? airport->catchment : (uint)CA_UNMODIFIED; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
792
diff
changeset
|
183 |
|
2639 | 184 |
if (_station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); |
0 | 185 |
|
186 |
DrawWindowWidgets(w); |
|
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4059
diff
changeset
|
187 |
// 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
|
188 |
// 'Coverage Area' |
9342
ca61cbfca47a
(svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents:
9281
diff
changeset
|
189 |
int text_end = DrawStationCoverageAreaText(2, 206, SCT_ALL, rad, false); |
ca61cbfca47a
(svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents:
9281
diff
changeset
|
190 |
text_end = DrawStationCoverageAreaText(2, text_end + 4, SCT_ALL, rad, true) + 4; |
ca61cbfca47a
(svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
rubidium
parents:
9281
diff
changeset
|
191 |
if (text_end != w->widget[6].bottom) { |
8919
b627c71f9cc3
(svn r11993) -Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long.
peter1138
parents:
8766
diff
changeset
|
192 |
SetWindowDirty(w); |
b627c71f9cc3
(svn r11993) -Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long.
peter1138
parents:
8766
diff
changeset
|
193 |
ResizeWindowForWidget(w, 6, 0, text_end - w->widget[6].bottom); |
b627c71f9cc3
(svn r11993) -Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long.
peter1138
parents:
8766
diff
changeset
|
194 |
SetWindowDirty(w); |
b627c71f9cc3
(svn r11993) -Fix: Resize station/roadstop/dock/airport construction windows if cargo acceptance list is too long.
peter1138
parents:
8766
diff
changeset
|
195 |
} |
0 | 196 |
break; |
197 |
} |
|
198 |
||
199 |
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
|
200 |
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
|
201 |
case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: |
8493
3ab458f7cff4
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
8424
diff
changeset
|
202 |
w->RaiseWidget(_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
|
203 |
_selected_airport_type = e->we.click.widget - 7; |
8493
3ab458f7cff4
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
8424
diff
changeset
|
204 |
w->LowerWidget(_selected_airport_type + 7); |
541 | 205 |
SndPlayFx(SND_15_BEEP); |
0 | 206 |
SetWindowDirty(w); |
207 |
break; |
|
4059
f1442dfe1c8a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3884
diff
changeset
|
208 |
case 16: case 17: |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
209 |
_station_show_coverage = (e->we.click.widget != 16); |
8493
3ab458f7cff4
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
8424
diff
changeset
|
210 |
w->SetWidgetLoweredState(16, !_station_show_coverage); |
3ab458f7cff4
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
8424
diff
changeset
|
211 |
w->SetWidgetLoweredState(17, _station_show_coverage); |
541 | 212 |
SndPlayFx(SND_15_BEEP); |
0 | 213 |
SetWindowDirty(w); |
214 |
break; |
|
215 |
} |
|
216 |
} break; |
|
217 |
||
218 |
case WE_MOUSELOOP: { |
|
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6573
diff
changeset
|
219 |
if (WP(w, def_d).close) { |
0 | 220 |
DeleteWindow(w); |
221 |
return; |
|
222 |
} |
|
223 |
||
224 |
CheckRedrawStationCoverage(w); |
|
225 |
} break; |
|
1109
1bab892228cd
(svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents:
1093
diff
changeset
|
226 |
|
1072
01bf9fc64236
(svn r1573) -Fix: Station and depot building mode is now terminated if the
celestar
parents:
1019
diff
changeset
|
227 |
case WE_DESTROY: |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6573
diff
changeset
|
228 |
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
|
229 |
break; |
0 | 230 |
} |
231 |
} |
|
232 |
||
233 |
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
|
234 |
{ 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
|
235 |
{ 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
|
236 |
{ 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
|
237 |
{ 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
|
238 |
{ 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
|
239 |
{ 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
|
240 |
{ 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
|
241 |
{ 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
|
242 |
{ 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
|
243 |
{ 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
|
244 |
{ 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
|
245 |
{ 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
|
246 |
{ 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
|
247 |
{ 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
|
248 |
{ 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
|
249 |
{ 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
|
250 |
{ 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
|
251 |
{ 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
|
252 |
{ 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
|
253 |
{ 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
|
254 |
{ 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
|
255 |
{ 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
|
256 |
{ 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
|
257 |
{ WIDGETS_END}, |
0 | 258 |
}; |
259 |
||
260 |
static const WindowDesc _build_airport_desc = { |
|
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7737
diff
changeset
|
261 |
WDP_AUTO, WDP_AUTO, 148, 240, 148, 240, |
5070
0bbf5264bfb7
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
262 |
WC_BUILD_STATION, WC_BUILD_TOOLBAR, |
0 | 263 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
264 |
_build_airport_picker_widgets, |
|
265 |
BuildAirportPickerWndProc |
|
266 |
}; |
|
267 |
||
6573 | 268 |
static void ShowBuildAirportPicker() |
0 | 269 |
{ |
270 |
AllocateWindowDesc(&_build_airport_desc); |
|
271 |
} |
|
272 |
||
6573 | 273 |
void InitializeAirportGui() |
0 | 274 |
{ |
275 |
_selected_airport_type = AT_SMALL; |
|
276 |
} |