1
0
Fork 0

Add: Set and show unbunching behavior in order and vehicle GUIs

pull/11945/head
Tyler Trahan 2024-02-01 11:10:54 -05:00
parent aae2694da3
commit 1c9f5da779
6 changed files with 57 additions and 19 deletions

View File

@ -4400,6 +4400,7 @@ STR_VEHICLE_VIEW_AIRCRAFT_STATUS_START_STOP_TOOLTIP :{BLACK}Current
# Messages in the start stop button in the vehicle view # Messages in the start stop button in the vehicle view
STR_VEHICLE_STATUS_LOADING_UNLOADING :{LTBLUE}Loading / Unloading STR_VEHICLE_STATUS_LOADING_UNLOADING :{LTBLUE}Loading / Unloading
STR_VEHICLE_STATUS_LEAVING :{LTBLUE}Leaving STR_VEHICLE_STATUS_LEAVING :{LTBLUE}Leaving
STR_VEHICLE_STATUS_WAITING_UNBUNCHING :{LTBLUE}Waiting to unbunch
STR_VEHICLE_STATUS_CRASHED :{RED}Crashed! STR_VEHICLE_STATUS_CRASHED :{RED}Crashed!
STR_VEHICLE_STATUS_BROKEN_DOWN :{RED}Broken down STR_VEHICLE_STATUS_BROKEN_DOWN :{RED}Broken down
STR_VEHICLE_STATUS_STOPPED :{RED}Stopped STR_VEHICLE_STATUS_STOPPED :{RED}Stopped
@ -4413,6 +4414,7 @@ STR_VEHICLE_STATUS_NO_ORDERS_VEL :{LTBLUE}No orde
STR_VEHICLE_STATUS_HEADING_FOR_WAYPOINT_VEL :{LTBLUE}Heading for {WAYPOINT}, {VELOCITY} STR_VEHICLE_STATUS_HEADING_FOR_WAYPOINT_VEL :{LTBLUE}Heading for {WAYPOINT}, {VELOCITY}
STR_VEHICLE_STATUS_HEADING_FOR_DEPOT_VEL :{ORANGE}Heading for {DEPOT}, {VELOCITY} STR_VEHICLE_STATUS_HEADING_FOR_DEPOT_VEL :{ORANGE}Heading for {DEPOT}, {VELOCITY}
STR_VEHICLE_STATUS_HEADING_FOR_DEPOT_SERVICE_VEL :{LTBLUE}Service at {DEPOT}, {VELOCITY} STR_VEHICLE_STATUS_HEADING_FOR_DEPOT_SERVICE_VEL :{LTBLUE}Service at {DEPOT}, {VELOCITY}
STR_VEHICLE_STATUS_HEADING_FOR_DEPOT_UNBUNCH_VEL :{LTBLUE}Unbunch and service at {DEPOT}, {VELOCITY}
STR_VEHICLE_STATUS_CANNOT_REACH_STATION_VEL :{LTBLUE}Cannot reach {STATION}, {VELOCITY} STR_VEHICLE_STATUS_CANNOT_REACH_STATION_VEL :{LTBLUE}Cannot reach {STATION}, {VELOCITY}
STR_VEHICLE_STATUS_CANNOT_REACH_WAYPOINT_VEL :{LTBLUE}Cannot reach {WAYPOINT}, {VELOCITY} STR_VEHICLE_STATUS_CANNOT_REACH_WAYPOINT_VEL :{LTBLUE}Cannot reach {WAYPOINT}, {VELOCITY}
@ -4543,7 +4545,7 @@ STR_ORDERS_TIMETABLE_VIEW_TOOLTIP :{BLACK}Switch t
STR_ORDERS_LIST_TOOLTIP :{BLACK}Order list - click on an order to highlight it. Ctrl+Click to scroll to the order's destination STR_ORDERS_LIST_TOOLTIP :{BLACK}Order list - click on an order to highlight it. Ctrl+Click to scroll to the order's destination
STR_ORDER_INDEX :{COMMA}:{NBSP} STR_ORDER_INDEX :{COMMA}:{NBSP}
STR_ORDER_TEXT :{STRING4} {STRING2} {STRING} STR_ORDER_TEXT :{STRING4} {STRING2} {STRING} {STRING}
STR_ORDERS_END_OF_ORDERS :- - End of Orders - - STR_ORDERS_END_OF_ORDERS :- - End of Orders - -
STR_ORDERS_END_OF_SHARED_ORDERS :- - End of Shared Orders - - STR_ORDERS_END_OF_SHARED_ORDERS :- - End of Shared Orders - -
@ -4577,11 +4579,11 @@ STR_ORDER_REFIT_AUTO_TOOLTIP :{BLACK}Select w
STR_ORDER_DROP_REFIT_AUTO :Fixed cargo STR_ORDER_DROP_REFIT_AUTO :Fixed cargo
STR_ORDER_DROP_REFIT_AUTO_ANY :Available cargo STR_ORDER_DROP_REFIT_AUTO_ANY :Available cargo
STR_ORDER_SERVICE :{BLACK}Service
STR_ORDER_DROP_GO_ALWAYS_DEPOT :Always go STR_ORDER_DROP_GO_ALWAYS_DEPOT :Always go
STR_ORDER_DROP_SERVICE_DEPOT :Service if needed STR_ORDER_DROP_SERVICE_DEPOT :Service if needed
STR_ORDER_DROP_HALT_DEPOT :Stop STR_ORDER_DROP_HALT_DEPOT :Stop
STR_ORDER_SERVICE_TOOLTIP :{BLACK}Skip this order unless a service is needed STR_ORDER_DROP_UNBUNCH :Unbunch
STR_ORDER_DEPOT_ACTION_TOOLTIP :{BLACK}Select the action to take at this depot
STR_ORDER_CONDITIONAL_VARIABLE_TOOLTIP :{BLACK}Vehicle data to base jumping on STR_ORDER_CONDITIONAL_VARIABLE_TOOLTIP :{BLACK}Vehicle data to base jumping on
@ -4650,6 +4652,8 @@ STR_ORDER_REFIT_ORDER :(Refit to {STRI
STR_ORDER_REFIT_STOP_ORDER :(Refit to {STRING} and stop) STR_ORDER_REFIT_STOP_ORDER :(Refit to {STRING} and stop)
STR_ORDER_STOP_ORDER :(Stop) STR_ORDER_STOP_ORDER :(Stop)
STR_ORDER_WAIT_TO_UNBUNCH :(wait to unbunch)
STR_ORDER_GO_TO_STATION :{STRING} {STATION} {STRING1} STR_ORDER_GO_TO_STATION :{STRING} {STATION} {STRING1}
STR_ORDER_GO_TO_STATION_CAN_T_USE_STATION :{PUSH_COLOUR}{RED}(Can't use station){POP_COLOUR} {STRING} {STATION} {STRING1} STR_ORDER_GO_TO_STATION_CAN_T_USE_STATION :{PUSH_COLOUR}{RED}(Can't use station){POP_COLOUR} {STRING} {STATION} {STRING1}

View File

@ -1361,6 +1361,7 @@ CommandCost CmdModifyOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID se
case DA_ALWAYS_GO: case DA_ALWAYS_GO:
order->SetDepotOrderType((OrderDepotTypeFlags)(order->GetDepotOrderType() & ~ODTFB_SERVICE)); order->SetDepotOrderType((OrderDepotTypeFlags)(order->GetDepotOrderType() & ~ODTFB_SERVICE));
order->SetDepotActionType((OrderDepotActionFlags)(order->GetDepotActionType() & ~ODATFB_HALT)); order->SetDepotActionType((OrderDepotActionFlags)(order->GetDepotActionType() & ~ODATFB_HALT));
order->SetDepotActionType((OrderDepotActionFlags)(order->GetDepotActionType() & ~ODATFB_UNBUNCH));
break; break;
case DA_SERVICE: case DA_SERVICE:
@ -1371,10 +1372,17 @@ CommandCost CmdModifyOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID se
case DA_STOP: case DA_STOP:
order->SetDepotOrderType((OrderDepotTypeFlags)(order->GetDepotOrderType() & ~ODTFB_SERVICE)); order->SetDepotOrderType((OrderDepotTypeFlags)(order->GetDepotOrderType() & ~ODTFB_SERVICE));
order->SetDepotActionType((OrderDepotActionFlags)(order->GetDepotActionType() & ~ODATFB_UNBUNCH));
order->SetDepotActionType((OrderDepotActionFlags)(order->GetDepotActionType() | ODATFB_HALT)); order->SetDepotActionType((OrderDepotActionFlags)(order->GetDepotActionType() | ODATFB_HALT));
order->SetRefit(CARGO_NO_REFIT); order->SetRefit(CARGO_NO_REFIT);
break; break;
case DA_UNBUNCH:
order->SetDepotOrderType((OrderDepotTypeFlags)(order->GetDepotOrderType() & ~ODTFB_SERVICE));
order->SetDepotActionType((OrderDepotActionFlags)(order->GetDepotActionType() & ~ODATFB_HALT));
order->SetDepotActionType((OrderDepotActionFlags)(order->GetDepotActionType() | ODATFB_UNBUNCH));
break;
default: default:
NOT_REACHED(); NOT_REACHED();
} }

View File

@ -184,6 +184,7 @@ static const StringID _order_depot_action_dropdown[] = {
STR_ORDER_DROP_GO_ALWAYS_DEPOT, STR_ORDER_DROP_GO_ALWAYS_DEPOT,
STR_ORDER_DROP_SERVICE_DEPOT, STR_ORDER_DROP_SERVICE_DEPOT,
STR_ORDER_DROP_HALT_DEPOT, STR_ORDER_DROP_HALT_DEPOT,
STR_ORDER_DROP_UNBUNCH,
INVALID_STRING_ID INVALID_STRING_ID
}; };
@ -243,11 +244,12 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
SetDParam(5, STR_EMPTY); SetDParam(5, STR_EMPTY);
SetDParam(8, STR_EMPTY); SetDParam(8, STR_EMPTY);
SetDParam(9, STR_EMPTY);
/* Check range for aircraft. */ /* Check range for aircraft. */
if (v->type == VEH_AIRCRAFT && Aircraft::From(v)->GetRange() > 0 && order->IsGotoOrder()) { if (v->type == VEH_AIRCRAFT && Aircraft::From(v)->GetRange() > 0 && order->IsGotoOrder()) {
const Order *next = order->next != nullptr ? order->next : v->GetFirstOrder(); const Order *next = order->next != nullptr ? order->next : v->GetFirstOrder();
if (GetOrderDistance(order, next, v) > Aircraft::From(v)->acache.cached_max_range_sqr) SetDParam(8, STR_ORDER_OUT_OF_RANGE); if (GetOrderDistance(order, next, v) > Aircraft::From(v)->acache.cached_max_range_sqr) SetDParam(9, STR_ORDER_OUT_OF_RANGE);
} }
switch (order->GetType()) { switch (order->GetType()) {
@ -332,6 +334,12 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
SetDParam(5, (order->GetDepotActionType() & ODATFB_HALT) ? STR_ORDER_REFIT_STOP_ORDER : STR_ORDER_REFIT_ORDER); SetDParam(5, (order->GetDepotActionType() & ODATFB_HALT) ? STR_ORDER_REFIT_STOP_ORDER : STR_ORDER_REFIT_ORDER);
SetDParam(6, CargoSpec::Get(order->GetRefitCargo())->name); SetDParam(6, CargoSpec::Get(order->GetRefitCargo())->name);
} }
/* Do not show unbunching in the depot in the timetable window. */
if (!timetable && (order->GetDepotActionType() & ODATFB_UNBUNCH)) {
SetDParam(8, STR_ORDER_WAIT_TO_UNBUNCH);
}
break; break;
case OT_GOTO_WAYPOINT: case OT_GOTO_WAYPOINT:
@ -941,7 +949,6 @@ public:
/* First row. */ /* First row. */
this->RaiseWidget(WID_O_FULL_LOAD); this->RaiseWidget(WID_O_FULL_LOAD);
this->RaiseWidget(WID_O_UNLOAD); this->RaiseWidget(WID_O_UNLOAD);
this->RaiseWidget(WID_O_SERVICE);
/* Selection widgets. */ /* Selection widgets. */
/* Train or road vehicle. */ /* Train or road vehicle. */
@ -1027,7 +1034,6 @@ public:
this->SetWidgetDisabledState(WID_O_REFIT, this->SetWidgetDisabledState(WID_O_REFIT,
(order->GetDepotOrderType() & ODTFB_SERVICE) || (order->GetDepotActionType() & ODATFB_HALT) || (order->GetDepotOrderType() & ODTFB_SERVICE) || (order->GetDepotActionType() & ODATFB_HALT) ||
(!this->can_do_refit && !order->IsRefit())); (!this->can_do_refit && !order->IsRefit()));
this->SetWidgetLoweredState(WID_O_SERVICE, order->GetDepotOrderType() & ODTFB_SERVICE);
break; break;
case OT_CONDITIONAL: { case OT_CONDITIONAL: {
@ -1155,6 +1161,24 @@ public:
case WID_O_CAPTION: case WID_O_CAPTION:
SetDParam(0, this->vehicle->index); SetDParam(0, this->vehicle->index);
break; break;
case WID_O_DEPOT_ACTION: {
VehicleOrderID sel = this->OrderGetSel();
const Order *order = this->vehicle->GetOrder(sel);
if (order == nullptr || !order->IsType(OT_GOTO_DEPOT)) break;
/* Select the current action selected in the dropdown. The flags don't match the dropdown so we can't just use an index. */
if (order->GetDepotOrderType() & ODTFB_SERVICE) {
SetDParam(0, STR_ORDER_DROP_SERVICE_DEPOT);
} else if (order->GetDepotActionType() & ODATFB_HALT) {
SetDParam(0, STR_ORDER_DROP_HALT_DEPOT);
} else if (order->GetDepotActionType() & ODATFB_UNBUNCH) {
SetDParam(0, STR_ORDER_DROP_UNBUNCH);
} else {
SetDParam(0, STR_ORDER_DROP_GO_ALWAYS_DEPOT);
}
break;
}
} }
} }
@ -1273,12 +1297,8 @@ public:
this->OrderClick_Refit(0, false); this->OrderClick_Refit(0, false);
break; break;
case WID_O_SERVICE: case WID_O_DEPOT_ACTION:
if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) { ShowDropDownMenu(this, _order_depot_action_dropdown, DepotActionStringIndex(this->vehicle->GetOrder(this->OrderGetSel())), WID_O_DEPOT_ACTION, 0, 0);
this->OrderClick_Service(-1);
} else {
ShowDropDownMenu(this, _order_depot_action_dropdown, DepotActionStringIndex(this->vehicle->GetOrder(this->OrderGetSel())), WID_O_SERVICE, 0, 0);
}
break; break;
case WID_O_REFIT_DROPDOWN: case WID_O_REFIT_DROPDOWN:
@ -1373,7 +1393,7 @@ public:
} }
break; break;
case WID_O_SERVICE: case WID_O_DEPOT_ACTION:
this->OrderClick_Service(index); this->OrderClick_Service(index);
break; break;
@ -1593,8 +1613,8 @@ static constexpr NWidgetPart _nested_orders_train_widgets[] = {
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_TOP_MIDDLE), NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_TOP_MIDDLE),
NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_UNLOAD), SetMinimalSize(93, 12), SetFill(1, 0), NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_UNLOAD), SetMinimalSize(93, 12), SetFill(1, 0),
SetDataTip(STR_ORDER_TOGGLE_UNLOAD, STR_ORDER_TOOLTIP_UNLOAD), SetResize(1, 0), SetDataTip(STR_ORDER_TOGGLE_UNLOAD, STR_ORDER_TOOLTIP_UNLOAD), SetResize(1, 0),
NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_SERVICE), SetMinimalSize(93, 12), SetFill(1, 0), NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_DEPOT_ACTION), SetMinimalSize(93, 12), SetFill(1, 0),
SetDataTip(STR_ORDER_SERVICE, STR_ORDER_SERVICE_TOOLTIP), SetResize(1, 0), SetDataTip(STR_JUST_STRING, STR_ORDER_DEPOT_ACTION_TOOLTIP), SetResize(1, 0),
EndContainer(), EndContainer(),
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_TOP_RIGHT), NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_TOP_RIGHT),
NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(93, 12), SetFill(1, 0), SetResize(1, 0), EndContainer(), NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(93, 12), SetFill(1, 0), SetResize(1, 0), EndContainer(),
@ -1671,8 +1691,8 @@ static constexpr NWidgetPart _nested_orders_widgets[] = {
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_REFIT), SetMinimalSize(186, 12), SetFill(1, 0), NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_REFIT), SetMinimalSize(186, 12), SetFill(1, 0),
SetDataTip(STR_ORDER_REFIT, STR_ORDER_REFIT_TOOLTIP), SetResize(1, 0), SetDataTip(STR_ORDER_REFIT, STR_ORDER_REFIT_TOOLTIP), SetResize(1, 0),
NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_SERVICE), SetMinimalSize(124, 12), SetFill(1, 0), NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_DEPOT_ACTION), SetMinimalSize(124, 12), SetFill(1, 0),
SetDataTip(STR_ORDER_SERVICE, STR_ORDER_SERVICE_TOOLTIP), SetResize(1, 0), SetDataTip(STR_JUST_STRING, STR_ORDER_DEPOT_ACTION_TOOLTIP), SetResize(1, 0),
EndContainer(), EndContainer(),
/* Buttons for setting a condition. */ /* Buttons for setting a condition. */

