[App] Improve content_root cvar handling, set content_root after reading config
Old code also had a chance of leaving config_folder empty, if content_root was set before reading config (eg. was set on command line), which didn't seem like it was intended? Now config_folder should always be set up to one of the default folders. The content_root value from config was also being ignored, since we set up content_root before reading config, now we'll set it up again if content_root is set.
This commit is contained in:
parent
219a4db3ba
commit
ab063d6850
|
@ -205,33 +205,43 @@ int xenia_main(const std::vector<std::wstring>& args) {
|
|||
std::wstring content_root = xe::to_wstring(cvars::content_root);
|
||||
std::wstring config_folder;
|
||||
|
||||
if (content_root.empty()) {
|
||||
auto base_path = xe::filesystem::GetExecutableFolder();
|
||||
base_path = xe::to_absolute_path(base_path);
|
||||
auto base_path = xe::filesystem::GetExecutableFolder();
|
||||
base_path = xe::to_absolute_path(base_path);
|
||||
|
||||
auto portable_path = xe::join_paths(base_path, L"portable.txt");
|
||||
if (xe::filesystem::PathExists(portable_path)) {
|
||||
content_root = xe::join_paths(base_path, L"content");
|
||||
config_folder = base_path;
|
||||
} else {
|
||||
content_root = xe::filesystem::GetUserFolder();
|
||||
// Setup config folder location
|
||||
auto portable_path = xe::join_paths(base_path, L"portable.txt");
|
||||
if (xe::filesystem::PathExists(portable_path)) {
|
||||
config_folder = base_path;
|
||||
} else {
|
||||
config_folder = xe::filesystem::GetUserFolder();
|
||||
#if defined(XE_PLATFORM_WIN32)
|
||||
content_root = xe::join_paths(content_root, L"Xenia");
|
||||
config_folder = xe::join_paths(config_folder, L"Xenia");
|
||||
#elif defined(XE_PLATFORM_LINUX)
|
||||
content_root = xe::join_paths(content_root, L"Xenia");
|
||||
config_folder = xe::join_paths(config_folder, L"Xenia");
|
||||
#else
|
||||
#warning Unhandled platform for content root.
|
||||
content_root = xe::join_paths(content_root, L"Xenia");
|
||||
config_folder = xe::join_paths(config_folder, L"Xenia");
|
||||
#endif
|
||||
config_folder = content_root;
|
||||
content_root = xe::join_paths(content_root, L"content");
|
||||
}
|
||||
}
|
||||
|
||||
// If no content_root set, use folder inside config dir
|
||||
if (content_root.empty()) {
|
||||
content_root = xe::join_paths(config_folder, L"content");
|
||||
}
|
||||
|
||||
content_root = xe::to_absolute_path(content_root);
|
||||
|
||||
XELOGI("Content root: %S", content_root.c_str());
|
||||
XELOGI("Config folder: %S", config_folder.c_str());
|
||||
config::SetupConfig(config_folder);
|
||||
|
||||
// If content_root cvar is set after reading config, use that
|
||||
if (!cvars::content_root.empty()) {
|
||||
content_root = xe::to_wstring(cvars::content_root);
|
||||
content_root = xe::to_absolute_path(content_root);
|
||||
}
|
||||
|
||||
XELOGI("Content root: %S", content_root.c_str());
|
||||
|
||||
if (cvars::discord) {
|
||||
discord::DiscordPresence::Initialize();
|
||||
discord::DiscordPresence::NotPlaying();
|
||||
|
|
Loading…
Reference in New Issue