Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/KEYMAPPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 2 additions & 4 deletions src/libs/il2cpp/include/il2cpp/il2cpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,8 @@ namespace detail
return Invoke<R, typename Param<P>::Type...>(method, target, Param<P>::From(std::forward<A>(args))...);
}
};
template <typename F, typename... A> struct CallOf : MethodCall<F(A...)> {
};
template <typename R, typename... P, typename... A> struct CallOf<R(P...), A...> : MethodCall<R(P...)> {
};
template <typename F, typename... A> struct CallOf : MethodCall<F(A...)> {};
template <typename R, typename... P, typename... A> struct CallOf<R(P...), A...> : MethodCall<R(P...)> {};

template <typename T> T ReadField(FieldInfo* field, const Il2CppObject* object)
{
Expand Down
6 changes: 3 additions & 3 deletions src/mod/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/mod/features/chat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 36 additions & 0 deletions src/mod/features/dock.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<FleetBarViewController>();
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,
Expand Down
2 changes: 2 additions & 0 deletions src/mod/features/features.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/mod/features/fleet_actions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,11 @@ bool SelectShipShortcuts()
return false;
const auto index = static_cast<int32_t>(ship - kShips.begin());

if (SelectManagedDock(index)) {
last_index = -1;
return true;
}

auto* fleet_bar = unity::Newest<FleetBarViewController>();
if (!fleet_bar)
return false;
Expand Down
2 changes: 2 additions & 0 deletions src/mod/game/fleet.h
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,8 @@ struct ShipManagementViewContext : il2cpp::Object {
{ return Field<"SortedIdleShips", il2cpp::List<FleetPlayerData*>*>(); }
FleetPlayerData* CurrentFleet()
{ return Get<"CurrentFleet", FleetPlayerData*>(); }
il2cpp::List<FleetPlayerData*>* FleetList()
{ return Field<"FleetList", il2cpp::List<FleetPlayerData*>*>(); }
int32_t CurrentIndex()
{ return Get<"CurrentIndex", int32_t>(); }
void SetCurrentIndex(int32_t index)
Expand Down
Loading