add specify a config file as argument

This commit is contained in:
Sam39
2022-08-22 11:15:08 +03:00
parent 000af36510
commit e485d457a6
4 changed files with 56 additions and 41 deletions

View File

@@ -8,8 +8,8 @@
#include "Logger.h"
void Launcher::LoadConfig() {
if (fs::exists("Launcher.toml")) {
toml::parse_result config = toml::parse_file("Launcher.toml");
if (fs::exists(UIData::ConfigPath)) {
toml::parse_result config = toml::parse_file(UIData::ConfigPath);
auto ui = config["UI"];
auto build = config["Build"];
auto GamePath = config["GamePath"];
@@ -26,24 +26,24 @@ void Launcher::LoadConfig() {
} else LOG(ERROR) << "Failed to get 'Build' string from config";
if (GamePath.is_string()) {
if(!GamePath.as_string()->get().empty()) {
if (!GamePath.as_string()->get().empty()) {
BeamRoot = GamePath.as_string()->get();
} else throw ShutdownException("GamePath cannot be empty");
}
else LOG(ERROR) << "Failed to get 'GamePath' string from config";
} else LOG(ERROR) << "Failed to get 'GamePath' string from config";
if (ProfilePath.is_string()) {
auto GameVer = VersionParser(UIData::GameVer).split;
if (!UIData::GameVer.empty()) {
auto GameVer = VersionParser(UIData::GameVer).split;
if (!ProfilePath.as_string()->get().empty()) {
BeamUserPath = fs::path(ProfilePath.as_string()->get())/(GameVer[0] + '.' + GameVer[1]);
MPUserPath = BeamUserPath/"mods"/"multiplayer";
} else throw ShutdownException("ProfilePath cannot be empty");
}
else LOG(ERROR) << "Failed to get 'ProfilePath' string from config";
if (!ProfilePath.as_string()->get().empty()) {
BeamUserPath = fs::path(ProfilePath.as_string()->get()) / (GameVer[0] + '.' + GameVer[1]);
MPUserPath = BeamUserPath / "mods" / "multiplayer";
} else throw ShutdownException("ProfilePath cannot be empty");
} else throw ShutdownException ("Check game path in config");
} else LOG(ERROR) << "Failed to get 'ProfilePath' string from config";
if (CachePath.is_string()) {
if(!CachePath.as_string()->get().empty()) {
if (!CachePath.as_string()->get().empty()) {
LauncherCache = CachePath.as_string()->get();
} else throw ShutdownException("CachePath cannot be empty");
} else LOG(ERROR) << "Failed to get 'CachePath' string from config";