2009-08-21 21:21:05 +01:00
|
|
|
/*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2008-05-06 16:11:33 +01:00
|
|
|
/** @file airport_gui.cpp The GUI for airports. */
|
2007-02-23 01:48:53 +00:00
|
|
|
|
2004-08-09 18:04:08 +01:00
|
|
|
#include "stdafx.h"
|
2022-10-21 08:00:00 +01:00
|
|
|
#include "economy_func.h"
|
2007-12-19 20:45:46 +00:00
|
|
|
#include "window_gui.h"
|
|
|
|
#include "station_gui.h"
|
2008-01-06 18:56:43 +00:00
|
|
|
#include "terraform_gui.h"
|
2007-12-29 09:24:26 +00:00
|
|
|
#include "sound_func.h"
|
2007-12-25 11:26:07 +00:00
|
|
|
#include "window_func.h"
|
2008-05-24 03:54:47 +01:00
|
|
|
#include "strings_func.h"
|
2008-01-09 09:45:45 +00:00
|
|
|
#include "viewport_func.h"
|
2008-09-30 21:51:04 +01:00
|
|
|
#include "company_func.h"
|
2008-05-07 14:10:15 +01:00
|
|
|
#include "tilehighlight_func.h"
|
2008-09-30 21:51:04 +01:00
|
|
|
#include "company_base.h"
|
2010-01-15 16:41:15 +00:00
|
|
|
#include "station_type.h"
|
2010-02-22 16:09:26 +00:00
|
|
|
#include "newgrf_airport.h"
|
2010-08-05 13:05:15 +01:00
|
|
|
#include "newgrf_callbacks.h"
|
2010-03-05 23:21:56 +00:00
|
|
|
#include "widgets/dropdown_type.h"
|
|
|
|
#include "core/geometry_func.hpp"
|
2010-07-03 19:10:18 +01:00
|
|
|
#include "hotkeys.h"
|
2011-08-04 18:13:24 +01:00
|
|
|
#include "vehicle_func.h"
|
2013-06-15 16:05:54 +01:00
|
|
|
#include "gui.h"
|
2021-10-28 23:56:07 +01:00
|
|
|
#include "command_func.h"
|
2021-10-10 01:35:06 +01:00
|
|
|
#include "airport_cmd.h"
|
2021-10-28 23:56:07 +01:00
|
|
|
#include "station_cmd.h"
|
2021-05-04 12:35:27 +01:00
|
|
|
#include "zoom_func.h"
|
2023-04-13 12:56:00 +01:00
|
|
|
#include "timer/timer.h"
|
|
|
|
#include "timer/timer_game_calendar.h"
|
2004-08-09 18:04:08 +01:00
|
|
|
|
2011-12-15 22:22:55 +00:00
|
|
|
#include "widgets/airport_widget.h"
|
|
|
|
|
2014-04-23 21:13:33 +01:00
|
|
|
#include "safeguards.h"
|
|
|
|
|
2008-01-13 01:21:35 +00:00
|
|
|
|
2010-03-05 23:21:56 +00:00
|
|
|
static AirportClassID _selected_airport_class; ///< the currently visible airport class
|
|
|
|
static int _selected_airport_index; ///< the index of the selected airport in the current class or -1
|
2010-08-05 12:59:07 +01:00
|
|
|
static byte _selected_airport_layout; ///< selected airport layout number.
|
2004-08-09 18:04:08 +01:00
|
|
|
|
2008-05-24 12:19:30 +01:00
|
|
|
static void ShowBuildAirportPicker(Window *parent);
|
2004-08-09 18:04:08 +01:00
|
|
|
|
2010-08-05 13:03:34 +01:00
|
|
|
SpriteID GetCustomAirportSprite(const AirportSpec *as, byte layout);
|
2004-08-09 18:04:08 +01:00
|
|
|
|
2021-11-28 21:43:38 +00:00
|
|
|
void CcBuildAirport(Commands cmd, const CommandCost &result, TileIndex tile)
|
2004-08-09 18:04:08 +01:00
|
|
|
{
|
2010-01-11 18:46:09 +00:00
|
|
|
if (result.Failed()) return;
|
|
|
|
|
2021-02-20 18:01:04 +00:00
|
|
|
if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile);
|
2010-01-11 18:46:09 +00:00
|
|
|
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
|
2004-08-09 18:04:08 +01:00
|
|
|
}
|
|
|
|
|
2010-12-21 16:27:50 +00:00
|
|
|
/**
|
|
|
|
* Place an airport.
|
|
|
|
* @param tile Position to put the new airport.
|
|
|
|
*/
|
2005-06-24 13:38:35 +01:00
|
|
|
static void PlaceAirport(TileIndex tile)
|
2004-08-09 18:04:08 +01:00
|
|
|
{
|
2010-03-05 23:21:56 +00:00
|
|
|
if (_selected_airport_index == -1) return;
|
2009-01-08 16:35:45 +00:00
|
|
|
|
2021-11-14 15:39:17 +00:00
|
|
|
byte airport_type = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index)->GetIndex();
|
|
|
|
byte layout = _selected_airport_layout;
|
|
|
|
bool adjacent = _ctrl_pressed;
|
2021-10-28 23:56:07 +01:00
|
|
|
|
|
|
|
auto proc = [=](bool test, StationID to_join) -> bool {
|
|
|
|
if (test) {
|
2021-11-14 15:39:17 +00:00
|
|
|
return Command<CMD_BUILD_AIRPORT>::Do(CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_AIRPORT>()), tile, airport_type, layout, INVALID_STATION, adjacent).Succeeded();
|
2021-10-28 23:56:07 +01:00
|
|
|
} else {
|
2021-11-14 15:39:17 +00:00
|
|
|
return Command<CMD_BUILD_AIRPORT>::Post(STR_ERROR_CAN_T_BUILD_AIRPORT_HERE, CcBuildAirport, tile, airport_type, layout, to_join, adjacent);
|
2021-10-28 23:56:07 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
ShowSelectStationIfNeeded(TileArea(tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE), proc);
|
2004-08-09 18:04:08 +01:00
|
|
|
}
|
|
|
|
|
2010-12-21 16:26:34 +00:00
|
|
|
/** Airport build toolbar window handler. */
|
2008-05-18 22:34:35 +01:00
|
|
|
struct BuildAirToolbarWindow : Window {
|
2010-12-21 16:26:34 +00:00
|
|
|
int last_user_action; // Last started user action.
|
|
|
|
|
2013-05-26 20:23:42 +01:00
|
|
|
BuildAirToolbarWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
|
2008-05-18 22:34:35 +01:00
|
|
|
{
|
2013-05-26 20:23:42 +01:00
|
|
|
this->InitNested(window_number);
|
Change: always allow to click on the toolbar icons for road/rail/dock/airport
This change allows a user to see what is available and what will become
available before it is available, instead of only disabling the button
with no further explanation. It also always allows building roads and
canals, even if no vehicles are available for road / water.
For rail/road/tram, a dropdown with available types is shown. If
none are available, it reads "None". If the type is not yet available,
it is greyed out.
For dock/airport, this always open the toolbar, but building airports,
docks, and depots buttons are disabled till vehicles are available
for those.
Road is the only exception, with the primary road always being
available. Here too, stations and depots are disabled till vehicles
become available. It does mean you can now always build roads to
for example help towns grow.
2021-01-07 21:28:08 +00:00
|
|
|
this->OnInvalidateData();
|
2008-05-29 16:13:28 +01:00
|
|
|
if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
|
2010-12-21 16:26:34 +00:00
|
|
|
this->last_user_action = WIDGET_LIST_END;
|
2004-08-09 18:04:08 +01:00
|
|
|
}
|
2008-05-18 22:34:35 +01:00
|
|
|
|
2021-05-15 22:12:25 +01:00
|
|
|
void Close() override
|
2008-05-18 22:34:35 +01:00
|
|
|
{
|
2019-03-30 16:58:40 +00:00
|
|
|
if (this->IsWidgetLowered(WID_AT_AIRPORT)) SetViewportCatchmentStation(nullptr, true);
|
2021-05-17 14:46:38 +01:00
|
|
|
if (_settings_client.gui.link_terraform_toolbar) CloseWindowById(WC_SCEN_LAND_GEN, 0, false);
|
2021-05-15 22:12:25 +01:00
|
|
|
this->Window::Close();
|
2008-05-18 22:34:35 +01:00
|
|
|
}
|
|
|
|
|
2015-02-22 15:26:27 +00:00
|
|
|
/**
|
|
|
|
* Some data on this window has become invalid.
|
|
|
|
* @param data Information about the changed data.
|
|
|
|
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
|
|
|
|
*/
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
2015-02-22 15:26:27 +00:00
|
|
|
{
|
|
|
|
if (!gui_scope) return;
|
|
|
|
|
Change: always allow to click on the toolbar icons for road/rail/dock/airport
This change allows a user to see what is available and what will become
available before it is available, instead of only disabling the button
with no further explanation. It also always allows building roads and
canals, even if no vehicles are available for road / water.
For rail/road/tram, a dropdown with available types is shown. If
none are available, it reads "None". If the type is not yet available,
it is greyed out.
For dock/airport, this always open the toolbar, but building airports,
docks, and depots buttons are disabled till vehicles are available
for those.
Road is the only exception, with the primary road always being
available. Here too, stations and depots are disabled till vehicles
become available. It does mean you can now always build roads to
for example help towns grow.
2021-01-07 21:28:08 +00:00
|
|
|
bool can_build = CanBuildVehicleInfrastructure(VEH_AIRCRAFT);
|
|
|
|
this->SetWidgetsDisabledState(!can_build,
|
|
|
|
WID_AT_AIRPORT,
|
|
|
|
WIDGET_LIST_END);
|
|
|
|
if (!can_build) {
|
2021-05-17 14:46:38 +01:00
|
|
|
CloseWindowById(WC_BUILD_STATION, TRANSPORT_AIR);
|
2021-01-07 22:06:23 +00:00
|
|
|
|
|
|
|
/* Show in the tooltip why this button is disabled. */
|
|
|
|
this->GetWidget<NWidgetCore>(WID_AT_AIRPORT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
|
|
|
|
} else {
|
|
|
|
this->GetWidget<NWidgetCore>(WID_AT_AIRPORT)->SetToolTip(STR_TOOLBAR_AIRCRAFT_BUILD_AIRPORT_TOOLTIP);
|
Change: always allow to click on the toolbar icons for road/rail/dock/airport
This change allows a user to see what is available and what will become
available before it is available, instead of only disabling the button
with no further explanation. It also always allows building roads and
canals, even if no vehicles are available for road / water.
For rail/road/tram, a dropdown with available types is shown. If
none are available, it reads "None". If the type is not yet available,
it is greyed out.
For dock/airport, this always open the toolbar, but building airports,
docks, and depots buttons are disabled till vehicles are available
for those.
Road is the only exception, with the primary road always being
available. Here too, stations and depots are disabled till vehicles
become available. It does mean you can now always build roads to
for example help towns grow.
2021-01-07 21:28:08 +00:00
|
|
|
}
|
2015-02-22 15:26:27 +00:00
|
|
|
}
|
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnClick(Point pt, int widget, int click_count) override
|
2008-05-18 22:34:35 +01:00
|
|
|
{
|
2010-12-21 16:26:34 +00:00
|
|
|
switch (widget) {
|
2011-12-16 16:27:45 +00:00
|
|
|
case WID_AT_AIRPORT:
|
|
|
|
if (HandlePlacePushButton(this, WID_AT_AIRPORT, SPR_CURSOR_AIRPORT, HT_RECT)) {
|
2010-12-21 16:26:34 +00:00
|
|
|
ShowBuildAirportPicker(this);
|
|
|
|
this->last_user_action = widget;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-12-16 16:27:45 +00:00
|
|
|
case WID_AT_DEMOLISH:
|
|
|
|
HandlePlacePushButton(this, WID_AT_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT | HT_DIAGONAL);
|
2010-12-21 16:26:34 +00:00
|
|
|
this->last_user_action = widget;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: break;
|
|
|
|
}
|
2008-05-18 22:34:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnPlaceObject(Point pt, TileIndex tile) override
|
2008-05-18 22:34:35 +01:00
|
|
|
{
|
2010-12-21 16:27:50 +00:00
|
|
|
switch (this->last_user_action) {
|
2011-12-16 16:27:45 +00:00
|
|
|
case WID_AT_AIRPORT:
|
2010-12-21 16:27:50 +00:00
|
|
|
PlaceAirport(tile);
|
|
|
|
break;
|
|
|
|
|
2011-12-16 16:27:45 +00:00
|
|
|
case WID_AT_DEMOLISH:
|
2010-12-21 16:27:50 +00:00
|
|
|
PlaceProc_DemolishArea(tile);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: NOT_REACHED();
|
|
|
|
}
|
2008-05-18 22:34:35 +01:00
|
|
|
}
|
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override
|
2008-05-18 22:34:35 +01:00
|
|
|
{
|
|
|
|
VpSelectTilesWithMethod(pt.x, pt.y, select_method);
|
|
|
|
}
|
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) override
|
2008-05-18 22:34:35 +01:00
|
|
|
{
|
|
|
|
if (pt.x != -1 && select_proc == DDSP_DEMOLISH_AREA) {
|
|
|
|
GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnPlaceObjectAbort() override
|
2008-05-18 22:34:35 +01:00
|
|
|
{
|
2019-03-30 16:58:40 +00:00
|
|
|
if (this->IsWidgetLowered(WID_AT_AIRPORT)) SetViewportCatchmentStation(nullptr, true);
|
|
|
|
|
2008-05-18 22:34:35 +01:00
|
|
|
this->RaiseButtons();
|
|
|
|
|
2021-05-17 14:46:38 +01:00
|
|
|
CloseWindowById(WC_BUILD_STATION, TRANSPORT_AIR);
|
|
|
|
CloseWindowById(WC_SELECT_STATION, 0);
|
2008-05-18 22:34:35 +01:00
|
|
|
}
|
2010-07-03 19:10:18 +01:00
|
|
|
|
2013-06-15 16:28:09 +01:00
|
|
|
static HotkeyList hotkeys;
|
2010-07-03 19:10:18 +01:00
|
|
|
};
|
|
|
|
|
2013-06-15 16:31:22 +01:00
|
|
|
/**
|
|
|
|
* Handler for global hotkeys of the BuildAirToolbarWindow.
|
|
|
|
* @param hotkey Hotkey
|
|
|
|
* @return ES_HANDLED if hotkey was accepted.
|
|
|
|
*/
|
|
|
|
static EventState AirportToolbarGlobalHotkeys(int hotkey)
|
|
|
|
{
|
2021-01-08 22:28:46 +00:00
|
|
|
if (_game_mode != GM_NORMAL) return ES_NOT_HANDLED;
|
2013-06-15 16:31:22 +01:00
|
|
|
Window *w = ShowBuildAirToolbar();
|
2019-04-10 22:07:06 +01:00
|
|
|
if (w == nullptr) return ES_NOT_HANDLED;
|
2013-06-15 16:31:22 +01:00
|
|
|
return w->OnHotkey(hotkey);
|
|
|
|
}
|
|
|
|
|
2013-06-15 16:28:09 +01:00
|
|
|
static Hotkey airtoolbar_hotkeys[] = {
|
2013-06-15 16:27:33 +01:00
|
|
|
Hotkey('1', "airport", WID_AT_AIRPORT),
|
|
|
|
Hotkey('2', "demolish", WID_AT_DEMOLISH),
|
|
|
|
HOTKEY_LIST_END
|
2008-05-18 22:34:35 +01:00
|
|
|
};
|
2013-06-15 16:31:22 +01:00
|
|
|
HotkeyList BuildAirToolbarWindow::hotkeys("airtoolbar", airtoolbar_hotkeys, AirportToolbarGlobalHotkeys);
|
2004-08-09 18:04:08 +01:00
|
|
|
|
2009-03-22 21:16:57 +00:00
|
|
|
static const NWidgetPart _nested_air_toolbar_widgets[] = {
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
|
|
|
|
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_TOOLBAR_AIRCRAFT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
|
|
|
NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
|
2009-03-22 21:16:57 +00:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2011-12-16 16:27:45 +00:00
|
|
|
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),
|
2009-11-24 21:13:36 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetMinimalSize(4, 22), SetFill(1, 1), EndContainer(),
|
2011-12-16 16:27:45 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_AT_DEMOLISH), SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
|
2009-03-22 21:16:57 +00:00
|
|
|
EndContainer(),
|
|
|
|
};
|
2004-08-09 18:04:08 +01:00
|
|
|
|
2013-05-26 20:23:42 +01:00
|
|
|
static WindowDesc _air_toolbar_desc(
|
2013-05-26 20:25:01 +01:00
|
|
|
WDP_ALIGN_TOOLBAR, "toolbar_air", 0, 0,
|
2007-02-01 15:49:12 +00:00
|
|
|
WC_BUILD_TOOLBAR, WC_NONE,
|
2009-11-24 17:28:29 +00:00
|
|
|
WDF_CONSTRUCTION,
|
2013-06-15 16:30:44 +01:00
|
|
|
_nested_air_toolbar_widgets, lengthof(_nested_air_toolbar_widgets),
|
|
|
|
&BuildAirToolbarWindow::hotkeys
|
2009-03-15 15:12:06 +00:00
|
|
|
);
|
2004-08-09 18:04:08 +01:00
|
|
|
|
2010-07-04 10:27:15 +01:00
|
|
|
/**
|
|
|
|
* Open the build airport toolbar window
|
|
|
|
*
|
|
|
|
* If the terraform toolbar is linked to the toolbar, that window is also opened.
|
|
|
|
*
|
2019-04-10 22:07:06 +01:00
|
|
|
* @return newly opened airport toolbar, or nullptr if the toolbar could not be opened.
|
2010-07-04 10:27:15 +01:00
|
|
|
*/
|
|
|
|
Window *ShowBuildAirToolbar()
|
2004-08-09 18:04:08 +01:00
|
|
|
{
|
2019-04-10 22:07:06 +01:00
|
|
|
if (!Company::IsValidID(_local_company)) return nullptr;
|
2006-10-31 21:15:56 +00:00
|
|
|
|
2021-05-17 14:46:38 +01:00
|
|
|
CloseWindowByClass(WC_BUILD_TOOLBAR);
|
2010-07-04 10:27:15 +01:00
|
|
|
return AllocateWindowDescFront<BuildAirToolbarWindow>(&_air_toolbar_desc, TRANSPORT_AIR);
|
2004-08-09 18:04:08 +01:00
|
|
|
}
|
|
|
|
|
2010-03-05 23:21:56 +00:00
|
|
|
class BuildAirportWindow : public PickerWindowBase {
|
2010-08-05 13:03:34 +01:00
|
|
|
SpriteID preview_sprite; ///< Cached airport preview sprite.
|
2010-03-05 23:21:56 +00:00
|
|
|
int line_height;
|
2010-08-12 09:37:01 +01:00
|
|
|
Scrollbar *vscroll;
|
2010-03-05 23:21:56 +00:00
|
|
|
|
|
|
|
/** Build a dropdown list of available airport classes */
|
2019-04-02 20:31:24 +01:00
|
|
|
static DropDownList BuildAirportClassDropDown()
|
2010-03-05 23:21:56 +00:00
|
|
|
{
|
2019-04-02 20:31:24 +01:00
|
|
|
DropDownList list;
|
2010-03-05 23:21:56 +00:00
|
|
|
|
2012-04-22 17:28:19 +01:00
|
|
|
for (uint i = 0; i < AirportClass::GetClassCount(); i++) {
|
2019-04-02 20:31:24 +01:00
|
|
|
list.emplace_back(new DropDownListStringItem(AirportClass::Get((AirportClassID)i)->name, i, false));
|
2010-03-05 23:21:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2008-05-17 04:31:22 +01:00
|
|
|
public:
|
2013-05-26 20:23:42 +01:00
|
|
|
BuildAirportWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
|
2008-05-17 04:31:22 +01:00
|
|
|
{
|
2013-05-26 20:23:42 +01:00
|
|
|
this->CreateNestedTree();
|
2010-08-12 09:37:01 +01:00
|
|
|
|
2011-12-16 16:27:45 +00:00
|
|
|
this->vscroll = this->GetScrollbar(WID_AP_SCROLLBAR);
|
2010-08-12 09:37:01 +01:00
|
|
|
this->vscroll->SetCapacity(5);
|
|
|
|
this->vscroll->SetPosition(0);
|
|
|
|
|
2013-05-26 20:23:42 +01:00
|
|
|
this->FinishInitNested(TRANSPORT_AIR);
|
2010-03-05 23:21:56 +00:00
|
|
|
|
2011-12-16 16:27:45 +00:00
|
|
|
this->SetWidgetLoweredState(WID_AP_BTN_DONTHILIGHT, !_settings_client.gui.station_show_coverage);
|
|
|
|
this->SetWidgetLoweredState(WID_AP_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage);
|
2009-07-05 17:50:56 +01:00
|
|
|
this->OnInvalidateData();
|
2010-03-05 23:21:56 +00:00
|
|
|
|
2014-08-15 20:41:57 +01:00
|
|
|
/* Ensure airport class is valid (changing NewGRFs). */
|
|
|
|
_selected_airport_class = Clamp(_selected_airport_class, APC_BEGIN, (AirportClassID)(AirportClass::GetClassCount() - 1));
|
|
|
|
const AirportClass *ac = AirportClass::Get(_selected_airport_class);
|
|
|
|
this->vscroll->SetCount(ac->GetSpecCount());
|
|
|
|
|
|
|
|
/* Ensure the airport index is valid for this class (changing NewGRFs). */
|
|
|
|
_selected_airport_index = Clamp(_selected_airport_index, -1, ac->GetSpecCount() - 1);
|
|
|
|
|
|
|
|
/* Only when no valid airport was selected, we want to select the first airport. */
|
|
|
|
bool selectFirstAirport = true;
|
|
|
|
if (_selected_airport_index != -1) {
|
|
|
|
const AirportSpec *as = ac->GetSpec(_selected_airport_index);
|
|
|
|
if (as->IsAvailable()) {
|
|
|
|
/* Ensure the airport layout is valid. */
|
|
|
|
_selected_airport_layout = Clamp(_selected_airport_layout, 0, as->num_table - 1);
|
|
|
|
selectFirstAirport = false;
|
|
|
|
this->UpdateSelectSize();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selectFirstAirport) this->SelectFirstAvailableAirport(true);
|
2008-05-17 04:31:22 +01:00
|
|
|
}
|
2008-04-10 03:14:14 +01:00
|
|
|
|
2021-05-15 22:12:25 +01:00
|
|
|
void Close() override
|
2009-01-08 16:35:45 +00:00
|
|
|
{
|
2021-05-17 14:46:38 +01:00
|
|
|
CloseWindowById(WC_SELECT_STATION, 0);
|
2021-05-15 22:12:25 +01:00
|
|
|
this->PickerWindowBase::Close();
|
2009-01-08 16:35:45 +00:00
|
|
|
}
|
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void SetStringParameters(int widget) const override
|
2010-03-05 23:21:56 +00:00
|
|
|
{
|
2010-08-05 12:59:07 +01:00
|
|
|
switch (widget) {
|
2011-12-16 16:27:45 +00:00
|
|
|
case WID_AP_CLASS_DROPDOWN:
|
2012-04-22 17:27:55 +01:00
|
|
|
SetDParam(0, AirportClass::Get(_selected_airport_class)->name);
|
2010-08-05 12:59:07 +01:00
|
|
|
break;
|
|
|
|
|
2011-12-16 16:27:45 +00:00
|
|
|
case WID_AP_LAYOUT_NUM:
|
2010-08-05 18:24:45 +01:00
|
|
|
SetDParam(0, STR_EMPTY);
|
2010-08-05 13:05:56 +01:00
|
|
|
if (_selected_airport_index != -1) {
|
2012-04-22 17:28:14 +01:00
|
|
|
const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index);
|
2010-08-05 13:05:56 +01:00
|
|
|
StringID string = GetAirportTextCallback(as, _selected_airport_layout, CBID_AIRPORT_LAYOUT_NAME);
|
2010-08-05 18:24:45 +01:00
|
|
|
if (string != STR_UNDEFINED) {
|
|
|
|
SetDParam(0, string);
|
|
|
|
} else if (as->num_table > 1) {
|
|
|
|
SetDParam(0, STR_STATION_BUILD_AIRPORT_LAYOUT_NAME);
|
|
|
|
SetDParam(1, _selected_airport_layout + 1);
|
|
|
|
}
|
2010-08-05 13:05:56 +01:00
|
|
|
}
|
2010-08-05 12:59:07 +01:00
|
|
|
break;
|
2010-03-05 23:21:56 +00:00
|
|
|
|
2010-08-05 12:59:07 +01:00
|
|
|
default: break;
|
|
|
|
}
|
2010-03-05 23:21:56 +00:00
|
|
|
}
|
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
2010-03-05 23:21:56 +00:00
|
|
|
{
|
|
|
|
switch (widget) {
|
2011-12-16 16:27:45 +00:00
|
|
|
case WID_AP_CLASS_DROPDOWN: {
|
2010-03-05 23:21:56 +00:00
|
|
|
Dimension d = {0, 0};
|
2012-04-22 17:28:19 +01:00
|
|
|
for (uint i = 0; i < AirportClass::GetClassCount(); i++) {
|
2023-04-25 10:03:48 +01:00
|
|
|
d = maxdim(d, GetStringBoundingBox(AirportClass::Get((AirportClassID)i)->name));
|
2010-03-05 23:21:56 +00:00
|
|
|
}
|
|
|
|
d.width += padding.width;
|
|
|
|
d.height += padding.height;
|
|
|
|
*size = maxdim(*size, d);
|
2010-08-01 19:53:30 +01:00
|
|
|
break;
|
|
|
|
}
|
2010-03-05 23:21:56 +00:00
|
|
|
|
2011-12-16 16:27:45 +00:00
|
|
|
case WID_AP_AIRPORT_LIST: {
|
2010-03-05 23:21:56 +00:00
|
|
|
for (int i = 0; i < NUM_AIRPORTS; i++) {
|
|
|
|
const AirportSpec *as = AirportSpec::Get(i);
|
|
|
|
if (!as->enabled) continue;
|
|
|
|
|
2022-09-23 09:36:22 +01:00
|
|
|
size->width = std::max(size->width, GetStringBoundingBox(as->name).width + padding.width);
|
2010-03-05 23:21:56 +00:00
|
|
|
}
|
|
|
|
|
2021-05-03 16:56:02 +01:00
|
|
|
this->line_height = FONT_HEIGHT_NORMAL + padding.height;
|
2013-06-30 15:33:15 +01:00
|
|
|
size->height = 5 * this->line_height;
|
2010-08-01 19:53:30 +01:00
|
|
|
break;
|
|
|
|
}
|
2010-03-05 23:21:56 +00:00
|
|
|
|
2011-12-16 16:27:45 +00:00
|
|
|
case WID_AP_AIRPORT_SPRITE:
|
2010-08-05 13:03:34 +01:00
|
|
|
for (int i = 0; i < NUM_AIRPORTS; i++) {
|
|
|
|
const AirportSpec *as = AirportSpec::Get(i);
|
|
|
|
if (!as->enabled) continue;
|
|
|
|
for (byte layout = 0; layout < as->num_table; layout++) {
|
|
|
|
SpriteID sprite = GetCustomAirportSprite(as, layout);
|
|
|
|
if (sprite != 0) {
|
|
|
|
Dimension d = GetSpriteSize(sprite);
|
2022-09-23 09:36:22 +01:00
|
|
|
d.width += WidgetDimensions::scaled.framerect.Horizontal();
|
|
|
|
d.height += WidgetDimensions::scaled.framerect.Vertical();
|
2010-08-05 13:03:34 +01:00
|
|
|
*size = maxdim(d, *size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-12-16 16:27:45 +00:00
|
|
|
case WID_AP_EXTRA_TEXT:
|
2010-08-05 13:05:15 +01:00
|
|
|
for (int i = NEW_AIRPORT_OFFSET; i < NUM_AIRPORTS; i++) {
|
|
|
|
const AirportSpec *as = AirportSpec::Get(i);
|
|
|
|
if (!as->enabled) continue;
|
|
|
|
for (byte layout = 0; layout < as->num_table; layout++) {
|
|
|
|
StringID string = GetAirportTextCallback(as, layout, CBID_AIRPORT_ADDITIONAL_TEXT);
|
|
|
|
if (string == STR_UNDEFINED) continue;
|
|
|
|
|
2023-04-25 10:03:48 +01:00
|
|
|
Dimension d = GetStringMultiLineBoundingBox(string, *size);
|
2010-08-05 13:05:15 +01:00
|
|
|
*size = maxdim(d, *size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-03-05 23:21:56 +00:00
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void DrawWidget(const Rect &r, int widget) const override
|
2010-03-05 23:21:56 +00:00
|
|
|
{
|
2010-08-05 13:03:34 +01:00
|
|
|
switch (widget) {
|
2011-12-16 16:27:45 +00:00
|
|
|
case WID_AP_AIRPORT_LIST: {
|
2022-09-23 09:36:22 +01:00
|
|
|
Rect row = r.WithHeight(this->line_height).Shrink(WidgetDimensions::scaled.bevel);
|
|
|
|
Rect text = r.WithHeight(this->line_height).Shrink(WidgetDimensions::scaled.matrix);
|
2012-04-22 17:28:14 +01:00
|
|
|
AirportClass *apclass = AirportClass::Get(_selected_airport_class);
|
|
|
|
for (uint i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < apclass->GetSpecCount(); i++) {
|
|
|
|
const AirportSpec *as = apclass->GetSpec(i);
|
2010-08-05 13:03:34 +01:00
|
|
|
if (!as->IsAvailable()) {
|
2022-10-15 16:55:47 +01:00
|
|
|
GfxFillRect(row, PC_BLACK, FILLRECT_CHECKER);
|
2010-08-05 13:03:34 +01:00
|
|
|
}
|
2022-10-15 16:55:47 +01:00
|
|
|
DrawString(text, as->name, ((int)i == _selected_airport_index) ? TC_WHITE : TC_BLACK);
|
|
|
|
row = row.Translate(0, this->line_height);
|
|
|
|
text = text.Translate(0, this->line_height);
|
2010-08-05 13:03:34 +01:00
|
|
|
}
|
|
|
|
break;
|
2010-03-05 23:21:56 +00:00
|
|
|
}
|
2010-08-05 13:03:34 +01:00
|
|
|
|
2011-12-16 16:27:45 +00:00
|
|
|
case WID_AP_AIRPORT_SPRITE:
|
2010-08-05 13:03:34 +01:00
|
|
|
if (this->preview_sprite != 0) {
|
|
|
|
Dimension d = GetSpriteSize(this->preview_sprite);
|
2022-09-07 08:31:02 +01:00
|
|
|
DrawSprite(this->preview_sprite, COMPANY_SPRITE_COLOUR(_local_company), CenterBounds(r.left, r.right, d.width), CenterBounds(r.top, r.bottom, d.height));
|
2010-08-05 13:03:34 +01:00
|
|
|
}
|
|
|
|
break;
|
2010-08-05 13:05:15 +01:00
|
|
|
|
2011-12-16 16:27:45 +00:00
|
|
|
case WID_AP_EXTRA_TEXT:
|
2010-08-05 13:05:15 +01:00
|
|
|
if (_selected_airport_index != -1) {
|
2012-04-22 17:28:14 +01:00
|
|
|
const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index);
|
2010-08-05 13:05:15 +01:00
|
|
|
StringID string = GetAirportTextCallback(as, _selected_airport_layout, CBID_AIRPORT_ADDITIONAL_TEXT);
|
|
|
|
if (string != STR_UNDEFINED) {
|
2023-04-25 10:03:48 +01:00
|
|
|
DrawStringMultiLine(r.left, r.right, r.top, r.bottom, string, TC_BLACK);
|
2010-08-05 13:05:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2010-03-05 23:21:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnPaint() override
|
2008-05-17 04:31:22 +01:00
|
|
|
{
|
2009-07-05 17:50:56 +01:00
|
|
|
this->DrawWidgets();
|
2008-05-17 04:31:22 +01:00
|
|
|
|
2021-05-04 12:35:27 +01:00
|
|
|
Rect r = this->GetWidget<NWidgetBase>(WID_AP_ACCEPTANCE)->GetCurrentRect();
|
2022-09-23 09:36:22 +01:00
|
|
|
int top = r.top + WidgetDimensions::scaled.vsep_normal;
|
2010-03-05 23:21:56 +00:00
|
|
|
|
|
|
|
if (_selected_airport_index != -1) {
|
2012-04-22 17:28:14 +01:00
|
|
|
const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index);
|
2010-03-05 23:21:56 +00:00
|
|
|
int rad = _settings_game.station.modified_catchment ? as->catchment : (uint)CA_UNMODIFIED;
|
|
|
|
|
|
|
|
/* 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, as->noise_level);
|
2021-05-04 12:35:27 +01:00
|
|
|
DrawString(r.left, r.right, top, STR_STATION_BUILD_NOISE);
|
2022-09-23 09:36:22 +01:00
|
|
|
top += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
|
2010-03-05 23:21:56 +00:00
|
|
|
}
|
|
|
|
|
2022-10-21 08:00:00 +01:00
|
|
|
if (_settings_game.economy.infrastructure_maintenance) {
|
|
|
|
Money monthly = _price[PR_INFRASTRUCTURE_AIRPORT] * as->maintenance_cost >> 3;
|
|
|
|
SetDParam(0, monthly * 12);
|
|
|
|
DrawString(r.left, r.right, top, STR_STATION_BUILD_INFRASTRUCTURE_COST);
|
2022-09-23 09:36:22 +01:00
|
|
|
top += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
|
2022-10-21 08:00:00 +01:00
|
|
|
}
|
|
|
|
|
2010-03-05 23:21:56 +00:00
|
|
|
/* strings such as 'Size' and 'Coverage Area' */
|
2022-09-23 09:36:22 +01:00
|
|
|
top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, false) + WidgetDimensions::scaled.vsep_normal;
|
|
|
|
top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, true) + WidgetDimensions::scaled.vsep_normal;
|
2008-05-24 03:54:47 +01:00
|
|
|
}
|
|
|
|
|
2013-06-11 19:36:26 +01:00
|
|
|
/* Resize background if the window is too small.
|
|
|
|
* Never make the window smaller to avoid oscillating if the size change affects the acceptance.
|
|
|
|
* (This is the case, if making the window bigger moves the mouse into the window.) */
|
2021-05-04 12:35:27 +01:00
|
|
|
if (top > r.bottom) {
|
|
|
|
ResizeWindow(this, 0, top - r.bottom, false);
|
2008-04-10 03:14:14 +01:00
|
|
|
}
|
2008-05-17 04:31:22 +01:00
|
|
|
}
|
2008-04-10 03:14:14 +01:00
|
|
|
|
2010-03-05 23:21:56 +00:00
|
|
|
void SelectOtherAirport(int airport_index)
|
2009-07-05 17:50:56 +01:00
|
|
|
{
|
2010-03-05 23:21:56 +00:00
|
|
|
_selected_airport_index = airport_index;
|
2010-08-05 12:59:07 +01:00
|
|
|
_selected_airport_layout = 0;
|
2009-07-05 17:50:56 +01:00
|
|
|
|
2010-03-05 23:21:56 +00:00
|
|
|
this->UpdateSelectSize();
|
2009-07-05 17:50:56 +01:00
|
|
|
this->SetDirty();
|
|
|
|
}
|
|
|
|
|
2010-03-05 23:21:56 +00:00
|
|
|
void UpdateSelectSize()
|
2009-07-05 17:50:56 +01:00
|
|
|
{
|
2010-03-05 23:21:56 +00:00
|
|
|
if (_selected_airport_index == -1) {
|
|
|
|
SetTileSelectSize(1, 1);
|
2011-12-16 16:27:45 +00:00
|
|
|
this->DisableWidget(WID_AP_LAYOUT_DECREASE);
|
|
|
|
this->DisableWidget(WID_AP_LAYOUT_INCREASE);
|
2010-03-05 23:21:56 +00:00
|
|
|
} else {
|
2012-04-22 17:28:14 +01:00
|
|
|
const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index);
|
2010-08-05 13:00:09 +01:00
|
|
|
int w = as->size_x;
|
|
|
|
int h = as->size_y;
|
|
|
|
Direction rotation = as->rotation[_selected_airport_layout];
|
|
|
|
if (rotation == DIR_E || rotation == DIR_W) Swap(w, h);
|
|
|
|
SetTileSelectSize(w, h);
|
2010-03-05 23:21:56 +00:00
|
|
|
|
2011-05-27 16:31:54 +01:00
|
|
|
this->preview_sprite = GetCustomAirportSprite(as, _selected_airport_layout);
|
|
|
|
|
2011-12-16 16:27:45 +00:00
|
|
|
this->SetWidgetDisabledState(WID_AP_LAYOUT_DECREASE, _selected_airport_layout == 0);
|
|
|
|
this->SetWidgetDisabledState(WID_AP_LAYOUT_INCREASE, _selected_airport_layout + 1 >= as->num_table);
|
2010-08-05 12:59:07 +01:00
|
|
|
|
2010-03-05 23:21:56 +00:00
|
|
|
int rad = _settings_game.station.modified_catchment ? as->catchment : (uint)CA_UNMODIFIED;
|
|
|
|
if (_settings_client.gui.station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
|
2009-07-05 17:50:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnClick(Point pt, int widget, int click_count) override
|
2008-05-17 04:31:22 +01:00
|
|
|
{
|
|
|
|
switch (widget) {
|
2011-12-16 16:27:45 +00:00
|
|
|
case WID_AP_CLASS_DROPDOWN:
|
|
|
|
ShowDropDownList(this, BuildAirportClassDropDown(), _selected_airport_class, WID_AP_CLASS_DROPDOWN);
|
2008-05-17 04:31:22 +01:00
|
|
|
break;
|
|
|
|
|
2011-12-16 16:27:45 +00:00
|
|
|
case WID_AP_AIRPORT_LIST: {
|
2023-05-15 18:57:50 +01:00
|
|
|
int num_clicked = this->vscroll->GetScrolledRowFromWidget(pt.y, this, widget, 0, this->line_height);
|
2023-05-03 11:17:52 +01:00
|
|
|
if (num_clicked == INT_MAX) break;
|
2012-04-22 17:28:14 +01:00
|
|
|
const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(num_clicked);
|
2010-03-05 23:21:56 +00:00
|
|
|
if (as->IsAvailable()) this->SelectOtherAirport(num_clicked);
|
2010-08-01 19:53:30 +01:00
|
|
|
break;
|
|
|
|
}
|
2010-03-05 23:21:56 +00:00
|
|
|
|
2011-12-16 16:27:45 +00:00
|
|
|
case WID_AP_BTN_DONTHILIGHT: case WID_AP_BTN_DOHILIGHT:
|
|
|
|
_settings_client.gui.station_show_coverage = (widget != WID_AP_BTN_DONTHILIGHT);
|
|
|
|
this->SetWidgetLoweredState(WID_AP_BTN_DONTHILIGHT, !_settings_client.gui.station_show_coverage);
|
|
|
|
this->SetWidgetLoweredState(WID_AP_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage);
|
2010-03-05 23:21:56 +00:00
|
|
|
this->SetDirty();
|
2012-12-23 21:09:09 +00:00
|
|
|
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
2010-03-05 23:21:56 +00:00
|
|
|
this->UpdateSelectSize();
|
2020-07-27 17:37:47 +01:00
|
|
|
SetViewportCatchmentStation(nullptr, true);
|
2008-05-17 04:31:22 +01:00
|
|
|
break;
|
2010-08-05 12:59:07 +01:00
|
|
|
|
2011-12-16 16:27:45 +00:00
|
|
|
case WID_AP_LAYOUT_DECREASE:
|
2010-08-05 12:59:07 +01:00
|
|
|
_selected_airport_layout--;
|
|
|
|
this->UpdateSelectSize();
|
|
|
|
this->SetDirty();
|
|
|
|
break;
|
|
|
|
|
2011-12-16 16:27:45 +00:00
|
|
|
case WID_AP_LAYOUT_INCREASE:
|
2010-08-05 12:59:07 +01:00
|
|
|
_selected_airport_layout++;
|
|
|
|
this->UpdateSelectSize();
|
|
|
|
this->SetDirty();
|
|
|
|
break;
|
2008-05-17 04:31:22 +01:00
|
|
|
}
|
|
|
|
}
|
2008-04-10 03:14:14 +01:00
|
|
|
|
2010-03-05 23:21:56 +00:00
|
|
|
/**
|
|
|
|
* Select the first available airport.
|
|
|
|
* @param change_class If true, change the class if no airport in the current
|
|
|
|
* class is available.
|
|
|
|
*/
|
|
|
|
void SelectFirstAvailableAirport(bool change_class)
|
|
|
|
{
|
|
|
|
/* First try to select an airport in the selected class. */
|
2012-04-22 17:28:14 +01:00
|
|
|
AirportClass *sel_apclass = AirportClass::Get(_selected_airport_class);
|
|
|
|
for (uint i = 0; i < sel_apclass->GetSpecCount(); i++) {
|
|
|
|
const AirportSpec *as = sel_apclass->GetSpec(i);
|
2010-03-05 23:21:56 +00:00
|
|
|
if (as->IsAvailable()) {
|
|
|
|
this->SelectOtherAirport(i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (change_class) {
|
|
|
|
/* If that fails, select the first available airport
|
|
|
|
* from a random class. */
|
|
|
|
for (AirportClassID j = APC_BEGIN; j < APC_MAX; j++) {
|
2012-04-22 17:28:14 +01:00
|
|
|
AirportClass *apclass = AirportClass::Get(j);
|
|
|
|
for (uint i = 0; i < apclass->GetSpecCount(); i++) {
|
|
|
|
const AirportSpec *as = apclass->GetSpec(i);
|
2010-03-05 23:21:56 +00:00
|
|
|
if (as->IsAvailable()) {
|
|
|
|
_selected_airport_class = j;
|
|
|
|
this->SelectOtherAirport(i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* If all airports are unavailable, select nothing. */
|
|
|
|
this->SelectOtherAirport(-1);
|
|
|
|
}
|
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnDropdownSelect(int widget, int index) override
|
2010-03-05 23:21:56 +00:00
|
|
|
{
|
2011-12-16 16:27:45 +00:00
|
|
|
assert(widget == WID_AP_CLASS_DROPDOWN);
|
2010-03-05 23:21:56 +00:00
|
|
|
_selected_airport_class = (AirportClassID)index;
|
2012-04-22 17:28:14 +01:00
|
|
|
this->vscroll->SetCount(AirportClass::Get(_selected_airport_class)->GetSpecCount());
|
2010-03-05 23:21:56 +00:00
|
|
|
this->SelectFirstAvailableAirport(false);
|
|
|
|
}
|
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnRealtimeTick(uint delta_ms) override
|
2008-05-17 04:31:22 +01:00
|
|
|
{
|
|
|
|
CheckRedrawStationCoverage(this);
|
2004-08-09 18:04:08 +01:00
|
|
|
}
|
2023-04-13 12:56:00 +01:00
|
|
|
|
|
|
|
IntervalTimer<TimerGameCalendar> yearly_interval = {{TimerGameCalendar::YEAR, TimerGameCalendar::Priority::NONE}, [this](auto) {
|
|
|
|
this->InvalidateData();
|
|
|
|
}};
|
2008-05-17 04:31:22 +01:00
|
|
|
};
|
2004-08-09 18:04:08 +01:00
|
|
|
|
2009-03-22 21:16:57 +00:00
|
|
|
static const NWidgetPart _nested_build_airport_widgets[] = {
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
|
|
|
|
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_AIRPORT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
2009-03-22 21:16:57 +00:00
|
|
|
EndContainer(),
|
2010-08-04 11:33:18 +01:00
|
|
|
NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetFill(1, 0), SetPIP(2, 0, 2),
|
|
|
|
NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_AIRPORT_CLASS_LABEL, STR_NULL), SetFill(1, 0),
|
2023-04-25 10:03:48 +01:00
|
|
|
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_AP_CLASS_DROPDOWN), SetFill(1, 0), SetDataTip(STR_JUST_STRING, STR_STATION_BUILD_AIRPORT_TOOLTIP),
|
2013-12-18 18:23:30 +00:00
|
|
|
NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_AP_AIRPORT_SPRITE), SetFill(1, 0),
|
2009-03-22 21:16:57 +00:00
|
|
|
NWidget(NWID_HORIZONTAL),
|
2013-06-30 15:32:31 +01:00
|
|
|
NWidget(WWT_MATRIX, COLOUR_GREY, WID_AP_AIRPORT_LIST), SetFill(1, 0), SetMatrixDataTip(1, 5, STR_STATION_BUILD_AIRPORT_TOOLTIP), SetScrollbar(WID_AP_SCROLLBAR),
|
2011-12-16 16:27:45 +00:00
|
|
|
NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_AP_SCROLLBAR),
|
2009-03-22 21:16:57 +00:00
|
|
|
EndContainer(),
|
2010-08-05 12:59:07 +01:00
|
|
|
NWidget(NWID_HORIZONTAL),
|
2011-12-16 16:27:45 +00:00
|
|
|
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_AP_LAYOUT_DECREASE), SetMinimalSize(12, 0), SetDataTip(AWV_DECREASE, STR_NULL),
|
2023-04-25 10:03:48 +01:00
|
|
|
NWidget(WWT_LABEL, COLOUR_GREY, WID_AP_LAYOUT_NUM), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_JUST_STRING, STR_NULL),
|
2011-12-16 16:27:45 +00:00
|
|
|
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_AP_LAYOUT_INCREASE), SetMinimalSize(12, 0), SetDataTip(AWV_INCREASE, STR_NULL),
|
2010-08-05 12:59:07 +01:00
|
|
|
EndContainer(),
|
2011-12-16 16:27:45 +00:00
|
|
|
NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_AP_EXTRA_TEXT), SetFill(1, 0), SetMinimalSize(150, 0),
|
2009-03-22 21:16:57 +00:00
|
|
|
EndContainer(),
|
|
|
|
/* Bottom panel. */
|
2022-09-26 17:52:31 +01:00
|
|
|
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_AP_BOTTOMPANEL),
|
2022-09-23 09:36:22 +01:00
|
|
|
NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetPadding(WidgetDimensions::unscaled.framerect), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0),
|
2009-03-22 21:16:57 +00:00
|
|
|
NWidget(NWID_HORIZONTAL),
|
2010-08-04 11:33:18 +01:00
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(14, 0), SetFill(1, 0),
|
2009-08-02 22:04:15 +01:00
|
|
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
2011-12-16 16:27:45 +00:00
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_AP_BTN_DONTHILIGHT), SetMinimalSize(60, 12), SetFill(1, 0),
|
2009-08-02 22:04:15 +01:00
|
|
|
SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
|
2011-12-16 16:27:45 +00:00
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_AP_BTN_DOHILIGHT), SetMinimalSize(60, 12), SetFill(1, 0),
|
2009-08-02 22:04:15 +01:00
|
|
|
SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
|
|
|
|
EndContainer(),
|
2010-08-04 11:33:18 +01:00
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(14, 0), SetFill(1, 0),
|
2009-03-22 21:16:57 +00:00
|
|
|
EndContainer(),
|
2022-09-23 09:36:22 +01:00
|
|
|
NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_AP_ACCEPTANCE), SetPadding(WidgetDimensions::unscaled.framerect), SetResize(0, 1), SetFill(1, 0),
|
2009-03-22 21:16:57 +00:00
|
|
|
EndContainer(),
|
|
|
|
};
|
|
|
|
|
2013-05-26 20:23:42 +01:00
|
|
|
static WindowDesc _build_airport_desc(
|
2013-05-26 20:25:01 +01:00
|
|
|
WDP_AUTO, "build_station_air", 0, 0,
|
2006-11-10 19:24:14 +00:00
|
|
|
WC_BUILD_STATION, WC_BUILD_TOOLBAR,
|
2012-11-11 16:10:43 +00:00
|
|
|
WDF_CONSTRUCTION,
|
2009-11-15 10:26:01 +00:00
|
|
|
_nested_build_airport_widgets, lengthof(_nested_build_airport_widgets)
|
2009-03-15 15:12:06 +00:00
|
|
|
);
|
2004-08-09 18:04:08 +01:00
|
|
|
|
2008-05-24 12:19:30 +01:00
|
|
|
static void ShowBuildAirportPicker(Window *parent)
|
2004-08-09 18:04:08 +01:00
|
|
|
{
|
2010-03-05 23:21:56 +00:00
|
|
|
new BuildAirportWindow(&_build_airport_desc, parent);
|
2004-08-09 18:04:08 +01:00
|
|
|
}
|
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void InitializeAirportGui()
|
2004-08-09 18:04:08 +01:00
|
|
|
{
|
2010-03-05 23:21:56 +00:00
|
|
|
_selected_airport_class = APC_BEGIN;
|
2011-06-04 15:48:21 +01:00
|
|
|
_selected_airport_index = -1;
|
2004-08-09 18:04:08 +01:00
|
|
|
}
|