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