mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
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.
This commit is contained in:
parent
a6aec252b1
commit
85a49a0d36
@ -71,6 +71,7 @@ struct BuildAirToolbarWindow : Window {
|
||||
BuildAirToolbarWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
|
||||
{
|
||||
this->InitNested(window_number);
|
||||
this->OnInvalidateData();
|
||||
if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
|
||||
this->last_user_action = WIDGET_LIST_END;
|
||||
}
|
||||
@ -90,7 +91,13 @@ struct BuildAirToolbarWindow : Window {
|
||||
{
|
||||
if (!gui_scope) return;
|
||||
|
||||
if (!CanBuildVehicleInfrastructure(VEH_AIRCRAFT)) delete this;
|
||||
bool can_build = CanBuildVehicleInfrastructure(VEH_AIRCRAFT);
|
||||
this->SetWidgetsDisabledState(!can_build,
|
||||
WID_AT_AIRPORT,
|
||||
WIDGET_LIST_END);
|
||||
if (!can_build) {
|
||||
DeleteWindowById(WC_BUILD_STATION, TRANSPORT_AIR);
|
||||
}
|
||||
}
|
||||
|
||||
void OnClick(Point pt, int widget, int click_count) override
|
||||
@ -160,7 +167,6 @@ struct BuildAirToolbarWindow : Window {
|
||||
*/
|
||||
static EventState AirportToolbarGlobalHotkeys(int hotkey)
|
||||
{
|
||||
if (_game_mode != GM_NORMAL || !CanBuildVehicleInfrastructure(VEH_AIRCRAFT)) return ES_NOT_HANDLED;
|
||||
Window *w = ShowBuildAirToolbar();
|
||||
if (w == nullptr) return ES_NOT_HANDLED;
|
||||
return w->OnHotkey(hotkey);
|
||||
|
@ -144,17 +144,14 @@ struct BuildDocksToolbarWindow : Window {
|
||||
break;
|
||||
|
||||
case WID_DT_DEPOT: // Build depot button
|
||||
if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return;
|
||||
if (HandlePlacePushButton(this, WID_DT_DEPOT, SPR_CURSOR_SHIP_DEPOT, HT_RECT)) ShowBuildDocksDepotPicker(this);
|
||||
break;
|
||||
|
||||
case WID_DT_STATION: // Build station button
|
||||
if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return;
|
||||
if (HandlePlacePushButton(this, WID_DT_STATION, SPR_CURSOR_DOCK, HT_SPECIAL)) ShowBuildDockStationPicker(this);
|
||||
break;
|
||||
|
||||
case WID_DT_BUOY: // Build buoy button
|
||||
if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return;
|
||||
HandlePlacePushButton(this, WID_DT_BUOY, SPR_CURSOR_BUOY, HT_RECT);
|
||||
break;
|
||||
|
||||
|
@ -436,18 +436,6 @@ struct BuildRailToolbarWindow : Window {
|
||||
if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
||||
{
|
||||
if (!gui_scope) return;
|
||||
|
||||
if (!CanBuildVehicleInfrastructure(VEH_TRAIN)) delete this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the rail toolbar for railtype given
|
||||
* @param railtype the railtype to display
|
||||
@ -781,7 +769,6 @@ struct BuildRailToolbarWindow : Window {
|
||||
*/
|
||||
static EventState RailToolbarGlobalHotkeys(int hotkey)
|
||||
{
|
||||
if (_game_mode != GM_NORMAL || !CanBuildVehicleInfrastructure(VEH_TRAIN)) return ES_NOT_HANDLED;
|
||||
extern RailType _last_built_railtype;
|
||||
Window *w = ShowBuildRailToolbar(_last_built_railtype);
|
||||
if (w == nullptr) return ES_NOT_HANDLED;
|
||||
|
@ -304,7 +304,17 @@ struct BuildRoadToolbarWindow : Window {
|
||||
{
|
||||
if (!gui_scope) return;
|
||||
|
||||
if (_game_mode != GM_EDITOR && !CanBuildVehicleInfrastructure(VEH_ROAD, GetRoadTramType(this->roadtype))) delete this;
|
||||
bool can_build = CanBuildVehicleInfrastructure(VEH_ROAD, GetRoadTramType(this->roadtype));
|
||||
this->SetWidgetsDisabledState(!can_build,
|
||||
WID_ROT_DEPOT,
|
||||
WID_ROT_BUS_STATION,
|
||||
WID_ROT_TRUCK_STATION,
|
||||
WIDGET_LIST_END);
|
||||
if (!can_build) {
|
||||
DeleteWindowById(WC_BUS_STATION, TRANSPORT_ROAD);
|
||||
DeleteWindowById(WC_TRUCK_STATION, TRANSPORT_ROAD);
|
||||
DeleteWindowById(WC_BUILD_DEPOT, TRANSPORT_ROAD);
|
||||
}
|
||||
}
|
||||
|
||||
void Initialize(RoadType roadtype)
|
||||
@ -434,7 +444,6 @@ struct BuildRoadToolbarWindow : Window {
|
||||
break;
|
||||
|
||||
case WID_ROT_DEPOT:
|
||||
if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD, GetRoadTramType(this->roadtype))) return;
|
||||
if (HandlePlacePushButton(this, WID_ROT_DEPOT, this->rti->cursor.depot, HT_RECT)) {
|
||||
ShowRoadDepotPicker(this);
|
||||
this->last_started_action = widget;
|
||||
@ -442,7 +451,6 @@ struct BuildRoadToolbarWindow : Window {
|
||||
break;
|
||||
|
||||
case WID_ROT_BUS_STATION:
|
||||
if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD, GetRoadTramType(this->roadtype))) return;
|
||||
if (HandlePlacePushButton(this, WID_ROT_BUS_STATION, SPR_CURSOR_BUS_STATION, HT_RECT)) {
|
||||
ShowRVStationPicker(this, ROADSTOP_BUS);
|
||||
this->last_started_action = widget;
|
||||
@ -450,7 +458,6 @@ struct BuildRoadToolbarWindow : Window {
|
||||
break;
|
||||
|
||||
case WID_ROT_TRUCK_STATION:
|
||||
if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD, GetRoadTramType(this->roadtype))) return;
|
||||
if (HandlePlacePushButton(this, WID_ROT_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, HT_RECT)) {
|
||||
ShowRVStationPicker(this, ROADSTOP_TRUCK);
|
||||
this->last_started_action = widget;
|
||||
@ -711,7 +718,6 @@ static EventState RoadTramToolbarGlobalHotkeys(int hotkey, RoadType last_build,
|
||||
Window* w = nullptr;
|
||||
switch (_game_mode) {
|
||||
case GM_NORMAL:
|
||||
if (!CanBuildVehicleInfrastructure(VEH_ROAD, rtt)) return ES_NOT_HANDLED;
|
||||
w = ShowBuildRoadToolbar(last_build);
|
||||
break;
|
||||
|
||||
|
@ -2033,11 +2033,6 @@ struct MainToolbarWindow : Window {
|
||||
this->SetWidgetDisabledState(WID_TN_GOAL, Goal::GetNumItems() == 0);
|
||||
this->SetWidgetDisabledState(WID_TN_STORY, StoryPage::GetNumItems() == 0);
|
||||
|
||||
this->SetWidgetDisabledState(WID_TN_RAILS, !CanBuildVehicleInfrastructure(VEH_TRAIN));
|
||||
this->SetWidgetDisabledState(WID_TN_ROADS, !CanBuildVehicleInfrastructure(VEH_ROAD, RTT_ROAD));
|
||||
this->SetWidgetDisabledState(WID_TN_TRAMS, !CanBuildVehicleInfrastructure(VEH_ROAD, RTT_TRAM));
|
||||
this->SetWidgetDisabledState(WID_TN_AIR, !CanBuildVehicleInfrastructure(VEH_AIRCRAFT));
|
||||
|
||||
this->DrawWidgets();
|
||||
}
|
||||
|
||||
@ -2078,11 +2073,11 @@ struct MainToolbarWindow : Window {
|
||||
case MTHK_AIRCRAFT_LIST: ShowVehicleListWindow(_local_company, VEH_AIRCRAFT); break;
|
||||
case MTHK_ZOOM_IN: ToolbarZoomInClick(this); break;
|
||||
case MTHK_ZOOM_OUT: ToolbarZoomOutClick(this); break;
|
||||
case MTHK_BUILD_RAIL: if (CanBuildVehicleInfrastructure(VEH_TRAIN)) ShowBuildRailToolbar(_last_built_railtype); break;
|
||||
case MTHK_BUILD_RAIL: ShowBuildRailToolbar(_last_built_railtype); break;
|
||||
case MTHK_BUILD_ROAD: ShowBuildRoadToolbar(_last_built_roadtype); break;
|
||||
case MTHK_BUILD_TRAM: if (CanBuildVehicleInfrastructure(VEH_ROAD, RTT_TRAM)) ShowBuildRoadToolbar(_last_built_tramtype); break;
|
||||
case MTHK_BUILD_TRAM: ShowBuildRoadToolbar(_last_built_tramtype); break;
|
||||
case MTHK_BUILD_DOCKS: ShowBuildDocksToolbar(); break;
|
||||
case MTHK_BUILD_AIRPORT: if (CanBuildVehicleInfrastructure(VEH_AIRCRAFT)) ShowBuildAirToolbar(); break;
|
||||
case MTHK_BUILD_AIRPORT: ShowBuildAirToolbar(); break;
|
||||
case MTHK_BUILD_TREES: ShowBuildTreesToolbar(); break;
|
||||
case MTHK_MUSIC: ShowMusicWindow(); break;
|
||||
case MTHK_AI_DEBUG: ShowAIDebugWindow(); break;
|
||||
|
Loading…
Reference in New Issue
Block a user