OpenTTD

airport_gui.cpp
Go to the documentation of this file.
1 /* $Id: airport_gui.cpp 27163 2015-02-22 15:26:27Z frosch $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
9
12 #include "stdafx.h"
13 #include "window_gui.h"
14 #include "station_gui.h"
15 #include "terraform_gui.h"
16 #include "sound_func.h"
17 #include "window_func.h"
18 #include "strings_func.h"
19 #include "viewport_func.h"
20 #include "company_func.h"
21 #include "tilehighlight_func.h"
22 #include "company_base.h"
23 #include "station_type.h"
24 #include "newgrf_airport.h"
25 #include "newgrf_callbacks.h"
26 #include "widgets/dropdown_type.h"
27 #include "core/geometry_func.hpp"
28 #include "hotkeys.h"
29 #include "vehicle_func.h"
30 #include "gui.h"
31
32 #include "widgets/airport_widget.h"
33
34 #include "safeguards.h"
35
36
37 static AirportClassID _selected_airport_class;
38 static int _selected_airport_index;
39 static byte _selected_airport_layout;
40
41 static void ShowBuildAirportPicker(Window *parent);
42
43 SpriteID GetCustomAirportSprite(const AirportSpec *as, byte layout);
44
45 void CcBuildAirport(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
46 {
47 if (result.Failed()) return;
48
49 if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_SPLAT_OTHER, tile);
50 if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
51 }
52
57 static void PlaceAirport(TileIndex tile)
58 {
59 if (_selected_airport_index == -1) return;
60 uint32 p2 = _ctrl_pressed;
61 SB(p2, 16, 16, INVALID_STATION); // no station to join
62
63 uint32 p1 = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index)->GetIndex();
64 p1 |= _selected_airport_layout << 8;
65 CommandContainer cmdcont = { tile, p1, p2, CMD_BUILD_AIRPORT | CMD_MSG(STR_ERROR_CAN_T_BUILD_AIRPORT_HERE), CcBuildAirport, "" };
66 ShowSelectStationIfNeeded(cmdcont, TileArea(tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE));
67 }
68
70 struct BuildAirToolbarWindow : Window {
71 int last_user_action; // Last started user action.
72
73 BuildAirToolbarWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
74 {
75 this->InitNested(window_number);
76 if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
77 this->last_user_action = WIDGET_LIST_END;
78 }
79
80 ~BuildAirToolbarWindow()
81 {
82 if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0, false);
83 }
84
90 virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
91 {
92 if (!gui_scope) return;
93
94 if (!CanBuildVehicleInfrastructure(VEH_AIRCRAFT)) delete this;
95 }
96
97 virtual void OnClick(Point pt, int widget, int click_count)
98 {
99 switch (widget) {
100 case WID_AT_AIRPORT:
101 if (HandlePlacePushButton(this, WID_AT_AIRPORT, SPR_CURSOR_AIRPORT, HT_RECT)) {
102 ShowBuildAirportPicker(this);
103 this->last_user_action = widget;
104 }
105 break;
106
107 case WID_AT_DEMOLISH:
108 HandlePlacePushButton(this, WID_AT_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT | HT_DIAGONAL);
109 this->last_user_action = widget;
110 break;
111
112 default: break;
113 }
114 }
115
116
117 virtual void OnPlaceObject(Point pt, TileIndex tile)
118 {
119 switch (this->last_user_action) {
120 case WID_AT_AIRPORT:
121 PlaceAirport(tile);
122 break;
123
124 case WID_AT_DEMOLISH:
125 PlaceProc_DemolishArea(tile);
126 break;
127
128 default: NOT_REACHED();
129 }
130 }
131
132 virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
133 {
134 VpSelectTilesWithMethod(pt.x, pt.y, select_method);
135 }
136
137 virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
138 {
139 if (pt.x != -1 && select_proc == DDSP_DEMOLISH_AREA) {
140 GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
141 }
142 }
143
144 virtual void OnPlaceObjectAbort()
145 {
146 this->RaiseButtons();
147
148 DeleteWindowById(WC_BUILD_STATION, TRANSPORT_AIR);
149 DeleteWindowById(WC_SELECT_STATION, 0);
150 }
151
152 static HotkeyList hotkeys;
153 };
154
160 static EventState AirportToolbarGlobalHotkeys(int hotkey)
161 {
162 if (_game_mode != GM_NORMAL || !CanBuildVehicleInfrastructure(VEH_AIRCRAFT)) return ES_NOT_HANDLED;
163 Window *w = ShowBuildAirToolbar();
164 if (w == NULL) return ES_NOT_HANDLED;
165 return w->OnHotkey(hotkey);
166 }
167
168 static Hotkey airtoolbar_hotkeys[] = {
169 Hotkey('1', "airport", WID_AT_AIRPORT),
170 Hotkey('2', "demolish", WID_AT_DEMOLISH),
171 HOTKEY_LIST_END
172 };
173 HotkeyList BuildAirToolbarWindow::hotkeys("airtoolbar", airtoolbar_hotkeys, AirportToolbarGlobalHotkeys);
174
175 static const NWidgetPart _nested_air_toolbar_widgets[] = {
176 NWidget(NWID_HORIZONTAL),
177 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
178 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_TOOLBAR_AIRCRAFT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
179 NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
180 EndContainer(),
181 NWidget(NWID_HORIZONTAL),
182 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_AT_AIRPORT), SetFill(0, 1), SetMinimalSize(42, 22), SetDataTip(SPR_IMG_AIRPORT, STR_TOOLBAR_AIRCRAFT_BUILD_AIRPORT_TOOLTIP),
183 NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetMinimalSize(4, 22), SetFill(1, 1), EndContainer(),
184 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_AT_DEMOLISH), SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
185 EndContainer(),
186 };
187
188 static WindowDesc _air_toolbar_desc(
189 WDP_ALIGN_TOOLBAR, "toolbar_air", 0, 0,
190 WC_BUILD_TOOLBAR, WC_NONE,
191 WDF_CONSTRUCTION,
192 _nested_air_toolbar_widgets, lengthof(_nested_air_toolbar_widgets),
193 &BuildAirToolbarWindow::hotkeys
194 );
195
203 Window *ShowBuildAirToolbar()
204 {
205 if (!Company::IsValidID(_local_company)) return NULL;
206
207 DeleteWindowByClass(WC_BUILD_TOOLBAR);
208 return AllocateWindowDescFront<BuildAirToolbarWindow>(&_air_toolbar_desc, TRANSPORT_AIR);
209 }
210
211 class BuildAirportWindow : public PickerWindowBase {
212 SpriteID preview_sprite;
213 int line_height;
214 Scrollbar *vscroll;
215
217 static DropDownList *BuildAirportClassDropDown()
218 {
219 DropDownList *list = new DropDownList();
220
221 for (uint i = 0; i < AirportClass::GetClassCount(); i++) {
222 *list->Append() = new DropDownListStringItem(AirportClass::Get((AirportClassID)i)->name, i, false);
223 }
224
225 return list;
226 }
227
228 public:
229 BuildAirportWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
230 {
231 this->CreateNestedTree();
232
233 this->vscroll = this->GetScrollbar(WID_AP_SCROLLBAR);
234 this->vscroll->SetCapacity(5);
235 this->vscroll->SetPosition(0);
236
237 this->FinishInitNested(TRANSPORT_AIR);
238
239 this->SetWidgetLoweredState(WID_AP_BTN_DONTHILIGHT, !_settings_client.gui.station_show_coverage);
240 this->SetWidgetLoweredState(WID_AP_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage);
241 this->OnInvalidateData();
242
243 /* Ensure airport class is valid (changing NewGRFs). */
244 _selected_airport_class = Clamp(_selected_airport_class, APC_BEGIN, (AirportClassID)(AirportClass::GetClassCount() - 1));
245 const AirportClass *ac = AirportClass::Get(_selected_airport_class);
246 this->vscroll->SetCount(ac->GetSpecCount());
247
248 /* Ensure the airport index is valid for this class (changing NewGRFs). */
249 _selected_airport_index = Clamp(_selected_airport_index, -1, ac->GetSpecCount() - 1);
250
251 /* Only when no valid airport was selected, we want to select the first airport. */
252 bool selectFirstAirport = true;
253 if (_selected_airport_index != -1) {
254 const AirportSpec *as = ac->GetSpec(_selected_airport_index);
255 if (as->IsAvailable()) {
256 /* Ensure the airport layout is valid. */
257 _selected_airport_layout = Clamp(_selected_airport_layout, 0, as->num_table - 1);
258 selectFirstAirport = false;
259 this->UpdateSelectSize();
260 }
261 }
262
263 if (selectFirstAirport) this->SelectFirstAvailableAirport(true);
264 }
265
266 virtual ~BuildAirportWindow()
267 {
268 DeleteWindowById(WC_SELECT_STATION, 0);
269 }
270
271 virtual void SetStringParameters(int widget) const
272 {
273 switch (widget) {
274 case WID_AP_CLASS_DROPDOWN:
275 SetDParam(0, AirportClass::Get(_selected_airport_class)->name);
276 break;
277
278 case WID_AP_LAYOUT_NUM:
279 SetDParam(0, STR_EMPTY);
280 if (_selected_airport_index != -1) {
281 const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index);
282 StringID string = GetAirportTextCallback(as, _selected_airport_layout, CBID_AIRPORT_LAYOUT_NAME);
283 if (string != STR_UNDEFINED) {
284 SetDParam(0, string);
285 } else if (as->num_table > 1) {
286 SetDParam(0, STR_STATION_BUILD_AIRPORT_LAYOUT_NAME);
287 SetDParam(1, _selected_airport_layout + 1);
288 }
289 }
290 break;
291
292 default: break;
293 }
294 }
295
296 virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
297 {
298 switch (widget) {
299 case WID_AP_CLASS_DROPDOWN: {
300 Dimension d = {0, 0};
301 for (uint i = 0; i < AirportClass::GetClassCount(); i++) {
302 SetDParam(0, AirportClass::Get((AirportClassID)i)->name);
303 d = maxdim(d, GetStringBoundingBox(STR_BLACK_STRING));
304 }
305 d.width += padding.width;
306 d.height += padding.height;
307 *size = maxdim(*size, d);
308 break;
309 }
310
311 case WID_AP_AIRPORT_LIST: {
312 for (int i = 0; i < NUM_AIRPORTS; i++) {
313 const AirportSpec *as = AirportSpec::Get(i);
314 if (!as->enabled) continue;
315
316 size->width = max(size->width, GetStringBoundingBox(as->name).width);
317 }
318
319 this->line_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM;
320 size->height = 5 * this->line_height;
321 break;
322 }
323
324 case WID_AP_AIRPORT_SPRITE:
325 for (int i = 0; i < NUM_AIRPORTS; i++) {
326 const AirportSpec *as = AirportSpec::Get(i);
327 if (!as->enabled) continue;
328 for (byte layout = 0; layout < as->num_table; layout++) {
329 SpriteID sprite = GetCustomAirportSprite(as, layout);
330 if (sprite != 0) {
331 Dimension d = GetSpriteSize(sprite);
332 d.width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
333 d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
334 *size = maxdim(d, *size);
335 }
336 }
337 }
338 break;
339
340 case WID_AP_EXTRA_TEXT:
341 for (int i = NEW_AIRPORT_OFFSET; i < NUM_AIRPORTS; i++) {
342 const AirportSpec *as = AirportSpec::Get(i);
343 if (!as->enabled) continue;
344 for (byte layout = 0; layout < as->num_table; layout++) {
345 StringID string = GetAirportTextCallback(as, layout, CBID_AIRPORT_ADDITIONAL_TEXT);
346 if (string == STR_UNDEFINED) continue;
347
348 /* STR_BLACK_STRING is used to start the string with {BLACK} */
349 SetDParam(0, string);
350 Dimension d = GetStringMultiLineBoundingBox(STR_BLACK_STRING, *size);
351 *size = maxdim(d, *size);
352 }
353 }
354 break;
355
356 default: break;
357 }
358 }
359
360 virtual void DrawWidget(const Rect &r, int widget) const
361 {
362 switch (widget) {
363 case WID_AP_AIRPORT_LIST: {
364 int y = r.top;
365 AirportClass *apclass = AirportClass::Get(_selected_airport_class);
366 for (uint i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < apclass->GetSpecCount(); i++) {
367 const AirportSpec *as = apclass->GetSpec(i);
368 if (!as->IsAvailable()) {
369 GfxFillRect(r.left + 1, y + 1, r.right - 1, y + this->line_height - 2, PC_BLACK, FILLRECT_CHECKER);
370 }
371 DrawString(r.left + WD_MATRIX_LEFT, r.right - WD_MATRIX_RIGHT, y + WD_MATRIX_TOP, as->name, ((int)i == _selected_airport_index) ? TC_WHITE : TC_BLACK);
372 y += this->line_height;
373 }
374 break;
375 }
376
377 case WID_AP_AIRPORT_SPRITE:
378 if (this->preview_sprite != 0) {
379 Dimension d = GetSpriteSize(this->preview_sprite);
380 DrawSprite(this->preview_sprite, COMPANY_SPRITE_COLOUR(_local_company), (r.left + r.right - d.width) / 2, (r.top + r.bottom - d.height) / 2);
381 }
382 break;
383
384 case WID_AP_EXTRA_TEXT:
385 if (_selected_airport_index != -1) {
386 const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index);
387 StringID string = GetAirportTextCallback(as, _selected_airport_layout, CBID_AIRPORT_ADDITIONAL_TEXT);
388 if (string != STR_UNDEFINED) {
389 SetDParam(0, string);
390 DrawStringMultiLine(r.left, r.right, r.top, r.bottom, STR_BLACK_STRING);
391 }
392 }
393 break;
394 }
395 }
396
397 virtual void OnPaint()
398 {
399 this->DrawWidgets();
400
401 uint16 top = this->GetWidget<NWidgetBase>(WID_AP_BTN_DOHILIGHT)->pos_y + this->GetWidget<NWidgetBase>(WID_AP_BTN_DOHILIGHT)->current_y + WD_PAR_VSEP_NORMAL;
402 NWidgetBase *panel_nwi = this->GetWidget<NWidgetBase>(WID_AP_BOTTOMPANEL);
403
404 int right = panel_nwi->pos_x + panel_nwi->current_x;
405 int bottom = panel_nwi->pos_y + panel_nwi->current_y;
406
407 if (_selected_airport_index != -1) {
408 const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index);
409 int rad = _settings_game.station.modified_catchment ? as->catchment : (uint)CA_UNMODIFIED;
410
411 /* only show the station (airport) noise, if the noise option is activated */
412 if (_settings_game.economy.station_noise_level) {
413 /* show the noise of the selected airport */
414 SetDParam(0, as->noise_level);
415 DrawString(panel_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, STR_STATION_BUILD_NOISE);
416 top += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
417 }
418
419 /* strings such as 'Size' and 'Coverage Area' */
420 top = DrawStationCoverageAreaText(panel_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, false) + WD_PAR_VSEP_NORMAL;
421 top = DrawStationCoverageAreaText(panel_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, true) + WD_PAR_VSEP_NORMAL;
422 }
423
424 /* Resize background if the window is too small.
425 * Never make the window smaller to avoid oscillating if the size change affects the acceptance.
426 * (This is the case, if making the window bigger moves the mouse into the window.) */
427 if (top > bottom) {
428 ResizeWindow(this, 0, top - bottom, false);
429 }
430 }
431
432 void SelectOtherAirport(int airport_index)
433 {
434 _selected_airport_index = airport_index;
435 _selected_airport_layout = 0;
436
437 this->UpdateSelectSize();
438 this->SetDirty();
439 }
440
441 void UpdateSelectSize()
442 {
443 if (_selected_airport_index == -1) {
444 SetTileSelectSize(1, 1);
445 this->DisableWidget(WID_AP_LAYOUT_DECREASE);
446 this->DisableWidget(WID_AP_LAYOUT_INCREASE);
447 } else {
448 const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index);
449 int w = as->size_x;
450 int h = as->size_y;
451 Direction rotation = as->rotation[_selected_airport_layout];
452 if (rotation == DIR_E || rotation == DIR_W) Swap(w, h);
453 SetTileSelectSize(w, h);
454
455 this->preview_sprite = GetCustomAirportSprite(as, _selected_airport_layout);
456
457 this->SetWidgetDisabledState(WID_AP_LAYOUT_DECREASE, _selected_airport_layout == 0);
458 this->SetWidgetDisabledState(WID_AP_LAYOUT_INCREASE, _selected_airport_layout + 1 >= as->num_table);
459
460 int rad = _settings_game.station.modified_catchment ? as->catchment : (uint)CA_UNMODIFIED;
461 if (_settings_client.gui.station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
462 }
463 }
464
465 virtual void OnClick(Point pt, int widget, int click_count)
466 {
467 switch (widget) {
468 case WID_AP_CLASS_DROPDOWN:
469 ShowDropDownList(this, BuildAirportClassDropDown(), _selected_airport_class, WID_AP_CLASS_DROPDOWN);
470 break;
471
472 case WID_AP_AIRPORT_LIST: {
473 int num_clicked = this->vscroll->GetPosition() + (pt.y - this->nested_array[widget]->pos_y) / this->line_height;
474 if (num_clicked >= this->vscroll->GetCount()) break;
475 const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(num_clicked);
476 if (as->IsAvailable()) this->SelectOtherAirport(num_clicked);
477 break;
478 }
479
480 case WID_AP_BTN_DONTHILIGHT: case WID_AP_BTN_DOHILIGHT:
481 _settings_client.gui.station_show_coverage = (widget != WID_AP_BTN_DONTHILIGHT);
482 this->SetWidgetLoweredState(WID_AP_BTN_DONTHILIGHT, !_settings_client.gui.station_show_coverage);
483 this->SetWidgetLoweredState(WID_AP_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage);
484 this->SetDirty();
485 if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
486 this->UpdateSelectSize();
487 break;
488
489 case WID_AP_LAYOUT_DECREASE:
490 _selected_airport_layout--;
491 this->UpdateSelectSize();
492 this->SetDirty();
493 break;
494
495 case WID_AP_LAYOUT_INCREASE:
496 _selected_airport_layout++;
497 this->UpdateSelectSize();
498 this->SetDirty();
499 break;
500 }
501 }
502
508 void SelectFirstAvailableAirport(bool change_class)
509 {
510 /* First try to select an airport in the selected class. */
511 AirportClass *sel_apclass = AirportClass::Get(_selected_airport_class);
512 for (uint i = 0; i < sel_apclass->GetSpecCount(); i++) {
513 const AirportSpec *as = sel_apclass->GetSpec(i);
514 if (as->IsAvailable()) {
515 this->SelectOtherAirport(i);
516 return;
517 }
518 }
519 if (change_class) {
520 /* If that fails, select the first available airport
521 * from a random class. */
522 for (AirportClassID j = APC_BEGIN; j < APC_MAX; j++) {
523 AirportClass *apclass = AirportClass::Get(j);
524 for (uint i = 0; i < apclass->GetSpecCount(); i++) {
525 const AirportSpec *as = apclass->GetSpec(i);
526 if (as->IsAvailable()) {
527 _selected_airport_class = j;
528 this->SelectOtherAirport(i);
529 return;
530 }
531 }
532 }
533 }
534 /* If all airports are unavailable, select nothing. */
535 this->SelectOtherAirport(-1);
536 }
537
538 virtual void OnDropdownSelect(int widget, int index)
539 {
540 assert(widget == WID_AP_CLASS_DROPDOWN);
541 _selected_airport_class = (AirportClassID)index;
542 this->vscroll->SetCount(AirportClass::Get(_selected_airport_class)->GetSpecCount());
543 this->SelectFirstAvailableAirport(false);
544 }
545
546 virtual void OnTick()
547 {
548 CheckRedrawStationCoverage(this);
549 }
550 };
551
552 static const NWidgetPart _nested_build_airport_widgets[] = {
553 NWidget(NWID_HORIZONTAL),
554 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
555 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_AIRPORT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
556 EndContainer(),
557 NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetFill(1, 0), SetPIP(2, 0, 2),
558 NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_AIRPORT_CLASS_LABEL, STR_NULL), SetFill(1, 0),
559 NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_AP_CLASS_DROPDOWN), SetFill(1, 0), SetDataTip(STR_BLACK_STRING, STR_STATION_BUILD_AIRPORT_TOOLTIP),
560 NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_AP_AIRPORT_SPRITE), SetFill(1, 0),
561 NWidget(NWID_HORIZONTAL),
562 NWidget(WWT_MATRIX, COLOUR_GREY, WID_AP_AIRPORT_LIST), SetFill(1, 0), SetMatrixDataTip(1, 5, STR_STATION_BUILD_AIRPORT_TOOLTIP), SetScrollbar(WID_AP_SCROLLBAR),
563 NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_AP_SCROLLBAR),
564 EndContainer(),
565 NWidget(NWID_HORIZONTAL),
566 NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_AP_LAYOUT_DECREASE), SetMinimalSize(12, 0), SetDataTip(AWV_DECREASE, STR_NULL),
567 NWidget(WWT_LABEL, COLOUR_GREY, WID_AP_LAYOUT_NUM), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_BLACK_STRING, STR_NULL),
568 NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_AP_LAYOUT_INCREASE), SetMinimalSize(12, 0), SetDataTip(AWV_INCREASE, STR_NULL),
569 EndContainer(),
570 NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_AP_EXTRA_TEXT), SetFill(1, 0), SetMinimalSize(150, 0),
571 EndContainer(),
572 /* Bottom panel. */
573 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_AP_BOTTOMPANEL), SetPIP(2, 2, 2),
574 NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0),
575 NWidget(NWID_HORIZONTAL),
576 NWidget(NWID_SPACER), SetMinimalSize(14, 0), SetFill(1, 0),
577 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
578 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_AP_BTN_DONTHILIGHT), SetMinimalSize(60, 12), SetFill(1, 0),
579 SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
580 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_AP_BTN_DOHILIGHT), SetMinimalSize(60, 12), SetFill(1, 0),
581 SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
582 EndContainer(),
583 NWidget(NWID_SPACER), SetMinimalSize(14, 0), SetFill(1, 0),
584 EndContainer(),
585 NWidget(NWID_SPACER), SetMinimalSize(0, 10), SetResize(0, 1), SetFill(1, 0),
586 EndContainer(),
587 };
588
589 static WindowDesc _build_airport_desc(
590 WDP_AUTO, "build_station_air", 0, 0,
591 WC_BUILD_STATION, WC_BUILD_TOOLBAR,
592 WDF_CONSTRUCTION,
593 _nested_build_airport_widgets, lengthof(_nested_build_airport_widgets)
594 );
595
596 static void ShowBuildAirportPicker(Window *parent)
597 {
598 new BuildAirportWindow(&_build_airport_desc, parent);
599 }
600
601 void InitializeAirportGui()
602 {
603 _selected_airport_class = APC_BEGIN;
604 _selected_airport_index = -1;
605 }
EventState
EventState
State of handling an event.
Definition: window_type.h:701
CBID_AIRPORT_ADDITIONAL_TEXT
This callback is called from airport list.
Definition: newgrf_callbacks.h:250
strings_func.h
Functions related to OTTD&#39;s strings.
ViewportDragDropSelectionProcess
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you&#39;ve selected it...
Definition: viewport_type.h:97
WWT_EMPTY
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:48
Swap
static void Swap(T &a, T &b)
Type safe swap operation.
Definition: math_func.hpp:277
SCT_ALL
Draw all cargoes.
Definition: station_gui.h:24
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:77
company_base.h
Definition of stuff that is very close to a company, like the company struct itself.
AirportSpec::IsAvailable
bool IsAvailable() const
Check whether this airport is available to build.
Definition: newgrf_airport.cpp:124
BuildAirToolbarWindow::OnInvalidateData
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
Definition: airport_gui.cpp:90
WC_SELECT_STATION
Select station (when joining stations); Window numbers:
Definition: window_type.h:237
WID_AP_EXTRA_TEXT
Additional text about the airport.
Definition: airport_widget.h:30
GUISettings::link_terraform_toolbar
bool link_terraform_toolbar
display terraform toolbar when displaying rail, road, water and airport toolbars
Definition: settings_type.h:87
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:317
Window::OnHotkey
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
Definition: window.cpp:590
BuildAirToolbarWindow::OnPlaceDrag
virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
The user is dragging over the map when the tile highlight mode has been set.
Definition: airport_gui.cpp:132
SetResize
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:930
Window::Window
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition: window.cpp:1843
AirportClassID
AirportClassID
List of default airport classes.
Definition: newgrf_airport.h:70
GfxFillRect
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen...
Definition: gfx.cpp:112
CheckRedrawStationCoverage
void CheckRedrawStationCoverage(const Window *w)
Check whether we need to redraw the station coverage text.
Definition: station_gui.cpp:88
Window::SetWidgetDisabledState
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:387
WD_MATRIX_RIGHT
Offset at right of a matrix cell.
Definition: window_gui.h:79
Window::SetWidgetLoweredState
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:448
AirportSpec::size_y
byte size_y
size of airport in y direction
Definition: newgrf_airport.h:108
Window::parent
Window * parent
Parent window.
Definition: window_gui.h:332
Hotkey
All data for a single hotkey.
Definition: hotkeys.h:24
WindowDesc
High level window description.
Definition: window_gui.h:168
DIR_E
East.
Definition: direction_type.h:30
ANIMCURSOR_DEMOLISH
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
Definition: sprites.h:1467
WC_SCEN_LAND_GEN
Landscape generation (in Scenario Editor); Window numbers:
Definition: window_type.h:444
GameSettings::economy
EconomySettings economy
settings to change the economy
Definition: settings_type.h:553
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:604
GUISettings::station_show_coverage
bool station_show_coverage
whether to highlight coverage area
Definition: settings_type.h:133
hotkeys.h
Hotkey related functions.
NewGRFClass::GetSpecCount
uint GetSpecCount() const
Get the number of allocated specs within the class.
Definition: newgrf_class.h:46
WWT_LABEL
Centered label.
Definition: widget_type.h:57
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:589
ShowSelectStationIfNeeded
void ShowSelectStationIfNeeded(const CommandContainer &cmd, TileArea ta)
Show the station selection window when needed.
Definition: station_gui.cpp:2408
station_gui.h
Contains enums and function declarations connected with stations GUI.
ShowTerraformToolbar
Window * ShowTerraformToolbar(Window *link)
Show the toolbar for terraforming in the game.
Definition: terraform_gui.cpp:358
WD_FRAMERECT_TOP
Offset at top to draw the frame rectangular area.
Definition: window_gui.h:64
WD_PAR_VSEP_NORMAL
Normal amount of vertical space between two paragraphs of text.
Definition: window_gui.h:139
NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:75
ES_NOT_HANDLED
The passed event is not handled.
Definition: window_type.h:703
SetTileSelectSize
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
Definition: viewport.cpp:2295
AWV_INCREASE
Arrow to the right or in case of RTL to the left.
Definition: widget_type.h:38
AWV_DECREASE
Arrow to the left or in case of RTL to the right.
Definition: widget_type.h:37
ShowDropDownList
void ShowDropDownList(Window *w, const DropDownList *list, int selected, int button, uint width, bool auto_width, bool instant_close)
Show a drop down list.
Definition: dropdown.cpp:421
TileHighlightData::size
Point size
Size, in tile "units", of the white/red selection area.
Definition: tilehighlight_type.h:50
vehicle_func.h
Functions related to vehicles.
Scrollbar::SetPosition
void SetPosition(int position)
Sets the position of the first visible element.
Definition: widget_type.h:701
BuildAirportWindow::OnClick
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
Definition: airport_gui.cpp:465
Window::top
int top
y position of top edge of the window
Definition: window_gui.h:313
_selected_airport_class
static AirportClassID _selected_airport_class
the currently visible airport class
Definition: airport_gui.cpp:37
TRANSPORT_AIR
Transport through air.
Definition: transport_type.h:32
WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:69
WD_MATRIX_TOP
Offset at top of a matrix cell.
Definition: window_gui.h:80
airport_widget.h
Types related to the airport widgets.
CanBuildVehicleInfrastructure
bool CanBuildVehicleInfrastructure(VehicleType type)
Check whether we can build infrastructure for the given vehicle type.
Definition: vehicle.cpp:1743
_selected_airport_layout
static byte _selected_airport_layout
selected airport layout number.
Definition: airport_gui.cpp:39
WID_AP_LAYOUT_DECREASE
Decrease the layout number.
Definition: airport_widget.h:27
APC_BEGIN
Lowest valid airport class id.
Definition: newgrf_airport.h:71
Window::DisableWidget
void DisableWidget(byte widget_index)
Sets a widget to disabled.
Definition: window_gui.h:397
GUISettings::persistent_buildingtools
bool persistent_buildingtools
keep the building tools active after usage
Definition: settings_type.h:134
BuildAirportWindow::OnTick
virtual void OnTick()
Called once per (game) tick.
Definition: airport_gui.cpp:546
CommandCost
Common return value for all commands.
Definition: command_type.h:25
max
static T max(const T a, const T b)
Returns the maximum of two values.
Definition: math_func.hpp:26
DropDownListStringItem
Common string list item.
Definition: dropdown_type.h:41
Window::CreateNestedTree
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1804
newgrf_callbacks.h
Callbacks that NewGRFs could implement.
WID_AP_AIRPORT_LIST
List of airports.
Definition: airport_widget.h:24
GameSettings::station
StationSettings station
settings related to station management
Definition: settings_type.h:555
TILE_SIZE
static const uint TILE_SIZE
Tile size in world coordinates.
Definition: tile_type.h:15
BuildAirportWindow::BuildAirportClassDropDown
static DropDownList * BuildAirportClassDropDown()
Build a dropdown list of available airport classes.
Definition: airport_gui.cpp:217
Direction
Direction
Defines the 8 directions on the map.
Definition: direction_type.h:26
SB
static T SB(T &x, const uint8 s, const uint8 n, const U d)
Set n bits in x starting at bit s to d.
Definition: bitmath_func.hpp:60
window_gui.h
Functions, definitions and such used only by the GUI.
CMD_BUILD_AIRPORT
build an airport
Definition: command_type.h:206
newgrf_airport.h
NewGRF handling of airports.
Scrollbar::SetCapacity
void SetCapacity(int capacity)
Set the capacity of visible elements.
Definition: widget_type.h:686
SmallVector::Append
T * Append(uint to_add=1)
Append an item and return it.
Definition: smallvec_type.hpp:134
Scrollbar::SetCount
void SetCount(int num)
Sets the number of elements in the list.
Definition: widget_type.h:670
_local_company
CompanyByte _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:46
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:910
viewport_func.h
Functions related to (drawing on) viewports.
Window
Data structure for an opened window.
Definition: window_gui.h:271
DDSP_DEMOLISH_AREA
Clear area.
Definition: viewport_type.h:98
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:36
BuildAirportWindow::SetStringParameters
virtual void SetStringParameters(int widget) const
Initialize string parameters for a widget.
Definition: airport_gui.cpp:271
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1820
SetMatrixDataTip
static NWidgetPart SetMatrixDataTip(uint8 cols, uint8 rows, StringID tip)
Widget part function for setting the data and tooltip of WWT_MATRIX widgets.
Definition: widget_type.h:1032
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1833
BuildAirportWindow::DrawWidget
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
Definition: airport_gui.cpp:360
AirportSpec::catchment
byte catchment
catchment area of this airport
Definition: newgrf_airport.h:110
WID_AP_BOTTOMPANEL
Panel at the bottom.
Definition: airport_widget.h:31
NUM_AIRPORTS
Maximal number of airports in total.
Definition: airport.h:43
VEH_AIRCRAFT
Aircraft vehicle type.
Definition: vehicle_type.h:27
AirportSpec::noise_level
byte noise_level
noise that this airport generates
Definition: newgrf_airport.h:109
NewGRFClass
Struct containing information relating to NewGRF classes for stations and airports.
Definition: newgrf_class.h:21
station_type.h
Types related to stations.
TileArea
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
Definition: tilearea_type.h:96
Window::nested_array
NWidgetBase ** nested_array
Array of pointers into the tree. Do not access directly, use Window::GetWidget() instead.
Definition: window_gui.h:325
NWID_SPACER
Invisible widget that takes some space.
Definition: widget_type.h:79
WD_MATRIX_BOTTOM
Offset at bottom of a matrix cell.
Definition: window_gui.h:81
DrawStationCoverageAreaText
int DrawStationCoverageAreaText(int left, int right, int top, StationCoverageType sct, int rad, bool supplies)
Calculates and draws the accepted or supplied cargo around the selected tile(s)
Definition: station_gui.cpp:56
NWidgetBase::pos_y
uint pos_y
Vertical position of top-left corner of the widget in the window.
Definition: widget_type.h:178
WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Definition: window_gui.h:210
DIR_W
West.
Definition: direction_type.h:34
ClientSettings::sound
SoundSettings sound
sound effect settings
Definition: settings_type.h:564
NEW_AIRPORT_OFFSET
Number of the first newgrf airport.
Definition: airport.h:41
BuildAirToolbarWindow
Airport build toolbar window handler.
Definition: airport_gui.cpp:70
WID_AT_AIRPORT
Build airport button.
Definition: airport_widget.h:17
NWidgetBase::current_y
uint current_y
Current vertical size (after resizing).
Definition: widget_type.h:175
AirportSpec::rotation
const Direction * rotation
the rotation of each tiletable
Definition: newgrf_airport.h:103
ViewportPlaceMethod
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
Definition: viewport_type.h:78
Window::RaiseButtons
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
Definition: window.cpp:553
CommandContainer
Structure for buffering the build command when selecting a station to join.
Definition: command_type.h:472
FONT_HEIGHT_NORMAL
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:180
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1014
AutoDeleteSmallVector
Simple vector template class, with automatic delete.
Definition: smallvec_type.hpp:401
BuildAirToolbarWindow::OnPlaceMouseUp
virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
The user has dragged over the map when the tile highlight mode has been set.
Definition: airport_gui.cpp:137
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:76
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:947
APC_MAX
maximum number of airport classes
Definition: newgrf_airport.h:76
WID_AP_LAYOUT_NUM
Current number of the layout.
Definition: airport_widget.h:26
stdafx.h
Definition of base types and functions in a cross-platform compatible way.
safeguards.h
A number of safeguards to prevent using unsafe methods.
HotkeyList
List of hotkeys for a window.
Definition: hotkeys.h:42
geometry_func.hpp
Geometry functions.
HT_RECT
rectangle (stations, depots, ...)
Definition: tilehighlight_type.h:23
WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:50
AirportSpec::num_table
byte num_table
number of elements in the table
Definition: newgrf_airport.h:104
CBID_AIRPORT_LAYOUT_NAME
Called to determine text to show as airport layout name.
Definition: newgrf_callbacks.h:253
Window::GetScrollbar
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
Definition: window.cpp:307
WD_MATRIX_LEFT
Offset at left of a matrix cell.
Definition: window_gui.h:78
terraform_gui.h
GUI stuff related to terraforming.
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new &#39;real&#39; widget.
Definition: widget_type.h:1114
AirportSpec::Get
static const AirportSpec * Get(byte type)
Retrieve airport spec for the given airport.
Definition: newgrf_airport.cpp:98
WD_FRAMERECT_BOTTOM
Offset at bottom to draw the frame rectangular area.
Definition: window_gui.h:65
BuildAirToolbarWindow::OnPlaceObject
virtual void OnPlaceObject(Point pt, TileIndex tile)
The user clicked some place on the map when a tile highlight mode has been set.
Definition: airport_gui.cpp:117
BuildAirportWindow::SelectFirstAvailableAirport
void SelectFirstAvailableAirport(bool change_class)
Select the first available airport.
Definition: airport_gui.cpp:508
NWidgetBase
Baseclass for nested widgets.
Definition: widget_type.h:126
DrawString
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition: gfx.cpp:499
WC_BUILD_STATION
Build station; Window numbers:
Definition: window_type.h:392
CA_UNMODIFIED
Catchment for all stations with "modified catchment" disabled.
Definition: station_type.h:87
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: depend.cpp:42
PlaceProc_DemolishArea
void PlaceProc_DemolishArea(TileIndex tile)
Start a drag for demolishing an area.
Definition: terraform_gui.cpp:147
WWT_MATRIX
Grid of rows and columns.
Definition: widget_type.h:59
NWidgetBase::pos_x
uint pos_x
Horizontal position of top-left corner of the widget in the window.
Definition: widget_type.h:177
ShowBuildAirToolbar
Window * ShowBuildAirToolbar()
Open the build airport toolbar window.
Definition: airport_gui.cpp:203
dropdown_type.h
Types related to the drop down widget.
AirportToolbarGlobalHotkeys
static EventState AirportToolbarGlobalHotkeys(int hotkey)
Handler for global hotkeys of the BuildAirToolbarWindow.
Definition: airport_gui.cpp:160
HT_DIAGONAL
Also allow &#39;diagonal rectangles&#39;. Only usable in combination with HT_RECT or HT_POINT.
Definition: tilehighlight_type.h:30
sound_func.h
Functions related to sound.
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:18
GUIPlaceProcDragXY
bool GUIPlaceProcDragXY(ViewportDragDropSelectionProcess proc, TileIndex start_tile, TileIndex end_tile)
A central place to handle all X_AND_Y dragged GUI functions.
Definition: terraform_gui.cpp:108
DeleteWindowByClass
void DeleteWindowByClass(WindowClass cls)
Delete all windows of a given class.
Definition: window.cpp:1150
CommandCost::Failed
bool Failed() const
Did this command fail?
Definition: command_type.h:161
PC_BLACK
static const uint8 PC_BLACK
Black palette colour.
Definition: gfx_func.h:207
WID_AP_SCROLLBAR
Scrollbar of the list.
Definition: airport_widget.h:25
WID_AP_CLASS_DROPDOWN
Dropdown of airport classes.
Definition: airport_widget.h:23
VpSelectTilesWithMethod
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
Definition: viewport.cpp:2940
WIDGET_LIST_END
static const int WIDGET_LIST_END
indicate the end of widgets&#39; list for vararg functions
Definition: widget_type.h:22
BuildAirToolbarWindow::OnClick
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
Definition: airport_gui.cpp:97
Clamp
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition: math_func.hpp:139
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:959
Scrollbar::IsVisible
bool IsVisible(uint16 item) const
Checks whether given current item is visible in the list.
Definition: widget_type.h:641
WC_BUILD_TOOLBAR
Build toolbar; Window numbers:
Definition: window_type.h:68
BuildAirportWindow::OnPaint
virtual void OnPaint()
The window must be repainted.
Definition: airport_gui.cpp:397
GetStringBoundingBox
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:699
Scrollbar::GetCount
uint16 GetCount() const
Gets the number of elements in the list.
Definition: widget_type.h:613
GetStringMultiLineBoundingBox
Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion)
Calculate string bounding box for multi-line strings.
Definition: gfx.cpp:587
maxdim
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Definition: geometry_func.cpp:24
FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
Definition: gfx_type.h:284
WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:40
DeleteWindowById
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
Definition: window.cpp:1137
company_func.h
Functions related to companies.
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition: settings_type.h:561
WDP_ALIGN_TOOLBAR
Align toward the toolbar.
Definition: window_gui.h:158
WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:61
EconomySettings::station_noise_level
bool station_noise_level
build new airports when the town noise level is still within accepted limits
Definition: settings_type.h:488
SpriteID
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition: gfx_type.h:19
BuildAirportWindow::UpdateWidgetSize
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
Definition: airport_gui.cpp:296
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:80
HandlePlacePushButton
bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, HighLightStyle mode)
This code is shared for the majority of the pushbuttons.
Definition: main_gui.cpp:103
AirportSpec::name
StringID name
name of this airport
Definition: newgrf_airport.h:113
StationSettings::modified_catchment
bool modified_catchment
different-size catchment areas
Definition: settings_type.h:516
WID_AP_BTN_DOHILIGHT
Show the coverage button.
Definition: airport_widget.h:34
AirportSpec::size_x
byte size_x
size of airport in x direction
Definition: newgrf_airport.h:107
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME, WWT_INSET, or WWT_PANEL).
Definition: widget_type.h:999
NWidgetBase::current_x
uint current_x
Current horizontal size (after resizing).
Definition: widget_type.h:174
WID_AT_DEMOLISH
Demolish button.
Definition: airport_widget.h:18
NewGRFClass::Get
static NewGRFClass * Get(Tid cls_id)
Get a particular class.
Definition: newgrf_class_func.h:105
SoundSettings::confirm
bool confirm
Play sound effect on succesful constructions or other actions.
Definition: settings_type.h:177
SND_1F_SPLAT_OTHER
Non-water non-rail construction.
Definition: sound_type.h:70
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:28
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:768
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-NULL) Titem.
Definition: pool_type.hpp:235
WWT_DROPDOWN
Drop down list.
Definition: widget_type.h:70
WWT_PUSHARROWBTN
Normal push-button (no toggle button) with arrow caption.
Definition: widget_type.h:106
WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
Definition: window_gui.h:63
WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:66
AirportSpec::enabled
bool enabled
Entity still available (by default true). Newgrf can disable it, though.
Definition: newgrf_airport.h:119
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:983
CMD_MSG
#define CMD_MSG(x)
Used to combine a StringID with the command.
Definition: command_type.h:366
WindowNumber
int32 WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:695
ResetObjectToPlace
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows)...
Definition: viewport.cpp:3211
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:40
NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:84
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:307
tilehighlight_func.h
Functions related to tile highlights.
window_func.h
Window functions not directly related to making/drawing windows.
AirportSpec
Defines the data structure for an airport.
Definition: newgrf_airport.h:100
WDP_AUTO
Find a place automatically.
Definition: window_gui.h:156
WWT_IMGBTN
(Toggle) Button with image
Definition: widget_type.h:52
gui.h
GUI functions that shouldn&#39;t be here.
PlaceAirport
static void PlaceAirport(TileIndex tile)
Place an airport.
Definition: airport_gui.cpp:57
GetAirportTextCallback
StringID GetAirportTextCallback(const AirportSpec *as, byte layout, uint16 callback)
Get a custom text for the airport.
Definition: newgrf_airport.cpp:278
ResizeWindow
void ResizeWindow(Window *w, int delta_x, int delta_y, bool clamp_to_screen)
Resize the window.
Definition: window.cpp:2116
WID_AP_AIRPORT_SPRITE
A visual display of the airport currently selected.
Definition: airport_widget.h:29
SetScrollbar
static NWidgetPart SetScrollbar(int index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1095
BuildAirportWindow::preview_sprite
SpriteID preview_sprite
Cached airport preview sprite.
Definition: airport_gui.cpp:212
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:34
NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:429
BuildAirportWindow::OnDropdownSelect
virtual void OnDropdownSelect(int widget, int index)
A dropdown option associated to this window has been selected.
Definition: airport_gui.cpp:538
SoundSettings::click_beep
bool click_beep
Beep on a random selection of buttons.
Definition: settings_type.h:178
WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
Definition: window_gui.h:62
WID_AP_LAYOUT_INCREASE
Increase the layout number.
Definition: airport_widget.h:28
BuildAirportWindow
Definition: airport_gui.cpp:211
DrawSprite
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Definition: gfx.cpp:833
SetPIP
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1076
PickerWindowBase
Base class for windows opened from a toolbar.
Definition: window_gui.h:836
BuildAirToolbarWindow::OnPlaceObjectAbort
virtual void OnPlaceObjectAbort()
The user cancelled a tile highlight mode that has been set.
Definition: airport_gui.cpp:144
_selected_airport_index
static int _selected_airport_index
the index of the selected airport in the current class or -1
Definition: airport_gui.cpp:38
DropDownList
AutoDeleteSmallVector< const DropDownListItem *, 4 > DropDownList
A drop down list is a collection of drop down list items.
Definition: dropdown_type.h:86
DrawStringMultiLine
int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
Definition: gfx.cpp:620
WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:55
Scrollbar::GetPosition
uint16 GetPosition() const
Gets the position of the first visible element in the list.
Definition: widget_type.h:631
WID_AP_BTN_DONTHILIGHT
Don&#39;t show the coverage button.
Definition: airport_widget.h:33
SetDParam
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings_func.h:201