From d61fbb977ec3b35fc0d88507e4b9f30f0833f6ee Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sat, 8 Oct 2022 00:46:22 +0100 Subject: [PATCH] Add order management dropdown, add duplicate order and move jump target Add setting to control if order management button shown Move order list management to order management dropdown if enabled See: #439 --- src/command.cpp | 2 + src/command_type.h | 1 + src/lang/english.txt | 7 ++ src/order_cmd.cpp | 53 ++++++++++++- src/order_gui.cpp | 129 +++++++++++++++++++++++++++----- src/settings_gui.cpp | 1 + src/settings_type.h | 1 + src/table/settings/settings.ini | 9 +++ src/widgets/order_widget.h | 3 + 9 files changed, 187 insertions(+), 19 deletions(-) diff --git a/src/command.cpp b/src/command.cpp index dcf59a81f1..41681a961d 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -110,6 +110,7 @@ CommandProcEx CmdModifyOrder; CommandProc CmdSkipToOrder; CommandProc CmdDeleteOrder; CommandProcEx CmdInsertOrder; +CommandProc CmdDuplicateOrder; CommandProc CmdMassChangeOrder; CommandProc CmdChangeServiceInt; @@ -354,6 +355,7 @@ static const Command _command_proc_table[] = { DEF_CMD(CmdSkipToOrder, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_SKIP_TO_ORDER DEF_CMD(CmdDeleteOrder, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_DELETE_ORDER DEF_CMD(CmdInsertOrder, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_INSERT_ORDER + DEF_CMD(CmdDuplicateOrder, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_DUPLICATE_ORDER DEF_CMD(CmdMassChangeOrder, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_MASS_CHANGE_ORDER DEF_CMD(CmdChangeServiceInt, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_CHANGE_SERVICE_INT diff --git a/src/command_type.h b/src/command_type.h index f572f29844..4043825739 100644 --- a/src/command_type.h +++ b/src/command_type.h @@ -288,6 +288,7 @@ enum Commands { CMD_SKIP_TO_ORDER, ///< skip an order to the next of specific one CMD_DELETE_ORDER, ///< delete an order CMD_INSERT_ORDER, ///< insert a new order + CMD_DUPLICATE_ORDER, ///< duplicate an order CMD_MASS_CHANGE_ORDER, ///< mass change the target of an order CMD_CHANGE_SERVICE_INT, ///< change the server interval of a vehicle diff --git a/src/lang/english.txt b/src/lang/english.txt index 075e15d867..173af233e5 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1636,6 +1636,9 @@ STR_CONFIG_SETTING_DISABLE_WATER_ANIMATION_32X :32x zoom and ab STR_CONFIG_SETTING_SHOW_ORDER_OCCUPANCY_BY_DEFAULT :Show order occupancy by default: {STRING2} STR_CONFIG_SETTING_SHOW_ORDER_OCCUPANCY_BY_DEFAULT_HELPTEXT :Show detailed per-order occupancy by default when opening a vehicle's orders window +STR_CONFIG_SETTING_SHOW_ORDER_MANAGEMENT_BY_DEFAULT :Show order management button: {STRING2} +STR_CONFIG_SETTING_SHOW_ORDER_MANAGEMENT_BY_DEFAULT_HELPTEXT :Show a button for order management in the vehicle order window + STR_CONFIG_SETTING_SHOW_GROUP_HIERARCHY_NAME :Show group hierarchy in name: {STRING2} STR_CONFIG_SETTING_SHOW_GROUP_HIERARCHY_NAME_HELPTEXT :When enabled, group names include the full hierarchy of their parent group names @@ -5628,8 +5631,12 @@ STR_ORDERS_SKIP_TOOLTIP :{BLACK}Skip the STR_ORDERS_MANAGE_LIST :{BLACK}Manage List STR_ORDERS_MANAGE_LIST_TOOLTIP :{BLACK}Manage this order list +STR_ORDERS_MANAGE_ORDER :{BLACK}Manage Order +STR_ORDERS_MANAGE_ORDER_TOOLTIP :{BLACK}Manage this order STR_ORDER_REVERSE_ORDER_LIST :Reverse order list STR_ORDER_APPEND_REVERSED_ORDER_LIST :Append reversed order list +STR_ORDER_DUPLICATE_ORDER :Duplicate order +STR_ORDER_CHANGE_JUMP_TARGET :Change jump target STR_ORDERS_DELETE_BUTTON :{BLACK}Delete STR_ORDERS_DELETE_TOOLTIP :{BLACK}Delete the highlighted order diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index e92cb2797b..b289663a55 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -967,6 +967,57 @@ CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 return CmdInsertOrderIntl(flags, Vehicle::GetIfValid(veh), sel_ord, new_order, false); } +/** + * Duplicate an order in the orderlist of a vehicle. + * @param tile unused + * @param flags operation to perform + * @param p1 various bitstuffed elements + * - p1 = (bit 0 - 19) - ID of the vehicle + * @param p2 various bitstuffed elements + * - p2 = (bit 0 - 15) - The order to duplicate + * @param text unused + * @return the cost of this operation or an error + */ +CommandCost CmdDuplicateOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +{ + VehicleID veh_id = GB(p1, 0, 20); + VehicleOrderID sel_ord = GB(p2, 0, 16); + + Vehicle *v = Vehicle::GetIfValid(veh_id); + + if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR; + + CommandCost ret = CheckOwnership(v->owner); + if (ret.Failed()) return ret; + + if (sel_ord >= v->GetNumOrders()) return CMD_ERROR; + + const Order *src_order = v->GetOrder(sel_ord); + if (src_order == nullptr) return CMD_ERROR; + + Order new_order; + new_order.AssignOrder(*src_order); + const bool wait_fixed = new_order.IsWaitFixed(); + const bool wait_timetabled = wait_fixed && new_order.IsWaitTimetabled(); + new_order.SetWaitTimetabled(false); + new_order.SetTravelTimetabled(false); + new_order.SetTravelTime(0); + new_order.SetTravelFixed(false); + CommandCost cost = CmdInsertOrderIntl(flags, v, sel_ord + 1, new_order, true); + if (cost.Failed()) return cost; + if (flags & DC_EXEC) { + Order *order = v->orders->GetOrderAt(sel_ord + 1); + order->SetRefit(new_order.GetRefitCargo()); + order->SetMaxSpeed(new_order.GetMaxSpeed()); + if (wait_fixed) { + extern void SetOrderFixedWaitTime(Vehicle *v, VehicleOrderID order_number, uint32 wait_time, bool wait_timetabled); + SetOrderFixedWaitTime(v, sel_ord + 1, new_order.GetWaitTime(), wait_timetabled); + } + } + new_order.Free(); + return CommandCost(); +} + CommandCost CmdInsertOrderIntl(DoCommandFlag flags, Vehicle *v, VehicleOrderID sel_ord, const Order &new_order, bool allow_load_by_cargo_type) { if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR; @@ -1895,7 +1946,7 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 break; case MOF_COND_DESTINATION: - if (data >= v->GetNumOrders()) return CMD_ERROR; + if (data >= v->GetNumOrders() || data == sel_ord) return CMD_ERROR; break; case MOF_WAYPOINT_FLAGS: diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 1d7c5702d9..0499fe92f8 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -640,6 +640,12 @@ static const StringID _order_manage_list_dropdown[] = { INVALID_STRING_ID }; +static const StringID _order_manage_dropdown[] = { + STR_ORDER_DUPLICATE_ORDER, + STR_ORDER_CHANGE_JUMP_TARGET, + INVALID_STRING_ID +}; + /** Variables for conditional orders; this defines the order of appearance in the dropdown box */ static const OrderConditionVariable _order_conditional_variable[] = { OCV_LOAD_PERCENTAGE, @@ -1296,6 +1302,7 @@ private: OPOS_CONDITIONAL, OPOS_SHARE, OPOS_COND_VIA, + OPOS_CONDITIONAL_RETARGET, OPOS_END, }; @@ -1352,6 +1359,10 @@ private: /* WID_O_SEL_SHARED */ DP_SHARED_LIST = 0, ///< Display shared order list button DP_SHARED_VEH_GROUP = 1, ///< Display add veh to new group button + + /* WID_O_SEL_MGMT */ + DP_MGMT_BTN = 0, ///< Display order management button + DP_MGMT_LIST_BTN = 1, ///< Display order list management button }; int selected_order; @@ -1364,6 +1375,7 @@ private: int query_text_widget; ///< widget which most recently called ShowQueryString int current_aux_plane; int current_aux2_plane; + int current_mgmt_plane; /** * Return the memorised selected order. @@ -1449,11 +1461,13 @@ private: HT_NONE, // OPOS_CONDITIONAL HT_VEHICLE, // OPOS_SHARE HT_RECT, // OPOS_COND_VIA + HT_NONE, // OPOS_CONDITIONAL_RETARGET }; SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, goto_place_style[type - 1], this); this->goto_type = type; this->SetWidgetDirty(WID_O_GOTO); this->SetWidgetDirty(WID_O_COND_AUX_VIA); + this->SetWidgetDirty(WID_O_MGMT_BTN); } /** @@ -1667,6 +1681,15 @@ private: } } + int GetOrderManagementPlane() const + { + if (_settings_client.gui.show_order_management_button) { + return this->selected_order == this->vehicle->GetNumOrders() ? DP_MGMT_LIST_BTN : DP_MGMT_BTN; + } else { + return SZSP_NONE; + } + } + public: OrdersWindow(WindowDesc *desc, const Vehicle *v) : Window(desc) { @@ -1676,12 +1699,14 @@ public: this->vscroll = this->GetScrollbar(WID_O_SCROLLBAR); this->GetWidget(WID_O_SEL_OCCUPANCY)->SetDisplayedPlane(_settings_client.gui.show_order_occupancy_by_default ? 0 : SZSP_NONE); this->SetWidgetLoweredState(WID_O_OCCUPANCY_TOGGLE, _settings_client.gui.show_order_occupancy_by_default); - if (v->owner == _local_company) { - this->GetWidget(WID_O_SEL_COND_AUX)->SetDisplayedPlane(SZSP_NONE); - this->GetWidget(WID_O_SEL_COND_AUX2)->SetDisplayedPlane(SZSP_NONE); - } this->current_aux_plane = SZSP_NONE; this->current_aux2_plane = SZSP_NONE; + this->current_mgmt_plane = this->GetOrderManagementPlane(); + if (v->owner == _local_company) { + this->GetWidget(WID_O_SEL_COND_AUX)->SetDisplayedPlane(this->current_aux_plane); + this->GetWidget(WID_O_SEL_COND_AUX2)->SetDisplayedPlane(this->current_aux2_plane); + this->GetWidget(WID_O_SEL_MGMT)->SetDisplayedPlane(this->current_mgmt_plane); + } this->FinishInitNested(v->index); if (v->owner == _local_company) { this->DisableWidget(WID_O_EMPTY); @@ -1896,7 +1921,9 @@ public: /* skip / extra menu */ NWidgetStacked *skip_sel = this->GetWidget(WID_O_SEL_BOTTOM_LEFT); NWidgetLeaf *manage_list_dropdown = this->GetWidget(WID_O_MANAGE_LIST); - skip_sel->SetDisplayedPlane((manage_list_dropdown->IsLowered() || (_ctrl_pressed && this->selected_order == this->vehicle->GetNumOrders())) ? DP_BOTTOM_LEFT_MANAGE_LIST : DP_BOTTOM_LEFT_SKIP); + skip_sel->SetDisplayedPlane((manage_list_dropdown->IsLowered() || + (!_settings_client.gui.show_order_management_button && _ctrl_pressed && this->selected_order == this->vehicle->GetNumOrders())) + ? DP_BOTTOM_LEFT_MANAGE_LIST : DP_BOTTOM_LEFT_SKIP); /* First row. */ this->RaiseWidget(WID_O_FULL_LOAD); @@ -1915,6 +1942,8 @@ public: NWidgetStacked *aux_sel = this->GetWidget(WID_O_SEL_COND_AUX); NWidgetStacked *aux2_sel = this->GetWidget(WID_O_SEL_COND_AUX2); + NWidgetStacked *mgmt_sel = this->GetWidget(WID_O_SEL_MGMT); + mgmt_sel->SetDisplayedPlane(this->GetOrderManagementPlane()); auto aux_plane_guard = scope_guard([&]() { if (this->current_aux_plane != aux_sel->shown_plane) { @@ -1925,6 +1954,12 @@ public: this->current_aux2_plane = aux2_sel->shown_plane; this->ReInit(); } + if ((this->current_mgmt_plane == SZSP_NONE) != (mgmt_sel->shown_plane == SZSP_NONE)) { + this->current_mgmt_plane = mgmt_sel->shown_plane; + this->ReInit(); + } else if (this->current_mgmt_plane != mgmt_sel->shown_plane) { + this->current_mgmt_plane = mgmt_sel->shown_plane; + } }); if (order == nullptr) { @@ -1941,9 +1976,11 @@ public: this->DisableWidget(WID_O_FULL_LOAD); this->DisableWidget(WID_O_UNLOAD); this->DisableWidget(WID_O_REFIT_DROPDOWN); + this->DisableWidget(WID_O_MGMT_BTN); } else { this->SetWidgetDisabledState(WID_O_FULL_LOAD, (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) != 0); // full load this->SetWidgetDisabledState(WID_O_UNLOAD, (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) != 0); // unload + this->EnableWidget(WID_O_MGMT_BTN); switch (order->GetType()) { case OT_GOTO_STATION: @@ -2126,8 +2163,9 @@ public: if (this->vehicle->owner != _local_company) { this->selected_order = -1; // Disable selection any selected row at a competitor order window. } else { - this->SetWidgetLoweredState(WID_O_GOTO, this->goto_type != OPOS_NONE && this->goto_type != OPOS_COND_VIA); + this->SetWidgetLoweredState(WID_O_GOTO, this->goto_type != OPOS_NONE && this->goto_type != OPOS_COND_VIA && this->goto_type != OPOS_CONDITIONAL_RETARGET); this->SetWidgetLoweredState(WID_O_COND_AUX_VIA, this->goto_type == OPOS_COND_VIA); + this->SetWidgetLoweredState(WID_O_MGMT_BTN, this->goto_type == OPOS_CONDITIONAL_RETARGET); } this->DrawWidgets(); } @@ -2375,6 +2413,14 @@ public: ResetObjectToPlace(); break; } + if (this->goto_type == OPOS_CONDITIONAL_RETARGET) { + VehicleOrderID order_id = this->GetOrderFromPt(_cursor.pos.y - this->top); + if (order_id != INVALID_VEH_ORDER_ID) { + this->ModifyOrder(this->OrderGetSel(), MOF_COND_DESTINATION | (order_id << 4)); + } + ResetObjectToPlace(); + break; + } VehicleOrderID sel = this->GetOrderFromPt(pt.y); @@ -2434,7 +2480,8 @@ public: this->OrderClick_Skip(); break; - case WID_O_MANAGE_LIST: { + case WID_O_MANAGE_LIST: + case WID_O_MGMT_LIST_BTN: { uint disabled_mask = (this->vehicle->GetNumOrders() < 2 ? 1 : 0) | (this->vehicle->GetNumOrders() < 3 ? 2 : 0); uint order_count = this->vehicle->GetNumOrders(); for (uint i = 0; i < order_count; i++) { @@ -2443,7 +2490,19 @@ public: break; } } - ShowDropDownMenu(this, _order_manage_list_dropdown, -1, WID_O_MANAGE_LIST, disabled_mask, 0, 0, DDSF_LOST_FOCUS); + ShowDropDownMenu(this, _order_manage_list_dropdown, -1, widget, disabled_mask, 0, 0, DDSF_LOST_FOCUS); + break; + } + + case WID_O_MGMT_BTN: { + VehicleOrderID sel = this->OrderGetSel(); + const Order *order = this->vehicle->GetOrder(sel); + if (order == nullptr) break; + + uint hidden_mask = 0; + if (!order->IsType(OT_CONDITIONAL)) hidden_mask |= 2; + + ShowDropDownMenu(this, _order_manage_dropdown, -1, widget, 0, hidden_mask, UINT_MAX, DDSF_LOST_FOCUS); break; } @@ -2480,6 +2539,7 @@ public: case OPOS_GOTO: sel = 0; break; case OPOS_CONDITIONAL: sel = 2; break; case OPOS_SHARE: sel = 3; break; + case OPOS_CONDITIONAL_RETARGET: sel = -1; break; default: NOT_REACHED(); } ShowDropDownMenu(this, this->vehicle->type == VEH_AIRCRAFT ? _order_goto_dropdown_aircraft : _order_goto_dropdown, sel, WID_O_GOTO, @@ -2861,12 +2921,32 @@ public: break; case WID_O_MANAGE_LIST: + case WID_O_MGMT_LIST_BTN: switch (index) { case 0: this->OrderClick_ReverseOrderList(0); break; case 1: this->OrderClick_ReverseOrderList(1); break; default: NOT_REACHED(); } break; + + case WID_O_MGMT_BTN: + if (this->goto_type == OPOS_CONDITIONAL_RETARGET) { + ResetObjectToPlace(); + 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)); + break; + + case 1: + this->OrderClick_Goto(OPOS_CONDITIONAL_RETARGET); + break; + + default: + NOT_REACHED(); + } + break; } } @@ -2977,6 +3057,7 @@ public: this->goto_type = OPOS_NONE; this->SetWidgetDirty(WID_O_GOTO); this->SetWidgetDirty(WID_O_COND_AUX_VIA); + this->SetWidgetDirty(WID_O_MGMT_BTN); /* Remove drag highlighting if it exists. */ if (this->order_over != INVALID_VEH_ORDER_ID) { @@ -3155,19 +3236,25 @@ static const NWidgetPart _nested_orders_train_widgets[] = { /* Second button row. */ NWidget(NWID_HORIZONTAL), NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), + NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_MGMT), + NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_MGMT_BTN), SetMinimalSize(100, 12), SetFill(1, 0), + SetDataTip(STR_ORDERS_MANAGE_ORDER, STR_ORDERS_MANAGE_ORDER_TOOLTIP), SetResize(1, 0), SetAlignment(SA_TOP | SA_LEFT), + NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_MGMT_LIST_BTN), SetMinimalSize(100, 12), SetFill(1, 0), + SetDataTip(STR_ORDERS_MANAGE_LIST, STR_ORDERS_MANAGE_LIST_TOOLTIP), SetResize(1, 0), + EndContainer(), NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_BOTTOM_LEFT), - NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_SKIP), SetMinimalSize(124, 12), SetFill(1, 0), + NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_SKIP), SetMinimalSize(100, 12), SetFill(1, 0), SetDataTip(STR_ORDERS_SKIP_BUTTON, STR_ORDERS_SKIP_TOOLTIP), SetResize(1, 0), - NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_MANAGE_LIST), SetMinimalSize(124, 12), SetFill(1, 0), + NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_MANAGE_LIST), SetMinimalSize(100, 12), SetFill(1, 0), SetDataTip(STR_ORDERS_MANAGE_LIST, STR_ORDERS_MANAGE_LIST_TOOLTIP), SetResize(1, 0), EndContainer(), NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_BOTTOM_MIDDLE), - NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_DELETE), SetMinimalSize(124, 12), SetFill(1, 0), + NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_DELETE), SetMinimalSize(100, 12), SetFill(1, 0), SetDataTip(STR_ORDERS_DELETE_BUTTON, STR_ORDERS_DELETE_TOOLTIP), SetResize(1, 0), - NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_STOP_SHARING), SetMinimalSize(124, 12), SetFill(1, 0), + NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_STOP_SHARING), SetMinimalSize(100, 12), SetFill(1, 0), SetDataTip(STR_ORDERS_STOP_SHARING_BUTTON, STR_ORDERS_STOP_SHARING_TOOLTIP), SetResize(1, 0), EndContainer(), - NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_GOTO), SetMinimalSize(124, 12), SetFill(1, 0), + NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_GOTO), SetMinimalSize(100, 12), SetFill(1, 0), SetDataTip(STR_ORDERS_GO_TO_BUTTON, STR_ORDERS_GO_TO_TOOLTIP), SetResize(1, 0), EndContainer(), NWidget(WWT_RESIZEBOX, COLOUR_GREY), @@ -3271,19 +3358,25 @@ static const NWidgetPart _nested_orders_widgets[] = { /* Second button row. */ NWidget(NWID_HORIZONTAL), + NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_MGMT), + NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_MGMT_BTN), SetMinimalSize(100, 12), SetFill(1, 0), + SetDataTip(STR_ORDERS_MANAGE_ORDER, STR_ORDERS_MANAGE_ORDER_TOOLTIP), SetResize(1, 0), SetAlignment(SA_TOP | SA_LEFT), + NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_MGMT_LIST_BTN), SetMinimalSize(100, 12), SetFill(1, 0), + SetDataTip(STR_ORDERS_MANAGE_LIST, STR_ORDERS_MANAGE_LIST_TOOLTIP), SetResize(1, 0), + EndContainer(), NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_BOTTOM_LEFT), - NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_SKIP), SetMinimalSize(124, 12), SetFill(1, 0), + NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_SKIP), SetMinimalSize(100, 12), SetFill(1, 0), SetDataTip(STR_ORDERS_SKIP_BUTTON, STR_ORDERS_SKIP_TOOLTIP), SetResize(1, 0), - NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_MANAGE_LIST), SetMinimalSize(124, 12), SetFill(1, 0), + NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_MANAGE_LIST), SetMinimalSize(100, 12), SetFill(1, 0), SetDataTip(STR_ORDERS_MANAGE_LIST, STR_ORDERS_MANAGE_LIST_TOOLTIP), SetResize(1, 0), EndContainer(), NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_BOTTOM_MIDDLE), - NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_DELETE), SetMinimalSize(124, 12), SetFill(1, 0), + NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_DELETE), SetMinimalSize(100, 12), SetFill(1, 0), SetDataTip(STR_ORDERS_DELETE_BUTTON, STR_ORDERS_DELETE_TOOLTIP), SetResize(1, 0), - NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_STOP_SHARING), SetMinimalSize(124, 12), SetFill(1, 0), + NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_STOP_SHARING), SetMinimalSize(100, 12), SetFill(1, 0), SetDataTip(STR_ORDERS_STOP_SHARING_BUTTON, STR_ORDERS_STOP_SHARING_TOOLTIP), SetResize(1, 0), EndContainer(), - NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_GOTO), SetMinimalSize(124, 12), SetFill(1, 0), + NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_GOTO), SetMinimalSize(100, 12), SetFill(1, 0), SetDataTip(STR_ORDERS_GO_TO_BUTTON, STR_ORDERS_GO_TO_TOOLTIP), SetResize(1, 0), NWidget(WWT_RESIZEBOX, COLOUR_GREY), EndContainer(), diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index e3bc870292..b9bf4e8339 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1939,6 +1939,7 @@ static SettingsContainer &GetSettingsTree() interface->Add(new SettingEntry("gui.allow_hiding_waypoint_labels")); interface->Add(new SettingEntry("gui.disable_water_animation")); interface->Add(new SettingEntry("gui.show_order_occupancy_by_default")); + interface->Add(new SettingEntry("gui.show_order_management_button")); interface->Add(new SettingEntry("gui.show_group_hierarchy_name")); interface->Add(new ConditionallyHiddenSettingEntry("gui.show_vehicle_group_hierarchy_name", []() -> bool { return !_settings_client.gui.show_group_hierarchy_name; })); } diff --git a/src/settings_type.h b/src/settings_type.h index d860d1fef4..0bf57aabcb 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -249,6 +249,7 @@ struct GUISettings : public TimeSettings { bool allow_hiding_waypoint_labels; ///< Allow hiding waypoint viewport labels uint8 disable_water_animation; ///< Disable water animation depending on zoom level bool show_order_occupancy_by_default; ///< Show order occupancy by default in vehicle order window + bool show_order_management_button; ///< Show order management button in vehicle order window bool show_group_hierarchy_name; ///< Show the full hierarchy in group names bool show_vehicle_group_hierarchy_name;///< Show the full group hierarchy in vehicle names diff --git a/src/table/settings/settings.ini b/src/table/settings/settings.ini index 60a38f5a17..496b0e3240 100644 --- a/src/table/settings/settings.ini +++ b/src/table/settings/settings.ini @@ -5555,6 +5555,15 @@ str = STR_CONFIG_SETTING_SHOW_ORDER_OCCUPANCY_BY_DEFAULT strhelp = STR_CONFIG_SETTING_SHOW_ORDER_OCCUPANCY_BY_DEFAULT_HELPTEXT cat = SC_BASIC +[SDTC_BOOL] +var = gui.show_order_management_button +flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC +def = true +str = STR_CONFIG_SETTING_SHOW_ORDER_MANAGEMENT_BY_DEFAULT +strhelp = STR_CONFIG_SETTING_SHOW_ORDER_MANAGEMENT_BY_DEFAULT_HELPTEXT +post_cb = [](auto) { InvalidateWindowClassesData(WC_VEHICLE_ORDERS); } +cat = SC_BASIC + [SDTC_BOOL] var = gui.show_group_hierarchy_name flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC diff --git a/src/widgets/order_widget.h b/src/widgets/order_widget.h index 1a8693ee24..77df413aef 100644 --- a/src/widgets/order_widget.h +++ b/src/widgets/order_widget.h @@ -20,6 +20,8 @@ enum OrderWidgets { WID_O_SCROLLBAR, ///< Order list scrollbar. WID_O_SKIP, ///< Skip current order. WID_O_MANAGE_LIST, ///< Manage order list. + WID_O_MGMT_BTN, ///< Management button. + WID_O_MGMT_LIST_BTN, ///< Management list button. WID_O_DELETE, ///< Delete selected order. WID_O_STOP_SHARING, ///< Stop sharing orders. WID_O_NON_STOP, ///< Goto non-stop to destination. @@ -47,6 +49,7 @@ enum OrderWidgets { 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_AUX2, ///< Widget for auxiliary conditional via button. + WID_O_SEL_MGMT, ///< Widget for management buttons. 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_RIGHT, ///< #NWID_SELECTION widget for right part of the top row of the 'your train' order window.