Conditional orders: Add mode to check waiting station cargo via next node
This commit is contained in:
@@ -946,6 +946,15 @@ uint StationCargoList::ShiftCargo(Taction action, StationIDStack next, bool incl
|
|||||||
return max_move - action.MaxMove();
|
return max_move - action.MaxMove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint StationCargoList::AvailableViaCount(StationID next) const
|
||||||
|
{
|
||||||
|
uint count = 0;
|
||||||
|
for (ConstIterator it = this->packets.lower_bound(next); it != this->packets.end() && it.GetKey() == next; ++it) {
|
||||||
|
count += (*it)->count;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Truncates where each destination loses roughly the same percentage of its
|
* Truncates where each destination loses roughly the same percentage of its
|
||||||
* cargo. This is done by randomizing the selection of packets to be removed.
|
* cargo. This is done by randomizing the selection of packets to be removed.
|
||||||
|
@@ -546,6 +546,8 @@ public:
|
|||||||
return this->count;
|
return this->count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint AvailableViaCount(StationID next) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns sum of cargo reserved for loading onto vehicles.
|
* Returns sum of cargo reserved for loading onto vehicles.
|
||||||
* @return Cargo reserved for loading.
|
* @return Cargo reserved for loading.
|
||||||
|
@@ -4654,7 +4654,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 scrolls to the order's destination
|
STR_ORDERS_LIST_TOOLTIP :{BLACK}Order list - click on an order to highlight it. Ctrl+Click scrolls to the order's destination
|
||||||
STR_ORDER_INDEX :{COMMA}:{NBSP}
|
STR_ORDER_INDEX :{COMMA}:{NBSP}
|
||||||
STR_ORDER_TEXT :{STRING5} {STRING4} {STRING}
|
STR_ORDER_TEXT :{STRING6} {STRING4} {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 - -
|
||||||
@@ -4743,6 +4743,9 @@ STR_ORDER_CONDITIONAL_CARGO_TOOLTIP :{BLACK}The carg
|
|||||||
STR_ORDER_CONDITIONAL_SLOT_TOOLTIP :{BLACK}The train slot to check the occupancy of
|
STR_ORDER_CONDITIONAL_SLOT_TOOLTIP :{BLACK}The train slot to check the occupancy of
|
||||||
STR_ORDER_CONDITIONAL_VALUE_CAPT :{WHITE}Enter value to compare against
|
STR_ORDER_CONDITIONAL_VALUE_CAPT :{WHITE}Enter value to compare against
|
||||||
|
|
||||||
|
STR_ORDER_CONDITIONAL_VIA :{BLACK}Via
|
||||||
|
STR_ORDER_CONDITIONAL_VIA_TOOLTIP :{BLACK}The via station to check the waiting cargo amount for
|
||||||
|
|
||||||
STR_ORDER_CONDITIONAL_COMPARATOR_ACCEPTS :accepts
|
STR_ORDER_CONDITIONAL_COMPARATOR_ACCEPTS :accepts
|
||||||
STR_ORDER_CONDITIONAL_COMPARATOR_DOES_NOT_ACCEPT :does not accept
|
STR_ORDER_CONDITIONAL_COMPARATOR_DOES_NOT_ACCEPT :does not accept
|
||||||
STR_ORDER_CONDITIONAL_COMPARATOR_HAS :has
|
STR_ORDER_CONDITIONAL_COMPARATOR_HAS :has
|
||||||
@@ -4872,6 +4875,7 @@ STR_ORDER_CONDITIONAL_IN_INVALID_SLOT :Jump to order {
|
|||||||
STR_ORDER_CONDITIONAL_TRUE_FALSE :Jump to order {COMMA} when {STRING} {STRING}
|
STR_ORDER_CONDITIONAL_TRUE_FALSE :Jump to order {COMMA} when {STRING} {STRING}
|
||||||
STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE_DISPLAY :Jump to order {COMMA} when Load percentage of {STRING} {STRING} {COMMA}
|
STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE_DISPLAY :Jump to order {COMMA} when Load percentage of {STRING} {STRING} {COMMA}
|
||||||
STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_DISPLAY :Jump to order {COMMA} when {STRING} at next station {STRING} {CARGO_SHORT}
|
STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_DISPLAY :Jump to order {COMMA} when {STRING} at next station {STRING} {CARGO_SHORT}
|
||||||
|
STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_VIA_DISPLAY :Jump to order {COMMA} when {STRING} at next station via {STATION} {STRING} {CARGO_SHORT}
|
||||||
|
|
||||||
STR_INVALID_ORDER :{RED} (Invalid Order)
|
STR_INVALID_ORDER :{RED} (Invalid Order)
|
||||||
|
|
||||||
|
@@ -1609,7 +1609,7 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case OT_CONDITIONAL:
|
case OT_CONDITIONAL:
|
||||||
if (mof != MOF_COND_VARIABLE && mof != MOF_COND_COMPARATOR && mof != MOF_COND_VALUE && mof != MOF_COND_VALUE_2 && mof != MOF_COND_DESTINATION) return CMD_ERROR;
|
if (mof != MOF_COND_VARIABLE && mof != MOF_COND_COMPARATOR && mof != MOF_COND_VALUE && mof != MOF_COND_VALUE_2 && mof != MOF_COND_VALUE_3 && mof != MOF_COND_DESTINATION) return CMD_ERROR;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -1711,6 +1711,7 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case OCV_CARGO_WAITING_AMOUNT:
|
case OCV_CARGO_WAITING_AMOUNT:
|
||||||
|
if (data >= (1 << 16)) return CMD_ERROR;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -1731,6 +1732,17 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MOF_COND_VALUE_3:
|
||||||
|
switch (order->GetConditionVariable()) {
|
||||||
|
case OCV_CARGO_WAITING_AMOUNT:
|
||||||
|
if (!(data == NEW_STATION || Station::GetIfValid(data) != nullptr)) return CMD_ERROR;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return CMD_ERROR;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case MOF_COND_DESTINATION:
|
case MOF_COND_DESTINATION:
|
||||||
if (data >= v->GetNumOrders()) return CMD_ERROR;
|
if (data >= v->GetNumOrders()) return CMD_ERROR;
|
||||||
break;
|
break;
|
||||||
@@ -1866,10 +1878,13 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|||||||
case OCV_SLOT_OCCUPANCY:
|
case OCV_SLOT_OCCUPANCY:
|
||||||
case OCV_TRAIN_IN_SLOT:
|
case OCV_TRAIN_IN_SLOT:
|
||||||
case OCV_CARGO_LOAD_PERCENTAGE:
|
case OCV_CARGO_LOAD_PERCENTAGE:
|
||||||
case OCV_CARGO_WAITING_AMOUNT:
|
|
||||||
order->GetXDataRef() = data;
|
order->GetXDataRef() = data;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case OCV_CARGO_WAITING_AMOUNT:
|
||||||
|
SB(order->GetXDataRef(), 0, 16, data);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
order->SetConditionValue(data);
|
order->SetConditionValue(data);
|
||||||
break;
|
break;
|
||||||
@@ -1880,6 +1895,10 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|||||||
order->SetConditionValue(data);
|
order->SetConditionValue(data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MOF_COND_VALUE_3:
|
||||||
|
SB(order->GetXDataRef(), 16, 16, data + 2);
|
||||||
|
break;
|
||||||
|
|
||||||
case MOF_COND_DESTINATION:
|
case MOF_COND_DESTINATION:
|
||||||
order->SetConditionSkipToOrder(data);
|
order->SetConditionSkipToOrder(data);
|
||||||
break;
|
break;
|
||||||
@@ -2592,7 +2611,13 @@ VehicleOrderID ProcessConditionalOrder(const Order *order, const Vehicle *v)
|
|||||||
}
|
}
|
||||||
case OCV_CARGO_WAITING_AMOUNT: {
|
case OCV_CARGO_WAITING_AMOUNT: {
|
||||||
StationID next_station = GetNextRealStation(v, order);
|
StationID next_station = GetNextRealStation(v, order);
|
||||||
if (Station::IsValidID(next_station)) skip_order = OrderConditionCompare(occ, Station::Get(next_station)->goods[value].cargo.AvailableCount(), order->GetXData());
|
if (Station::IsValidID(next_station)) {
|
||||||
|
if (GB(order->GetXData(), 16, 16) == 0) {
|
||||||
|
skip_order = OrderConditionCompare(occ, Station::Get(next_station)->goods[value].cargo.AvailableCount(), GB(order->GetXData(), 0, 16));
|
||||||
|
} else {
|
||||||
|
skip_order = OrderConditionCompare(occ, Station::Get(next_station)->goods[value].cargo.AvailableViaCount(GB(order->GetXData(), 16, 16) - 2), GB(order->GetXData(), 0, 16));
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OCV_CARGO_ACCEPTANCE: {
|
case OCV_CARGO_ACCEPTANCE: {
|
||||||
|
@@ -739,8 +739,8 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
|
|||||||
SetDParam(0, order_index + 1);
|
SetDParam(0, order_index + 1);
|
||||||
DrawString(left, rtl ? right - 2 * sprite_size.width - 3 : middle, y, STR_ORDER_INDEX, colour, SA_RIGHT | SA_FORCE);
|
DrawString(left, rtl ? right - 2 * sprite_size.width - 3 : middle, y, STR_ORDER_INDEX, colour, SA_RIGHT | SA_FORCE);
|
||||||
|
|
||||||
SetDParam(6, STR_EMPTY);
|
SetDParam(7, STR_EMPTY);
|
||||||
SetDParam(11, STR_EMPTY);
|
SetDParam(12, 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()) {
|
||||||
@@ -775,8 +775,8 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
|
|||||||
SetDParam(3, STR_EMPTY);
|
SetDParam(3, STR_EMPTY);
|
||||||
|
|
||||||
if (order->GetWaitTime() > 0) {
|
if (order->GetWaitTime() > 0) {
|
||||||
SetDParam(6, order->IsWaitTimetabled() ? STR_TIMETABLE_STAY_FOR : STR_TIMETABLE_STAY_FOR_ESTIMATED);
|
SetDParam(7, order->IsWaitTimetabled() ? STR_TIMETABLE_STAY_FOR : STR_TIMETABLE_STAY_FOR_ESTIMATED);
|
||||||
SetTimetableParams(7, order->GetWaitTime());
|
SetTimetableParams(8, order->GetWaitTime());
|
||||||
}
|
}
|
||||||
timetable_wait_time_valid = true;
|
timetable_wait_time_valid = true;
|
||||||
} else {
|
} else {
|
||||||
@@ -785,7 +785,7 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
|
|||||||
SetDParam(4, order->IsAutoRefit() ? STR_ORDER_AUTO_REFIT_ANY : CargoSpec::Get(order->GetRefitCargo())->name);
|
SetDParam(4, order->IsAutoRefit() ? STR_ORDER_AUTO_REFIT_ANY : CargoSpec::Get(order->GetRefitCargo())->name);
|
||||||
}
|
}
|
||||||
if (v->type == VEH_TRAIN && (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) == 0) {
|
if (v->type == VEH_TRAIN && (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) == 0) {
|
||||||
SetDParam(6, order->GetStopLocation() + STR_ORDER_STOP_LOCATION_NEAR_END);
|
SetDParam(7, order->GetStopLocation() + STR_ORDER_STOP_LOCATION_NEAR_END);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -814,22 +814,22 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!timetable && (order->GetDepotActionType() & ODATFB_SELL)) {
|
if (!timetable && (order->GetDepotActionType() & ODATFB_SELL)) {
|
||||||
SetDParam(6, STR_ORDER_SELL_ORDER);
|
SetDParam(7, STR_ORDER_SELL_ORDER);
|
||||||
} else {
|
} else {
|
||||||
if (!timetable && (order->GetDepotActionType() & ODATFB_HALT)) {
|
if (!timetable && (order->GetDepotActionType() & ODATFB_HALT)) {
|
||||||
SetDParam(6, STR_ORDER_STOP_ORDER);
|
SetDParam(7, STR_ORDER_STOP_ORDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!timetable && order->IsRefit()) {
|
if (!timetable && order->IsRefit()) {
|
||||||
SetDParam(6, (order->GetDepotActionType() & ODATFB_HALT) ? STR_ORDER_REFIT_STOP_ORDER : STR_ORDER_REFIT_ORDER);
|
SetDParam(7, (order->GetDepotActionType() & ODATFB_HALT) ? STR_ORDER_REFIT_STOP_ORDER : STR_ORDER_REFIT_ORDER);
|
||||||
SetDParam(7, CargoSpec::Get(order->GetRefitCargo())->name);
|
SetDParam(8, CargoSpec::Get(order->GetRefitCargo())->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timetable) {
|
if (timetable) {
|
||||||
if (order->GetWaitTime() > 0) {
|
if (order->GetWaitTime() > 0) {
|
||||||
SetDParam(6, order->IsWaitTimetabled() ? STR_TIMETABLE_STAY_FOR : STR_TIMETABLE_STAY_FOR_ESTIMATED);
|
SetDParam(7, order->IsWaitTimetabled() ? STR_TIMETABLE_STAY_FOR : STR_TIMETABLE_STAY_FOR_ESTIMATED);
|
||||||
SetTimetableParams(7, order->GetWaitTime());
|
SetTimetableParams(8, order->GetWaitTime());
|
||||||
}
|
}
|
||||||
timetable_wait_time_valid = !(order->GetDepotActionType() & ODATFB_HALT);
|
timetable_wait_time_valid = !(order->GetDepotActionType() & ODATFB_HALT);
|
||||||
}
|
}
|
||||||
@@ -841,8 +841,8 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
|
|||||||
SetDParam(0, str);
|
SetDParam(0, str);
|
||||||
SetDParam(1, order->GetDestination());
|
SetDParam(1, order->GetDestination());
|
||||||
if (timetable && order->IsWaitTimetabled()) {
|
if (timetable && order->IsWaitTimetabled()) {
|
||||||
SetDParam(6, STR_TIMETABLE_STAY_FOR);
|
SetDParam(7, STR_TIMETABLE_STAY_FOR);
|
||||||
SetTimetableParams(7, order->GetWaitTime());
|
SetTimetableParams(8, order->GetWaitTime());
|
||||||
timetable_wait_time_valid = true;
|
timetable_wait_time_valid = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -885,11 +885,20 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
|
|||||||
SetDParam(3, STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS + order->GetConditionComparator());
|
SetDParam(3, STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS + order->GetConditionComparator());
|
||||||
SetDParam(4, order->GetXData());
|
SetDParam(4, order->GetXData());
|
||||||
} else if (ocv == OCV_CARGO_WAITING_AMOUNT) {
|
} else if (ocv == OCV_CARGO_WAITING_AMOUNT) {
|
||||||
|
if (GB(order->GetXData(), 16, 16) == 0) {
|
||||||
SetDParam(0, STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_DISPLAY);
|
SetDParam(0, STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_DISPLAY);
|
||||||
SetDParam(2, CargoSpec::Get(order->GetConditionValue())->name);
|
SetDParam(2, CargoSpec::Get(order->GetConditionValue())->name);
|
||||||
SetDParam(3, STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS + order->GetConditionComparator());
|
SetDParam(3, STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS + order->GetConditionComparator());
|
||||||
SetDParam(4, order->GetConditionValue());
|
SetDParam(4, order->GetConditionValue());
|
||||||
SetDParam(5, order->GetXData());
|
SetDParam(5, GB(order->GetXData(), 0, 16));
|
||||||
|
} else {
|
||||||
|
SetDParam(0, STR_ORDER_CONDITIONAL_CARGO_WAITING_AMOUNT_VIA_DISPLAY);
|
||||||
|
SetDParam(2, CargoSpec::Get(order->GetConditionValue())->name);
|
||||||
|
SetDParam(3, GB(order->GetXData(), 16, 16) - 2);
|
||||||
|
SetDParam(4, STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS + order->GetConditionComparator());
|
||||||
|
SetDParam(5, order->GetConditionValue());
|
||||||
|
SetDParam(6, GB(order->GetXData(), 0, 16));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
OrderConditionComparator occ = order->GetConditionComparator();
|
OrderConditionComparator occ = order->GetConditionComparator();
|
||||||
bool is_cargo = ocv == OCV_CARGO_ACCEPTANCE || ocv == OCV_CARGO_WAITING;
|
bool is_cargo = ocv == OCV_CARGO_ACCEPTANCE || ocv == OCV_CARGO_WAITING;
|
||||||
@@ -920,10 +929,10 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (timetable && order->GetWaitTime() > 0) {
|
if (timetable && order->GetWaitTime() > 0) {
|
||||||
SetDParam(6, order->IsWaitTimetabled() ? STR_TIMETABLE_AND_TRAVEL_FOR : STR_TIMETABLE_AND_TRAVEL_FOR_ESTIMATED);
|
SetDParam(7, order->IsWaitTimetabled() ? STR_TIMETABLE_AND_TRAVEL_FOR : STR_TIMETABLE_AND_TRAVEL_FOR_ESTIMATED);
|
||||||
SetTimetableParams(7, order->GetWaitTime());
|
SetTimetableParams(8, order->GetWaitTime());
|
||||||
} else {
|
} else {
|
||||||
SetDParam(6, STR_EMPTY);
|
SetDParam(7, STR_EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -1097,6 +1106,7 @@ private:
|
|||||||
OPOS_GOTO,
|
OPOS_GOTO,
|
||||||
OPOS_CONDITIONAL,
|
OPOS_CONDITIONAL,
|
||||||
OPOS_SHARE,
|
OPOS_SHARE,
|
||||||
|
OPOS_COND_VIA,
|
||||||
OPOS_END,
|
OPOS_END,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1131,6 +1141,9 @@ private:
|
|||||||
/* WID_O_SEL_COND_AUX */
|
/* WID_O_SEL_COND_AUX */
|
||||||
DP_COND_AUX_CARGO = 0, ///< Display dropdown widget cargo types
|
DP_COND_AUX_CARGO = 0, ///< Display dropdown widget cargo types
|
||||||
|
|
||||||
|
/* WID_O_SEL_COND_AUX2 */
|
||||||
|
DP_COND_AUX2_VIA = 0, ///< Display via button
|
||||||
|
|
||||||
DP_ROW_CONDITIONAL = 2, ///< Display the conditional order buttons in the top row of the ship/airplane order window.
|
DP_ROW_CONDITIONAL = 2, ///< Display the conditional order buttons in the top row of the ship/airplane order window.
|
||||||
|
|
||||||
/* WID_O_SEL_BOTTOM_MIDDLE */
|
/* WID_O_SEL_BOTTOM_MIDDLE */
|
||||||
@@ -1151,6 +1164,7 @@ private:
|
|||||||
bool can_do_autorefit; ///< Vehicle chain can be auto-refitted.
|
bool can_do_autorefit; ///< Vehicle chain can be auto-refitted.
|
||||||
int query_text_widget; ///< widget which most recently called ShowQueryString
|
int query_text_widget; ///< widget which most recently called ShowQueryString
|
||||||
int current_aux_plane;
|
int current_aux_plane;
|
||||||
|
int current_aux2_plane;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the memorised selected order.
|
* Return the memorised selected order.
|
||||||
@@ -1222,10 +1236,12 @@ private:
|
|||||||
HT_RECT | HT_VEHICLE, // OPOS_GOTO
|
HT_RECT | HT_VEHICLE, // OPOS_GOTO
|
||||||
HT_NONE, // OPOS_CONDITIONAL
|
HT_NONE, // OPOS_CONDITIONAL
|
||||||
HT_VEHICLE, // OPOS_SHARE
|
HT_VEHICLE, // OPOS_SHARE
|
||||||
|
HT_RECT, // OPOS_COND_VIA
|
||||||
};
|
};
|
||||||
SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, goto_place_style[type - 1], this);
|
SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, goto_place_style[type - 1], this);
|
||||||
this->goto_type = type;
|
this->goto_type = type;
|
||||||
this->SetWidgetDirty(WID_O_GOTO);
|
this->SetWidgetDirty(WID_O_GOTO);
|
||||||
|
this->SetWidgetDirty(WID_O_COND_AUX_VIA);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1445,8 +1461,10 @@ public:
|
|||||||
if (v->owner == _local_company) {
|
if (v->owner == _local_company) {
|
||||||
this->GetWidget<NWidgetStacked>(WID_O_SEL_OCCUPANCY)->SetDisplayedPlane(SZSP_NONE);
|
this->GetWidget<NWidgetStacked>(WID_O_SEL_OCCUPANCY)->SetDisplayedPlane(SZSP_NONE);
|
||||||
this->GetWidget<NWidgetStacked>(WID_O_SEL_COND_AUX)->SetDisplayedPlane(SZSP_NONE);
|
this->GetWidget<NWidgetStacked>(WID_O_SEL_COND_AUX)->SetDisplayedPlane(SZSP_NONE);
|
||||||
|
this->GetWidget<NWidgetStacked>(WID_O_SEL_COND_AUX2)->SetDisplayedPlane(SZSP_NONE);
|
||||||
}
|
}
|
||||||
this->current_aux_plane = SZSP_NONE;
|
this->current_aux_plane = SZSP_NONE;
|
||||||
|
this->current_aux2_plane = SZSP_NONE;
|
||||||
this->FinishInitNested(v->index);
|
this->FinishInitNested(v->index);
|
||||||
if (v->owner == _local_company) {
|
if (v->owner == _local_company) {
|
||||||
this->DisableWidget(WID_O_EMPTY);
|
this->DisableWidget(WID_O_EMPTY);
|
||||||
@@ -1661,12 +1679,17 @@ public:
|
|||||||
assert(row_sel != nullptr || (train_row_sel != nullptr && left_sel != nullptr && middle_sel != nullptr && right_sel != nullptr));
|
assert(row_sel != nullptr || (train_row_sel != nullptr && left_sel != nullptr && middle_sel != nullptr && right_sel != nullptr));
|
||||||
|
|
||||||
NWidgetStacked *aux_sel = this->GetWidget<NWidgetStacked>(WID_O_SEL_COND_AUX);
|
NWidgetStacked *aux_sel = this->GetWidget<NWidgetStacked>(WID_O_SEL_COND_AUX);
|
||||||
|
NWidgetStacked *aux2_sel = this->GetWidget<NWidgetStacked>(WID_O_SEL_COND_AUX2);
|
||||||
|
|
||||||
auto aux_plane_guard = scope_guard([&]() {
|
auto aux_plane_guard = scope_guard([&]() {
|
||||||
if (this->current_aux_plane != aux_sel->shown_plane) {
|
if (this->current_aux_plane != aux_sel->shown_plane) {
|
||||||
this->current_aux_plane = aux_sel->shown_plane;
|
this->current_aux_plane = aux_sel->shown_plane;
|
||||||
this->ReInit();
|
this->ReInit();
|
||||||
}
|
}
|
||||||
|
if (this->current_aux2_plane != aux2_sel->shown_plane) {
|
||||||
|
this->current_aux2_plane = aux2_sel->shown_plane;
|
||||||
|
this->ReInit();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (order == nullptr) {
|
if (order == nullptr) {
|
||||||
@@ -1785,6 +1808,12 @@ public:
|
|||||||
aux_sel->SetDisplayedPlane(SZSP_NONE);
|
aux_sel->SetDisplayedPlane(SZSP_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ocv == OCV_CARGO_WAITING_AMOUNT) {
|
||||||
|
aux2_sel->SetDisplayedPlane(DP_COND_AUX2_VIA);
|
||||||
|
} else {
|
||||||
|
aux2_sel->SetDisplayedPlane(SZSP_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
/* Set the strings for the dropdown boxes. */
|
/* Set the strings for the dropdown boxes. */
|
||||||
this->GetWidget<NWidgetCore>(WID_O_COND_VARIABLE)->widget_data = STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + ocv;
|
this->GetWidget<NWidgetCore>(WID_O_COND_VARIABLE)->widget_data = STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + ocv;
|
||||||
this->GetWidget<NWidgetCore>(WID_O_COND_COMPARATOR)->widget_data = GetComparatorStrings(order)[order->GetConditionComparator()];
|
this->GetWidget<NWidgetCore>(WID_O_COND_COMPARATOR)->widget_data = GetComparatorStrings(order)[order->GetConditionComparator()];
|
||||||
@@ -1825,7 +1854,8 @@ public:
|
|||||||
if (this->vehicle->owner != _local_company) {
|
if (this->vehicle->owner != _local_company) {
|
||||||
this->selected_order = -1; // Disable selection any selected row at a competitor order window.
|
this->selected_order = -1; // Disable selection any selected row at a competitor order window.
|
||||||
} else {
|
} else {
|
||||||
this->SetWidgetLoweredState(WID_O_GOTO, this->goto_type != OPOS_NONE);
|
this->SetWidgetLoweredState(WID_O_GOTO, this->goto_type != OPOS_NONE && this->goto_type != OPOS_COND_VIA);
|
||||||
|
this->SetWidgetLoweredState(WID_O_COND_AUX_VIA, this->goto_type == OPOS_COND_VIA);
|
||||||
}
|
}
|
||||||
this->DrawWidgets();
|
this->DrawWidgets();
|
||||||
}
|
}
|
||||||
@@ -1931,8 +1961,20 @@ public:
|
|||||||
const Order *order = this->vehicle->GetOrder(sel);
|
const Order *order = this->vehicle->GetOrder(sel);
|
||||||
|
|
||||||
if (order != nullptr && order->IsType(OT_CONDITIONAL)) {
|
if (order != nullptr && order->IsType(OT_CONDITIONAL)) {
|
||||||
OrderConditionVariable ocv = order->GetConditionVariable();
|
uint value;
|
||||||
uint value = (ocv == OCV_CARGO_LOAD_PERCENTAGE || ocv == OCV_CARGO_WAITING_AMOUNT) ? order->GetXData() : order->GetConditionValue();
|
switch (order->GetConditionVariable()) {
|
||||||
|
case OCV_CARGO_LOAD_PERCENTAGE:
|
||||||
|
value = order->GetXData();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OCV_CARGO_WAITING_AMOUNT:
|
||||||
|
value = GB(order->GetXData(), 0, 16);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
value = order->GetConditionValue();
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
|
if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
|
||||||
if (order->GetConditionVariable() == OCV_CARGO_WAITING_AMOUNT) value = ConvertCargoQuantityToDisplayQuantity(order->GetConditionValue(), value);
|
if (order->GetConditionVariable() == OCV_CARGO_WAITING_AMOUNT) value = ConvertCargoQuantityToDisplayQuantity(order->GetConditionValue(), value);
|
||||||
SetDParam(0, value);
|
SetDParam(0, value);
|
||||||
@@ -2064,6 +2106,7 @@ public:
|
|||||||
this->OrderClick_Goto(OPOS_GOTO);
|
this->OrderClick_Goto(OPOS_GOTO);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (this->goto_type == OPOS_COND_VIA) ResetObjectToPlace();
|
||||||
int sel;
|
int sel;
|
||||||
switch (this->goto_type) {
|
switch (this->goto_type) {
|
||||||
case OPOS_NONE: sel = -1; break;
|
case OPOS_NONE: sel = -1; break;
|
||||||
@@ -2144,6 +2187,17 @@ public:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case WID_O_COND_AUX_VIA: {
|
||||||
|
if (this->goto_type != OPOS_NONE) {
|
||||||
|
ResetObjectToPlace();
|
||||||
|
} else if (GB(this->vehicle->GetOrder(this->OrderGetSel())->GetXData(), 16, 16) != 0) {
|
||||||
|
DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), MOF_COND_VALUE_3 | NEW_STATION << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
||||||
|
} else {
|
||||||
|
this->OrderClick_Goto(OPOS_COND_VIA);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case WID_O_TIMETABLE_VIEW:
|
case WID_O_TIMETABLE_VIEW:
|
||||||
ShowTimetableWindow(this->vehicle);
|
ShowTimetableWindow(this->vehicle);
|
||||||
break;
|
break;
|
||||||
@@ -2176,8 +2230,20 @@ public:
|
|||||||
|
|
||||||
case WID_O_COND_VALUE: {
|
case WID_O_COND_VALUE: {
|
||||||
const Order *order = this->vehicle->GetOrder(this->OrderGetSel());
|
const Order *order = this->vehicle->GetOrder(this->OrderGetSel());
|
||||||
OrderConditionVariable ocv = order->GetConditionVariable();
|
uint value;
|
||||||
uint value = (ocv == OCV_CARGO_LOAD_PERCENTAGE || ocv == OCV_CARGO_WAITING_AMOUNT) ? order->GetXData() : order->GetConditionValue();
|
switch (order->GetConditionVariable()) {
|
||||||
|
case OCV_CARGO_LOAD_PERCENTAGE:
|
||||||
|
value = order->GetXData();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OCV_CARGO_WAITING_AMOUNT:
|
||||||
|
value = GB(order->GetXData(), 0, 16);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
value = order->GetConditionValue();
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
|
if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
|
||||||
if (order->GetConditionVariable() == OCV_CARGO_WAITING_AMOUNT) value = ConvertCargoQuantityToDisplayQuantity(order->GetConditionValue(), value);
|
if (order->GetConditionVariable() == OCV_CARGO_WAITING_AMOUNT) value = ConvertCargoQuantityToDisplayQuantity(order->GetConditionValue(), value);
|
||||||
this->query_text_widget = widget;
|
this->query_text_widget = widget;
|
||||||
@@ -2356,6 +2422,22 @@ public:
|
|||||||
/* With quick goto the Go To button stays active */
|
/* With quick goto the Go To button stays active */
|
||||||
if (!_settings_client.gui.quick_goto) ResetObjectToPlace();
|
if (!_settings_client.gui.quick_goto) ResetObjectToPlace();
|
||||||
}
|
}
|
||||||
|
} else if (this->goto_type == OPOS_COND_VIA) {
|
||||||
|
if (IsTileType(tile, MP_STATION) || IsTileType(tile, MP_INDUSTRY)) {
|
||||||
|
const Station *st = nullptr;
|
||||||
|
|
||||||
|
if (IsTileType(tile, MP_STATION)) {
|
||||||
|
st = Station::GetByTile(tile);
|
||||||
|
} else {
|
||||||
|
const Industry *in = Industry::GetByTile(tile);
|
||||||
|
st = in->neutral_station;
|
||||||
|
}
|
||||||
|
if (st != nullptr && IsInfraUsageAllowed(this->vehicle->type, this->vehicle->owner, st->owner)) {
|
||||||
|
if (DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), MOF_COND_VALUE_3 | st->index << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER))) {
|
||||||
|
ResetObjectToPlace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2381,6 +2463,7 @@ public:
|
|||||||
{
|
{
|
||||||
this->goto_type = OPOS_NONE;
|
this->goto_type = OPOS_NONE;
|
||||||
this->SetWidgetDirty(WID_O_GOTO);
|
this->SetWidgetDirty(WID_O_GOTO);
|
||||||
|
this->SetWidgetDirty(WID_O_COND_AUX_VIA);
|
||||||
|
|
||||||
/* Remove drag highlighting if it exists. */
|
/* Remove drag highlighting if it exists. */
|
||||||
if (this->order_over != INVALID_VEH_ORDER_ID) {
|
if (this->order_over != INVALID_VEH_ORDER_ID) {
|
||||||
@@ -2508,6 +2591,10 @@ static const NWidgetPart _nested_orders_train_widgets[] = {
|
|||||||
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_COND_AUX_CARGO), SetMinimalSize(124, 12), SetFill(1, 0),
|
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_COND_AUX_CARGO), SetMinimalSize(124, 12), SetFill(1, 0),
|
||||||
SetDataTip(STR_NULL, STR_ORDER_CONDITIONAL_CARGO_TOOLTIP), SetResize(1, 0),
|
SetDataTip(STR_NULL, STR_ORDER_CONDITIONAL_CARGO_TOOLTIP), SetResize(1, 0),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
|
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_COND_AUX2),
|
||||||
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_O_COND_AUX_VIA), SetMinimalSize(36, 12),
|
||||||
|
SetDataTip(STR_ORDER_CONDITIONAL_VIA, STR_ORDER_CONDITIONAL_VIA_TOOLTIP),
|
||||||
|
EndContainer(),
|
||||||
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_COND_COMPARATOR), SetMinimalSize(124, 12), SetFill(1, 0),
|
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_COND_COMPARATOR), SetMinimalSize(124, 12), SetFill(1, 0),
|
||||||
SetDataTip(STR_NULL, STR_ORDER_CONDITIONAL_COMPARATOR_TOOLTIP), SetResize(1, 0),
|
SetDataTip(STR_NULL, STR_ORDER_CONDITIONAL_COMPARATOR_TOOLTIP), SetResize(1, 0),
|
||||||
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_COND_VALUE),
|
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_COND_VALUE),
|
||||||
@@ -2600,6 +2687,10 @@ static const NWidgetPart _nested_orders_widgets[] = {
|
|||||||
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_COND_AUX_CARGO), SetMinimalSize(124, 12), SetFill(1, 0),
|
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_COND_AUX_CARGO), SetMinimalSize(124, 12), SetFill(1, 0),
|
||||||
SetDataTip(STR_NULL, STR_ORDER_CONDITIONAL_CARGO_TOOLTIP), SetResize(1, 0),
|
SetDataTip(STR_NULL, STR_ORDER_CONDITIONAL_CARGO_TOOLTIP), SetResize(1, 0),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
|
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_COND_AUX2),
|
||||||
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_O_COND_AUX_VIA), SetMinimalSize(36, 12),
|
||||||
|
SetDataTip(STR_ORDER_CONDITIONAL_VIA, STR_ORDER_CONDITIONAL_VIA_TOOLTIP),
|
||||||
|
EndContainer(),
|
||||||
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_COND_COMPARATOR), SetMinimalSize(124, 12), SetFill(1, 0),
|
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_COND_COMPARATOR), SetMinimalSize(124, 12), SetFill(1, 0),
|
||||||
SetDataTip(STR_NULL, STR_ORDER_CONDITIONAL_COMPARATOR_TOOLTIP), SetResize(1, 0),
|
SetDataTip(STR_NULL, STR_ORDER_CONDITIONAL_COMPARATOR_TOOLTIP), SetResize(1, 0),
|
||||||
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_COND_VALUE),
|
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_COND_VALUE),
|
||||||
|
@@ -177,6 +177,7 @@ enum ModifyOrderFlags {
|
|||||||
MOF_COND_COMPARATOR, ///< A comparator changes.
|
MOF_COND_COMPARATOR, ///< A comparator changes.
|
||||||
MOF_COND_VALUE, ///< The value to set the condition to.
|
MOF_COND_VALUE, ///< The value to set the condition to.
|
||||||
MOF_COND_VALUE_2, ///< The secondary value to set the condition to.
|
MOF_COND_VALUE_2, ///< The secondary value to set the condition to.
|
||||||
|
MOF_COND_VALUE_3, ///< The tertiary value to set the condition to.
|
||||||
MOF_COND_DESTINATION,///< Change the destination of a conditional order.
|
MOF_COND_DESTINATION,///< Change the destination of a conditional order.
|
||||||
MOF_WAYPOINT_FLAGS, ///< Change the waypoint flags
|
MOF_WAYPOINT_FLAGS, ///< Change the waypoint flags
|
||||||
MOF_CARGO_TYPE_UNLOAD, ///< Passes an OrderUnloadType and a CargoID.
|
MOF_CARGO_TYPE_UNLOAD, ///< Passes an OrderUnloadType and a CargoID.
|
||||||
|
@@ -77,7 +77,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
|
|||||||
{ XSLFI_INFRA_SHARING, XSCF_NULL, 2, 2, "infra_sharing", nullptr, nullptr, "CPDP" },
|
{ XSLFI_INFRA_SHARING, XSCF_NULL, 2, 2, "infra_sharing", nullptr, nullptr, "CPDP" },
|
||||||
{ XSLFI_VARIABLE_DAY_LENGTH, XSCF_NULL, 2, 2, "variable_day_length", nullptr, nullptr, nullptr },
|
{ XSLFI_VARIABLE_DAY_LENGTH, XSCF_NULL, 2, 2, "variable_day_length", nullptr, nullptr, nullptr },
|
||||||
{ XSLFI_ORDER_OCCUPANCY, XSCF_NULL, 2, 2, "order_occupancy", nullptr, nullptr, nullptr },
|
{ XSLFI_ORDER_OCCUPANCY, XSCF_NULL, 2, 2, "order_occupancy", nullptr, nullptr, nullptr },
|
||||||
{ XSLFI_MORE_COND_ORDERS, XSCF_NULL, 3, 3, "more_cond_orders", nullptr, nullptr, nullptr },
|
{ XSLFI_MORE_COND_ORDERS, XSCF_NULL, 4, 4, "more_cond_orders", nullptr, nullptr, nullptr },
|
||||||
{ XSLFI_EXTRA_LARGE_MAP, XSCF_NULL, 0, 1, "extra_large_map", nullptr, nullptr, nullptr },
|
{ XSLFI_EXTRA_LARGE_MAP, XSCF_NULL, 0, 1, "extra_large_map", nullptr, nullptr, nullptr },
|
||||||
{ XSLFI_REVERSE_AT_WAYPOINT, XSCF_NULL, 1, 1, "reverse_at_waypoint", nullptr, nullptr, nullptr },
|
{ XSLFI_REVERSE_AT_WAYPOINT, XSCF_NULL, 1, 1, "reverse_at_waypoint", nullptr, nullptr, nullptr },
|
||||||
{ XSLFI_VEH_LIFETIME_PROFIT, XSCF_NULL, 1, 1, "veh_lifetime_profit", nullptr, nullptr, nullptr },
|
{ XSLFI_VEH_LIFETIME_PROFIT, XSCF_NULL, 1, 1, "veh_lifetime_profit", nullptr, nullptr, nullptr },
|
||||||
|
@@ -36,8 +36,10 @@ enum OrderWidgets {
|
|||||||
WID_O_COND_CARGO, ///< Choose condition cargo.
|
WID_O_COND_CARGO, ///< Choose condition cargo.
|
||||||
WID_O_COND_AUX_CARGO, ///< Choose condition cargo.
|
WID_O_COND_AUX_CARGO, ///< Choose condition cargo.
|
||||||
WID_O_COND_SLOT, ///< Choose condition slot.
|
WID_O_COND_SLOT, ///< Choose condition slot.
|
||||||
|
WID_O_COND_AUX_VIA, ///< Condition via button.
|
||||||
WID_O_SEL_COND_VALUE, ///< Widget for conditional value or conditional cargo type.
|
WID_O_SEL_COND_VALUE, ///< Widget for conditional value or conditional cargo type.
|
||||||
WID_O_SEL_COND_AUX, ///< Widget for auxiliary conditional cargo type.
|
WID_O_SEL_COND_AUX, ///< Widget for auxiliary conditional cargo type.
|
||||||
|
WID_O_SEL_COND_AUX2, ///< Widget for auxiliary conditional via button.
|
||||||
WID_O_SEL_TOP_LEFT, ///< #NWID_SELECTION widget for left part of the top row of the 'your train' order window.
|
WID_O_SEL_TOP_LEFT, ///< #NWID_SELECTION widget for left part of the top row of the 'your train' order window.
|
||||||
WID_O_SEL_TOP_MIDDLE, ///< #NWID_SELECTION widget for middle part of the top row of the 'your train' order window.
|
WID_O_SEL_TOP_MIDDLE, ///< #NWID_SELECTION widget for middle part of the top row of the 'your train' order window.
|
||||||
WID_O_SEL_TOP_RIGHT, ///< #NWID_SELECTION widget for right part of the top row of the 'your train' order window.
|
WID_O_SEL_TOP_RIGHT, ///< #NWID_SELECTION widget for right part of the top row of the 'your train' order window.
|
||||||
|
Reference in New Issue
Block a user