mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
Move patch saving code to PatchEngine
This commit is contained in:
@ -7,8 +7,6 @@
|
||||
#include <QListWidget>
|
||||
#include <QPushButton>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/IniFile.h"
|
||||
#include "Common/StringUtil.h"
|
||||
@ -28,7 +26,7 @@ PatchesWidget::PatchesWidget(const UICommon::GameFile& game)
|
||||
|
||||
IniFile game_ini_default = SConfig::GetInstance().LoadDefaultGameIni(m_game_id, m_game_revision);
|
||||
|
||||
PatchEngine::LoadPatchSection("OnFrame", m_patches, game_ini_default, game_ini_local);
|
||||
PatchEngine::LoadPatchSection("OnFrame", &m_patches, game_ini_default, game_ini_local);
|
||||
|
||||
CreateWidgets();
|
||||
ConnectWidgets();
|
||||
@ -128,44 +126,12 @@ void PatchesWidget::OnRemove()
|
||||
|
||||
void PatchesWidget::SavePatches()
|
||||
{
|
||||
std::vector<std::string> lines;
|
||||
std::vector<std::string> lines_enabled;
|
||||
std::vector<std::string> lines_disabled;
|
||||
|
||||
for (const auto& patch : m_patches)
|
||||
{
|
||||
if (patch.enabled != patch.default_enabled)
|
||||
(patch.enabled ? lines_enabled : lines_disabled).emplace_back('$' + patch.name);
|
||||
|
||||
if (!patch.user_defined)
|
||||
continue;
|
||||
|
||||
lines.emplace_back('$' + patch.name);
|
||||
|
||||
for (const auto& entry : patch.entries)
|
||||
{
|
||||
if (!entry.conditional)
|
||||
{
|
||||
lines.emplace_back(fmt::format("0x{:08X}:{}:0x{:08X}", entry.address,
|
||||
PatchEngine::PatchTypeAsString(entry.type), entry.value));
|
||||
}
|
||||
else
|
||||
{
|
||||
lines.emplace_back(fmt::format("0x{:08X}:{}:0x{:08X}:0x{:08X}", entry.address,
|
||||
PatchEngine::PatchTypeAsString(entry.type), entry.value,
|
||||
entry.comparand));
|
||||
}
|
||||
}
|
||||
}
|
||||
const std::string ini_path = File::GetUserPath(D_GAMESETTINGS_IDX) + m_game_id + ".ini";
|
||||
|
||||
IniFile game_ini_local;
|
||||
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");
|
||||
game_ini_local.Load(ini_path);
|
||||
PatchEngine::SavePatchSection(&game_ini_local, m_patches);
|
||||
game_ini_local.Save(ini_path);
|
||||
}
|
||||
|
||||
void PatchesWidget::Update()
|
||||
|
Reference in New Issue
Block a user