mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-03 13:31:18 +12:00
Code clean up + replace some wstring instances with utf8 (#640)
This commit is contained in:
parent
ca79a6aa0d
commit
f3ff919be2
41 changed files with 163 additions and 641 deletions
|
@ -241,7 +241,7 @@ fs::path ActiveSettings::GetMlcPath()
|
|||
return launch_mlc.value();
|
||||
|
||||
if(const auto config_mlc = GetConfig().mlc_path.GetValue(); !config_mlc.empty())
|
||||
return config_mlc;
|
||||
return _utf8ToPath(config_mlc);
|
||||
|
||||
return GetDefaultMLCPath();
|
||||
}
|
||||
|
|
|
@ -10,19 +10,19 @@
|
|||
|
||||
XMLCemuConfig_t g_config(L"settings.xml");
|
||||
|
||||
void CemuConfig::SetMLCPath(std::wstring_view path, bool save)
|
||||
void CemuConfig::SetMLCPath(fs::path path, bool save)
|
||||
{
|
||||
mlc_path.SetValue(path);
|
||||
mlc_path.SetValue(_pathToUtf8(path));
|
||||
if(save)
|
||||
g_config.Save();
|
||||
|
||||
// if custom mlc path has been selected, store it in permanent config
|
||||
if (!boost::starts_with(path, ActiveSettings::GetDefaultMLCPath().generic_wstring()))
|
||||
if (path != ActiveSettings::GetDefaultMLCPath())
|
||||
{
|
||||
try
|
||||
{
|
||||
auto pconfig = PermanentConfig::Load();
|
||||
pconfig.custom_mlc_path = boost::nowide::narrow(path.data(), path.size());
|
||||
pconfig.custom_mlc_path = _pathToUtf8(path);
|
||||
pconfig.Store();
|
||||
}
|
||||
catch (const PSDisabledException&) {}
|
||||
|
@ -46,14 +46,7 @@ void CemuConfig::Load(XMLConfigParser& parser)
|
|||
advanced_ppc_logging = parser.get("advanced_ppc_logging", advanced_ppc_logging.GetInitValue());
|
||||
|
||||
const char* mlc = parser.get("mlc_path", "");
|
||||
try
|
||||
{
|
||||
mlc_path = boost::nowide::widen(mlc);
|
||||
}
|
||||
catch (const std::exception&)
|
||||
{
|
||||
forceLog_printf("config load error: can't load mlc path: %s", mlc);
|
||||
}
|
||||
mlc_path = mlc;
|
||||
|
||||
permanent_storage = parser.get("permanent_storage", permanent_storage);
|
||||
|
||||
|
@ -357,7 +350,7 @@ void CemuConfig::Save(XMLConfigParser& parser)
|
|||
// general settings
|
||||
config.set("logflag", log_flag.GetValue());
|
||||
config.set("advanced_ppc_logging", advanced_ppc_logging.GetValue());
|
||||
config.set("mlc_path", boost::nowide::narrow(mlc_path.GetValue()).c_str());
|
||||
config.set("mlc_path", mlc_path.GetValue().c_str());
|
||||
config.set<bool>("permanent_storage", permanent_storage);
|
||||
config.set<sint32>("language", language);
|
||||
config.set<bool>("use_discord_presence", use_discord_presence);
|
||||
|
|
|
@ -356,7 +356,7 @@ struct CemuConfig
|
|||
//
|
||||
|
||||
// sets mlc path, updates permanent config value, saves config
|
||||
void SetMLCPath(std::wstring_view path, bool save = true);
|
||||
void SetMLCPath(fs::path path, bool save = true);
|
||||
|
||||
ConfigValue<uint64> log_flag{ 0 };
|
||||
ConfigValue<bool> advanced_ppc_logging{ false };
|
||||
|
@ -365,7 +365,7 @@ struct CemuConfig
|
|||
|
||||
ConfigValue<sint32> language{ wxLANGUAGE_DEFAULT };
|
||||
ConfigValue<bool> use_discord_presence{ true };
|
||||
ConfigValue<std::wstring> mlc_path {};
|
||||
ConfigValue<std::string> mlc_path {};
|
||||
ConfigValue<bool> fullscreen_menubar{ false };
|
||||
ConfigValue<bool> fullscreen{ false };
|
||||
ConfigValue<std::string> proxy_server{};
|
||||
|
|
|
@ -344,10 +344,9 @@ public:
|
|||
if (L == nullptr)
|
||||
return false;
|
||||
FileStream* fs = FileStream::openFile(filename.c_str());
|
||||
|
||||
if (fs == nullptr)
|
||||
if (!fs)
|
||||
{
|
||||
forceLogDebug_printfW(L"XMLConfig::Load > failed \"%s\" with error %d", filename.c_str(), errno);
|
||||
cemuLog_logDebug(LogType::Force, "XMLConfig::Load > failed \"{}\" with error {}", boost::nowide::narrow(filename), errno);
|
||||
return false;
|
||||
}
|
||||
std::vector<uint8> xmlData;
|
||||
|
@ -360,7 +359,7 @@ public:
|
|||
const bool success = error == tinyxml2::XML_SUCCESS;
|
||||
if (error != 0)
|
||||
{
|
||||
forceLogDebug_printf("XMLConfig::Load > LoadFile %d", error);
|
||||
cemuLog_logDebug(LogType::Force, "XMLConfig::Load > LoadFile {}", error);
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
|
@ -401,9 +400,9 @@ public:
|
|||
#else
|
||||
file = fopen(boost::nowide::narrow(tmp_name).c_str(), "wb");
|
||||
#endif
|
||||
if (file == nullptr)
|
||||
if (!file)
|
||||
{
|
||||
forceLogDebug_printfW(L"XMLConfig::Save > failed \"%s\" with error %d", filename.c_str(), errno);
|
||||
cemuLog_logDebug(LogType::Force, "XMLConfig::Save > failed \"{}\" with error {}", boost::nowide::narrow(filename), errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -417,7 +416,7 @@ public:
|
|||
const tinyxml2::XMLError error = doc.SaveFile(file);
|
||||
const bool success = error == tinyxml2::XML_SUCCESS;
|
||||
if(error != 0)
|
||||
forceLogDebug_printfW(L"XMLConfig::Save > SaveFile %d", error);
|
||||
cemuLog_logDebug(LogType::Force, "XMLConfig::Save > SaveFile {}", error);
|
||||
|
||||
fflush(file);
|
||||
fclose(file);
|
||||
|
@ -425,7 +424,7 @@ public:
|
|||
fs::rename(tmp_name, filename, err);
|
||||
if(err)
|
||||
{
|
||||
forceLog_printf("can't save settings to file: %s", err.message().c_str());
|
||||
cemuLog_log(LogType::Force, "Unable to save settings to file: {}", err.message().c_str());
|
||||
fs::remove(tmp_name, err);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue