mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-04-15 14:21:35 -06:00
actually make game specific configs load and fix the issue with autosave
This commit is contained in:
parent
5970ab6ee2
commit
60b051a74c
@ -6,8 +6,10 @@
|
||||
#include <iomanip>
|
||||
#include <map>
|
||||
#include <common/path_util.h>
|
||||
#include <common/scm_rev.h>
|
||||
#include "common/logging/log.h"
|
||||
#include "emulator_settings.h"
|
||||
#include "emulator_state.h"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
@ -189,7 +191,7 @@ void EmulatorSettings::ResetGameSpecificValue(const std::string& key) {
|
||||
LOG_WARNING(EmuSettings, "ResetGameSpecificValue: key '{}' not found", key);
|
||||
}
|
||||
|
||||
bool EmulatorSettings::Save(const std::string& serial) const {
|
||||
bool EmulatorSettings::Save(const std::string& serial) {
|
||||
try {
|
||||
if (!serial.empty()) {
|
||||
const auto cfgDir = Common::FS::GetUserPath(Common::FS::PathType::CustomConfigs);
|
||||
@ -235,6 +237,7 @@ bool EmulatorSettings::Save(const std::string& serial) const {
|
||||
const auto path =
|
||||
Common::FS::GetUserPath(Common::FS::PathType::UserDir) / "config.json";
|
||||
|
||||
SetConfigVersion(Common::g_scm_rev);
|
||||
json j;
|
||||
j["General"] = m_general;
|
||||
j["Debug"] = m_debug;
|
||||
@ -297,7 +300,9 @@ bool EmulatorSettings::Load(const std::string& serial) {
|
||||
Save();
|
||||
}
|
||||
return true;
|
||||
|
||||
if (GetConfigVersion() != Common::g_scm_rev) {
|
||||
Save();
|
||||
}
|
||||
} else {
|
||||
// ── Per-game override file ─────────────────────────────────
|
||||
// Never reloads global settings. Only applies
|
||||
@ -341,6 +346,7 @@ bool EmulatorSettings::Load(const std::string& serial) {
|
||||
ApplyGroupOverrides(m_vulkan, gj.at("Vulkan"), changed);
|
||||
|
||||
PrintChangedSummary(changed);
|
||||
EmulatorState::GetInstance()->SetGameSpecifigConfigUsed(true);
|
||||
return true;
|
||||
}
|
||||
} catch (const std::exception& e) {
|
||||
|
||||
@ -202,6 +202,7 @@ struct DebugSettings {
|
||||
Setting<bool> debug_dump{false}; // specific
|
||||
Setting<bool> shader_collect{false}; // specific
|
||||
Setting<bool> log_enabled{true}; // specific
|
||||
Setting<std::string> config_version{""}; // specific
|
||||
|
||||
std::vector<OverrideItem> GetOverrideableFields() const {
|
||||
return std::vector<OverrideItem>{
|
||||
@ -213,7 +214,7 @@ struct DebugSettings {
|
||||
}
|
||||
};
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(DebugSettings, separate_logging_enabled, debug_dump,
|
||||
shader_collect, log_enabled)
|
||||
shader_collect, log_enabled, config_version)
|
||||
|
||||
// -------------------------------
|
||||
// Input settings
|
||||
@ -383,7 +384,7 @@ public:
|
||||
static std::shared_ptr<EmulatorSettings> GetInstance();
|
||||
static void SetInstance(std::shared_ptr<EmulatorSettings> instance);
|
||||
|
||||
bool Save(const std::string& serial = "") const;
|
||||
bool Save(const std::string& serial = "");
|
||||
bool Load(const std::string& serial = "");
|
||||
void SetDefaultValues();
|
||||
|
||||
@ -536,6 +537,7 @@ public:
|
||||
SETTING_FORWARD_BOOL(m_debug, DebugDump, debug_dump)
|
||||
SETTING_FORWARD_BOOL(m_debug, ShaderCollect, shader_collect)
|
||||
SETTING_FORWARD_BOOL(m_debug, LogEnabled, log_enabled)
|
||||
SETTING_FORWARD(m_debug, ConfigVersion, config_version)
|
||||
|
||||
// GPU Settings
|
||||
SETTING_FORWARD_BOOL(m_gpu, NullGPU, null_gpu)
|
||||
|
||||
@ -209,12 +209,7 @@ void Emulator::Run(std::filesystem::path file, std::vector<std::string> args,
|
||||
Config::load(Common::FS::GetUserPath(Common::FS::PathType::CustomConfigs) / (id + ".toml"),
|
||||
true);
|
||||
|
||||
if (std::filesystem::exists(Common::FS::GetUserPath(Common::FS::PathType::CustomConfigs) /
|
||||
(id + ".toml"))) {
|
||||
EmulatorState::GetInstance()->SetGameSpecifigConfigUsed(true);
|
||||
} else {
|
||||
EmulatorState::GetInstance()->SetGameSpecifigConfigUsed(false);
|
||||
}
|
||||
EmulatorSettings::GetInstance()->Load(id);
|
||||
|
||||
// Initialize logging as soon as possible
|
||||
if (!id.empty() && EmulatorSettings::GetInstance()->IsSeparateLoggingEnabled()) {
|
||||
@ -235,9 +230,8 @@ void Emulator::Run(std::filesystem::path file, std::vector<std::string> args,
|
||||
LOG_INFO(Loader, "Description {}", Common::g_scm_desc);
|
||||
LOG_INFO(Loader, "Remote {}", Common::g_scm_remote_url);
|
||||
|
||||
const bool has_game_config = std::filesystem::exists(
|
||||
Common::FS::GetUserPath(Common::FS::PathType::CustomConfigs) / (id + ".toml"));
|
||||
LOG_INFO(Config, "Game-specific config exists: {}", has_game_config);
|
||||
LOG_INFO(Config, "Game-specific config used: {}",
|
||||
EmulatorState::GetInstance()->IsGameSpecifigConfigUsed());
|
||||
|
||||
LOG_INFO(Config, "General LogType: {}", EmulatorSettings::GetInstance()->GetLogType());
|
||||
LOG_INFO(Config, "General isIdenticalLogGrouped: {}",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user