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
2 changes: 2 additions & 0 deletions example_community_patch_settings_da.toml
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,8 @@ zoom_reset = "="
# <[=================================================================================]>

[ui]
# Hide artifact shards "Exchange All"; individual exchanges remain available. Requires restart.
hide_artifact_exchange_all = false
# Spring animationen ved åbning af kasser over, og åbn blot kasserne
always_skip_reveal_sequence = true
auto_confirm_discovery = true
Expand Down
2 changes: 2 additions & 0 deletions example_community_patch_settings_de.toml
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,8 @@ zoom_reset = "="
# <[==================================================================================================================================]>

[ui]
# Blendet "Alle umtauschen" bei Artefaktfragmenten aus; einzelne Tauschvorgänge bleiben verfügbar. Neustart erforderlich.
hide_artifact_exchange_all = false
# Überspringt die Animation und öffnet die Boxen direkt
always_skip_reveal_sequence = true
auto_confirm_discovery = true
Expand Down
2 changes: 2 additions & 0 deletions example_community_patch_settings_en-GB-x-cockney.toml
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,8 @@ zoom_reset = "="
# <[===================================================================]>

[ui]
# Hide artifact shards "Exchange All"; individual exchanges remain available. Requires restart.
hide_artifact_exchange_all = false
# Skip the reveal box animation, and just open the boxes
always_skip_reveal_sequence = true
auto_confirm_discovery = true
Expand Down
2 changes: 2 additions & 0 deletions example_community_patch_settings_en-x-minionese.toml
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,8 @@ zoom_reset = "="
# <[==================]>

[ui]
# Hide artifact shards "Exchange All"; individual exchanges remain available. Requires restart.
hide_artifact_exchange_all = false
# Skip the reveal box animation, and just open the boxes
always_skip_reveal_sequence = true
auto_confirm_discovery = true
Expand Down
4 changes: 4 additions & 0 deletions example_community_patch_settings_en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ loadingtiphooks = true
doubleclickassignshiphooks = true
forbiddentechconfirmhooks = true
audioeventhooks = true
# Install the artifact popup hook independently of the hide preference.
artifactexchangehooks = true
freeresizehooks = true
game_version = true
giftsbulkclaimhooks = true
Expand Down Expand Up @@ -648,6 +650,8 @@ zoom_reset = "="
# <[===================================================================]>

[ui]
# Hide artifact shards "Exchange All"; individual exchanges remain available. Requires restart.
hide_artifact_exchange_all = false
# Skip the reveal box animation, and just open the boxes
always_skip_reveal_sequence = true
auto_confirm_discovery = true
Expand Down
2 changes: 2 additions & 0 deletions example_community_patch_settings_es.toml
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,8 @@ zoom_reset = "="
# <[============================================================]>

[ui]
# Hide artifact shards "Exchange All"; individual exchanges remain available. Requires restart.
hide_artifact_exchange_all = false
# Omite la animación de revelado de cajas y simplemente ábrelas
always_skip_reveal_sequence = true
auto_confirm_discovery = true
Expand Down
2 changes: 2 additions & 0 deletions example_community_patch_settings_fr.toml
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,8 @@ zoom_reset = "="
# <[===================================================================]>

[ui]
# Masque "Tout échanger" pour les fragments d’artefacts ; les échanges individuels restent disponibles. Redémarrage requis.
hide_artifact_exchange_all = false
# Ignorer l'animation d'ouverture des coffres et les ouvrir directement
always_skip_reveal_sequence = true
auto_confirm_discovery = true
Expand Down
2 changes: 2 additions & 0 deletions example_community_patch_settings_nl.toml
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,8 @@ zoom_reset = "="
# <[===================================================================]>

[ui]
# Verberg "Alles inwisselen" voor artefactfragmenten; afzonderlijk inwisselen blijft beschikbaar. Herstart vereist.
hide_artifact_exchange_all = false
# Slaat de onthullig animatie van een kist altijd over en opent gewoon de kist
always_skip_reveal_sequence = true
auto_confirm_discovery = true
Expand Down
2 changes: 2 additions & 0 deletions example_community_patch_settings_ru.toml
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,8 @@ zoom_reset = "="
# <[===================================================================]>

[ui]
# Hide artifact shards "Exchange All"; individual exchanges remain available. Requires restart.
hide_artifact_exchange_all = false
# Пропускать анимацию открытия контейнеров и сразу открывать их
always_skip_reveal_sequence = true
auto_confirm_discovery = true
Expand Down
2 changes: 2 additions & 0 deletions example_community_patch_settings_tlh.toml
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,8 @@ zoom_reset = "="
# <[========================================================================================]>

