From 082cc43d59b3315dbd71b9463dc9976e6a199b96 Mon Sep 17 00:00:00 2001 From: netniV Date: Sat, 14 Nov 2026 12:33:02 +0000 Subject: [PATCH] Switch docks in management screen --- docs/KEYMAPPING.md | 3 +++ src/libs/il2cpp/include/il2cpp/il2cpp.h | 6 ++--- src/mod/config.h | 6 ++--- src/mod/features/chat.cc | 4 +-- src/mod/features/dock.cc | 36 +++++++++++++++++++++++++ src/mod/features/features.h | 2 ++ src/mod/features/fleet_actions.cc | 5 ++++ src/mod/game/fleet.h | 2 ++ 8 files changed, 55 insertions(+), 9 deletions(-) diff --git a/docs/KEYMAPPING.md b/docs/KEYMAPPING.md index 40f25c6c4..6fee778ed 100644 --- a/docs/KEYMAPPING.md +++ b/docs/KEYMAPPING.md @@ -69,6 +69,9 @@ Actions depend on the selected ship and target. The Kir'Shara queue requires the artifact. `[control].select_timer` sets the ship-selection double-tap interval in milliseconds. +In ship management (Manage), the ship selection shortcuts switch to the corresponding dock's ship. +Numbering follows the fleet bar, skipping locked docks just as it does outside management. +Empty docks and ships unavailable in the management list leave the current ship selected. ### Screens and chat diff --git a/src/libs/il2cpp/include/il2cpp/il2cpp.h b/src/libs/il2cpp/include/il2cpp/il2cpp.h index 6f51775f1..72ea2c53d 100644 --- a/src/libs/il2cpp/include/il2cpp/il2cpp.h +++ b/src/libs/il2cpp/include/il2cpp/il2cpp.h @@ -308,10 +308,8 @@ namespace detail return Invoke::Type...>(method, target, Param