View File

@ -161,6 +161,7 @@ enum OrderDepotAction {
DA_ALWAYS_GO, ///< Always go to the depot DA_ALWAYS_GO, ///< Always go to the depot
DA_SERVICE, ///< Service only if needed DA_SERVICE, ///< Service only if needed
DA_STOP, ///< Go to the depot and stop there DA_STOP, ///< Go to the depot and stop there
DA_UNBUNCH, ///< Go to the depot and unbunch
DA_END DA_END
}; };

View File

@ -3087,7 +3087,7 @@ public:
{ {
if (widget != WID_VV_START_STOP) return; if (widget != WID_VV_START_STOP) return;
const Vehicle *v = Vehicle::Get(this->window_number); Vehicle *v = Vehicle::Get(this->window_number);
StringID str; StringID str;
TextColour text_colour = TC_FROMSTRING; TextColour text_colour = TC_FROMSTRING;
if (v->vehstatus & VS_CRASHED) { if (v->vehstatus & VS_CRASHED) {
@ -3113,6 +3113,8 @@ public:
str = STR_VEHICLE_STATUS_TRAIN_STUCK; str = STR_VEHICLE_STATUS_TRAIN_STUCK;
} else if (v->type == VEH_AIRCRAFT && HasBit(Aircraft::From(v)->flags, VAF_DEST_TOO_FAR) && !v->current_order.IsType(OT_LOADING)) { } else if (v->type == VEH_AIRCRAFT && HasBit(Aircraft::From(v)->flags, VAF_DEST_TOO_FAR) && !v->current_order.IsType(OT_LOADING)) {
str = STR_VEHICLE_STATUS_AIRCRAFT_TOO_FAR; str = STR_VEHICLE_STATUS_AIRCRAFT_TOO_FAR;
} else if (v->IsInDepot() && v->IsWaitingForUnbunching()) {
str = STR_VEHICLE_STATUS_WAITING_UNBUNCHING;
} else { // vehicle is in a "normal" state, show current order } else { // vehicle is in a "normal" state, show current order
if (mouse_over_start_stop) { if (mouse_over_start_stop) {
if (v->vehstatus & VS_STOPPED) { if (v->vehstatus & VS_STOPPED) {
@ -3143,6 +3145,8 @@ public:
str = STR_EMPTY; str = STR_EMPTY;
} else if (v->current_order.GetDepotActionType() & ODATFB_HALT) { } else if (v->current_order.GetDepotActionType() & ODATFB_HALT) {
str = HasBit(v->vehicle_flags, VF_PATHFINDER_LOST) ? STR_VEHICLE_STATUS_CANNOT_REACH_DEPOT_VEL : STR_VEHICLE_STATUS_HEADING_FOR_DEPOT_VEL; str = HasBit(v->vehicle_flags, VF_PATHFINDER_LOST) ? STR_VEHICLE_STATUS_CANNOT_REACH_DEPOT_VEL : STR_VEHICLE_STATUS_HEADING_FOR_DEPOT_VEL;
} else if (v->current_order.GetDepotActionType() & ODATFB_UNBUNCH) {
str = HasBit(v->vehicle_flags, VF_PATHFINDER_LOST) ? STR_VEHICLE_STATUS_CANNOT_REACH_DEPOT_SERVICE_VEL : STR_VEHICLE_STATUS_HEADING_FOR_DEPOT_UNBUNCH_VEL;
} else { } else {
str = HasBit(v->vehicle_flags, VF_PATHFINDER_LOST) ? STR_VEHICLE_STATUS_CANNOT_REACH_DEPOT_SERVICE_VEL : STR_VEHICLE_STATUS_HEADING_FOR_DEPOT_SERVICE_VEL; str = HasBit(v->vehicle_flags, VF_PATHFINDER_LOST) ? STR_VEHICLE_STATUS_CANNOT_REACH_DEPOT_SERVICE_VEL : STR_VEHICLE_STATUS_HEADING_FOR_DEPOT_SERVICE_VEL;
} }

View File

@ -20,11 +20,12 @@ enum OrderWidgets : WidgetID {
WID_O_DELETE, ///< Delete selected order. WID_O_DELETE, ///< Delete selected order.
WID_O_STOP_SHARING, ///< Stop sharing orders. WID_O_STOP_SHARING, ///< Stop sharing orders.
WID_O_NON_STOP, ///< Goto non-stop to destination. WID_O_NON_STOP, ///< Goto non-stop to destination.
WID_O_DEPOT_UNBUNCHING, ///< Toggle unbunching.
WID_O_GOTO, ///< Goto destination. WID_O_GOTO, ///< Goto destination.
WID_O_FULL_LOAD, ///< Select full load. WID_O_FULL_LOAD, ///< Select full load.
WID_O_UNLOAD, ///< Select unload. WID_O_UNLOAD, ///< Select unload.
WID_O_REFIT, ///< Select refit. WID_O_REFIT, ///< Select refit.
WID_O_SERVICE, ///< Select service (at depot). WID_O_DEPOT_ACTION, ///< Dropdown to select the depot action (stop, service if needed, unbunch).
WID_O_REFIT_DROPDOWN, ///< Open refit options. WID_O_REFIT_DROPDOWN, ///< Open refit options.
WID_O_COND_VARIABLE, ///< Choose condition variable. WID_O_COND_VARIABLE, ///< Choose condition variable.
WID_O_COND_COMPARATOR, ///< Choose condition type. WID_O_COND_COMPARATOR, ///< Choose condition type.