[ui]
# Hide artifact shards "Exchange All"; individual exchanges remain available. Requires restart.
hide_artifact_exchange_all = false
# Skip reveal box animation, 'ej just poSmoH boxes
always_skip_reveal_sequence = true
auto_confirm_discovery = true
Expand Down
5 changes: 5 additions & 0 deletions mods/src/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,8 @@ void Config::Load()
get_config_or_default(config, parsed, "patches", "doubleclickassignshiphooks", DCP::doubleclickassignshiphooks, write_config);
this->installForbiddenTechConfirmationHooks =
get_config_or_default(config, parsed, "patches", "forbiddentechconfirmhooks", DCP::forbiddentechconfirmhooks, write_config);
this->installArtifactExchangeHooks =
get_config_or_default(config, parsed, "patches", "artifactexchangehooks", DCP::artifactexchangehooks, write_config);
this->installAudioEventHooks =
get_config_or_default(config, parsed, "patches", "audioeventhooks", DCP::audioeventhooks, write_config);
this->installInstantCargoCounterHooks =
Expand Down Expand Up @@ -1114,6 +1116,9 @@ void Config::Load()
get_mission_hud_visibility(config, parsed, "hud_daily_goals", DCU::hud_daily_goals, write_config));
this->mission_hud_buttons.emplace(
"missions", get_mission_hud_visibility(config, parsed, "hud_missions", DCU::hud_missions, write_config));
this->hide_artifact_exchange_all = get_config_or_default(
config, parsed, "ui", "hide_artifact_exchange_all", DCU::hide_artifact_exchange_all, write_config);

spdlog::debug("");

this->sync_debug = get_config_or_default(config, parsed, "sync", "debug", DCS::debug, write_config);
Expand Down
2 changes: 2 additions & 0 deletions mods/src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ class Config final
bool installTestPatches;
bool installMiscPatches;
bool installMissionHudTweaksHooks;
bool hide_artifact_exchange_all;
bool installChatPatches;
bool installSyncPatches;
bool installGameVersionHook;
Expand All @@ -278,6 +279,7 @@ class Config final
bool installForbiddenTechConfirmationHooks;
bool installInstantWarpConfirmationHooks;
bool installAudioEventHooks;
bool installArtifactExchangeHooks;

std::string config_settings_url;
std::string config_assets_url_override;
Expand Down
2 changes: 2 additions & 0 deletions mods/src/defaultconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ namespace Patches
constexpr bool doubleclickassignshiphooks = true;
constexpr bool forbiddentechconfirmhooks = true;
constexpr bool audioeventhooks = true;
constexpr bool artifactexchangehooks = true;
constexpr bool instantcargocounterhooks = true;
constexpr bool cargoformathooks = true; // on by default: cargo number precision override
constexpr bool officersorthooks = true; // restore Below Deck Ability sort option
Expand Down Expand Up @@ -241,6 +242,7 @@ namespace Sync

