Cargo type orders window: Use single command to change all cargoes at once
This commit is contained in:
@@ -1644,7 +1644,7 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MOF_CARGO_TYPE_UNLOAD:
|
case MOF_CARGO_TYPE_UNLOAD:
|
||||||
if (cargo_id >= NUM_CARGO) return CMD_ERROR;
|
if (cargo_id >= NUM_CARGO && cargo_id != CT_INVALID) return CMD_ERROR;
|
||||||
if (data == OUFB_CARGO_TYPE_UNLOAD) return CMD_ERROR;
|
if (data == OUFB_CARGO_TYPE_UNLOAD) return CMD_ERROR;
|
||||||
/* FALL THROUGH */
|
/* FALL THROUGH */
|
||||||
case MOF_UNLOAD:
|
case MOF_UNLOAD:
|
||||||
@@ -1658,7 +1658,7 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MOF_CARGO_TYPE_LOAD:
|
case MOF_CARGO_TYPE_LOAD:
|
||||||
if (cargo_id >= NUM_CARGO) return CMD_ERROR;
|
if (cargo_id >= NUM_CARGO && cargo_id != CT_INVALID) return CMD_ERROR;
|
||||||
if (data == OLFB_CARGO_TYPE_LOAD || data == OLF_FULL_LOAD_ANY) return CMD_ERROR;
|
if (data == OLFB_CARGO_TYPE_LOAD || data == OLF_FULL_LOAD_ANY) return CMD_ERROR;
|
||||||
/* FALL THROUGH */
|
/* FALL THROUGH */
|
||||||
case MOF_LOAD:
|
case MOF_LOAD:
|
||||||
@@ -1787,7 +1787,13 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MOF_CARGO_TYPE_UNLOAD:
|
case MOF_CARGO_TYPE_UNLOAD:
|
||||||
|
if (cargo_id == CT_INVALID) {
|
||||||
|
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
||||||
|
order->SetUnloadType((OrderUnloadFlags)data, i);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
order->SetUnloadType((OrderUnloadFlags)data, cargo_id);
|
order->SetUnloadType((OrderUnloadFlags)data, cargo_id);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MOF_LOAD:
|
case MOF_LOAD:
|
||||||
@@ -1796,7 +1802,13 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MOF_CARGO_TYPE_LOAD:
|
case MOF_CARGO_TYPE_LOAD:
|
||||||
|
if (cargo_id == CT_INVALID) {
|
||||||
|
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
||||||
|
order->SetLoadType((OrderLoadFlags)data, i);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
order->SetLoadType((OrderLoadFlags)data, cargo_id);
|
order->SetLoadType((OrderLoadFlags)data, cargo_id);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MOF_DEPOT_ACTION: {
|
case MOF_DEPOT_ACTION: {
|
||||||
@@ -1948,11 +1960,23 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|||||||
}
|
}
|
||||||
switch (mof) {
|
switch (mof) {
|
||||||
case MOF_CARGO_TYPE_UNLOAD:
|
case MOF_CARGO_TYPE_UNLOAD:
|
||||||
|
if (cargo_id == CT_INVALID) {
|
||||||
|
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
||||||
|
u->current_order.SetUnloadType((OrderUnloadFlags)data, i);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
u->current_order.SetUnloadType((OrderUnloadFlags)data, cargo_id);
|
u->current_order.SetUnloadType((OrderUnloadFlags)data, cargo_id);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MOF_CARGO_TYPE_LOAD:
|
case MOF_CARGO_TYPE_LOAD:
|
||||||
|
if (cargo_id == CT_INVALID) {
|
||||||
|
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
||||||
|
u->current_order.SetLoadType((OrderLoadFlags)data, i);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
u->current_order.SetLoadType((OrderLoadFlags)data, cargo_id);
|
u->current_order.SetLoadType((OrderLoadFlags)data, cargo_id);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@@ -117,7 +117,6 @@ private:
|
|||||||
uint8 order_type = (this->variant == CTOWV_LOAD) ? (uint8) order->GetCargoLoadTypeRaw(cargo_id) : (uint8) order->GetCargoUnloadTypeRaw(cargo_id);
|
uint8 order_type = (this->variant == CTOWV_LOAD) ? (uint8) order->GetCargoLoadTypeRaw(cargo_id) : (uint8) order->GetCargoUnloadTypeRaw(cargo_id);
|
||||||
this->GetWidget<NWidgetCore>(WID_CTO_CARGO_DROPDOWN_FIRST + i)->SetDataTip(this->cargo_type_order_dropdown[order_type], tooltip);
|
this->GetWidget<NWidgetCore>(WID_CTO_CARGO_DROPDOWN_FIRST + i)->SetDataTip(this->cargo_type_order_dropdown[order_type], tooltip);
|
||||||
}
|
}
|
||||||
this->set_to_all_dropdown_sel = 0;
|
|
||||||
this->GetWidget<NWidgetCore>(WID_CTO_SET_TO_ALL_DROPDOWN)->widget_data = this->cargo_type_order_dropdown[this->set_to_all_dropdown_sel];
|
this->GetWidget<NWidgetCore>(WID_CTO_SET_TO_ALL_DROPDOWN)->widget_data = this->cargo_type_order_dropdown[this->set_to_all_dropdown_sel];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,6 +158,7 @@ public:
|
|||||||
this->order_id = order_id;
|
this->order_id = order_id;
|
||||||
this->order_count = v->GetNumOrders();
|
this->order_count = v->GetNumOrders();
|
||||||
this->order = v->GetOrder(order_id);
|
this->order = v->GetOrder(order_id);
|
||||||
|
this->set_to_all_dropdown_sel = 0;
|
||||||
|
|
||||||
this->CreateNestedTree(desc);
|
this->CreateNestedTree(desc);
|
||||||
this->GetWidget<NWidgetCore>(WID_CTO_CAPTION)->SetDataTip(STR_CARGO_TYPE_ORDERS_LOAD_CAPTION + this->variant, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS);
|
this->GetWidget<NWidgetCore>(WID_CTO_CAPTION)->SetDataTip(STR_CARGO_TYPE_ORDERS_LOAD_CAPTION + this->variant, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS);
|
||||||
@@ -240,6 +240,7 @@ public:
|
|||||||
delete this;
|
delete this;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ModifyOrderFlags mof = (this->variant == CTOWV_LOAD) ? MOF_CARGO_TYPE_LOAD : MOF_CARGO_TYPE_UNLOAD;
|
||||||
if (WID_CTO_CARGO_DROPDOWN_FIRST <= widget && widget <= WID_CTO_CARGO_DROPDOWN_LAST) {
|
if (WID_CTO_CARGO_DROPDOWN_FIRST <= widget && widget <= WID_CTO_CARGO_DROPDOWN_LAST) {
|
||||||
const CargoSpec *cs = _sorted_cargo_specs[widget - WID_CTO_CARGO_DROPDOWN_FIRST];
|
const CargoSpec *cs = _sorted_cargo_specs[widget - WID_CTO_CARGO_DROPDOWN_FIRST];
|
||||||
const CargoID cargo_id = cs->Index();
|
const CargoID cargo_id = cs->Index();
|
||||||
@@ -247,14 +248,20 @@ public:
|
|||||||
|
|
||||||
if (action_type == order_action_type) return;
|
if (action_type == order_action_type) return;
|
||||||
|
|
||||||
ModifyOrderFlags mof = (this->variant == CTOWV_LOAD) ? MOF_CARGO_TYPE_LOAD : MOF_CARGO_TYPE_UNLOAD;
|
|
||||||
DoCommandP(this->vehicle->tile, this->vehicle->index + (this->order_id << 20), mof | (action_type << 4) | (cargo_id << 20), CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
DoCommandP(this->vehicle->tile, this->vehicle->index + (this->order_id << 20), mof | (action_type << 4) | (cargo_id << 20), CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
||||||
|
|
||||||
this->GetWidget<NWidgetCore>(widget)->SetDataTip(this->cargo_type_order_dropdown[this->GetOrderActionTypeForCargo(cargo_id)], STR_CARGO_TYPE_LOAD_ORDERS_DROP_TOOLTIP + this->variant);
|
this->GetWidget<NWidgetCore>(widget)->SetDataTip(this->cargo_type_order_dropdown[this->GetOrderActionTypeForCargo(cargo_id)], STR_CARGO_TYPE_LOAD_ORDERS_DROP_TOOLTIP + this->variant);
|
||||||
this->SetWidgetDirty(widget);
|
this->SetWidgetDirty(widget);
|
||||||
} else if (widget == WID_CTO_SET_TO_ALL_DROPDOWN) {
|
} else if (widget == WID_CTO_SET_TO_ALL_DROPDOWN) {
|
||||||
|
DoCommandP(this->vehicle->tile, this->vehicle->index + (this->order_id << 20), mof | (action_type << 4) | (CT_INVALID << 20), CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
||||||
|
|
||||||
for (int i = 0; i < _sorted_standard_cargo_specs_size; i++) {
|
for (int i = 0; i < _sorted_standard_cargo_specs_size; i++) {
|
||||||
this->OnDropdownSelect(i + WID_CTO_CARGO_DROPDOWN_FIRST, action_type);
|
const CargoSpec *cs = _sorted_cargo_specs[i];
|
||||||
|
const CargoID cargo_id = cs->Index();
|
||||||
|
if (action_type != this->GetOrderActionTypeForCargo(cargo_id)) {
|
||||||
|
this->GetWidget<NWidgetCore>(i + WID_CTO_CARGO_DROPDOWN_FIRST)->SetDataTip(this->cargo_type_order_dropdown[this->GetOrderActionTypeForCargo(cargo_id)], STR_CARGO_TYPE_LOAD_ORDERS_DROP_TOOLTIP + this->variant);
|
||||||
|
this->SetWidgetDirty(i + WID_CTO_CARGO_DROPDOWN_FIRST);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action_type != (int) this->set_to_all_dropdown_sel) {
|
if (action_type != (int) this->set_to_all_dropdown_sel) {
|
||||||
|
Reference in New Issue
Block a user