cheat_manager: move cheats.yml to patches folder

This commit is contained in:
Megamouse 2020-07-22 22:02:07 +02:00
parent cb6e536fbd
commit d0bb9d2b62
3 changed files with 15 additions and 9 deletions

View File

@ -57,7 +57,7 @@ void fmt_class_string<patch_type>::format(std::string& out, u64 arg)
patch_engine::patch_engine()
{
const std::string patches_path = fs::get_config_dir() + "patches/";
const std::string patches_path = get_patches_path();
if (!fs::create_path(patches_path))
{
@ -89,7 +89,7 @@ std::string patch_engine::get_patches_path()
std::string patch_engine::get_imported_patch_path()
{
return fs::get_config_dir() + "patches/imported_patch.yml";
return get_patches_path() + "imported_patch.yml";
}
static void append_log_message(std::stringstream* log_messages, const std::string& message)
@ -554,7 +554,7 @@ void patch_engine::append_global_patches()
load(m_map, fs::get_config_dir() + "patch.yml");
// New patch.yml
load(m_map, fs::get_config_dir() + "patches/patch.yml");
load(m_map, get_patches_path() + "patch.yml");
// Imported patch.yml
load(m_map, get_imported_patch_path());
@ -571,7 +571,7 @@ void patch_engine::append_title_patches(const std::string& title_id)
load(m_map, fs::get_config_dir() + "data/" + title_id + "/patch.yml");
// New patch.yml
load(m_map, fs::get_config_dir() + "patches/" + title_id + "_patch.yml");
load(m_map, get_patches_path() + title_id + "_patch.yml");
}
std::size_t patch_engine::apply(const std::string& name, u8* dst)

View File

@ -19,6 +19,7 @@
#include "util/yaml.hpp"
#include "Utilities/StrUtil.h"
#include "Utilities/bin_patch.h" // get_patches_path()
LOG_CHANNEL(log_cheat, "Cheat");
@ -109,13 +110,16 @@ std::string cheat_info::to_str() const
cheat_engine::cheat_engine()
{
if (fs::file cheat_file{fs::get_config_dir() + cheats_filename, fs::read + fs::create})
const std::string path = patch_engine::get_patches_path() + m_cheats_filename;
if (fs::file cheat_file{path, fs::read + fs::create})
{
auto [yml_cheats, error] = yaml_load(cheat_file.to_string());
if (!error.empty())
{
log_cheat.error("Error parsing %s: %s", cheats_filename, error);
log_cheat.error("Error parsing %s: %s", path, error);
return;
}
for (const auto& yml_cheat : yml_cheats)
@ -133,13 +137,15 @@ cheat_engine::cheat_engine()
}
else
{
log_cheat.error("Error loading %s", cheats_filename);
log_cheat.error("Error loading %s", path);
}
}
void cheat_engine::save() const
{
fs::file cheat_file(fs::get_config_dir() + cheats_filename, fs::rewrite);
const std::string path = patch_engine::get_patches_path() + m_cheats_filename;
fs::file cheat_file(path, fs::rewrite);
if (!cheat_file)
return;

View File

@ -67,7 +67,7 @@ public:
std::map<std::string, std::map<u32, cheat_info>> cheats;
private:
const std::string cheats_filename = "/cheats.yml";
const std::string m_cheats_filename = "cheats.yml";
};
class cheat_manager_dialog : public QDialog