author | dominik |
Sun, 12 Dec 2004 17:42:04 +0000 | |
changeset 606 | 0e507bb0f63a |
parent 568 | 6eb7d394fb35 |
child 679 | e959706a3e4d |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
337
diff
changeset
|
3 |
#include "table/strings.h" |
0 | 4 |
#include "window.h" |
5 |
#include "gui.h" |
|
6 |
#include "viewport.h" |
|
7 |
#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
|
8 |
#include "sound.h" |
0 | 9 |
#include "command.h" |
10 |
#include "vehicle.h" |
|
11 |
#include "station.h" |
|
12 |
#include "airport.h" |
|
13 |
||
14 |
static byte _selected_airport_type; |
|
15 |
||
16 |
static void ShowBuildAirportPicker(); |
|
17 |
||
18 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
19 |
void CcBuildAirport(bool success, uint tile, uint32 p1, uint32 p2) |
0 | 20 |
{ |
21 |
if (success) { |
|
541 | 22 |
SndPlayTileFx(SND_1F_SPLAT, tile); |
0 | 23 |
ResetObjectToPlace(); |
24 |
} |
|
25 |
} |
|
26 |
||
27 |
static void PlaceAirport(uint tile) |
|
28 |
{ |
|
29 |
DoCommandP(tile, _selected_airport_type, 0, CcBuildAirport, CMD_BUILD_AIRPORT | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_A001_CAN_T_BUILD_AIRPORT_HERE)); |
|
30 |
} |
|
31 |
||
32 |
static void PlaceAir_DemolishArea(uint tile) |
|
33 |
{ |
|
34 |
VpStartPlaceSizing(tile, 4); |
|
35 |
} |
|
36 |
||
37 |
||
38 |
static void BuildAirClick_Airport(Window *w) |
|
39 |
{ |
|
40 |
if (HandlePlacePushButton(w, 2, 0xAA4, 1, PlaceAirport)) ShowBuildAirportPicker(); |
|
41 |
} |
|
42 |
||
43 |
static void BuildAirClick_Demolish(Window *w) |
|
44 |
{ |
|
45 |
HandlePlacePushButton(w, 3, ANIMCURSOR_DEMOLISH, 1, PlaceAir_DemolishArea); |
|
46 |
} |
|
47 |
||
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
48 |
static void BuildAirClick_Landscaping(Window *w) |
0 | 49 |
{ |
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
50 |
ShowTerraformToolbar(); |
0 | 51 |
} |
52 |
||
53 |
typedef void OnButtonClick(Window *w); |
|
54 |
static OnButtonClick * const _build_air_button_proc[] = { |
|
55 |
BuildAirClick_Airport, |
|
56 |
BuildAirClick_Demolish, |
|
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
57 |
BuildAirClick_Landscaping, |
0 | 58 |
}; |
59 |
||
60 |
static void BuildAirToolbWndProc(Window *w, WindowEvent *e) |
|
61 |
{ |
|
62 |
switch(e->event) { |
|
63 |
case WE_PAINT: |
|
64 |
DrawWindowWidgets(w); |
|
65 |
break; |
|
66 |
||
67 |
case WE_CLICK: |
|
68 |
if (e->click.widget-2 >= 0) |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
69 |
_build_air_button_proc[e->click.widget - 2](w); |
0 | 70 |
break; |
71 |
||
72 |
case WE_PLACE_OBJ: |
|
73 |
_place_proc(e->place.tile); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
74 |
break; |
0 | 75 |
|
76 |
case WE_PLACE_DRAG: { |
|
77 |
VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, e->place.userdata); |
|
78 |
return; |
|
79 |
} |
|
80 |
||
81 |
case WE_PLACE_MOUSEUP: |
|
82 |
if (e->place.pt.x != -1) { |
|
83 |
DoCommandP(e->place.tile, e->place.starttile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA)); |
|
84 |
} |
|
85 |
break; |
|
86 |
||
87 |
case WE_ABORT_PLACE_OBJ: |
|
88 |
w->click_state = 0; |
|
89 |
SetWindowDirty(w); |
|
90 |
w = FindWindowById(WC_BUILD_STATION, 0); |
|
91 |
if (w != 0) |
|
92 |
WP(w,def_d).close = true; |
|
93 |
break; |
|
94 |
} |
|
95 |
} |
|
96 |
||
97 |
static const Widget _air_toolbar_widgets[] = { |
|
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
98 |
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
99 |
{ WWT_CAPTION, 7, 11, 85, 0, 13, STR_A000_AIRPORTS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
100 |
{ WWT_PANEL, 7, 0, 41, 14, 35, 0x2E8, STR_A01E_BUILD_AIRPORT}, |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
101 |
{ WWT_PANEL, 7, 42, 63, 14, 35, 0x2BF, STR_018D_DEMOLISH_BUILDINGS_ETC}, |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
102 |
{ WWT_PANEL, 7, 64, 85, 14, 35, SPR_IMG_LANDSCAPING_S, 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
|
103 |
{ WIDGETS_END}, |
0 | 104 |
}; |
105 |
||
106 |
||
107 |
static const WindowDesc _air_toolbar_desc = { |
|
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
568
diff
changeset
|
108 |
640-86, 22, 86, 36, |
0 | 109 |
WC_BUILD_TOOLBAR,0, |
110 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
111 |
_air_toolbar_widgets, |
|
112 |
BuildAirToolbWndProc |
|
113 |
}; |
|
114 |
||
115 |
void ShowBuildAirToolbar() |
|
116 |
{ |
|
117 |
DeleteWindowById(WC_BUILD_TOOLBAR, 0); |
|
118 |
AllocateWindowDescFront(&_air_toolbar_desc, 0); |
|
119 |
} |
|
120 |
||
121 |
static void BuildAirportPickerWndProc(Window *w, WindowEvent *e) |
|
122 |
{ |
|
568
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
123 |
int rad; |
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
124 |
|
0 | 125 |
switch(e->event) { |
126 |
case WE_PAINT: { |
|
127 |
int sel; |
|
128 |
||
129 |
if (WP(w,def_d).close) |
|
130 |
return; |
|
131 |
w->disabled_state = 0; |
|
132 |
||
133 |
sel = _selected_airport_type; |
|
134 |
// FIXME -- BuildAirportPickerWndProc - set availability of airports by year, instead of airplane |
|
135 |
if (!(_avail_aircraft & 1)) { w->disabled_state |= (1<<3); if (sel == AT_SMALL) sel = AT_LARGE; } |
|
136 |
if (!(_avail_aircraft & 2)) { w->disabled_state |= (1<<4); if (sel == AT_LARGE) sel = AT_SMALL; } |
|
137 |
if (!(_avail_aircraft & 4)) { w->disabled_state |= (1<<5); } // heliport |
|
138 |
// 1980-1-1 is --> 21915 |
|
139 |
// 1990-1-1 is --> 25568 |
|
140 |
if (_date < 21915) {w->disabled_state |= (1<<6);} // metropilitan airport 1980 |
|
141 |
if (_date < 25568) {w->disabled_state |= (1<<7);} // international airport 1990 |
|
142 |
_selected_airport_type = sel; |
|
143 |
// select default the coverage area to 'Off' (8) |
|
144 |
w->click_state = ((1<<3) << sel) | ((1<<8) << _station_show_coverage); |
|
145 |
SetTileSelectSize(_airport_size_x[sel],_airport_size_y[sel]); |
|
568
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
146 |
|
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
147 |
if (_patches.modified_catchment) { |
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
148 |
switch (sel) { |
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
149 |
case AT_OILRIG: rad = CA_AIR_OILPAD; break; |
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
150 |
case AT_HELIPORT: rad = CA_AIR_HELIPORT; break; |
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
151 |
case AT_SMALL: rad = CA_AIR_SMALL; break; |
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
152 |
case AT_LARGE: rad = CA_AIR_LARGE; break; |
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
153 |
case AT_METROPOLITAN: rad = CA_AIR_METRO; break; |
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
154 |
case AT_INTERNATIONAL: rad = CA_AIR_INTER; break; |
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
155 |
} |
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
156 |
} else { |
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
157 |
rad = 4; |
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
158 |
} |
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
159 |
|
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
160 |
|
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
161 |
if (_station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); |
0 | 162 |
|
163 |
DrawWindowWidgets(w); |
|
164 |
// strings such as 'Size' and 'Coverage Area' |
|
165 |
DrawStringCentered(74, 16, STR_305B_SIZE, 0); |
|
166 |
DrawStringCentered(74, 78, STR_3066_COVERAGE_AREA_HIGHLIGHT, 0); |
|
568
6eb7d394fb35
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
543
diff
changeset
|
167 |
DrawStationCoverageAreaText(2, 104, (uint)-1, rad); |
0 | 168 |
break; |
169 |
} |
|
170 |
||
171 |
case WE_CLICK: { |
|
172 |
switch(e->click.widget) { |
|
173 |
case 0: |
|
174 |
ResetObjectToPlace(); |
|
175 |
break; |
|
176 |
case 3: case 4: case 5: case 6: case 7: |
|
177 |
_selected_airport_type = e->click.widget - 3; |
|
541 | 178 |
SndPlayFx(SND_15_BEEP); |
0 | 179 |
SetWindowDirty(w); |
180 |
break; |
|
181 |
case 8: case 9: |
|
182 |
_station_show_coverage = e->click.widget - 8; |
|
541 | 183 |
SndPlayFx(SND_15_BEEP); |
0 | 184 |
SetWindowDirty(w); |
185 |
break; |
|
186 |
} |
|
187 |
} break; |
|
188 |
||
189 |
case WE_MOUSELOOP: { |
|
190 |
if (WP(w,def_d).close) { |
|
191 |
DeleteWindow(w); |
|
192 |
return; |
|
193 |
} |
|
194 |
||
195 |
CheckRedrawStationCoverage(w); |
|
196 |
} break; |
|
197 |
} |
|
198 |
} |
|
199 |
||
200 |
static const Widget _build_airport_picker_widgets[] = { |
|
201 |
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
|
202 |
{ WWT_CAPTION, 7, 11, 147, 0, 13, STR_3001_AIRPORT_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
0
diff
changeset
|
203 |
{ WWT_PANEL, 7, 0, 147, 14, 130, 0x0, STR_NULL}, |
0 | 204 |
{WWT_NODISTXTBTN, 14, 2, 73, 27, 38, STR_3059_SMALL, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
205 |
{WWT_NODISTXTBTN, 14, 74, 145, 27, 38, STR_305A_LARGE, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
|
206 |
{WWT_NODISTXTBTN, 14, 2, 145, 63, 74, STR_306B_HELIPORT, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
|
207 |
{WWT_NODISTXTBTN, 14, 2, 145, 39, 50, STR_305AA_LARGE, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
|
208 |
{WWT_NODISTXTBTN, 14, 2, 145, 51, 62, STR_305AB_LARGE, STR_3058_SELECT_SIZE_TYPE_OF_AIRPORT}, |
|
209 |
{ WWT_CLOSEBOX, 14, 14, 73, 88, 98, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE}, |
|
210 |
{ WWT_CLOSEBOX, 14, 74, 133, 88, 98, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA}, |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
0
diff
changeset
|
211 |
{ WIDGETS_END}, |
0 | 212 |
}; |
213 |
||
214 |
static const WindowDesc _build_airport_desc = { |
|
215 |
-1, -1, 148, 131, // height, 130+1 |
|
216 |
WC_BUILD_STATION,WC_BUILD_TOOLBAR, |
|
217 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
218 |
_build_airport_picker_widgets, |
|
219 |
BuildAirportPickerWndProc |
|
220 |
}; |
|
221 |
||
222 |
static void ShowBuildAirportPicker() |
|
223 |
{ |
|
224 |
AllocateWindowDesc(&_build_airport_desc); |
|
225 |
} |
|
226 |
||
227 |
void InitializeAirportGui() |
|
228 |
{ |
|
229 |
_selected_airport_type = AT_SMALL; |
|
230 |
_last_built_aircraft_depot_tile = 0; |
|
231 |
} |