Skip to content

Commit 27f6f49

Browse files
MegamouseAniLeo
authored andcommitted
use "config/custom_configs/" for custom configs (backwards compatible)
1 parent 09a8f7a commit 27f6f49

File tree

9 files changed

+185
-102
lines changed

9 files changed

+185
-102
lines changed

rpcs3/Emu/System.cpp

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ void Emulator::LimitCacheSize()
586586
LOG_SUCCESS(GENERAL, "Cleaned disk cache, removed %.2f MB", size / 1024.0 / 1024.0);
587587
}
588588

589-
bool Emulator::BootGame(const std::string& path, bool direct, bool add_only)
589+
bool Emulator::BootGame(const std::string& path, bool direct, bool add_only, bool force_global_config)
590590
{
591591
if (g_cfg.vfs.limit_cache_size)
592592
LimitCacheSize();
@@ -603,7 +603,7 @@ bool Emulator::BootGame(const std::string& path, bool direct, bool add_only)
603603
if (direct && fs::exists(path))
604604
{
605605
m_path = path;
606-
Load(add_only);
606+
Load(add_only, force_global_config);
607607
return true;
608608
}
609609

@@ -614,7 +614,7 @@ bool Emulator::BootGame(const std::string& path, bool direct, bool add_only)
614614
if (fs::is_file(elf))
615615
{
616616
m_path = elf;
617-
Load(add_only);
617+
Load(add_only, force_global_config);
618618
return true;
619619
}
620620
}
@@ -697,12 +697,33 @@ std::string Emulator::GetSfoDirFromGamePath(const std::string& game_path, const
697697
return game_path;
698698
}
699699

700+
std::string Emulator::GetCustomConfigDir()
701+
{
702+
#ifdef _WIN32
703+
return fs::get_config_dir() + "config/custom_configs/";
704+
#else
705+
return fs::get_config_dir() + "custom_configs/";
706+
#endif
707+
}
708+
709+
std::string Emulator::GetCustomConfigPath(const std::string& title_id, bool get_deprecated_path)
710+
{
711+
std::string path;
712+
713+
if (get_deprecated_path)
714+
path = fs::get_config_dir() + "data/" + title_id + "/config.yml";
715+
else
716+
path = GetCustomConfigDir() + "config_" + title_id + ".yml";
717+
718+
return path;
719+
}
720+
700721
void Emulator::SetForceBoot(bool force_boot)
701722
{
702723
m_force_boot = force_boot;
703724
}
704725

