mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-01-09 06:23:21 +08:00
parent
d7ea595359
commit
461f8586b6
@ -1565,7 +1565,7 @@ const Path Config::FindConfigFile(const std::string &baseFilename, bool *exists)
|
||||
return filename;
|
||||
}
|
||||
|
||||
void Config::RestoreDefaults(RestoreSettingsBits whatToRestore) {
|
||||
void Config::RestoreDefaults(RestoreSettingsBits whatToRestore, bool log) {
|
||||
if (bGameSpecific) {
|
||||
// TODO: This should be possible to do in a cleaner way.
|
||||
deleteGameConfig(gameId_);
|
||||
@ -1573,8 +1573,8 @@ void Config::RestoreDefaults(RestoreSettingsBits whatToRestore) {
|
||||
Load();
|
||||
} else {
|
||||
if (whatToRestore & RestoreSettingsBits::SETTINGS) {
|
||||
IterateSettings([](const ConfigSetting &setting) {
|
||||
setting.RestoreToDefault();
|
||||
IterateSettings([log](const ConfigSetting &setting) {
|
||||
setting.RestoreToDefault(log);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -612,7 +612,7 @@ public:
|
||||
void Load(const char *iniFileName = nullptr, const char *controllerIniFilename = nullptr);
|
||||
bool Save(const char *saveReason);
|
||||
void Reload();
|
||||
void RestoreDefaults(RestoreSettingsBits whatToRestore);
|
||||
void RestoreDefaults(RestoreSettingsBits whatToRestore, bool log = false);
|
||||
|
||||
//per game config managment, should maybe be in it's own class
|
||||
void changeGameSpecific(const std::string &gameId = "", const std::string &title = "");
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
#include <cstdint>
|
||||
#include "Common/Data/Format/IniFile.h"
|
||||
#include "Common/Net/URL.h"
|
||||
#include "Common/Log.h"
|
||||
@ -132,21 +133,112 @@ void ConfigSetting::Set(Section *section) const {
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigSetting::RestoreToDefault() const {
|
||||
bool ConfigSetting::RestoreToDefault(bool log) const {
|
||||
switch (type_) {
|
||||
case TYPE_BOOL: *ptr_.b = cb_.b ? cb_.b() : default_.b; break;
|
||||
case TYPE_INT: *ptr_.i = cb_.i ? cb_.i() : default_.i; break;
|
||||
case TYPE_UINT32: *ptr_.u = cb_.u ? cb_.u() : default_.u; break;
|
||||
case TYPE_UINT64: *ptr_.lu = cb_.lu ? cb_.lu() : default_.lu; break;
|
||||
case TYPE_FLOAT: *ptr_.f = cb_.f ? cb_.f() : default_.f; break;
|
||||
case TYPE_STRING: *ptr_.s = cb_.s ? cb_.s() : default_.s; break;
|
||||
case TYPE_STRING_VECTOR: *ptr_.v = *default_.v; break;
|
||||
case TYPE_TOUCH_POS: *ptr_.touchPos = cb_.touchPos ? cb_.touchPos() : default_.touchPos; break;
|
||||
case TYPE_PATH: *ptr_.p = Path(cb_.p ? cb_.p() : default_.p); break;
|
||||
case TYPE_CUSTOM_BUTTON: *ptr_.customButton = cb_.customButton ? cb_.customButton() : default_.customButton; break;
|
||||
case TYPE_BOOL:
|
||||
{
|
||||
const bool origValue = *ptr_.b;
|
||||
*ptr_.b = cb_.b ? cb_.b() : default_.b;
|
||||
if (*ptr_.b != origValue) {
|
||||
if (log) {
|
||||
INFO_LOG(Log::System, "Restored %s from %s to default %s", iniKey_,
|
||||
origValue ? "true" : "false",
|
||||
*ptr_.b ? "true" : "false");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TYPE_INT:
|
||||
{
|
||||
const int origValue = *ptr_.i;
|
||||
*ptr_.i = cb_.i ? cb_.i() : default_.i;
|
||||
if (*ptr_.i != origValue) {
|
||||
if (log) {
|
||||
INFO_LOG(Log::System, "Restored %s from %d to default %d", iniKey_,
|
||||
origValue, *ptr_.i);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TYPE_UINT32:
|
||||
{
|
||||
const u32 origValue = *ptr_.u;
|
||||
*ptr_.u = cb_.u ? cb_.u() : default_.u;
|
||||
if (*ptr_.u != origValue) {
|
||||
if (log) {
|
||||
INFO_LOG(Log::System, "Restored %s from %u to default %u", iniKey_,
|
||||
origValue, *ptr_.u);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TYPE_UINT64:
|
||||
{
|
||||
const u64 origValue = *ptr_.lu;
|
||||
*ptr_.lu = cb_.lu ? cb_.lu() : default_.lu;
|
||||
if (*ptr_.lu != origValue) {
|
||||
if (log) {
|
||||
INFO_LOG(Log::System, "Restored %s from %llu to default %llu", iniKey_,
|
||||
(unsigned long long)origValue, (unsigned long long)(*ptr_.lu));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TYPE_FLOAT:
|
||||
{
|
||||
const float origValue = *ptr_.f;
|
||||
*ptr_.f = cb_.f ? cb_.f() : default_.f;
|
||||
if (*ptr_.f != origValue) {
|
||||
if (log) {
|
||||
INFO_LOG(Log::System, "Restored %s from %f to default %f", iniKey_,
|
||||
origValue, *ptr_.f);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TYPE_STRING:
|
||||
{
|
||||
const std::string origValue = *ptr_.s;
|
||||
*ptr_.s = cb_.s ? cb_.s() : default_.s;
|
||||
if (*ptr_.s != origValue) {
|
||||
if (log) {
|
||||
INFO_LOG(Log::System, "Restored %s from \"%s\" to default \"%s\"", iniKey_,
|
||||
origValue.c_str(), ptr_.s->c_str());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TYPE_STRING_VECTOR:
|
||||
{
|
||||
*ptr_.v = *default_.v;
|
||||
break;
|
||||
}
|
||||
case TYPE_TOUCH_POS:
|
||||
{
|
||||
*ptr_.touchPos = cb_.touchPos ? cb_.touchPos() : default_.touchPos;
|
||||
break;
|
||||
}
|
||||
case TYPE_PATH:
|
||||
{
|
||||
*ptr_.p = Path(cb_.p ? cb_.p() : default_.p);
|
||||
break;
|
||||
}
|
||||
case TYPE_CUSTOM_BUTTON:
|
||||
{
|
||||
*ptr_.customButton = cb_.customButton ? cb_.customButton() : default_.customButton;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
_dbg_assert_msg_(false, "RestoreToDefault(%s): Unexpected ini setting type: %d", iniKey_, (int)type_);
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ConfigSetting::ReportSetting(UrlEncoder &data, const std::string &prefix) const {
|
||||
|
||||
@ -220,7 +220,8 @@ struct ConfigSetting {
|
||||
// Should actually be called WriteToIni or something.
|
||||
void Set(Section *section) const;
|
||||
|
||||
void RestoreToDefault() const;
|
||||
// If log is true, logs if the setting changed.
|
||||
bool RestoreToDefault(bool log) const;
|
||||
|
||||
void ReportSetting(UrlEncoder &data, const std::string &prefix) const;
|
||||
|
||||
|
||||
@ -448,8 +448,9 @@ static bool CPU_Init(FileLoader *fileLoader, IdentifiedFileType type, std::strin
|
||||
case IdentifiedFileType::PSP_PBP:
|
||||
case IdentifiedFileType::PSP_ELF:
|
||||
{
|
||||
INFO_LOG(Log::Loader, "File is an ELF or loose PBP! %s", fileLoader->GetPath().c_str());
|
||||
INFO_LOG(Log::Loader, "File is an ELF or loose PBP %s", fileLoader->GetPath().c_str());
|
||||
if (!Load_PSP_ELF_PBP(fileLoader, errorString)) {
|
||||
ERROR_LOG(Log::Loader, "Failed to load ELF or loose PBP: %s", errorString->c_str());
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
// To build on non-windows systems, just run CMake in the SDL directory, it will build both a normal ppsspp and the headless version.
|
||||
// Example command line to run a test in the VS debugger (useful to debug failures):
|
||||
// > --root pspautotests/tests/../ --compare --timeout=5 --graphics=software pspautotests/tests/cpu/cpu_alu/cpu_alu.prx
|
||||
// NOTE: In MSVC, don't forget to set the working directory to $ProjectDir\.. in debug settings.
|
||||
|
||||
#include "ppsspp_config.h"
|
||||
#include <cstdio>
|
||||
@ -200,8 +201,9 @@ bool RunAutoTest(HeadlessHost *headlessHost, CoreParameter &coreParameter, const
|
||||
headlessHost->SetComparisonScreenshot(ExpectedScreenshotFromFilename(coreParameter.fileToStart), opt.maxScreenshotError);
|
||||
|
||||
std::string error_string;
|
||||
while (PSP_InitUpdate(&error_string) == BootState::Booting)
|
||||
while (PSP_InitUpdate(&error_string) == BootState::Booting) {
|
||||
sleep_ms(1, "auto-test");
|
||||
}
|
||||
|
||||
if (!PSP_IsInited()) {
|
||||
TeamCityPrint("%s", error_string.c_str());
|
||||
@ -490,7 +492,7 @@ int main(int argc, const char* argv[])
|
||||
bool glWorking = headlessHost->InitGraphics(&error_string, &graphicsContext, gpuCore);
|
||||
|
||||
CoreParameter coreParameter;
|
||||
coreParameter.cpuCore = cpuCore;
|
||||
coreParameter.cpuCore = cpuCore; // apprently this gets overwritten somehow by g_Config below.
|
||||
coreParameter.gpuCore = glWorking ? gpuCore : GPUCORE_SOFTWARE;
|
||||
coreParameter.graphicsContext = graphicsContext;
|
||||
coreParameter.enableSound = false;
|
||||
@ -505,6 +507,14 @@ int main(int argc, const char* argv[])
|
||||
coreParameter.pixelHeight = 272;
|
||||
coreParameter.fastForward = true;
|
||||
|
||||
g_Config.RestoreDefaults(RestoreSettingsBits::SETTINGS | RestoreSettingsBits::CONTROLS, true);
|
||||
|
||||
// Somehow this affects the test execution of pspautotests/tests/gpu/vertices/morph.prx, even though
|
||||
// we actually set the cpu core in CoreParameter above. Probably because we end up using the JIT vs non-JIT
|
||||
// vertex decoder.
|
||||
g_Config.iCpuCore = 0;
|
||||
|
||||
// NOTE: In headless mode, we never save the config. This is just for this run.
|
||||
g_Config.iDumpFileTypes = 0;
|
||||
g_Config.bEnableSound = false;
|
||||
g_Config.bFirstRun = false;
|
||||
@ -545,6 +555,7 @@ int main(int argc, const char* argv[])
|
||||
g_Config.internalDataDirectory.clear();
|
||||
g_Config.bUseOldAtrac = oldAtrac;
|
||||
g_Config.iForceEnableHLE = 0xFFFFFFFF; // Run all modules as HLE. We don't have anything to load in this context.
|
||||
|
||||
// g_Config.bUseOldAtrac = true;
|
||||
|
||||
Path exePath = File::GetExeDirectory();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user