diff --git a/UnleashedRecomp/mod/mod_loader.cpp b/UnleashedRecomp/mod/mod_loader.cpp index 2aecb3f..ebb275b 100644 --- a/UnleashedRecomp/mod/mod_loader.cpp +++ b/UnleashedRecomp/mod/mod_loader.cpp @@ -5,7 +5,9 @@ #include #include #include +#include #include +#include #include #include @@ -208,6 +210,42 @@ void ModLoader::Init() if (!mod.includeDirs.empty()) g_mods.emplace_back(std::move(mod)); } + + auto codeCount = modsDbIni.get("Codes", "CodeCount", 0); + + if (codeCount) + { + std::vector codes{}; + + for (size_t i = 0; i < codeCount; i++) + { + auto name = modsDbIni.getString("Codes", fmt::format("Code{}", i), ""); + + if (name.empty()) + continue; + + codes.push_back(name); + } + + for (auto& def : g_configDefinitions) + { + if (!def->IsHidden() || def->GetSection() != "Codes") + continue; + + /* NOTE: this is inefficient, but it happens + once on boot for a handful of codes at release + and is temporary until we support real code mods. */ + for (size_t i = 0; i < codes.size(); i++) + { + if (def->GetName() == codes[i]) + { + LOGFN("Loaded code: {}", codes[i]); + *(bool*)def->GetValue() = true; + break; + } + } + } + } } static constexpr uint32_t LZX_SIGNATURE = 0xFF512EE; diff --git a/UnleashedRecomp/patches/frontend_listener.cpp b/UnleashedRecomp/patches/frontend_listener.cpp index 249c8e5..6ec8c29 100644 --- a/UnleashedRecomp/patches/frontend_listener.cpp +++ b/UnleashedRecomp/patches/frontend_listener.cpp @@ -11,7 +11,7 @@ static class FrontendListener : public SDLEventListener public: bool OnSDLEvent(SDL_Event* event) override { - if (!Config::HUDToggleHotkey || OptionsMenu::s_isVisible) + if (!Config::HUDToggleKey || OptionsMenu::s_isVisible) return false; switch (event->type) diff --git a/UnleashedRecomp/patches/player_patches.cpp b/UnleashedRecomp/patches/player_patches.cpp index 807b1fe..3377c98 100644 --- a/UnleashedRecomp/patches/player_patches.cpp +++ b/UnleashedRecomp/patches/player_patches.cpp @@ -97,7 +97,7 @@ void PostUnleashMidAsmHook(PPCRegister& r30) void SetXButtonHomingMidAsmHook(PPCRegister& r30) { - r30.u32 = Config::HomingAttackOnBoost; + r30.u32 = !Config::HomingAttackOnJump; } // SWA::Player::CEvilSonicContext diff --git a/UnleashedRecomp/user/config_def.h b/UnleashedRecomp/user/config_def.h index 34335e8..611aff3 100644 --- a/UnleashedRecomp/user/config_def.h +++ b/UnleashedRecomp/user/config_def.h @@ -98,15 +98,15 @@ CONFIG_DEFINE_LOCALISED("Video", bool, XboxColorCorrection, false); CONFIG_DEFINE_ENUM_LOCALISED("Video", ECutsceneAspectRatio, CutsceneAspectRatio, ECutsceneAspectRatio::Original); CONFIG_DEFINE_ENUM_LOCALISED("Video", EUIAlignmentMode, UIAlignmentMode, EUIAlignmentMode::Edge); -CONFIG_DEFINE_HIDDEN("Exports", bool, AllowCancellingUnleash, false); -CONFIG_DEFINE_HIDDEN("Exports", bool, DisableAutoSaveWarning, false); -CONFIG_DEFINE_HIDDEN("Exports", bool, DisableDLCIcon, false); -CONFIG_DEFINE_HIDDEN("Exports", bool, DisableDWMRoundedCorners, false); -CONFIG_DEFINE_HIDDEN("Exports", bool, FixUnleashOutOfControlDrain, false); -CONFIG_DEFINE_HIDDEN("Exports", bool, HomingAttackOnBoost, true); -CONFIG_DEFINE_HIDDEN("Exports", bool, HUDToggleHotkey, false); -CONFIG_DEFINE_HIDDEN("Exports", bool, SaveScoreAtCheckpoints, false); -CONFIG_DEFINE_HIDDEN("Exports", bool, SkipIntroLogos, false); -CONFIG_DEFINE_HIDDEN("Exports", bool, UseOfficialTitleOnTitleBar, false); +CONFIG_DEFINE_HIDDEN("Codes", bool, AllowCancellingUnleash, false); +CONFIG_DEFINE_HIDDEN("Codes", bool, DisableAutoSaveWarning, false); +CONFIG_DEFINE_HIDDEN("Codes", bool, DisableDLCIcon, false); +CONFIG_DEFINE_HIDDEN("Codes", bool, DisableDWMRoundedCorners, false); +CONFIG_DEFINE_HIDDEN("Codes", bool, FixUnleashOutOfControlDrain, false); +CONFIG_DEFINE_HIDDEN("Codes", bool, HomingAttackOnJump, false); +CONFIG_DEFINE_HIDDEN("Codes", bool, HUDToggleKey, false); +CONFIG_DEFINE_HIDDEN("Codes", bool, SaveScoreAtCheckpoints, false); +CONFIG_DEFINE_HIDDEN("Codes", bool, SkipIntroLogos, false); +CONFIG_DEFINE_HIDDEN("Codes", bool, UseOfficialTitleOnTitleBar, false); CONFIG_DEFINE("Update", time_t, LastChecked, 0);