Add: Lower the Send To Depot button when a vehicle is on its way to one (#15397)

This commit is contained in:
Tad Hardesty
2026-03-31 04:23:28 -07:00
committed by GitHub
parent d2dd4d4e4a
commit e40c7f0c81
2 changed files with 8 additions and 4 deletions
+3 -3
View File
@@ -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))) {
+5 -1
View File
@@ -2880,7 +2880,7 @@ static constexpr std::initializer_list<NWidgetPart> _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);