mirror of
https://github.com/Retropex/dolphin.git
synced 2025-06-02 15:32:33 +02:00
Core: Save the disabling of default enabled codes
The previous commit adjusted the code for loading and this commit adjusts the code for saving.
This commit is contained in:
parent
366cfd0f8c
commit
d77a9ad1b6
@ -266,6 +266,12 @@ std::vector<ARCode> LoadCodes(const IniFile& global_ini, const IniFile& local_in
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReadEnabledAndDisabled(*ini, "ActionReplay", &codes);
|
ReadEnabledAndDisabled(*ini, "ActionReplay", &codes);
|
||||||
|
|
||||||
|
if (ini == &global_ini)
|
||||||
|
{
|
||||||
|
for (ARCode& code : codes)
|
||||||
|
code.default_enabled = code.enabled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return codes;
|
return codes;
|
||||||
@ -275,21 +281,27 @@ void SaveCodes(IniFile* local_ini, const std::vector<ARCode>& codes)
|
|||||||
{
|
{
|
||||||
std::vector<std::string> lines;
|
std::vector<std::string> lines;
|
||||||
std::vector<std::string> enabled_lines;
|
std::vector<std::string> enabled_lines;
|
||||||
|
std::vector<std::string> disabled_lines;
|
||||||
|
|
||||||
for (const ActionReplay::ARCode& code : codes)
|
for (const ActionReplay::ARCode& code : codes)
|
||||||
{
|
{
|
||||||
if (code.enabled)
|
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)
|
if (code.user_defined)
|
||||||
{
|
{
|
||||||
lines.emplace_back("$" + code.name);
|
lines.emplace_back('$' + code.name);
|
||||||
for (const ActionReplay::AREntry& op : code.ops)
|
for (const ActionReplay::AREntry& op : code.ops)
|
||||||
{
|
{
|
||||||
lines.emplace_back(fmt::format("{:08X} {:08X}", op.cmd_addr, op.value));
|
lines.emplace_back(fmt::format("{:08X} {:08X}", op.cmd_addr, op.value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
local_ini->SetLines("ActionReplay_Enabled", enabled_lines);
|
local_ini->SetLines("ActionReplay_Enabled", enabled_lines);
|
||||||
|
local_ini->SetLines("ActionReplay_Disabled", disabled_lines);
|
||||||
local_ini->SetLines("ActionReplay", lines);
|
local_ini->SetLines("ActionReplay", lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ struct ARCode
|
|||||||
std::string name;
|
std::string name;
|
||||||
std::vector<AREntry> ops;
|
std::vector<AREntry> ops;
|
||||||
bool enabled = false;
|
bool enabled = false;
|
||||||
|
bool default_enabled = false;
|
||||||
bool user_defined = false;
|
bool user_defined = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ public:
|
|||||||
std::vector<std::string> notes;
|
std::vector<std::string> notes;
|
||||||
|
|
||||||
bool enabled = false;
|
bool enabled = false;
|
||||||
|
bool default_enabled = false;
|
||||||
bool user_defined = false;
|
bool user_defined = false;
|
||||||
|
|
||||||
bool Exist(u32 address, u32 data) const;
|
bool Exist(u32 address, u32 data) const;
|
||||||
|
@ -192,6 +192,12 @@ std::vector<GeckoCode> LoadCodes(const IniFile& globalIni, const IniFile& localI
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReadEnabledAndDisabled(*ini, "Gecko", &gcodes);
|
ReadEnabledAndDisabled(*ini, "Gecko", &gcodes);
|
||||||
|
|
||||||
|
if (ini == &globalIni)
|
||||||
|
{
|
||||||
|
for (GeckoCode& code : gcodes)
|
||||||
|
code.default_enabled = code.enabled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return gcodes;
|
return gcodes;
|
||||||
@ -210,12 +216,8 @@ static std::string MakeGeckoCodeTitle(const GeckoCode& code)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// used by the SaveGeckoCodes function
|
// used by the SaveGeckoCodes function
|
||||||
static void SaveGeckoCode(std::vector<std::string>& lines, std::vector<std::string>& enabledLines,
|
static void SaveGeckoCode(std::vector<std::string>& lines, const GeckoCode& gcode)
|
||||||
const GeckoCode& gcode)
|
|
||||||
{
|
{
|
||||||
if (gcode.enabled)
|
|
||||||
enabledLines.push_back('$' + gcode.name);
|
|
||||||
|
|
||||||
if (!gcode.user_defined)
|
if (!gcode.user_defined)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -235,14 +237,21 @@ static void SaveGeckoCode(std::vector<std::string>& lines, std::vector<std::stri
|
|||||||
void SaveCodes(IniFile& inifile, const std::vector<GeckoCode>& gcodes)
|
void SaveCodes(IniFile& inifile, const std::vector<GeckoCode>& gcodes)
|
||||||
{
|
{
|
||||||
std::vector<std::string> lines;
|
std::vector<std::string> lines;
|
||||||
std::vector<std::string> enabledLines;
|
std::vector<std::string> enabled_lines;
|
||||||
|
std::vector<std::string> disabled_lines;
|
||||||
|
|
||||||
for (const GeckoCode& geckoCode : gcodes)
|
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", lines);
|
||||||
inifile.SetLines("Gecko_Enabled", enabledLines);
|
inifile.SetLines("Gecko_Enabled", enabled_lines);
|
||||||
|
inifile.SetLines("Gecko_Disabled", disabled_lines);
|
||||||
}
|
}
|
||||||
} // namespace Gecko
|
} // namespace Gecko
|
||||||
|
@ -110,6 +110,12 @@ void LoadPatchSection(const std::string& section, std::vector<Patch>& patches, I
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReadEnabledAndDisabled(*ini, section, &patches);
|
ReadEnabledAndDisabled(*ini, section, &patches);
|
||||||
|
|
||||||
|
if (ini == &globalIni)
|
||||||
|
{
|
||||||
|
for (Patch& patch : patches)
|
||||||
|
patch.default_enabled = patch.enabled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ struct Patch
|
|||||||
std::string name;
|
std::string name;
|
||||||
std::vector<PatchEntry> entries;
|
std::vector<PatchEntry> entries;
|
||||||
bool enabled = false;
|
bool enabled = false;
|
||||||
|
bool default_enabled = false;
|
||||||
bool user_defined = false; // False if this code is shipped with Dolphin.
|
bool user_defined = false; // False if this code is shipped with Dolphin.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -129,21 +129,24 @@ void PatchesWidget::SavePatches()
|
|||||||
{
|
{
|
||||||
std::vector<std::string> lines;
|
std::vector<std::string> lines;
|
||||||
std::vector<std::string> lines_enabled;
|
std::vector<std::string> lines_enabled;
|
||||||
|
std::vector<std::string> lines_disabled;
|
||||||
|
|
||||||
for (const auto& patch : m_patches)
|
for (const auto& patch : m_patches)
|
||||||
{
|
{
|
||||||
if (patch.enabled)
|
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)
|
if (!patch.user_defined)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
lines.push_back("$" + patch.name);
|
lines.emplace_back('$' + patch.name);
|
||||||
|
|
||||||
for (const auto& entry : patch.entries)
|
for (const auto& entry : patch.entries)
|
||||||
{
|
{
|
||||||
lines.push_back(StringFromFormat("0x%08X:%s:0x%08X", entry.address,
|
lines.emplace_back(StringFromFormat("0x%08X:%s:0x%08X", entry.address,
|
||||||
PatchEngine::PatchTypeAsString(entry.type), entry.value));
|
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.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + m_game_id + ".ini");
|
||||||
|
|
||||||
game_ini_local.SetLines("OnFrame_Enabled", lines_enabled);
|
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.SetLines("OnFrame", lines);
|
||||||
|
|
||||||
game_ini_local.Save(File::GetUserPath(D_GAMESETTINGS_IDX) + m_game_id + ".ini");
|
game_ini_local.Save(File::GetUserPath(D_GAMESETTINGS_IDX) + m_game_id + ".ini");
|
||||||
|
Loading…
Reference in New Issue
Block a user