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:

committed by
Patric Stout

parent
a6aec252b1
commit
85a49a0d36
@@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user