705-
void Emulator::Load(bool add_only)
726+
void Emulator::Load(bool add_only, bool force_global_config)
706727
{
707728
if (!IsStopped())
708729
{
@@ -784,18 +805,31 @@ void Emulator::Load(bool add_only)
784805
LOG_NOTICE(LOADER, "Serial: %s", GetTitleID());
785806
LOG_NOTICE(LOADER, "Category: %s", GetCat());
786807

787-
// Load custom config-1
788-
if (fs::file cfg_file{fs::get_config_dir() + "data/" + m_title_id + "/config.yml"})
808+
if (!force_global_config)
789809
{
790-
LOG_NOTICE(LOADER, "Applying custom config: data/%s/config.yml", m_title_id);
791-
g_cfg.from_string(cfg_file.to_string());
792-
}
810+
const std::string config_path_new = GetCustomConfigPath(m_title_id);
811+
const std::string config_path_old = GetCustomConfigPath(m_title_id, true);
793812

794-
// Load custom config-2
795-
if (fs::file cfg_file{m_path + ".yml"})
796-
{
797-
LOG_NOTICE(LOADER, "Applying custom config: %s.yml", m_path);
798-
g_cfg.from_string(cfg_file.to_string());
813+
// Load custom config-1
814+
if (fs::file cfg_file{ config_path_old })
815+
{
816+
LOG_NOTICE(LOADER, "Applying custom config: %s", config_path_old);
817+
g_cfg.from_string(cfg_file.to_string());
818+
}
819+
820+
// Load custom config-2
821+
if (fs::file cfg_file{ config_path_new })
822+
{
823+
LOG_NOTICE(LOADER, "Applying custom config: %s", config_path_new);
824+
g_cfg.from_string(cfg_file.to_string());
825+
}
826+
827+
// Load custom config-3
828+
if (fs::file cfg_file{ m_path + ".yml" })
829+
{
830+
LOG_NOTICE(LOADER, "Applying custom config: %s.yml", m_path);
831+
g_cfg.from_string(cfg_file.to_string());
832+
}
799833
}
800834

801835
#if defined(_WIN32) || defined(HAVE_VULKAN)

rpcs3/Emu/System.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ class Emulator final
309309

310310
std::string PPUCache() const;
311311

312-
bool BootGame(const std::string& path, bool direct = false, bool add_only = false);
312+
bool BootGame(const std::string& path, bool direct = false, bool add_only = false, bool force_global_config = false);
313313
bool BootRsxCapture(const std::string& path);
314314
bool InstallPkg(const std::string& path);
315315

@@ -322,9 +322,12 @@ class Emulator final
322322
static std::string GetHddDir();
323323
static std::string GetSfoDirFromGamePath(const std::string& game_path, const std::string& user);
324324

325+
static std::string GetCustomConfigDir();
326+
static std::string GetCustomConfigPath(const std::string& title_id, bool get_deprecated_path = false);
327+
325328
void SetForceBoot(bool force_boot);
326329

327-
void Load(bool add_only = false);
330+
void Load(bool add_only = false, bool force_global_config = false);
328331
void Run();
329332
bool Pause();
330333
void Resume();

rpcs3/rpcs3qt/emu_settings.cpp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,12 @@ emu_settings::~emu_settings()
185185
{
186186
}
187187

188-
void emu_settings::LoadSettings(const std::string& path)
188+
void emu_settings::LoadSettings(const std::string& title_id)
189189
{
190-
m_path = path;
190+
m_title_id = title_id;
191191

192192
// Create config path if necessary
193-
fs::create_path(fs::get_config_dir() + path);
193+
fs::create_path(title_id.empty() ? fs::get_config_dir() : Emu.GetCustomConfigDir());
194194

195195
// Load default config
196196
m_defaultSettings = YAML::Load(g_cfg_defaults);
@@ -202,11 +202,23 @@ void emu_settings::LoadSettings(const std::string& path)
202202
config.close();
203203

204204
// Add game config
205-
if (!path.empty() && fs::is_file(fs::get_config_dir() + path + "/config.yml"))
205+
if (!title_id.empty())
206206
{
207-
config = fs::file(fs::get_config_dir() + path + "/config.yml", fs::read + fs::write);
208-
m_currentSettings += YAML::Load(config.to_string());
209-
config.close();
207+
const std::string config_path_new = Emu.GetCustomConfigPath(m_title_id);
208+
const std::string config_path_old = Emu.GetCustomConfigPath(m_title_id, true);
209+
210+
if (fs::is_file(config_path_new))
211+
{
212+
config = fs::file(config_path_new, fs::read + fs::write);
213+
m_currentSettings += YAML::Load(config.to_string());
214+
config.close();
215+
}
216+
else if (fs::is_file(config_path_old))
217+
{
218+
config = fs::file(config_path_old, fs::read + fs::write);
219+
m_currentSettings += YAML::Load(config.to_string());
220+
config.close();
221+
}
210222
}
211223
}
212224

@@ -216,9 +228,9 @@ void emu_settings::SaveSettings()
216228
YAML::Emitter out;
217229
emitData(out, m_currentSettings);
218230

219-
if (!m_path.empty())
231+
if (!m_title_id.empty())
220232
{
221-
config = fs::file(fs::get_config_dir() + m_path + "/config.yml", fs::read + fs::write + fs::create);
233+
config = fs::file(Emu.GetCustomConfigPath(m_title_id), fs::read + fs::write + fs::create);
222234
}
223235
else
224236
{

rpcs3/rpcs3qt/emu_settings.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#pragma once
1+
#pragma once
22

33
#include "Utilities/File.h"
44
#include "Utilities/Log.h"
@@ -223,7 +223,7 @@ class emu_settings : public QObject
223223
Render_Creator m_render_creator;
224224

225225
/** Loads the settings from path.*/
226-
void LoadSettings(const std::string& path = "");
226+
void LoadSettings(const std::string& title_id = "");
227227

228228
/** Fixes all registered invalid settings after asking the user for permission.*/
229229
void OpenCorrectionDialog(QWidget* parent = Q_NULLPTR);
@@ -355,5 +355,5 @@ public Q_SLOTS:
355355

356356
YAML::Node m_defaultSettings; // The default settings as a YAML node.
357357
YAML::Node m_currentSettings; // The current settings as a YAML node.
358-
std::string m_path;
358+
std::string m_title_id;
359359
};

0 commit comments

Comments
 (0)