diff --git a/src/vehicle.cpp b/src/vehicle.cpp index bcb22bd881..1173e5077c 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -2615,7 +2615,7 @@ CommandCost Vehicle::SendToDepot(DoCommandFlags flags, DepotCommandFlags command if (flags.Test(DoCommandFlag::Execute)) { this->current_order.SetDepotOrderType({}); this->current_order.SetDepotActionType(halt_in_depot ? OrderDepotActionFlags{} : OrderDepotActionFlag::Halt); - SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, WID_VV_START_STOP); + InvalidateWindowData(WC_VEHICLE_VIEW, this->index); } return CommandCost(); } @@ -2632,7 +2632,7 @@ CommandCost Vehicle::SendToDepot(DoCommandFlags flags, DepotCommandFlags command } this->current_order.MakeDummy(); - SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, WID_VV_START_STOP); + InvalidateWindowData(WC_VEHICLE_VIEW, this->index); } return CommandCost(); } @@ -2652,7 +2652,7 @@ CommandCost Vehicle::SendToDepot(DoCommandFlags flags, DepotCommandFlags command this->SetDestTile(closest_depot.location); this->current_order.MakeGoToDepot(closest_depot.destination.ToDepotID(), {}); if (!command.Test(DepotCommandFlag::Service)) this->current_order.SetDepotActionType(OrderDepotActionFlag::Halt); - SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, WID_VV_START_STOP); + InvalidateWindowData(WC_VEHICLE_VIEW, this->index); /* If there is no depot in front and the train is not already reversing, reverse automatically (trains only) */ if (this->type == VEH_TRAIN && (closest_depot.reverse ^ Train::From(this)->flags.Test(VehicleRailFlag::Reversing))) { diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index aa0a5be4ca..eb8bf3f967 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -2880,7 +2880,7 @@ static constexpr std::initializer_list _nested_vehicle_view_widgets EndContainer(), NWidget(NWID_VERTICAL), NWidget(NWID_SELECTION, INVALID_COLOUR, WID_VV_SELECT_DEPOT_CLONE), - NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_VV_GOTO_DEPOT), SetMinimalSize(18, 18), SetSpriteTip(SPR_EMPTY /* filled later */), + NWidget(WWT_IMGBTN, COLOUR_GREY, WID_VV_GOTO_DEPOT), SetMinimalSize(18, 18), SetSpriteTip(SPR_EMPTY /* filled later */), NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_VV_CLONE), SetMinimalSize(18, 18), SetSpriteTip(SPR_EMPTY /* filled later */), EndContainer(), /* For trains only, 'ignore signal' button. */ @@ -3141,6 +3141,10 @@ public: this->SetWidgetDisabledState(WID_VV_REFIT, !refittable_and_stopped_in_depot || !is_localcompany); this->SetWidgetDisabledState(WID_VV_CLONE, !is_localcompany); + /* Lower the Send To Depot button when clicking it would cause the + * vehicle to NOT go to the depot. */ + this->SetWidgetLoweredState(WID_VV_GOTO_DEPOT, v->current_order.IsType(OT_GOTO_DEPOT) && v->current_order.GetDepotActionType().Test(OrderDepotActionFlag::Halt)); + if (v->type == VEH_TRAIN) { this->SetWidgetLoweredState(WID_VV_FORCE_PROCEED, Train::From(v)->force_proceed == TFP_SIGNAL); this->SetWidgetDisabledState(WID_VV_FORCE_PROCEED, !is_localcompany);