mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2026-04-19 23:00:21 +00:00
- add uri connect
This commit is contained in:
@@ -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};
|
||||||
|
|||||||
@@ -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)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,23 +24,31 @@ LONG WINAPI CrashHandler(EXCEPTION_POINTERS* p) {
|
|||||||
Launcher::Launcher(int argc, char* argv[]) :
|
Launcher::Launcher(int argc, char* argv[]) :
|
||||||
CurrentPath(std::filesystem::current_path()),
|
CurrentPath(std::filesystem::current_path()),
|
||||||
DiscordMessage("Just launched") {
|
DiscordMessage("Just launched") {
|
||||||
Log::Init();
|
Log::Init();
|
||||||
Shutdown.store(false);
|
Shutdown.store(false);
|
||||||
Exit.store(false);
|
Exit.store(false);
|
||||||
Launcher::StaticAbort(this);
|
Launcher::StaticAbort(this);
|
||||||
DiscordTime = std::time(nullptr);
|
DiscordTime = std::time(nullptr);
|
||||||
WindowsInit();
|
WindowsInit();
|
||||||
SetUnhandledExceptionFilter(CrashHandler);
|
SetUnhandledExceptionFilter(CrashHandler);
|
||||||
LOG(INFO) << "Starting Launcher v" << FullVersion;
|
LOG(INFO) << "Starting Launcher v" << FullVersion;
|
||||||
if (argc > 1) {
|
|
||||||
if(std::string(argv[1]).find('0') != std::string::npos) {
|
fs::path config_path(fs::current_path() / "Launcher.toml");
|
||||||
DebugMode = true;
|
if (argc > 1) {
|
||||||
Memory::DebugMode = true;
|
std::string arg(argv[1]);
|
||||||
LoadConfig(fs::current_path() / "Launcher.toml");
|
if (arg.starts_with('0')) {
|
||||||
} else {
|
LOG(INFO) << "Debug param in effect";
|
||||||
LoadConfig(fs::current_path() / argv[1]);
|
DebugMode = true;
|
||||||
}
|
Memory::DebugMode = true;
|
||||||
} else LoadConfig(fs::current_path() / "Launcher.toml");
|
} else if (arg.starts_with("beammp://")) {
|
||||||
|
if (arg.starts_with("beammp://connect/")) {
|
||||||
|
ConnectURI = arg.substr(17);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
config_path = fs::current_path() / arg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LoadConfig(config_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Launcher::Abort() {
|
void Launcher::Abort() {
|
||||||
@@ -89,12 +97,29 @@ void Launcher::StaticAbort(Launcher* Instance) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Launcher::WindowsInit() {
|
void Launcher::WindowsInit() {
|
||||||
system("cls");
|
system("cls");
|
||||||
SetConsoleTitleA(("BeamMP Launcher v" + FullVersion).c_str());
|
SetConsoleTitleA(("BeamMP Launcher v" + FullVersion).c_str());
|
||||||
signal(SIGINT, ShutdownHandler);
|
signal(SIGINT, ShutdownHandler);
|
||||||
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() {
|
||||||
|
|||||||
Reference in New Issue
Block a user