mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2025-07-03 08:26:01 +00:00
- fix uri now show beammp launcher prompt
This commit is contained in:
parent
6e7803357a
commit
5d1aee98a1
@ -30,6 +30,7 @@ class Launcher {
|
||||
public: // available functions
|
||||
static void StaticAbort(Launcher* Instance = nullptr);
|
||||
std::string Login(const std::string& fields);
|
||||
void UpdateKey(const std::string& newKey);
|
||||
void SendIPC(const std::string& Data, bool core = true);
|
||||
void LoadConfig(const fs::path& conf);
|
||||
void RunDiscordRPC();
|
||||
@ -76,7 +77,7 @@ class Launcher {
|
||||
fs::path MPUserPath{};
|
||||
fs::path BeamUserPath{};
|
||||
fs::path BeamProfilePath{};
|
||||
fs::path LauncherCache{"Resources"};
|
||||
fs::path LauncherCache{};
|
||||
int64_t DiscordTime{};
|
||||
bool LoginAuth = false;
|
||||
bool DebugMode = false;
|
||||
|
@ -56,7 +56,7 @@ void Launcher::LoadConfig(const fs::path& conf) { // check if json (issue)
|
||||
|
||||
tml.close();
|
||||
LoadConfig(conf);
|
||||
} else LOG(ERROR) << "Failed to create config file";
|
||||
} else LOG(ERROR) << "Failed to create config file " << conf;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ LONG WINAPI CrashHandler(EXCEPTION_POINTERS* p) {
|
||||
}
|
||||
|
||||
Launcher::Launcher(int argc, char* argv[]) :
|
||||
CurrentPath(std::filesystem::current_path()),
|
||||
CurrentPath(fs::current_path()),
|
||||
DiscordMessage("Just launched") {
|
||||
Log::Init();
|
||||
Shutdown.store(false);
|
||||
@ -33,22 +33,31 @@ Launcher::Launcher(int argc, char* argv[]) :
|
||||
SetUnhandledExceptionFilter(CrashHandler);
|
||||
LOG(INFO) << "Starting Launcher v" << FullVersion;
|
||||
|
||||
fs::path config_path(fs::current_path() / "Launcher.toml");
|
||||
if (argc > 1) {
|
||||
std::string arg(argv[1]);
|
||||
fs::path config_path(CurrentPath / "Launcher.toml");
|
||||
|
||||
std::string arg, arg2;
|
||||
if(argc > 2) {
|
||||
arg = argv[1];
|
||||
arg2 = argv[2];
|
||||
} else if (argc > 1) {
|
||||
arg = argv[1];
|
||||
}
|
||||
if (arg.starts_with('0')) {
|
||||
LOG(INFO) << "Debug param in effect";
|
||||
DebugMode = true;
|
||||
Memory::DebugMode = true;
|
||||
} else if (arg.starts_with("beammp://")) {
|
||||
if (arg.starts_with("beammp://connect/")) {
|
||||
ConnectURI = arg.substr(17);
|
||||
}
|
||||
} else {
|
||||
config_path = fs::current_path() / arg;
|
||||
} else if (arg2.starts_with("beammp://")) {
|
||||
CurrentPath = arg;
|
||||
config_path = CurrentPath / "Launcher.toml";
|
||||
if (arg2.starts_with("beammp://connect/")) {
|
||||
ConnectURI = arg2.substr(17);
|
||||
}
|
||||
} else if (!arg.empty()) {
|
||||
config_path = CurrentPath / arg;
|
||||
}
|
||||
|
||||
LoadConfig(config_path);
|
||||
LauncherCache = CurrentPath/"Resources";
|
||||
}
|
||||
|
||||
void Launcher::Abort() {
|
||||
@ -105,7 +114,7 @@ void Launcher::WindowsInit() {
|
||||
signal(SIGBREAK, ShutdownHandler);
|
||||
|
||||
|
||||
std::wstring command = L"cmd /c \"cd /D \"" + CurrentPath.wstring() + L"\" && BeamMP-Launcher.exe \"%1\"\"";
|
||||
std::wstring command = L"\"" + (CurrentPath/"BeamMP-Launcher.exe").wstring() + L"\" \"" + CurrentPath.wstring() + L"\" \"%1\"";
|
||||
std::wstring ICON = L"\"" + (CurrentPath/"BeamMP-Launcher.exe").wstring() + L"\",0";
|
||||
std::wstring URL = L"URL:beammp Protocol";
|
||||
HKEY hKey;
|
||||
|
@ -8,9 +8,9 @@
|
||||
#include "Launcher.h"
|
||||
#include "Logger.h"
|
||||
|
||||
void UpdateKey(const std::string& newKey) {
|
||||
void Launcher::UpdateKey(const std::string& newKey) {
|
||||
if (!newKey.empty() && std::isalnum(newKey[0])) {
|
||||
std::ofstream Key("key");
|
||||
std::ofstream Key(CurrentPath/"key");
|
||||
if (Key.is_open()) {
|
||||
Key << newKey;
|
||||
Key.close();
|
||||
@ -18,8 +18,8 @@ void UpdateKey(const std::string& newKey) {
|
||||
LOG(FATAL) << "Cannot write to disk!";
|
||||
throw ShutdownException("Fatal Error");
|
||||
}
|
||||
} else if (fs::exists("key")) {
|
||||
remove("key");
|
||||
} else if (fs::exists(CurrentPath/"key")) {
|
||||
fs::remove(CurrentPath/"key");
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,10 +79,10 @@ std::string Launcher::Login(const std::string& fields) {
|
||||
}
|
||||
|
||||
void Launcher::CheckKey() {
|
||||
if (fs::exists("key") && fs::file_size("key") < 100) {
|
||||
std::ifstream Key("key");
|
||||
if (fs::exists(CurrentPath/"key") && fs::file_size(CurrentPath/"key") < 100) {
|
||||
std::ifstream Key(CurrentPath/"key");
|
||||
if (Key.is_open()) {
|
||||
auto Size = fs::file_size("key");
|
||||
auto Size = fs::file_size(CurrentPath/"key");
|
||||
std::string Buffer(Size, 0);
|
||||
Key.read(&Buffer[0], std::streamsize(Size));
|
||||
Key.close();
|
||||
|
@ -116,18 +116,18 @@ void Launcher::UpdateCheck() {
|
||||
|
||||
transform(LatestHash.begin(), LatestHash.end(), LatestHash.begin(), ::tolower);
|
||||
|
||||
std::string FileHash = hashpp::get::getFileHash(hashpp::ALGORITHMS::SHA2_256, "BeamMP-Launcher.exe");
|
||||
std::string FileHash = hashpp::get::getFileHash(hashpp::ALGORITHMS::SHA2_256, (CurrentPath/"BeamMP-Launcher.exe").string());
|
||||
|
||||
if(FileHash != LatestHash && VersionParser(LatestVersion) > VersionParser(FullVersion)) {
|
||||
LOG(INFO) << "Launcher update found!";
|
||||
fs::remove("BeamMP-Launcher.back");
|
||||
fs::rename("BeamMP-Launcher.exe", "BeamMP-Launcher.back");
|
||||
fs::remove((CurrentPath/"BeamMP-Launcher.back").string());
|
||||
fs::rename((CurrentPath/"BeamMP-Launcher.exe").string(), (CurrentPath/"BeamMP-Launcher.back").string());
|
||||
LOG(INFO) << "Downloading Launcher update " << LatestHash;
|
||||
HTTP::Download(
|
||||
"https://backend.beammp.com/builds/launcher?download=true"
|
||||
"&pk=" +
|
||||
PublicKey + "&branch=" + TargetBuild,
|
||||
"BeamMP-Launcher.exe");
|
||||
(CurrentPath/"BeamMP-Launcher.exe").string());
|
||||
throw ShutdownException("Launcher update");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user