namespace UI
{
constexpr bool hide_artifact_exchange_all = false;
constexpr bool always_skip_reveal_sequence = true;
constexpr bool arrow_keys_to_select_ship = true;
constexpr bool auto_confirm_discovery = true;
Expand Down
44 changes: 44 additions & 0 deletions mods/src/il2cpp/method_contract.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#pragma once

#include "il2cpp-functions.h"
#include <il2cpp-tabledefs.h>
#include <cstring>
#include <initializer_list>

namespace method_contract
{
inline bool Type(const Il2CppType* type, const char* name)
{
if (!type || type->byref) return false;
auto* actual = il2cpp_type_get_name(type);
const bool matches = actual && std::strcmp(actual, name) == 0;
il2cpp_free(actual);
return matches;
}

// Resolve the entire managed signature, including static/instance dispatch.
// A renamed, ambiguous or generic method is not a compatible callback.
inline const MethodInfo* Resolve(Il2CppClass* cls, const char* name, bool is_static,
const char* result, std::initializer_list<const char*> parameters)
{
if (!cls) return nullptr;
const MethodInfo* found = nullptr;
void* iterator = nullptr;
while (auto* method = il2cpp_class_get_methods(cls, &iterator)) {
if (std::strcmp(method->name, name) != 0 || !method->methodPointer || method->is_generic || method->is_inflated
|| bool(method->flags & METHOD_ATTRIBUTE_STATIC) != is_static
|| method->parameters_count != parameters.size() || !Type(method->return_type, result)) continue;
bool matches = true;
unsigned i = 0;
for (auto* parameter : parameters)
matches = Type(method->parameters[i++], parameter) && matches;
if (!matches) continue;
if (found) return nullptr;
found = method;
}
return found;
}

inline void* Pointer(const MethodInfo* method)
{ return method ? reinterpret_cast<void*>(method->methodPointer) : nullptr; }
} // namespace method_contract
59 changes: 59 additions & 0 deletions mods/src/patches/parts/artifact_exchange.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#include "config.h"

#include <il2cpp/il2cpp_helper.h>
#include <il2cpp/method_contract.h>
#include <il2cpp/runtime.h>
#include <spdlog/spdlog.h>
#include <spud/detour.h>

namespace
{
FieldInfo* convert_all_field = nullptr;
const MethodInfo* get_game_object = nullptr;
const MethodInfo* set_active = nullptr;

void InventoryUsePopup_Bind_Hook(auto original, void* controller)
{
original(controller);
if (!Config::Get().hide_artifact_exchange_all || !controller)
return;
Il2CppObject* button = nullptr;
il2cpp_field_get_value(static_cast<Il2CppObject*>(controller), convert_all_field, &button);
Il2CppObject* object = nullptr;
if (!button || !Il2CppRuntime::TryInvoke(get_game_object, button, nullptr, &object) || !object)
return;
bool active = false;
void* args[]{&active};
Il2CppRuntime::TryInvoke(set_active, object, args);
}
} // namespace

void InstallArtifactExchangeHooks()
{
// This dedicated field belongs to artifact bulk conversion, not the inventory
// entry button or individual exchanges. Preserve native binding first.
auto controller =
il2cpp_get_class_helper("Assembly-CSharp", "Digit.Prime.Inventories", "InventoryUsePopupViewController");
auto component = il2cpp_get_class_helper("UnityEngine.CoreModule", "UnityEngine", "Component");
auto game_object = il2cpp_get_class_helper("UnityEngine.CoreModule", "UnityEngine", "GameObject");
auto* cls = controller.get_cls();
auto* field = cls ? il2cpp_class_get_field_from_name(cls, "_convertAllButton") : nullptr;
auto* field_class = field && field->type ? il2cpp_class_from_type(field->type) : nullptr;
const auto* bind = method_contract::Resolve(cls, "OnDidBindCanvasContext", false, "System.Void", {});
get_game_object = method_contract::Resolve(component.get_cls(), "get_gameObject", false, "UnityEngine.GameObject", {});
set_active = method_contract::Resolve(game_object.get_cls(), "SetActive", false, "System.Void", {"System.Boolean"});
if (!cls || !component.get_cls() || !game_object.get_cls() || !field || !field->type || field->type->byref
|| (il2cpp_field_get_flags(field) & FIELD_ATTRIBUTE_STATIC) || !field_class
|| !il2cpp_class_is_assignable_from(component.get_cls(), field_class)
|| !bind || !get_game_object || !set_active
|| bind->has_full_generic_sharing_signature || get_game_object->has_full_generic_sharing_signature
|| set_active->has_full_generic_sharing_signature) {
spdlog::warn("[ArtifactExchange] required popup API unavailable; leaving game unchanged");
return;
}
convert_all_field = field;
if (SPUD_STATIC_DETOUR(bind->methodPointer, InventoryUsePopup_Bind_Hook))
spdlog::info("[ArtifactExchange] installed popup bind hook");
else
spdlog::warn("[ArtifactExchange] popup bind hook was not installed");
}
2 changes: 2 additions & 0 deletions mods/src/patches/patches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ void InstallDailyFactionBulkClaimHooks();
void InstallTestPatches();
void InstallMiscPatches();
void InstallMissionHudTweaksHooks();
void InstallArtifactExchangeHooks();
void InstallChatPatches();
void InstallTempCrashFixes();
void InstallSyncPatches();
Expand Down Expand Up @@ -137,6 +138,7 @@ __int64 il2cpp_init_hook(auto original, const char* domain_name)
{"TestPatches", {InstallTestPatches, &cfg.installTestPatches}},
{"MiscPatches", {InstallMiscPatches, &cfg.installMiscPatches}},
{"MissionHudTweaksHooks", {InstallMissionHudTweaksHooks, &cfg.installMissionHudTweaksHooks}},
{"ArtifactExchangeHooks", {InstallArtifactExchangeHooks, &cfg.installArtifactExchangeHooks}},
{"ChatPatches", {InstallChatPatches, &cfg.installChatPatches}},
{"SyncPatches", {InstallSyncPatches, &cfg.installSyncPatches}},
{"ObjectTracker", {InstallObjectTrackers, &cfg.installObjectTracker}},
Expand Down
Loading