- add uri connect

This commit is contained in:
Anonymous-275
2023-09-01 23:49:20 +01:00
parent f20635cc7e
commit d2dc3cfd76
3 changed files with 53 additions and 23 deletions
+1
View File
@@ -86,6 +86,7 @@ class Launcher {
std::string PublicKey{}; std::string PublicKey{};
std::thread IPCSystem{}; std::thread IPCSystem{};
std::thread DiscordRPC{}; std::thread DiscordRPC{};
std::string ConnectURI{};
std::string BeamVersion{}; std::string BeamVersion{};
std::string DiscordMessage{}; std::string DiscordMessage{};
Server ServerHandler{this}; Server ServerHandler{this};
+4
View File
@@ -53,6 +53,10 @@ void Launcher::HandleIPC(const std::string& Data) { //TODO Improve all cases si
case 'N': case 'N':
if (SubCode == 'c') { if (SubCode == 'c') {
SendIPC("N{\"Auth\":" + std::to_string(LoginAuth) + "}"); SendIPC("N{\"Auth\":" + std::to_string(LoginAuth) + "}");
if(LoginAuth && !ConnectURI.empty()) {
SendIPC("J" + ConnectURI);
ConnectURI.clear();
}
} else { } else {
SendIPC("N" + Login(Data.substr(Data.find(':') + 1))); SendIPC("N" + Login(Data.substr(Data.find(':') + 1)));
} }
+30 -5
View File
@@ -32,15 +32,23 @@ Launcher::Launcher(int argc, char* argv[]) :
WindowsInit(); WindowsInit();
SetUnhandledExceptionFilter(CrashHandler); SetUnhandledExceptionFilter(CrashHandler);
LOG(INFO) << "Starting Launcher v" << FullVersion; LOG(INFO) << "Starting Launcher v" << FullVersion;
fs::path config_path(fs::current_path() / "Launcher.toml");
if (argc > 1) { if (argc > 1) {
if(std::string(argv[1]).find('0') != std::string::npos) { std::string arg(argv[1]);
if (arg.starts_with('0')) {
LOG(INFO) << "Debug param in effect";
DebugMode = true; DebugMode = true;
Memory::DebugMode = true; Memory::DebugMode = true;
LoadConfig(fs::current_path() / "Launcher.toml"); } else if (arg.starts_with("beammp://")) {
} else { if (arg.starts_with("beammp://connect/")) {
LoadConfig(fs::current_path() / argv[1]); ConnectURI = arg.substr(17);
} }
} else LoadConfig(fs::current_path() / "Launcher.toml"); } else {
config_path = fs::current_path() / arg;
}
}
LoadConfig(config_path);
} }
void Launcher::Abort() { void Launcher::Abort() {
@@ -95,6 +103,23 @@ void Launcher::WindowsInit() {
signal(SIGTERM, ShutdownHandler); signal(SIGTERM, ShutdownHandler);
signal(SIGABRT, ShutdownHandler); signal(SIGABRT, ShutdownHandler);
signal(SIGBREAK, ShutdownHandler); signal(SIGBREAK, ShutdownHandler);
std::wstring command = L"cmd /c \"cd /D \"" + CurrentPath.wstring() + L"\" && BeamMP-Launcher.exe \"%1\"\"";
std::wstring ICON = L"\"" + (CurrentPath/"BeamMP-Launcher.exe").wstring() + L"\",0";
std::wstring URL = L"URL:beammp Protocol";
HKEY hKey;
RegCreateKey(HKEY_CLASSES_ROOT, L"beammp", &hKey);
RegSetValueEx(hKey, nullptr, 0, REG_SZ, (BYTE*)URL.c_str(), URL.size()*2);
RegSetValueEx(hKey, L"URL Protocol", 0, REG_SZ, (BYTE*)"", 0);
RegCreateKey(HKEY_CLASSES_ROOT, L"beammp\\DefaultIcon", &hKey);
RegSetValueEx(hKey, nullptr, 0, REG_SZ, (BYTE*)ICON.c_str(), ICON.size()*2);
RegCreateKey(HKEY_CLASSES_ROOT, L"beammp\\shell\\open\\command", &hKey);
RegSetValueEx(hKey, nullptr, 0, REG_SZ, (BYTE*)command.c_str(), command.size()*2);
RegCloseKey(hKey);
} }
void Launcher::LaunchGame() { void Launcher::LaunchGame() {