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
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ been applied. Valid values for any short can be found in [KEYMAPPING.md](KEYMAPP
| -----------: | -------------------------------- |
| F10 | Bug fixer (exits game) |
| F1-F5 | Zoom presets |
| Q | Zoom Out |
| E | Zoom In |
| Q | Zoom In |
| E | Zoom Out |
| MINUS | Zoom (min) |
| EQUALS | Zoom (default) |
| = | Zoom (default) |
| BACKSPACE | Zoom (max) |
| C | Open/Focus Chat - Full Screen |
| Alt-C | Open/Focus Chat - Side of Screen |
Expand Down Expand Up @@ -109,9 +109,12 @@ action items such as:

| Key | Shortcut |
| ------: | ---------------- |
| T | Events |
| T | Away Teams |
| G | Galaxy |
| Ctrl-G | Galaxy (native) |
| H | System |
| Shift-E | Events |
| Ctrl-E | Events (native) |
| Shift-G | Exterior View |
| Shift-H | Interior View |
| B | Bookmarks |
Expand All @@ -125,7 +128,6 @@ action items such as:
| O | Command Center |
| Shift-O | Officers |
| Shift-Q | Q-Trials |
| Shift-T | Away Teams |
| X | ExoComp |
| Z | Daily Missions |

Expand Down
6 changes: 6 additions & 0 deletions example_community_patch_settings_da.toml
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,9 @@ show_daily = "Z"
# Gå til begivenheder
show_events = "SHIFT-E"

# Scopely shortcut-native Events Action
native_shortcut_events = "CTRL-E"

# Gå til Exocomp
show_exocomp = "X"

Expand All @@ -464,6 +467,9 @@ show_factions = "F"
# Gå til galaksen
show_galaxy = "G"

# Scopely shortcut-native Galaxy Action
native_shortcut_galaxy = "CTRL-G"

# Gå til gaver
show_gifts = "/"

Expand Down
6 changes: 6 additions & 0 deletions example_community_patch_settings_de.toml
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,9 @@ show_daily = "Z"
# Zu den Events
show_events = "SHIFT-E"

# Scopely shortcut-native Events Action
native_shortcut_events = "CTRL-E"

# Zu den Exocomps
show_exocomp = "X"

Expand All @@ -464,6 +467,9 @@ show_factions = "F"
# Zur Galaxie
show_galaxy = "G"

# Scopely shortcut-native Galaxy Action
native_shortcut_galaxy = "CTRL-G"

# Zu den Geschenken
show_gifts = "/"

Expand Down
6 changes: 6 additions & 0 deletions example_community_patch_settings_en-GB-x-cockney.toml
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,9 @@ show_daily = "Z"
# Go to Events
show_events = "SHIFT-E"

# Scopely shortcut-native Events Action
native_shortcut_events = "CTRL-E"

# Go to Exocomp
show_exocomp = "X"

Expand All @@ -464,6 +467,9 @@ show_factions = "F"
# Go to Galaxy
show_galaxy = "G"

# Scopely shortcut-native Galaxy Action
native_shortcut_galaxy = "CTRL-G"

# Go to Gifts
show_gifts = "/"

Expand Down
6 changes: 6 additions & 0 deletions example_community_patch_settings_en-x-minionese.toml
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,9 @@ show_daily = "Z"
# Go to Events
show_events = "SHIFT-E"

# Scopely shortcut-native Events Action
native_shortcut_events = "CTRL-E"

# Go to Exocomp
show_exocomp = "X"

Expand All @@ -464,6 +467,9 @@ show_factions = "F"
# Go to Galaxy
show_galaxy = "G"

# Scopely shortcut-native Galaxy Action
native_shortcut_galaxy = "CTRL-G"

# Go to Gifts
show_gifts = "/"

Expand Down
6 changes: 6 additions & 0 deletions example_community_patch_settings_en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,9 @@ show_daily = "Z"
# Go to Events
show_events = "SHIFT-E"

# Scopely shortcut-native Events Action
native_shortcut_events = "CTRL-E"

# Go to Exocomp
show_exocomp = "X"

Expand All @@ -464,6 +467,9 @@ show_factions = "F"
# Go to Galaxy
show_galaxy = "G"

# Scopely shortcut-native Galaxy Action
native_shortcut_galaxy = "CTRL-G"

# Go to Gifts
show_gifts = "/"

Expand Down
6 changes: 6 additions & 0 deletions example_community_patch_settings_es.toml
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,9 @@ show_daily = "Z"
# Ir a eventos
show_events = "SHIFT-E"

# Scopely shortcut-native Events Action
native_shortcut_events = "CTRL-E"

# Ir a Exocomp
show_exocomp = "X"

Expand All @@ -464,6 +467,9 @@ show_factions = "F"
# Ir a la galaxia
show_galaxy = "G"

# Scopely shortcut-native Galaxy Action
native_shortcut_galaxy = "CTRL-G"

# Ir a regalos
show_gifts = "/"

Expand Down
6 changes: 6 additions & 0 deletions example_community_patch_settings_fr.toml
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,9 @@ show_daily = "Z"
# Aller aux événements
show_events = "SHIFT-E"

# Scopely shortcut-native Events Action
native_shortcut_events = "CTRL-E"

# Aller aux Exocomps
show_exocomp = "X"

Expand All @@ -464,6 +467,9 @@ show_factions = "F"
# Aller à la galaxie
show_galaxy = "G"

# Scopely shortcut-native Galaxy Action
native_shortcut_galaxy = "CTRL-G"

# Aller aux cadeaux
show_gifts = "/"

Expand Down
6 changes: 6 additions & 0 deletions example_community_patch_settings_nl.toml
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,9 @@ show_daily = "Z"
# Ga naar Evenementen
show_events = "SHIFT-E"

# Scopely shortcut-native Events Action
native_shortcut_events = "CTRL-E"

# Ga naar Exocomp
show_exocomp = "X"

Expand All @@ -464,6 +467,9 @@ show_factions = "F"
# Ga naar Sterrenstelsel
show_galaxy = "G"

# Scopely shortcut-native Galaxy Action
native_shortcut_galaxy = "CTRL-G"

# Ga naar Cadeaus
show_gifts = "/"

Expand Down
6 changes: 6 additions & 0 deletions example_community_patch_settings_ru.toml
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,9 @@ show_daily = "Z"
# Перейти к событиям
show_events = "SHIFT-E"

# Scopely shortcut-native Events Action
native_shortcut_events = "CTRL-E"

# Перейти к экзокомпу
show_exocomp = "X"

Expand All @@ -464,6 +467,9 @@ show_factions = "F"
# Перейти к галактике
show_galaxy = "G"

# Scopely shortcut-native Galaxy Action
native_shortcut_galaxy = "CTRL-G"

# Перейти к подаркам
show_gifts = "/"

Expand Down
6 changes: 6 additions & 0 deletions example_community_patch_settings_tlh.toml
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,9 @@ show_daily = "Z"
# Go Daq Events
show_events = "SHIFT-E"

# Scopely shortcut-native Events Action
native_shortcut_events = "CTRL-E"

# Go Daq Exocomp
show_exocomp = "X"

Expand All @@ -464,6 +467,9 @@ show_factions = "F"
# Go Daq Galaxy
show_galaxy = "G"

# Scopely shortcut-native Galaxy Action
native_shortcut_galaxy = "CTRL-G"

# Go Daq Gifts
show_gifts = "/"

Expand Down
4 changes: 4 additions & 0 deletions mods/src/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,8 @@ void Config::Load()
parse_config_shortcut(config, parsed, "show_chatside1", GameFunction::ShowChatSide1, DCSH::show_chatside1);
parse_config_shortcut(config, parsed, "show_chatside2", GameFunction::ShowChatSide2, DCSH::show_chatside2);
parse_config_shortcut(config, parsed, "show_galaxy", GameFunction::ShowGalaxy, DCSH::show_galaxy);
parse_config_shortcut_aliases(config, parsed, "native_shortcut_galaxy", GameFunction::NativeShortcutGalaxy,
DCSH::native_shortcut_galaxy, {"show_galaxy_native"});
parse_config_shortcut(config, parsed, "show_system", GameFunction::ShowSystem, DCSH::show_system);
parse_config_shortcut(config, parsed, "zoom_preset1", GameFunction::ZoomPreset1, DCSH::zoom_preset1);
parse_config_shortcut(config, parsed, "zoom_preset2", GameFunction::ZoomPreset2, DCSH::zoom_preset2);
Expand Down Expand Up @@ -1261,6 +1263,8 @@ void Config::Load()
parse_config_shortcut(config, parsed, "show_commander", GameFunction::ShowCommander, DCSH::show_commander);
parse_config_shortcut(config, parsed, "show_daily", GameFunction::ShowDaily, DCSH::show_daily);
parse_config_shortcut(config, parsed, "show_events", GameFunction::ShowEvents, DCSH::show_events);
parse_config_shortcut(config, parsed, "native_shortcut_events", GameFunction::NativeShortcutEvents,
DCSH::native_shortcut_events);
parse_config_shortcut(config, parsed, "show_exocomp", GameFunction::ShowExoComp, DCSH::show_exocomp);
parse_config_shortcut(config, parsed, "show_factions", GameFunction::ShowFactions, DCSH::show_factions);
parse_config_shortcut(config, parsed, "show_inventory", GameFunction::ShowInventory, DCSH::show_inventory);
Expand Down
4 changes: 4 additions & 0 deletions mods/src/defaultconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ namespace Shortcuts
constexpr const char* set_zoom_preset3 = "SHIFT-F3";
constexpr const char* set_zoom_preset4 = "SHIFT-F4";
constexpr const char* set_zoom_preset5 = "SHIFT-F5";

constexpr const char* native_shortcut_events = "CTRL-E";
constexpr const char* native_shortcut_galaxy = "CTRL-G";

constexpr const char* show_alliance = "ALT-'";
constexpr const char* show_alliance_armada = "CTRL-'";
constexpr const char* show_alliance_help = "SHIFT-'";
Expand Down
2 changes: 2 additions & 0 deletions mods/src/patches/gamefunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ enum GameFunction {
ShowStationInterior,
ShoWStationExterior,
ShowGalaxy,
NativeShortcutGalaxy,
ShowSystem,
ShowChat,
ShowChatSide1,
ShowChatSide2,
ShowEvents,
NativeShortcutEvents,
ShowSettings,
ZoomPreset1,
ZoomPreset2,
Expand Down
50 changes: 50 additions & 0 deletions mods/src/patches/parts/hotkeys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "prime/ScanEngageButtonsWidget.h"
#include "prime/ScreenManager.h"
#include "prime/SelectableList.h"
#include "prime/ShortcutsManager.h"

#include "patches/key.h"
#include "patches/mapkey.h"
Expand All @@ -42,6 +43,7 @@

#include <EASTL/vector.h>

#include <cstdint>
#include <iostream>
#include <span>

Expand All @@ -52,6 +54,38 @@
static bool reset_focus_next_frame = false;
static int show_info_pending = 0;

static const MethodInfo* on_events_action = nullptr;
static const MethodInfo* on_galaxy_action = nullptr;

struct InputActionCallbackContext {
void* state;
int32_t action_index;
};

static_assert(sizeof(InputActionCallbackContext) == 16);

bool InvokeNativeShortcut(const MethodInfo* method, const char* action_name)
{
auto* shortcuts_manager = ShortcutsManager::Instance();
if (!shortcuts_manager || !method) {
spdlog::warn("[Hotkeys] native {} shortcut is unavailable", action_name);
return false;
}

// These callbacks do not inspect CallbackContext, but runtime_invoke still requires storage for the value-type
// argument. Using the managed invoker also avoids platform-specific by-value ABI assumptions.
InputActionCallbackContext context{};
void* args[]{&context};
Il2CppException* exception = nullptr;
il2cpp_runtime_invoke(method, shortcuts_manager, args, &exception);
if (exception) {
spdlog::warn("[Hotkeys] native {} shortcut raised exception={}", action_name, static_cast<void*>(exception));
return false;
}

return true;
}

bool force_space_action_next_frame = false;

void ChangeNavigationSection(SectionID sectionID);
Expand Down Expand Up @@ -399,6 +433,9 @@ void ScreenManager_Update_Hook(auto original, ScreenManager* _this)
return GotoSection(SectionID::Shop_MainFactions);
} else if (MapKey::IsDown(GameFunction::ShoWStationExterior)) {
return GotoSection(SectionID::Starbase_Exterior);
} else if (MapKey::IsDown(GameFunction::NativeShortcutGalaxy)) {
InvokeNativeShortcut(on_galaxy_action, "Galaxy");
return;
} else if (MapKey::IsDown(GameFunction::ShowGalaxy)) {
return ChangeNavigationSection(SectionID::Navigation_Galaxy);
} else if (MapKey::IsDown(GameFunction::ShowStationInterior)) {
Expand All @@ -423,6 +460,9 @@ void ScreenManager_Update_Hook(auto original, ScreenManager* _this)
return GotoSection(SectionID::FleetCommander_Management);
} else if (MapKey::IsDown(GameFunction::ShowAwayTeam)) {
return GotoSection(SectionID::Missions_AwayTeamsList);
} else if (MapKey::IsDown(GameFunction::NativeShortcutEvents)) {
InvokeNativeShortcut(on_events_action, "Events");
return;
} else if (MapKey::IsDown(GameFunction::ShowEvents)) {
return GotoSection(SectionID::Tournament_Group_Selection);
} else if (MapKey::IsDown(GameFunction::ShowExoComp)) {
Expand Down Expand Up @@ -1034,6 +1074,16 @@ void InstallHotkeyHooks()
if (!shortcuts_manager_helper.isValidHelper()) {
ErrorMsg::MissingHelper("GameInput", "ShortcutsManager");
} else {
on_events_action = shortcuts_manager_helper.GetMethodInfo("OnEventsAction", 1);
if (on_events_action == nullptr) {
ErrorMsg::MissingMethod("ShortcutsManager", "OnEventsAction");
}

on_galaxy_action = shortcuts_manager_helper.GetMethodInfo("OnGalaxyAction", 1);
if (on_galaxy_action == nullptr) {
ErrorMsg::MissingMethod("ShortcutsManager", "OnGalaxyAction");
}

auto ptr_can_user_shortcuts = shortcuts_manager_helper.GetMethod("InitializeActions");
if (ptr_can_user_shortcuts == nullptr) {
ErrorMsg::MissingMethod("ShortcutsManager", "InitializeActions");
Expand Down
Loading
Loading