mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2025-07-01 15:36:10 +00:00
Added cli option for user-path
This commit is contained in:
parent
e216b6ec06
commit
ffc36e7f3d
@ -19,6 +19,7 @@ struct Options {
|
|||||||
bool no_download = false;
|
bool no_download = false;
|
||||||
bool no_update = false;
|
bool no_update = false;
|
||||||
bool no_launch = false;
|
bool no_launch = false;
|
||||||
|
const char* user_path = nullptr;
|
||||||
const char **game_arguments = nullptr;
|
const char **game_arguments = nullptr;
|
||||||
int game_arguments_length = 0;
|
int game_arguments_length = 0;
|
||||||
const char** argv = nullptr;
|
const char** argv = nullptr;
|
||||||
|
@ -31,28 +31,31 @@ std::string GetGamePath() {
|
|||||||
static std::string Path;
|
static std::string Path;
|
||||||
if (!Path.empty())
|
if (!Path.empty())
|
||||||
return Path;
|
return Path;
|
||||||
|
if (options.user_path) {
|
||||||
HKEY hKey;
|
Path = options.user_path;
|
||||||
LPCTSTR sk = "Software\\BeamNG\\BeamNG.drive";
|
} else {
|
||||||
LONG openRes = RegOpenKeyEx(HKEY_CURRENT_USER, sk, 0, KEY_ALL_ACCESS, &hKey);
|
HKEY hKey;
|
||||||
if (openRes != ERROR_SUCCESS) {
|
LPCTSTR sk = "Software\\BeamNG\\BeamNG.drive";
|
||||||
fatal("Please launch the game at least once!");
|
LONG openRes = RegOpenKeyEx(HKEY_CURRENT_USER, sk, 0, KEY_ALL_ACCESS, &hKey);
|
||||||
}
|
if (openRes != ERROR_SUCCESS) {
|
||||||
Path = QueryKey(hKey, 4);
|
fatal("Please launch the game at least once!");
|
||||||
|
|
||||||
if (Path.empty()) {
|
|
||||||
Path = "";
|
|
||||||
char appDataPath[MAX_PATH];
|
|
||||||
HRESULT result = SHGetFolderPathA(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, appDataPath);
|
|
||||||
if (SUCCEEDED(result)) {
|
|
||||||
Path = appDataPath;
|
|
||||||
}
|
}
|
||||||
|
Path = QueryKey(hKey, 4);
|
||||||
|
|
||||||
if (Path.empty()) {
|
if (Path.empty()) {
|
||||||
fatal("Cannot get Local Appdata directory");
|
Path = "";
|
||||||
}
|
char appDataPath[MAX_PATH];
|
||||||
|
HRESULT result = SHGetFolderPathA(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, appDataPath);
|
||||||
|
if (SUCCEEDED(result)) {
|
||||||
|
Path = appDataPath;
|
||||||
|
}
|
||||||
|
|
||||||
Path += "\\BeamNG.drive\\";
|
if (Path.empty()) {
|
||||||
|
fatal("Cannot get Local Appdata directory");
|
||||||
|
}
|
||||||
|
|
||||||
|
Path += "\\BeamNG.drive\\";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Ver = CheckVer(GetGameDir());
|
std::string Ver = CheckVer(GetGameDir());
|
||||||
|
@ -86,6 +86,12 @@ void InitOptions(int argc, const char *argv[], Options &options) {
|
|||||||
options.no_download = true;
|
options.no_download = true;
|
||||||
options.no_launch = true;
|
options.no_launch = true;
|
||||||
options.no_update = true;
|
options.no_update = true;
|
||||||
|
} else if (argument == "--user-path") {
|
||||||
|
if (i + 1 >= argc) {
|
||||||
|
error("No user path specified after flag");
|
||||||
|
}
|
||||||
|
options.user_path = argv[i + 1];
|
||||||
|
i++;
|
||||||
} else if (argument == "--" || argument == "--game") {
|
} else if (argument == "--" || argument == "--game") {
|
||||||
options.game_arguments = &argv[i + 1];
|
options.game_arguments = &argv[i + 1];
|
||||||
options.game_arguments_length = argc - i - 1;
|
options.game_arguments_length = argc - i - 1;
|
||||||
@ -101,6 +107,7 @@ void InitOptions(int argc, const char *argv[], Options &options) {
|
|||||||
"\t--no-update Skip applying launcher updates (you must update manually)\n"
|
"\t--no-update Skip applying launcher updates (you must update manually)\n"
|
||||||
"\t--no-launch Skip launching the game (you must launch the game manually)\n"
|
"\t--no-launch Skip launching the game (you must launch the game manually)\n"
|
||||||
"\t--dev Developer mode, same as --verbose --no-download --no-launch --no-update\n"
|
"\t--dev Developer mode, same as --verbose --no-download --no-launch --no-update\n"
|
||||||
|
"\t--user-path <path> Path to BeamNG's User Path\n"
|
||||||
"\t--game <args...> Passes ALL following arguments to the game, see also `--`\n"
|
"\t--game <args...> Passes ALL following arguments to the game, see also `--`\n"
|
||||||
<< std::flush;
|
<< std::flush;
|
||||||
exit(0);
|
exit(0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user