From 38e2605c14216e6369aa989258349a234ca5b0b3 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Tue, 2 Jan 2024 19:35:07 +0000 Subject: [PATCH] Add order stop location to manage order dropdown --- src/order_gui.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/order_gui.cpp b/src/order_gui.cpp index af485f5702..71cf6d5b15 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -2787,6 +2787,28 @@ public: DropDownList list; list.push_back(std::make_unique(STR_ORDER_DUPLICATE_ORDER, 0, false)); if (order->IsType(OT_CONDITIONAL)) list.push_back(std::make_unique(STR_ORDER_CHANGE_JUMP_TARGET, 1, false)); + + if (this->vehicle->type == VEH_TRAIN && order->IsType(OT_GOTO_STATION) && (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) == 0) { + const OrderStopLocation osl = order->GetStopLocation(); + list.push_back(std::make_unique(-1, false)); + list.push_back(std::make_unique(osl == OSL_PLATFORM_NEAR_END, STR_ORDER_STOP_LOCATION_NEAR_END, 0x200 + OSL_PLATFORM_NEAR_END, false)); + list.push_back(std::make_unique(osl == OSL_PLATFORM_MIDDLE, STR_ORDER_STOP_LOCATION_MIDDLE, 0x200 + OSL_PLATFORM_MIDDLE, false)); + list.push_back(std::make_unique(osl == OSL_PLATFORM_FAR_END, STR_ORDER_STOP_LOCATION_FAR_END, 0x200 + OSL_PLATFORM_FAR_END, false)); + if (osl == OSL_PLATFORM_THROUGH || _settings_client.gui.show_adv_load_mode_features) { + bool allowed = _settings_client.gui.show_adv_load_mode_features; + if (allowed) { + for (const Vehicle *u = this->vehicle; u != nullptr; u = u->Next()) { + /* Passengers may not be through-loaded */ + if (u->cargo_cap > 0 && IsCargoInClass(u->cargo_type, CC_PASSENGERS)) { + allowed = false; + break; + } + } + } + list.push_back(std::make_unique(osl == OSL_PLATFORM_THROUGH, STR_ORDER_STOP_LOCATION_THROUGH, 0x200 + OSL_PLATFORM_THROUGH, !allowed)); + } + } + if (!order->IsType(OT_IMPLICIT)) { list.push_back(std::make_unique(-1, false)); const Colours current_colour = order->GetColour(); @@ -3336,6 +3358,10 @@ public: this->ModifyOrder(this->OrderGetSel(), MOF_COLOUR | (index & 0xFF) << 8); break; } + if (index >= 0x200 && index < 0x200 + OSL_END) { + this->ModifyOrder(this->OrderGetSel(), MOF_STOP_LOCATION | (index & 0xFF) << 8); + break; + } switch (index) { case 0: DoCommandP(this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), CMD_DUPLICATE_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER));