diff --git a/Source/Core/Core/ActionReplay.cpp b/Source/Core/Core/ActionReplay.cpp index 24e54259e3..f3641f72bc 100644 --- a/Source/Core/Core/ActionReplay.cpp +++ b/Source/Core/Core/ActionReplay.cpp @@ -266,6 +266,12 @@ std::vector LoadCodes(const IniFile& global_ini, const IniFile& local_in } ReadEnabledAndDisabled(*ini, "ActionReplay", &codes); + + if (ini == &global_ini) + { + for (ARCode& code : codes) + code.default_enabled = code.enabled; + } } return codes; @@ -275,21 +281,27 @@ void SaveCodes(IniFile* local_ini, const std::vector& codes) { std::vector lines; std::vector enabled_lines; + std::vector disabled_lines; + for (const ActionReplay::ARCode& code : codes) { if (code.enabled) - enabled_lines.emplace_back("$" + code.name); + enabled_lines.emplace_back('$' + code.name); + else if (code.default_enabled) + disabled_lines.emplace_back('$' + code.name); if (code.user_defined) { - lines.emplace_back("$" + code.name); + lines.emplace_back('$' + code.name); for (const ActionReplay::AREntry& op : code.ops) { lines.emplace_back(fmt::format("{:08X} {:08X}", op.cmd_addr, op.value)); } } } + local_ini->SetLines("ActionReplay_Enabled", enabled_lines); + local_ini->SetLines("ActionReplay_Disabled", disabled_lines); local_ini->SetLines("ActionReplay", lines); } diff --git a/Source/Core/Core/ActionReplay.h b/Source/Core/Core/ActionReplay.h index bd93503f52..e79c6d4f38 100644 --- a/Source/Core/Core/ActionReplay.h +++ b/Source/Core/Core/ActionReplay.h @@ -29,6 +29,7 @@ struct ARCode std::string name; std::vector ops; bool enabled = false; + bool default_enabled = false; bool user_defined = false; }; diff --git a/Source/Core/Core/GeckoCode.h b/Source/Core/Core/GeckoCode.h index 9c6c7c7a14..74d750bcf4 100644 --- a/Source/Core/Core/GeckoCode.h +++ b/Source/Core/Core/GeckoCode.h @@ -29,6 +29,7 @@ public: std::vector notes; bool enabled = false; + bool default_enabled = false; bool user_defined = false; bool Exist(u32 address, u32 data) const; diff --git a/Source/Core/Core/GeckoCodeConfig.cpp b/Source/Core/Core/GeckoCodeConfig.cpp index 32ea337af3..605fb82533 100644 --- a/Source/Core/Core/GeckoCodeConfig.cpp +++ b/Source/Core/Core/GeckoCodeConfig.cpp @@ -192,6 +192,12 @@ std::vector LoadCodes(const IniFile& globalIni, const IniFile& localI } ReadEnabledAndDisabled(*ini, "Gecko", &gcodes); + + if (ini == &globalIni) + { + for (GeckoCode& code : gcodes) + code.default_enabled = code.enabled; + } } return gcodes; @@ -210,12 +216,8 @@ static std::string MakeGeckoCodeTitle(const GeckoCode& code) } // used by the SaveGeckoCodes function -static void SaveGeckoCode(std::vector& lines, std::vector& enabledLines, - const GeckoCode& gcode) +static void SaveGeckoCode(std::vector& lines, const GeckoCode& gcode) { - if (gcode.enabled) - enabledLines.push_back('$' + gcode.name); - if (!gcode.user_defined) return; @@ -235,14 +237,21 @@ static void SaveGeckoCode(std::vector& lines, std::vector& gcodes) { std::vector lines; - std::vector enabledLines; + std::vector enabled_lines; + std::vector disabled_lines; for (const GeckoCode& geckoCode : gcodes) { - SaveGeckoCode(lines, enabledLines, geckoCode); + if (geckoCode.enabled) + enabled_lines.emplace_back('$' + geckoCode.name); + else if (geckoCode.default_enabled) + disabled_lines.emplace_back('$' + geckoCode.name); + + SaveGeckoCode(lines, geckoCode); } inifile.SetLines("Gecko", lines); - inifile.SetLines("Gecko_Enabled", enabledLines); + inifile.SetLines("Gecko_Enabled", enabled_lines); + inifile.SetLines("Gecko_Disabled", disabled_lines); } } // namespace Gecko diff --git a/Source/Core/Core/PatchEngine.cpp b/Source/Core/Core/PatchEngine.cpp index 3e395fdc6c..4f4daafcd7 100644 --- a/Source/Core/Core/PatchEngine.cpp +++ b/Source/Core/Core/PatchEngine.cpp @@ -110,6 +110,12 @@ void LoadPatchSection(const std::string& section, std::vector& patches, I } ReadEnabledAndDisabled(*ini, section, &patches); + + if (ini == &globalIni) + { + for (Patch& patch : patches) + patch.default_enabled = patch.enabled; + } } } diff --git a/Source/Core/Core/PatchEngine.h b/Source/Core/Core/PatchEngine.h index 97386b6a9a..a496f04936 100644 --- a/Source/Core/Core/PatchEngine.h +++ b/Source/Core/Core/PatchEngine.h @@ -34,6 +34,7 @@ struct Patch std::string name; std::vector entries; bool enabled = false; + bool default_enabled = false; bool user_defined = false; // False if this code is shipped with Dolphin. }; diff --git a/Source/Core/DolphinQt/Config/PatchesWidget.cpp b/Source/Core/DolphinQt/Config/PatchesWidget.cpp index 724780e199..1ac7f55154 100644 --- a/Source/Core/DolphinQt/Config/PatchesWidget.cpp +++ b/Source/Core/DolphinQt/Config/PatchesWidget.cpp @@ -129,21 +129,24 @@ void PatchesWidget::SavePatches() { std::vector lines; std::vector lines_enabled; + std::vector lines_disabled; for (const auto& patch : m_patches) { if (patch.enabled) - lines_enabled.push_back("$" + patch.name); + lines_enabled.emplace_back('$' + patch.name); + else if (patch.default_enabled) + lines_disabled.emplace_back('$' + patch.name); if (!patch.user_defined) continue; - lines.push_back("$" + patch.name); + lines.emplace_back('$' + patch.name); for (const auto& entry : patch.entries) { - lines.push_back(StringFromFormat("0x%08X:%s:0x%08X", entry.address, - PatchEngine::PatchTypeAsString(entry.type), entry.value)); + lines.emplace_back(StringFromFormat("0x%08X:%s:0x%08X", entry.address, + PatchEngine::PatchTypeAsString(entry.type), entry.value)); } } @@ -151,6 +154,7 @@ void PatchesWidget::SavePatches() game_ini_local.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + m_game_id + ".ini"); game_ini_local.SetLines("OnFrame_Enabled", lines_enabled); + game_ini_local.SetLines("OnFrame_Disabled", lines_disabled); game_ini_local.SetLines("OnFrame", lines); game_ini_local.Save(File::GetUserPath(D_GAMESETTINGS_IDX) + m_game_id + ".ini");