From 60b051a74ce81649e4b3a15eb891e2da3adc655b Mon Sep 17 00:00:00 2001 From: kalaposfos13 <153381648+kalaposfos13@users.noreply.github.com> Date: Mon, 2 Mar 2026 17:58:41 +0100 Subject: [PATCH] actually make game specific configs load and fix the issue with autosave --- src/core/emulator_settings.cpp | 10 ++++++++-- src/core/emulator_settings.h | 6 ++++-- src/emulator.cpp | 12 +++--------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/core/emulator_settings.cpp b/src/core/emulator_settings.cpp index a3f63d0e2..71a0dd051 100644 --- a/src/core/emulator_settings.cpp +++ b/src/core/emulator_settings.cpp @@ -6,8 +6,10 @@ #include #include #include +#include #include "common/logging/log.h" #include "emulator_settings.h" +#include "emulator_state.h" using json = nlohmann::json; @@ -189,7 +191,7 @@ void EmulatorSettings::ResetGameSpecificValue(const std::string& key) { LOG_WARNING(EmuSettings, "ResetGameSpecificValue: key '{}' not found", key); } -bool EmulatorSettings::Save(const std::string& serial) const { +bool EmulatorSettings::Save(const std::string& serial) { try { if (!serial.empty()) { const auto cfgDir = Common::FS::GetUserPath(Common::FS::PathType::CustomConfigs); @@ -235,6 +237,7 @@ bool EmulatorSettings::Save(const std::string& serial) const { const auto path = Common::FS::GetUserPath(Common::FS::PathType::UserDir) / "config.json"; + SetConfigVersion(Common::g_scm_rev); json j; j["General"] = m_general; j["Debug"] = m_debug; @@ -297,7 +300,9 @@ bool EmulatorSettings::Load(const std::string& serial) { Save(); } return true; - + if (GetConfigVersion() != Common::g_scm_rev) { + Save(); + } } else { // ── Per-game override file ───────────────────────────────── // Never reloads global settings. Only applies @@ -341,6 +346,7 @@ bool EmulatorSettings::Load(const std::string& serial) { ApplyGroupOverrides(m_vulkan, gj.at("Vulkan"), changed); PrintChangedSummary(changed); + EmulatorState::GetInstance()->SetGameSpecifigConfigUsed(true); return true; } } catch (const std::exception& e) { diff --git a/src/core/emulator_settings.h b/src/core/emulator_settings.h index 976e18c8b..90c7f0126 100644 --- a/src/core/emulator_settings.h +++ b/src/core/emulator_settings.h @@ -202,6 +202,7 @@ struct DebugSettings { Setting debug_dump{false}; // specific Setting shader_collect{false}; // specific Setting log_enabled{true}; // specific + Setting config_version{""}; // specific std::vector GetOverrideableFields() const { return std::vector{ @@ -213,7 +214,7 @@ struct DebugSettings { } }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(DebugSettings, separate_logging_enabled, debug_dump, - shader_collect, log_enabled) + shader_collect, log_enabled, config_version) // ------------------------------- // Input settings @@ -383,7 +384,7 @@ public: static std::shared_ptr GetInstance(); static void SetInstance(std::shared_ptr instance); - bool Save(const std::string& serial = "") const; + bool Save(const std::string& serial = ""); bool Load(const std::string& serial = ""); void SetDefaultValues(); @@ -536,6 +537,7 @@ public: SETTING_FORWARD_BOOL(m_debug, DebugDump, debug_dump) SETTING_FORWARD_BOOL(m_debug, ShaderCollect, shader_collect) SETTING_FORWARD_BOOL(m_debug, LogEnabled, log_enabled) + SETTING_FORWARD(m_debug, ConfigVersion, config_version) // GPU Settings SETTING_FORWARD_BOOL(m_gpu, NullGPU, null_gpu) diff --git a/src/emulator.cpp b/src/emulator.cpp index d10311727..43d81c727 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -209,12 +209,7 @@ void Emulator::Run(std::filesystem::path file, std::vector args, Config::load(Common::FS::GetUserPath(Common::FS::PathType::CustomConfigs) / (id + ".toml"), true); - if (std::filesystem::exists(Common::FS::GetUserPath(Common::FS::PathType::CustomConfigs) / - (id + ".toml"))) { - EmulatorState::GetInstance()->SetGameSpecifigConfigUsed(true); - } else { - EmulatorState::GetInstance()->SetGameSpecifigConfigUsed(false); - } + EmulatorSettings::GetInstance()->Load(id); // Initialize logging as soon as possible if (!id.empty() && EmulatorSettings::GetInstance()->IsSeparateLoggingEnabled()) { @@ -235,9 +230,8 @@ void Emulator::Run(std::filesystem::path file, std::vector args, LOG_INFO(Loader, "Description {}", Common::g_scm_desc); LOG_INFO(Loader, "Remote {}", Common::g_scm_remote_url); - const bool has_game_config = std::filesystem::exists( - Common::FS::GetUserPath(Common::FS::PathType::CustomConfigs) / (id + ".toml")); - LOG_INFO(Config, "Game-specific config exists: {}", has_game_config); + LOG_INFO(Config, "Game-specific config used: {}", + EmulatorState::GetInstance()->IsGameSpecifigConfigUsed()); LOG_INFO(Config, "General LogType: {}", EmulatorSettings::GetInstance()->GetLogType()); LOG_INFO(Config, "General isIdenticalLogGrouped: {}",