mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-10 08:51:19 +12:00
Add support for non portable mode (#356)
This commit is contained in:
parent
2b9edced81
commit
d6ba61cf64
38 changed files with 233 additions and 163 deletions
|
@ -1,6 +1,7 @@
|
|||
#include "config/ActiveSettings.h"
|
||||
|
||||
#include "Cafe/GameProfile/GameProfile.h"
|
||||
#include "Cemu/Logging/CemuLogging.h"
|
||||
#include "LaunchSettings.h"
|
||||
#include "util/helpers/helpers.h"
|
||||
|
||||
|
@ -12,17 +13,41 @@
|
|||
|
||||
extern bool alwaysDisplayDRC;
|
||||
|
||||
void ActiveSettings::LoadOnce()
|
||||
std::set<fs::path>
|
||||
ActiveSettings::LoadOnce(const fs::path& user_data_path,
|
||||
const fs::path& config_path,
|
||||
const fs::path& cache_path,
|
||||
const fs::path& data_path)
|
||||
{
|
||||
s_full_path = boost::dll::program_location().generic_wstring();
|
||||
s_path = s_full_path.parent_path();
|
||||
|
||||
s_user_data_path = user_data_path;
|
||||
s_config_path = config_path;
|
||||
s_cache_path = cache_path;
|
||||
s_data_path = data_path;
|
||||
std::set<fs::path> failed_write_access;
|
||||
for (auto&& path : {user_data_path, config_path, cache_path})
|
||||
{
|
||||
if (!fs::exists(path))
|
||||
{
|
||||
std::error_code ec;
|
||||
fs::create_directories(path, ec);
|
||||
}
|
||||
if (!TestWriteAccess(path))
|
||||
{
|
||||
cemuLog_log(LogType::Force, "Failed to write to {}", path.generic_string());
|
||||
failed_write_access.insert(path);
|
||||
}
|
||||
}
|
||||
|
||||
s_filename = s_full_path.filename();
|
||||
|
||||
g_config.SetFilename(GetPath("settings.xml").generic_wstring());
|
||||
g_config.SetFilename(GetConfigPath("settings.xml").generic_wstring());
|
||||
g_config.Load();
|
||||
LaunchSettings::ChangeNetworkServiceURL(GetConfig().account.active_service);
|
||||
std::wstring additionalErrorInfo;
|
||||
s_has_required_online_files = iosuCrypt_checkRequirementsForOnlineMode(additionalErrorInfo) == IOS_CRYPTO_ONLINE_REQ_OK;
|
||||
return failed_write_access;
|
||||
}
|
||||
|
||||
bool ActiveSettings::LoadSharedLibrariesEnabled()
|
||||
|
@ -226,6 +251,6 @@ fs::path ActiveSettings::GetMlcPath()
|
|||
|
||||
fs::path ActiveSettings::GetDefaultMLCPath()
|
||||
{
|
||||
return GetPath("mlc01");
|
||||
return GetUserDataPath("mlc01");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,69 +1,70 @@
|
|||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
#include "config/CemuConfig.h"
|
||||
#include "config/NetworkSettings.h"
|
||||
|
||||
// global active settings for fast access (reflects settings from command line and game profile)
|
||||
class ActiveSettings
|
||||
{
|
||||
public:
|
||||
static void LoadOnce();
|
||||
|
||||
[[nodiscard]] static fs::path GetFullPath() { return s_full_path; }
|
||||
[[nodiscard]] static fs::path GetPath() { return s_path; }
|
||||
[[nodiscard]] static fs::path GetFilename() { return s_filename; }
|
||||
|
||||
[[nodiscard]] static fs::path GetMlcPath();
|
||||
|
||||
[[nodiscard]] static fs::path GetPath(std::string_view p)
|
||||
{
|
||||
std::basic_string_view<char8_t> s((const char8_t*)p.data(), p.size());
|
||||
return s_path / fs::path(s);
|
||||
}
|
||||
|
||||
[[nodiscard]] static fs::path GetMlcPath(std::string_view p)
|
||||
{
|
||||
std::basic_string_view<char8_t> s((const char8_t*)p.data(), p.size());
|
||||
return GetMlcPath() / fs::path(s);
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename ...TArgs>
|
||||
[[nodiscard]] static fs::path GetPath(std::string_view format, TArgs&&... args)
|
||||
static fs::path GetPath(const fs::path& path, std::string_view format, TArgs&&... args)
|
||||
{
|
||||
cemu_assert_debug(format.empty() || (format[0] != '/' && format[0] != '\\'));
|
||||
std::string tmpPathStr = fmt::format(fmt::runtime(format), std::forward<TArgs>(args)...);
|
||||
std::basic_string_view<char8_t> s((const char8_t*)tmpPathStr.data(), tmpPathStr.size());
|
||||
return s_path / fs::path(s);
|
||||
return path / _utf8ToPath(tmpPathStr);
|
||||
}
|
||||
|
||||
|
||||
template <typename ...TArgs>
|
||||
[[nodiscard]] static fs::path GetPath(std::wstring_view format, TArgs&&... args)
|
||||
static fs::path GetPath(const fs::path& path, std::wstring_view format, TArgs&&... args)
|
||||
{
|
||||
cemu_assert_debug(format.empty() || (format[0] != L'/' && format[0] != L'\\'));
|
||||
return s_path / fmt::format(format, std::forward<TArgs>(args)...);
|
||||
return path / fmt::format(fmt::runtime(format), std::forward<TArgs>(args)...);
|
||||
}
|
||||
|
||||
template <typename ...TArgs>
|
||||
[[nodiscard]] static fs::path GetMlcPath(std::string_view format, TArgs&&... args)
|
||||
static fs::path GetPath(const fs::path& path, std::string_view p)
|
||||
{
|
||||
cemu_assert_debug(format.empty() || (format[0] != '/' && format[0] != '\\'));
|
||||
auto tmp = fmt::format(fmt::runtime(format), std::forward<TArgs>(args)...);
|
||||
return GetMlcPath() / _utf8ToPath(tmp);
|
||||
std::basic_string_view<char8_t> s((const char8_t*)p.data(), p.size());
|
||||
return path / fs::path(s);
|
||||
}
|
||||
|
||||
template <typename ...TArgs>
|
||||
[[nodiscard]] static fs::path GetMlcPath(std::wstring_view format, TArgs&&... args)
|
||||
static fs::path GetPath(const fs::path& path)
|
||||
{
|
||||
cemu_assert_debug(format.empty() || (format[0] != L'/' && format[0] != L'\\'));
|
||||
return GetMlcPath() / fmt::format(fmt::runtime(format), std::forward<TArgs>(args)...);
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
// Set directories and return all directories that failed write access test
|
||||
static std::set<fs::path>
|
||||
LoadOnce(const fs::path& user_data_path,
|
||||
const fs::path& config_path,
|
||||
const fs::path& cache_path,
|
||||
const fs::path& data_path);
|
||||
|
||||
[[nodiscard]] static fs::path GetFullPath() { return s_full_path; }
|
||||
[[nodiscard]] static fs::path GetFilename() { return s_filename; }
|
||||
template <typename ...TArgs>
|
||||
[[nodiscard]] static fs::path GetUserDataPath(TArgs&&... args){ return GetPath(s_user_data_path, std::forward<TArgs>(args)...); };
|
||||
template <typename ...TArgs>
|
||||
[[nodiscard]] static fs::path GetConfigPath(TArgs&&... args){ return GetPath(s_config_path, std::forward<TArgs>(args)...); };
|
||||
template <typename ...TArgs>
|
||||
[[nodiscard]] static fs::path GetCachePath(TArgs&&... args){ return GetPath(s_cache_path, std::forward<TArgs>(args)...); };
|
||||
template <typename ...TArgs>
|
||||
[[nodiscard]] static fs::path GetDataPath(TArgs&&... args){ return GetPath(s_data_path, std::forward<TArgs>(args)...); };
|
||||
|
||||
[[nodiscard]] static fs::path GetMlcPath();
|
||||
|
||||
template <typename ...TArgs>
|
||||
[[nodiscard]] static fs::path GetMlcPath(TArgs&&... args){ return GetPath(GetMlcPath(), std::forward<TArgs>(args)...); };
|
||||
|
||||
// get mlc path to default cemu root dir/mlc01
|
||||
[[nodiscard]] static fs::path GetDefaultMLCPath();
|
||||
|
||||
private:
|
||||
inline static fs::path s_full_path; // full filename
|
||||
inline static fs::path s_path; // path
|
||||
inline static fs::path s_user_data_path;
|
||||
inline static fs::path s_config_path;
|
||||
inline static fs::path s_cache_path;
|
||||
inline static fs::path s_data_path;
|
||||
inline static fs::path s_filename; // cemu.exe
|
||||
inline static fs::path s_mlc_path;
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "NetworkSettings.h"
|
||||
#include "ActiveSettings.h"
|
||||
#include "LaunchSettings.h"
|
||||
#include "CemuConfig.h"
|
||||
#include <boost/dll/runtime_symbol_info.hpp>
|
||||
|
@ -6,11 +7,10 @@
|
|||
|
||||
XMLNetworkConfig_t n_config(L"network_services.xml");
|
||||
|
||||
|
||||
void NetworkConfig::LoadOnce()
|
||||
{
|
||||
s_full_path = boost::dll::program_location().generic_wstring();
|
||||
s_path = s_full_path.parent_path();
|
||||
n_config.SetFilename(GetPath("network_services.xml").generic_wstring());
|
||||
n_config.SetFilename(ActiveSettings::GetConfigPath("network_services.xml").generic_wstring());
|
||||
if (XMLExists())
|
||||
n_config.Load();
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ void NetworkConfig::Load(XMLConfigParser& parser)
|
|||
bool NetworkConfig::XMLExists()
|
||||
{
|
||||
std::error_code ec;
|
||||
if (!fs::exists(GetPath("network_services.xml"), ec))
|
||||
if (!fs::exists(ActiveSettings::GetConfigPath("network_services.xml"), ec))
|
||||
{
|
||||
if (static_cast<NetworkService>(GetConfig().account.active_service.GetValue()) == NetworkService::Custom)
|
||||
{
|
||||
|
|
|
@ -38,14 +38,6 @@ struct NetworkConfig {
|
|||
void Save(XMLConfigParser& parser);
|
||||
|
||||
static bool XMLExists();
|
||||
private:
|
||||
inline static fs::path s_path;
|
||||
inline static fs::path s_full_path;
|
||||
[[nodiscard]] static fs::path GetPath(std::string_view p)
|
||||
{
|
||||
std::basic_string_view<char8_t> s((const char8_t*)p.data(), p.size());
|
||||
return s_path / fs::path(s);
|
||||
}
|
||||
};
|
||||
|
||||
struct NintendoURLs {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue