Add release slot train order
This commit is contained in:
@@ -621,6 +621,7 @@ static const StringID _order_goto_dropdown[] = {
|
||||
STR_ORDER_GO_TO_NEAREST_DEPOT,
|
||||
STR_ORDER_CONDITIONAL,
|
||||
STR_ORDER_SHARE,
|
||||
STR_ORDER_RELEASE_SLOT_BUTTON,
|
||||
INVALID_STRING_ID
|
||||
};
|
||||
|
||||
@@ -629,6 +630,7 @@ static const StringID _order_goto_dropdown_aircraft[] = {
|
||||
STR_ORDER_GO_TO_NEAREST_HANGAR,
|
||||
STR_ORDER_CONDITIONAL,
|
||||
STR_ORDER_SHARE,
|
||||
STR_ORDER_RELEASE_SLOT_BUTTON,
|
||||
INVALID_STRING_ID
|
||||
};
|
||||
|
||||
@@ -1023,6 +1025,16 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
|
||||
break;
|
||||
}
|
||||
|
||||
case OT_RELEASE_SLOT:
|
||||
SetDParam(0, STR_ORDER_RELEASE_SLOT);
|
||||
if (order->GetDestination() == INVALID_TRACE_RESTRICT_SLOT_ID) {
|
||||
SetDParam(1, STR_TRACE_RESTRICT_VARIABLE_UNDEFINED_RED);
|
||||
} else {
|
||||
SetDParam(1, STR_TRACE_RESTRICT_SLOT_NAME);
|
||||
SetDParam(2, order->GetDestination());
|
||||
}
|
||||
break;
|
||||
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
|
||||
@@ -1200,6 +1212,7 @@ private:
|
||||
/* WID_O_SEL_TOP_ROW_GROUNDVEHICLE */
|
||||
DP_GROUNDVEHICLE_ROW_NORMAL = 0, ///< Display the row for normal/depot orders in the top row of the train/rv order window.
|
||||
DP_GROUNDVEHICLE_ROW_CONDITIONAL = 1, ///< Display the row for conditional orders in the top row of the train/rv order window.
|
||||
DP_GROUNDVEHICLE_ROW_SLOT = 2, ///< Display the row for release slot orders in the top row of the train/rv order window.
|
||||
|
||||
/* WID_O_SEL_TOP_LEFT */
|
||||
DP_LEFT_LOAD = 0, ///< Display 'load' in the left button of the top row of the train/rv order window.
|
||||
@@ -1404,6 +1417,19 @@ private:
|
||||
this->InsertNewOrder(order.Pack());
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the click on the release slot button.
|
||||
*/
|
||||
void OrderClick_ReleaseSlot()
|
||||
{
|
||||
Order order;
|
||||
order.next = nullptr;
|
||||
order.index = 0;
|
||||
order.MakeReleaseSlot();
|
||||
|
||||
this->InsertNewOrder(order.Pack());
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the click on the unload button.
|
||||
*/
|
||||
@@ -1947,6 +1973,19 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
case OT_RELEASE_SLOT: {
|
||||
if (row_sel != nullptr) {
|
||||
NOT_REACHED();
|
||||
} else {
|
||||
train_row_sel->SetDisplayedPlane(DP_GROUNDVEHICLE_ROW_SLOT);
|
||||
}
|
||||
|
||||
TraceRestrictSlotID slot_id = (order != nullptr && TraceRestrictSlot::IsValidID(order->GetDestination()) ? order->GetDestination() : INVALID_TRACE_RESTRICT_SLOT_ID);
|
||||
|
||||
this->GetWidget<NWidgetCore>(WID_O_RELEASE_SLOT)->widget_data = (slot_id != INVALID_TRACE_RESTRICT_SLOT_ID) ? STR_TRACE_RESTRICT_SLOT_NAME : STR_TRACE_RESTRICT_VARIABLE_UNDEFINED;
|
||||
break;
|
||||
}
|
||||
|
||||
default: // every other order
|
||||
if (row_sel != nullptr) {
|
||||
row_sel->SetDisplayedPlane(DP_ROW_LOAD);
|
||||
@@ -2145,6 +2184,17 @@ public:
|
||||
SetDParam(1, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case WID_O_RELEASE_SLOT: {
|
||||
VehicleOrderID sel = this->OrderGetSel();
|
||||
const Order *order = this->vehicle->GetOrder(sel);
|
||||
|
||||
if (order != nullptr && order->IsType(OT_RELEASE_SLOT)) {
|
||||
TraceRestrictSlotID value = order->GetDestination();
|
||||
SetDParam(0, value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2264,7 +2314,8 @@ public:
|
||||
case OPOS_SHARE: sel = 3; break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
ShowDropDownMenu(this, this->vehicle->type == VEH_AIRCRAFT ? _order_goto_dropdown_aircraft : _order_goto_dropdown, sel, WID_O_GOTO, 0, 0, 0, DDSF_LOST_FOCUS);
|
||||
ShowDropDownMenu(this, this->vehicle->type == VEH_AIRCRAFT ? _order_goto_dropdown_aircraft : _order_goto_dropdown, sel, WID_O_GOTO,
|
||||
0, (this->vehicle->type == VEH_TRAIN &&_settings_client.gui.show_adv_tracerestrict_features ? 0 : 0x10), 0, DDSF_LOST_FOCUS);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -2449,6 +2500,14 @@ public:
|
||||
this->UpdateButtonState();
|
||||
this->ReInit();
|
||||
break;
|
||||
|
||||
case WID_O_RELEASE_SLOT: {
|
||||
int selected;
|
||||
TraceRestrictSlotID value = this->vehicle->GetOrder(this->OrderGetSel())->GetDestination();
|
||||
DropDownList list = GetSlotDropDownList(this->vehicle->owner, value, selected);
|
||||
if (!list.empty()) ShowDropDownList(this, std::move(list), selected, WID_O_RELEASE_SLOT, 0, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2512,6 +2571,7 @@ public:
|
||||
case 1: this->OrderClick_NearestDepot(); break;
|
||||
case 2: this->OrderClick_Goto(OPOS_CONDITIONAL); break;
|
||||
case 3: this->OrderClick_Goto(OPOS_SHARE); break;
|
||||
case 4: this->OrderClick_ReleaseSlot(); break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
break;
|
||||
@@ -2552,6 +2612,10 @@ public:
|
||||
this->ModifyOrder(this->OrderGetSel(), MOF_COND_VALUE_2 | index << 4);
|
||||
break;
|
||||
|
||||
case WID_O_RELEASE_SLOT:
|
||||
this->ModifyOrder(this->OrderGetSel(), MOF_SLOT | index << 4);
|
||||
break;
|
||||
|
||||
case WID_O_MANAGE_LIST:
|
||||
switch (index) {
|
||||
case 0: this->OrderClick_ReverseOrderList(0); break;
|
||||
@@ -2822,6 +2886,12 @@ static const NWidgetPart _nested_orders_train_widgets[] = {
|
||||
SetDataTip(STR_NULL, STR_ORDER_CONDITIONAL_SLOT_TOOLTIP), SetResize(1, 0),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY), EndContainer(),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY), EndContainer(),
|
||||
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_RELEASE_SLOT), SetMinimalSize(124, 12), SetFill(1, 0),
|
||||
SetDataTip(STR_NULL, STR_ORDER_RELEASE_SLOT_TOOLTIP), SetResize(1, 0),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_O_OCCUPANCY_TOGGLE), SetMinimalSize(36, 12), SetDataTip(STR_ORDERS_OCCUPANCY_BUTTON, STR_ORDERS_OCCUPANCY_BUTTON_TOOLTIP),
|
||||
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_SHARED),
|
||||
|
Reference in New Issue
Block a user