::From(std::forward(args))...); } }; - template struct CallOf : MethodCall { - }; - template struct CallOf : MethodCall { - }; + template struct CallOf : MethodCall {}; + template struct CallOf : MethodCall {}; template T ReadField(FieldInfo* field, const Il2CppObject* object) { diff --git a/src/mod/config.h b/src/mod/config.h index 214ed0a35..c1177cd4f 100644 --- a/src/mod/config.h +++ b/src/mod/config.h @@ -294,9 +294,9 @@ class Config final // Abbreviated cargo values use cargo_significant_decimals. bool format_cargo_values = true; // Restores the Below Deck Ability officer sort option. - bool officer_sort = true; - bool arrow_keys_to_select_ship = true; - bool auto_confirm_ft_upgrade = false; + bool officer_sort = true; + bool arrow_keys_to_select_ship = true; + bool auto_confirm_ft_upgrade = false; // Shows the equipped ship below the Forbidden Tech header, including ships without a dock. bool forbidden_tech_ship_name = true; bool auto_confirm_alliance_contribution = false; diff --git a/src/mod/features/chat.cc b/src/mod/features/chat.cc index a4fca6288..0f6eb685e 100644 --- a/src/mod/features/chat.cc +++ b/src/mod/features/chat.cc @@ -237,8 +237,8 @@ bool InstallChatTitles() il2cpp::HookSet hooks("ChatTitles"); IL2CPP_STAGE(hooks, update, UserProfileWidget_UpdatePlayerTitle_Hook); const bool installed = hooks.Commit(); - const auto set_data = PlayerTitleWidget::Class::Method("SetWidgetData", 0); - const auto bind = PlayerTitleWidget::Class::Method("OnDidBindContext", 0); + const auto set_data = PlayerTitleWidget::Class::Method("SetWidgetData", 0); + const auto bind = PlayerTitleWidget::Class::Method("OnDidBindContext", 0); if (!set_data || !bind) return installed; // Both, or one of them and the update, often branch to one shared body, which SPUD patches in their place. One diff --git a/src/mod/features/dock.cc b/src/mod/features/dock.cc index bfe9df017..904033164 100644 --- a/src/mod/features/dock.cc +++ b/src/mod/features/dock.cc @@ -3,6 +3,7 @@ // Shift+click on a ship tile pins or unpins that ship; // - [ui] double_click_to_assign_ship presses Assign on a double click on a ship tile, or on Enter; // - [ui] dock_syncmanagement selects the fleet bar slot of the ship open in ship management. +// Ship selection shortcuts open the corresponding dock's ship in management. // // Only ShipManagementViewContext.Sort is hooked, not ISortedFleetsContext, so the hailing frequencies inventory keeps // the game's order. @@ -397,6 +398,41 @@ bool InstallDoubleClickAssign() } } // namespace +bool SelectManagedDock(int32_t index) +{ + // Manage is hosted under several sections. Follow the visible controller, as the dock's other actions do. + auto* controller = VisibleShipManagement(); + auto* context = controller ? controller->Context() : nullptr; + if (!context) + return false; + + auto* bar = unity::Newest(); + auto* bar_context = bar ? bar->CanvasContext() : nullptr; + auto* fleets = bar_context ? bar_context->FleetData() : nullptr; + // Use the bar's positions, as normal ship shortcuts do: locked docks can leave gaps in FleetPlayerData::Index. + auto* target = fleets && index >= 0 && std::cmp_less(index, fleets->size()) ? (*fleets)[index] : nullptr; + auto* list = context ? context->FleetList() : nullptr; + // Empty or unavailable docks consume the key too, rather than selecting or locating behind management. + if (!target || !target->HasShip() || !list) + return true; + + // Management includes undocked ships and has its own order. Match the fleet rather than using the dock index. + const auto id = target->Id(); + const auto count = list->Count(); + for (int32_t position = 0; position < count; ++position) { + auto* fleet = (*list)[position]; + if (!fleet || fleet->Id() != id) + continue; + const auto current = context->CurrentIndex(); + if (position != current) { + context->SetLastMovementWasToIncrement(position > current); + context->SetCurrentIndex(position); + } + return true; + } + return true; +} + const Feature kPinnedShips{"PinnedShips", &Config::Patches::pinnedshiphooks, InstallPinnedShips}; const Feature kPinnedShipClick{"PinnedShipClick", &Config::Patches::pinnedshipclicktoggle, InstallPinnedShipClick}; const Feature kDoubleClickAssign{"DoubleClickAssign", &Config::Patches::doubleclickassignshiphooks, diff --git a/src/mod/features/features.h b/src/mod/features/features.h index 5f838ca41..2f9b14927 100644 --- a/src/mod/features/features.h +++ b/src/mod/features/features.h @@ -96,6 +96,8 @@ extern const Feature kPinnedShipClick; extern const Feature kDoubleClickAssign; extern const Feature kAssignOnEnter; extern const Feature kDockSelection; +// Select a fleet bar slot in ship management. True when the management screen consumes the shortcut. +bool SelectManagedDock(int32_t index); // fleet_actions.cc extern const Feature kQueueSwitch; diff --git a/src/mod/features/fleet_actions.cc b/src/mod/features/fleet_actions.cc index caa2272a6..f8d8c84b4 100644 --- a/src/mod/features/fleet_actions.cc +++ b/src/mod/features/fleet_actions.cc @@ -454,6 +454,11 @@ bool SelectShipShortcuts() return false; const auto index = static_cast(ship - kShips.begin()); + if (SelectManagedDock(index)) { + last_index = -1; + return true; + } + auto* fleet_bar = unity::Newest(); if (!fleet_bar) return false; diff --git a/src/mod/game/fleet.h b/src/mod/game/fleet.h index b3e93bf2e..57ffdbc56 100644 --- a/src/mod/game/fleet.h +++ b/src/mod/game/fleet.h @@ -459,6 +459,8 @@ struct ShipManagementViewContext : il2cpp::Object { { return Field<"SortedIdleShips", il2cpp::List*>(); } FleetPlayerData* CurrentFleet() { return Get<"CurrentFleet", FleetPlayerData*>(); } + il2cpp::List* FleetList() + { return Field<"FleetList", il2cpp::List*>(); } int32_t CurrentIndex() { return Get<"CurrentIndex", int32_t>(); } void SetCurrentIndex(int32_t index)