mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2026-07-21 01:59:44 +00:00
Add: Lower the Send To Depot button when a vehicle is on its way to one (#15397)
This commit is contained in:
+3
-3
@@ -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
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user