Files
@ r13177:b124129e2270
Branch filter:
Location: cpp/openttd-patchpack/source/src/airport_gui.cpp - annotation
r13177:b124129e2270
15.3 KiB
text/x-c
(svn r17694) -Codechange: don't break $ to two lines in squirrel_export.awk
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | r5584:545d748cc681 r5584:545d748cc681 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r9111:983de9c5a848 r6117:d11b4c5c0aea r5584:545d748cc681 r8107:82461791b7a2 r8107:82461791b7a2 r8205:096604cfa48b r5584:545d748cc681 r8157:cf41aa22cd09 r8131:7a50db7be0ff r9334:6d079081ec24 r8224:194097dc7288 r8224:194097dc7288 r10208:ef8fcc3dc4ca r9127:933c13888121 r10208:ef8fcc3dc4ca r5584:545d748cc681 r8264:d493cb51fe8a r8264:d493cb51fe8a r8264:d493cb51fe8a r5584:545d748cc681 r5584:545d748cc681 r9338:cde59f9097ce r5584:545d748cc681 r5584:545d748cc681 r5584:545d748cc681 r5584:545d748cc681 r5584:545d748cc681 r5584:545d748cc681 r10611:8c42f79c312e r5584:545d748cc681 r5584:545d748cc681 r5584:545d748cc681 r5584:545d748cc681 r5584:545d748cc681 r10626:59619471b98d r10626:59619471b98d r10626:59619471b98d r11725:57bc99fdc1bc r12518:dd86e5f83232 r5584:545d748cc681 r5584:545d748cc681 r12072:bcf36828afcb r5584:545d748cc681 r12072:bcf36828afcb r12072:bcf36828afcb r12072:bcf36828afcb r12072:bcf36828afcb r12595:76a38a01973c r12595:76a38a01973c r5584:545d748cc681 r5584:545d748cc681 r5584:545d748cc681 r5584:545d748cc681 r5584:545d748cc681 r11697:53072e575f0b r5584:545d748cc681 r5584:545d748cc681 r5584:545d748cc681 r5584:545d748cc681 r11697:53072e575f0b r5584:545d748cc681 r5584:545d748cc681 r5584:545d748cc681 r5584:545d748cc681 r5584:545d748cc681 r5584:545d748cc681 r5584:545d748cc681 r5584:545d748cc681 r5584:545d748cc681 r9303:118e1699967e r12595:76a38a01973c r9303:118e1699967e r12595:76a38a01973c r9413:fcf267325763 r9303:118e1699967e r9303:118e1699967e r9303:118e1699967e r9303:118e1699967e r10530:43e4f3766fb1 r9303:118e1699967e r5584:545d748cc681 r9303:118e1699967e r9303:118e1699967e r9303:118e1699967e r9303:118e1699967e r5584:545d748cc681 r9303:118e1699967e r9303:118e1699967e r12691:e04e5da97d7e r12691:e04e5da97d7e r12691:e04e5da97d7e r9303:118e1699967e r9303:118e1699967e r5584:545d748cc681 r9303:118e1699967e r9303:118e1699967e r9303:118e1699967e r9303:118e1699967e r9303:118e1699967e r9303:118e1699967e r9303:118e1699967e r9303:118e1699967e r9303:118e1699967e r5584:545d748cc681 r9303:118e1699967e r9303:118e1699967e r9303:118e1699967e r9303:118e1699967e r5584:545d748cc681 r9303:118e1699967e r9303:118e1699967e r9303:118e1699967e r9303:118e1699967e r5584:545d748cc681 r9303:118e1699967e r9303:118e1699967e r9303:118e1699967e r9303:118e1699967e r9303:118e1699967e r9303:118e1699967e r5584:545d748cc681 r9303:118e1699967e r9303:118e1699967e r9303:118e1699967e r9303:118e1699967e r12459:0355f2f0513a r11073:77422c74f68a r5584:545d748cc681 r9303:118e1699967e r5584:545d748cc681 r11457:9a04ad49bedb r11457:9a04ad49bedb r12072:bcf36828afcb r12072:bcf36828afcb r12072:bcf36828afcb r11457:9a04ad49bedb r11457:9a04ad49bedb r12779:fb2b1d4a632c r12779:fb2b1d4a632c r12779:fb2b1d4a632c r11457:9a04ad49bedb r11457:9a04ad49bedb r5584:545d748cc681 r11368:058349c3a02c r7341:72820788b006 r5893:6c4fd9987e0f r10998:94dcb82c0e64 r12595:76a38a01973c r11368:058349c3a02c r5584:545d748cc681 r6247:96e840dbefcc r5584:545d748cc681 r11919:363b629324b9 r5584:545d748cc681 r9080:069681a7c2ba r9303:118e1699967e r5584:545d748cc681 r5584:545d748cc681 r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r9268:3a3bf913caaa r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11442:68b0d99ed664 r11457:9a04ad49bedb r9268:3a3bf913caaa r12595:76a38a01973c r9268:3a3bf913caaa r12595:76a38a01973c r10565:370655f37f41 r10565:370655f37f41 r12322:e6ca8896bfec r12352:deb769285474 r9268:3a3bf913caaa r8879:56a04fe5cd97 r10626:59619471b98d r10626:59619471b98d r10626:59619471b98d r10626:59619471b98d r10626:59619471b98d r9268:3a3bf913caaa r9268:3a3bf913caaa r12322:e6ca8896bfec r8879:56a04fe5cd97 r12322:e6ca8896bfec r9413:fcf267325763 r9268:3a3bf913caaa r13062:680961bd134a r13062:680961bd134a r12595:76a38a01973c r12595:76a38a01973c r9334:6d079081ec24 r9413:fcf267325763 r9334:6d079081ec24 r9334:6d079081ec24 r12622:202e83a6cee7 r12353:36b64190104b r9334:6d079081ec24 r9334:6d079081ec24 r9268:3a3bf913caaa r12595:76a38a01973c r12595:76a38a01973c r12595:76a38a01973c r12595:76a38a01973c r12595:76a38a01973c r5584:545d748cc681 r9268:3a3bf913caaa r8879:56a04fe5cd97 r12322:e6ca8896bfec r12322:e6ca8896bfec r12322:e6ca8896bfec r12322:e6ca8896bfec r12322:e6ca8896bfec r12322:e6ca8896bfec r12322:e6ca8896bfec r12322:e6ca8896bfec r12322:e6ca8896bfec r12322:e6ca8896bfec r12322:e6ca8896bfec r12322:e6ca8896bfec r12322:e6ca8896bfec r12322:e6ca8896bfec r12322:e6ca8896bfec r12322:e6ca8896bfec r12322:e6ca8896bfec r12322:e6ca8896bfec r12322:e6ca8896bfec r12322:e6ca8896bfec r12322:e6ca8896bfec r12322:e6ca8896bfec r12322:e6ca8896bfec r12322:e6ca8896bfec r12322:e6ca8896bfec r12322:e6ca8896bfec r12322:e6ca8896bfec r12322:e6ca8896bfec r12322:e6ca8896bfec r12322:e6ca8896bfec r9268:3a3bf913caaa r9268:3a3bf913caaa r9268:3a3bf913caaa r9268:3a3bf913caaa r11442:68b0d99ed664 r11442:68b0d99ed664 r12322:e6ca8896bfec r9268:3a3bf913caaa r10626:59619471b98d r9268:3a3bf913caaa r5584:545d748cc681 r9268:3a3bf913caaa r10565:370655f37f41 r10565:370655f37f41 r10565:370655f37f41 r9268:3a3bf913caaa r12359:3e8150d5ca12 r9268:3a3bf913caaa r9268:3a3bf913caaa r9268:3a3bf913caaa r5584:545d748cc681 r9268:3a3bf913caaa r9268:3a3bf913caaa r9268:3a3bf913caaa r5584:545d748cc681 r9268:3a3bf913caaa r5584:545d748cc681 r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11725:57bc99fdc1bc r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r12779:fb2b1d4a632c r11457:9a04ad49bedb r12595:76a38a01973c r11457:9a04ad49bedb r12779:fb2b1d4a632c r12609:70f427be341a r12779:fb2b1d4a632c r12609:70f427be341a r12779:fb2b1d4a632c r11457:9a04ad49bedb r12595:76a38a01973c r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r12779:fb2b1d4a632c r11457:9a04ad49bedb r12595:76a38a01973c r11457:9a04ad49bedb r12779:fb2b1d4a632c r12609:70f427be341a r12779:fb2b1d4a632c r12609:70f427be341a r12779:fb2b1d4a632c r11457:9a04ad49bedb r12595:76a38a01973c r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r12779:fb2b1d4a632c r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r12779:fb2b1d4a632c r12609:70f427be341a r12779:fb2b1d4a632c r12609:70f427be341a r12779:fb2b1d4a632c r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r12779:fb2b1d4a632c r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r12779:fb2b1d4a632c r12609:70f427be341a r12779:fb2b1d4a632c r12609:70f427be341a r12779:fb2b1d4a632c r12609:70f427be341a r12779:fb2b1d4a632c r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r12779:fb2b1d4a632c r11457:9a04ad49bedb r11457:9a04ad49bedb r12595:76a38a01973c r12779:fb2b1d4a632c r12595:76a38a01973c r12779:fb2b1d4a632c r12595:76a38a01973c r12595:76a38a01973c r11457:9a04ad49bedb r11457:9a04ad49bedb r12779:fb2b1d4a632c r11457:9a04ad49bedb r11457:9a04ad49bedb r11457:9a04ad49bedb r11368:058349c3a02c r11447:e1fd7dac6140 r5584:545d748cc681 r10998:94dcb82c0e64 r12595:76a38a01973c r11368:058349c3a02c r5584:545d748cc681 r9338:cde59f9097ce r5584:545d748cc681 r9338:cde59f9097ce r5584:545d748cc681 r5584:545d748cc681 r6247:96e840dbefcc r5584:545d748cc681 r5584:545d748cc681 r5584:545d748cc681 | /* $Id$ */
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file airport_gui.cpp The GUI for airports. */
#include "stdafx.h"
#include "window_gui.h"
#include "station_gui.h"
#include "terraform_gui.h"
#include "airport.h"
#include "sound_func.h"
#include "window_func.h"
#include "strings_func.h"
#include "viewport_func.h"
#include "gfx_func.h"
#include "company_func.h"
#include "tilehighlight_func.h"
#include "company_base.h"
#include "table/sprites.h"
#include "table/strings.h"
static byte _selected_airport_type;
static void ShowBuildAirportPicker(Window *parent);
void CcBuildAirport(bool success, TileIndex tile, uint32 p1, uint32 p2)
{
if (success) {
SndPlayTileFx(SND_1F_SPLAT, tile);
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
}
}
static void PlaceAirport(TileIndex tile)
{
uint32 p2 = _ctrl_pressed;
SB(p2, 16, 16, INVALID_STATION); // no station to join
CommandContainer cmdcont = { tile, _selected_airport_type, p2, CMD_BUILD_AIRPORT | CMD_MSG(STR_ERROR_CAN_T_BUILD_AIRPORT_HERE), CcBuildAirport, "" };
ShowSelectStationIfNeeded(cmdcont, TileArea(tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE));
}
/** Widget number of the airport build window. */
enum {
ATW_CLOSEBOX,
ATW_CAPTION,
ATW_STICKYBOX,
ATW_AIRPORT,
ATW_DEMOLISH,
ATW_SPACER,
};
static void BuildAirClick_Airport(Window *w)
{
if (HandlePlacePushButton(w, ATW_AIRPORT, SPR_CURSOR_AIRPORT, HT_RECT, PlaceAirport)) ShowBuildAirportPicker(w);
}
static void BuildAirClick_Demolish(Window *w)
{
HandlePlacePushButton(w, ATW_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT, PlaceProc_DemolishArea);
}
typedef void OnButtonClick(Window *w);
static OnButtonClick * const _build_air_button_proc[] = {
BuildAirClick_Airport,
BuildAirClick_Demolish,
};
struct BuildAirToolbarWindow : Window {
BuildAirToolbarWindow(const WindowDesc *desc, WindowNumber window_number) : Window()
{
this->InitNested(desc, window_number);
if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
}
~BuildAirToolbarWindow()
{
if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0, false);
}
virtual void OnPaint()
{
this->DrawWidgets();
}
virtual void OnClick(Point pt, int widget)
{
if (!IsInsideBS(widget, ATW_AIRPORT, lengthof(_build_air_button_proc))) return;
_build_air_button_proc[widget - ATW_AIRPORT](this);
}
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
{
switch (keycode) {
case '1': BuildAirClick_Airport(this); break;
case '2': BuildAirClick_Demolish(this); break;
default: return ES_NOT_HANDLED;
}
return ES_HANDLED;
}
virtual void OnPlaceObject(Point pt, TileIndex tile)
{
_place_proc(tile);
}
virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
{
VpSelectTilesWithMethod(pt.x, pt.y, select_method);
}
virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
{
if (pt.x != -1 && select_proc == DDSP_DEMOLISH_AREA) {
GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
}
}
virtual void OnPlaceObjectAbort()
{
this->RaiseButtons();
DeleteWindowById(WC_BUILD_STATION, TRANSPORT_AIR);
DeleteWindowById(WC_SELECT_STATION, 0);
}
};
static const NWidgetPart _nested_air_toolbar_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN, ATW_CLOSEBOX),
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, ATW_CAPTION), SetMinimalSize(41, 14), SetDataTip(STR_TOOLBAR_AIRCRAFT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN, ATW_STICKYBOX),
EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, ATW_AIRPORT), SetFill(false, true), SetMinimalSize(42, 22), SetDataTip(SPR_IMG_AIRPORT, STR_TOOLBAR_AIRCRAFT_BUILD_AIRPORT_TOOLTIP),
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, ATW_SPACER), SetMinimalSize(4, 22), SetFill(true, true), EndContainer(),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, ATW_DEMOLISH), SetFill(false, true), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
EndContainer(),
};
static const WindowDesc _air_toolbar_desc(
WDP_ALIGN_TBR, 22, 64, 36, 64, 36,
WC_BUILD_TOOLBAR, WC_NONE,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON | WDF_CONSTRUCTION,
NULL, _nested_air_toolbar_widgets, lengthof(_nested_air_toolbar_widgets)
);
void ShowBuildAirToolbar()
{
if (!Company::IsValidID(_local_company)) return;
DeleteWindowByClass(WC_BUILD_TOOLBAR);
AllocateWindowDescFront<BuildAirToolbarWindow>(&_air_toolbar_desc, TRANSPORT_AIR);
}
/** Airport widgets in the airport picker window. */
enum AirportPickerWidgets {
BAW_CLOSEBOX,
BAW_CAPTION,
/* Panels and labels. */
BAW_SMALL_AIRPORTS_PANEL,
BAW_SMALL_AIRPORTS_LABEL,
BAW_LARGE_AIRPORTS_PANEL,
BAW_LARGE_AIRPORTS_LABEL,
BAW_HUB_AIRPORTS_PANEL,
BAW_HUB_AIRPORTS_LABEL,
BAW_HELIPORTS_PANEL,
BAW_HELIPORTS_LABEL,
BAW_BOTTOMPANEL,
/* Airport selection buttons. */
BAW_SMALL_AIRPORT,
BAW_CITY_AIRPORT,
BAW_HELIPORT,
BAW_METRO_AIRPORT,
BAW_INTERNATIONAL_AIRPORT,
BAW_COMMUTER_AIRPORT,
BAW_HELIDEPOT,
BAW_INTERCONTINENTAL_AIRPORT,
BAW_HELISTATION,
/* Coverage. */
BAW_BTN_DONTHILIGHT,
BAW_BTN_DOHILIGHT,
BAW_COVERAGE_LABEL,
BAW_LAST_AIRPORT = BAW_HELISTATION,
BAW_AIRPORT_COUNT = BAW_LAST_AIRPORT - BAW_SMALL_AIRPORT + 1,
};
class AirportPickerWindow : public PickerWindowBase {
public:
AirportPickerWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(parent)
{
this->InitNested(desc, TRANSPORT_AIR);
this->SetWidgetLoweredState(BAW_BTN_DONTHILIGHT, !_settings_client.gui.station_show_coverage);
this->SetWidgetLoweredState(BAW_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage);
this->OnInvalidateData();
this->SelectOtherAirport(_selected_airport_type);
}
virtual ~AirportPickerWindow()
{
DeleteWindowById(WC_SELECT_STATION, 0);
}
virtual void OnPaint()
{
this->DrawWidgets();
const AirportFTAClass *airport = GetAirport(_selected_airport_type);
int rad = _settings_game.station.modified_catchment ? airport->catchment : (uint)CA_UNMODIFIED;
uint16 top = this->GetWidget<NWidgetBase>(BAW_BTN_DOHILIGHT)->pos_y + this->GetWidget<NWidgetBase>(BAW_BTN_DOHILIGHT)->current_y + WD_PAR_VSEP_NORMAL;
NWidgetBase *panel_nwi = this->GetWidget<NWidgetBase>(BAW_BOTTOMPANEL);
int right = panel_nwi->pos_x + panel_nwi->current_x;
int bottom = panel_nwi->pos_y + panel_nwi->current_y;
/* only show the station (airport) noise, if the noise option is activated */
if (_settings_game.economy.station_noise_level) {
/* show the noise of the selected airport */
SetDParam(0, airport->noise_level);
DrawString(panel_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, STR_STATION_BUILD_NOISE);
top += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
}
/* strings such as 'Size' and 'Coverage Area' */
top = DrawStationCoverageAreaText(panel_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, false) + WD_PAR_VSEP_NORMAL;
top = DrawStationCoverageAreaText(panel_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, true) + WD_PAR_VSEP_NORMAL;
/* Resize background if the text is not equally long as the window. */
if (top > bottom || (top < bottom && panel_nwi->current_y > panel_nwi->smallest_y)) {
ResizeWindow(this, 0, top - bottom);
}
}
void SelectOtherAirport(byte airport_id)
{
this->RaiseWidget(_selected_airport_type + BAW_SMALL_AIRPORT);
_selected_airport_type = airport_id;
this->LowerWidget(airport_id + BAW_SMALL_AIRPORT);
const AirportFTAClass *airport = GetAirport(airport_id);
SetTileSelectSize(airport->size_x, airport->size_y);
int rad = _settings_game.station.modified_catchment ? airport->catchment : (uint)CA_UNMODIFIED;
if (_settings_client.gui.station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
this->SetDirty();
}
virtual void OnInvalidateData(int data = 0)
{
if (!GetAirport(_selected_airport_type)->IsAvailable()) {
for (int i = 0; i < BAW_AIRPORT_COUNT; i++) {
if (GetAirport(i)->IsAvailable()) {
this->SelectOtherAirport(i);
break;
}
}
}
for (int i = 0; i < BAW_AIRPORT_COUNT; i++) {
this->SetWidgetDisabledState(i + BAW_SMALL_AIRPORT, !GetAirport(i)->IsAvailable());
}
}
virtual void OnClick(Point pt, int widget)
{
switch (widget) {
case BAW_SMALL_AIRPORT: case BAW_CITY_AIRPORT: case BAW_HELIPORT: case BAW_METRO_AIRPORT:
case BAW_INTERNATIONAL_AIRPORT: case BAW_COMMUTER_AIRPORT: case BAW_HELIDEPOT:
case BAW_INTERCONTINENTAL_AIRPORT: case BAW_HELISTATION:
this->SelectOtherAirport(widget - BAW_SMALL_AIRPORT);
SndPlayFx(SND_15_BEEP);
DeleteWindowById(WC_SELECT_STATION, 0);
break;
case BAW_BTN_DONTHILIGHT: case BAW_BTN_DOHILIGHT:
_settings_client.gui.station_show_coverage = (widget != BAW_BTN_DONTHILIGHT);
this->SetWidgetLoweredState(BAW_BTN_DONTHILIGHT, !_settings_client.gui.station_show_coverage);
this->SetWidgetLoweredState(BAW_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage);
SndPlayFx(SND_15_BEEP);
this->SelectOtherAirport(_selected_airport_type);
break;
}
}
virtual void OnTick()
{
CheckRedrawStationCoverage(this);
}
};
static const NWidgetPart _nested_build_airport_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN, BAW_CLOSEBOX),
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, BAW_CAPTION), SetMinimalSize(137, 14), SetDataTip(STR_STATION_BUILD_AIRPORT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
EndContainer(),
/* Small airports. */
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BAW_SMALL_AIRPORTS_PANEL),
NWidget(WWT_LABEL, COLOUR_DARK_GREEN, BAW_SMALL_AIRPORTS_LABEL), SetMinimalSize(148, 14), SetFill(true, false), SetDataTip(STR_STATION_BUILD_AIRPORT_SMALL_AIRPORTS, STR_NULL),
NWidget(NWID_HORIZONTAL),
NWidget(NWID_SPACER), SetMinimalSize(2, 0),
NWidget(NWID_VERTICAL),
NWidget(WWT_TEXTBTN, COLOUR_GREY, BAW_SMALL_AIRPORT), SetMinimalSize(144, 12), SetFill(true, false),
SetDataTip(STR_STATION_BUILD_AIRPORT_SMALL_AIRPORT, STR_STATION_BUILD_AIRPORT_TOOLTIP),
NWidget(WWT_TEXTBTN, COLOUR_GREY, BAW_COMMUTER_AIRPORT), SetMinimalSize(144, 12), SetFill(true, false),
SetDataTip(STR_STATION_BUILD_AIRPORT_COMMUTER_AIRPORT, STR_STATION_BUILD_AIRPORT_TOOLTIP),
NWidget(NWID_SPACER), SetMinimalSize(0, 1), SetFill(true, false),
EndContainer(),
NWidget(NWID_SPACER), SetMinimalSize(2, 0),
EndContainer(),
EndContainer(),
/* Large airports. */
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BAW_LARGE_AIRPORTS_PANEL),
NWidget(WWT_LABEL, COLOUR_DARK_GREEN, BAW_LARGE_AIRPORTS_LABEL), SetMinimalSize(148, 14), SetFill(true, false), SetDataTip(STR_STATION_BUILD_AIRPORT_LARGE_AIRPORTS, STR_NULL),
NWidget(NWID_HORIZONTAL),
NWidget(NWID_SPACER), SetMinimalSize(2, 0),
NWidget(NWID_VERTICAL),
NWidget(WWT_TEXTBTN, COLOUR_GREY, BAW_CITY_AIRPORT), SetMinimalSize(144, 12), SetFill(true, false),
SetDataTip(STR_STATION_BUILD_AIRPORT_CITY_AIRPORT, STR_STATION_BUILD_AIRPORT_TOOLTIP),
NWidget(WWT_TEXTBTN, COLOUR_GREY, BAW_METRO_AIRPORT), SetMinimalSize(144, 12), SetFill(true, false),
SetDataTip(STR_STATION_BUILD_AIRPORT_METRO_AIRPORT, STR_STATION_BUILD_AIRPORT_TOOLTIP),
NWidget(NWID_SPACER), SetMinimalSize(0, 1), SetFill(true, false),
EndContainer(),
NWidget(NWID_SPACER), SetMinimalSize(2, 0),
EndContainer(),
EndContainer(),
/* Hub airports. */
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BAW_HUB_AIRPORTS_PANEL),
NWidget(WWT_LABEL, COLOUR_DARK_GREEN, BAW_HUB_AIRPORTS_LABEL), SetMinimalSize(148, 14), SetFill(true, false), SetDataTip(STR_STATION_BUILD_AIRPORT_HUB_AIRPORTS, STR_NULL),
NWidget(NWID_HORIZONTAL),
NWidget(NWID_SPACER), SetMinimalSize(2, 0),
NWidget(NWID_VERTICAL),
NWidget(WWT_TEXTBTN, COLOUR_GREY, BAW_INTERNATIONAL_AIRPORT), SetMinimalSize(144, 12), SetFill(true, false),
SetDataTip(STR_STATION_BUILD_AIRPORT_INTERNATIONAL_AIRPORT, STR_STATION_BUILD_AIRPORT_TOOLTIP),
NWidget(WWT_TEXTBTN, COLOUR_GREY, BAW_INTERCONTINENTAL_AIRPORT), SetMinimalSize(144, 12), SetFill(true, false),
SetDataTip(STR_STATION_BUILD_AIRPORT_INTERCONTINENTAL_AIRPORT, STR_STATION_BUILD_AIRPORT_TOOLTIP),
NWidget(NWID_SPACER), SetMinimalSize(0, 1), SetFill(true, false),
EndContainer(),
NWidget(NWID_SPACER), SetMinimalSize(2, 0),
EndContainer(),
EndContainer(),
/* Heliports. */
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BAW_HELIPORTS_PANEL),
NWidget(WWT_LABEL, COLOUR_DARK_GREEN, BAW_HELIPORTS_LABEL), SetMinimalSize(148, 14), SetFill(true, false), SetDataTip(STR_STATION_BUILD_AIRPORT_HELIPORTS, STR_NULL),
NWidget(NWID_HORIZONTAL),
NWidget(NWID_SPACER), SetMinimalSize(2, 0),
NWidget(NWID_VERTICAL),
NWidget(WWT_TEXTBTN, COLOUR_GREY, BAW_HELIPORT), SetMinimalSize(144, 12), SetFill(true, false),
SetDataTip(STR_STATION_BUILD_AIRPORT_HELIPORT, STR_STATION_BUILD_AIRPORT_TOOLTIP),
NWidget(WWT_TEXTBTN, COLOUR_GREY, BAW_HELISTATION), SetMinimalSize(144, 12), SetFill(true, false),
SetDataTip(STR_STATION_BUILD_AIRPORT_HELISTATION, STR_STATION_BUILD_AIRPORT_TOOLTIP),
NWidget(WWT_TEXTBTN, COLOUR_GREY, BAW_HELIDEPOT), SetMinimalSize(144, 12), SetFill(true, false),
SetDataTip(STR_STATION_BUILD_AIRPORT_HELIDEPOT, STR_STATION_BUILD_AIRPORT_TOOLTIP),
NWidget(NWID_SPACER), SetMinimalSize(0, 1), SetFill(true, false),
EndContainer(),
NWidget(NWID_SPACER), SetMinimalSize(2, 0),
EndContainer(),
EndContainer(),
/* Bottom panel. */
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BAW_BOTTOMPANEL),
NWidget(WWT_LABEL, COLOUR_DARK_GREEN, BAW_COVERAGE_LABEL), SetMinimalSize(148, 14), SetFill(true, false), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL),
NWidget(NWID_HORIZONTAL),
NWidget(NWID_SPACER), SetMinimalSize(14, 0),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
NWidget(WWT_TEXTBTN, COLOUR_GREY, BAW_BTN_DONTHILIGHT), SetMinimalSize(60, 12), SetFill(true, false),
SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
NWidget(WWT_TEXTBTN, COLOUR_GREY, BAW_BTN_DOHILIGHT), SetMinimalSize(60, 12), SetFill(true, false),
SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
EndContainer(),
NWidget(NWID_SPACER), SetMinimalSize(14, 0),
EndContainer(),
NWidget(NWID_SPACER), SetMinimalSize(0, 10), SetResize(0, 1), SetFill(true, false),
EndContainer(),
};
static const WindowDesc _build_airport_desc(
WDP_AUTO, WDP_AUTO, 148, 245, 148, 245,
WC_BUILD_STATION, WC_BUILD_TOOLBAR,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_CONSTRUCTION,
NULL, _nested_build_airport_widgets, lengthof(_nested_build_airport_widgets)
);
static void ShowBuildAirportPicker(Window *parent)
{
new AirportPickerWindow(&_build_airport_desc, parent);
}
void InitializeAirportGui()
{
_selected_airport_type = AT_SMALL;
}
|