From d0d3f1decec4ec7ca4d07a9967dc3e442b59d911 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sun, 12 May 2019 04:25:52 +0100 Subject: [PATCH] Enable vehicle list buttons in station GUI when list would be non-empty --- src/station_gui.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/station_gui.cpp b/src/station_gui.cpp index a4ec6cfc98..b6308ddb03 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -1399,12 +1399,18 @@ struct StationViewWindow : public Window { this->vscroll->SetCount(cargo.GetNumChildren()); // update scrollbar + byte have_veh_types = 0; + IterateOrderRefcountMapForDestinationID(st->index, [&](CompanyID cid, OrderType order_type, VehicleType veh_type, uint32 refcount) { + SetBit(have_veh_types, veh_type); + return true; + }); + /* disable some buttons */ this->SetWidgetDisabledState(WID_SV_RENAME, st->owner != _local_company); - this->SetWidgetDisabledState(WID_SV_TRAINS, !(st->facilities & FACIL_TRAIN)); - this->SetWidgetDisabledState(WID_SV_ROADVEHS, !(st->facilities & FACIL_TRUCK_STOP) && !(st->facilities & FACIL_BUS_STOP)); - this->SetWidgetDisabledState(WID_SV_SHIPS, !(st->facilities & FACIL_DOCK)); - this->SetWidgetDisabledState(WID_SV_PLANES, !(st->facilities & FACIL_AIRPORT)); + this->SetWidgetDisabledState(WID_SV_TRAINS, !(st->facilities & FACIL_TRAIN) && !HasBit(have_veh_types, VEH_TRAIN)); + this->SetWidgetDisabledState(WID_SV_ROADVEHS, !(st->facilities & FACIL_TRUCK_STOP) && !(st->facilities & FACIL_BUS_STOP) && !HasBit(have_veh_types, VEH_ROAD)); + this->SetWidgetDisabledState(WID_SV_SHIPS, !(st->facilities & FACIL_DOCK) && !HasBit(have_veh_types, VEH_SHIP)); + this->SetWidgetDisabledState(WID_SV_PLANES, !(st->facilities & FACIL_AIRPORT) && !HasBit(have_veh_types, VEH_AIRCRAFT)); this->SetWidgetDisabledState(WID_SV_CLOSE_AIRPORT, !(st->facilities & FACIL_AIRPORT) || st->owner != _local_company || st->owner == OWNER_NONE); // Also consider SE, where _local_company == OWNER_NONE this->SetWidgetLoweredState(WID_SV_CLOSE_AIRPORT, (st->facilities & FACIL_AIRPORT) && (st->airport.flags & AIRPORT_CLOSED_block) != 0);