mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2026-06-22 08:31:07 +00:00
link UI data with launcher data
fix auto update fix crash caused by stdout
This commit is contained in:
+4
-12
@@ -18,6 +18,7 @@ struct VersionParser {
|
|||||||
std::vector<std::string> split;
|
std::vector<std::string> split;
|
||||||
std::vector<size_t> data;
|
std::vector<size_t> data;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct HKEY__;
|
struct HKEY__;
|
||||||
typedef HKEY__ *HKEY;
|
typedef HKEY__ *HKEY;
|
||||||
|
|
||||||
@@ -31,14 +32,11 @@ class Launcher {
|
|||||||
std::string Login(const std::string& fields);
|
std::string Login(const std::string& fields);
|
||||||
void SendIPC(const std::string& Data, bool core = true);
|
void SendIPC(const std::string& Data, bool core = true);
|
||||||
void RunDiscordRPC();
|
void RunDiscordRPC();
|
||||||
void QueryRegistry();
|
|
||||||
void WaitForGame();
|
void WaitForGame();
|
||||||
void LoadConfig();
|
void LoadConfig();
|
||||||
void LaunchGame();
|
void LaunchGame();
|
||||||
void CheckKey();
|
void CheckKey();
|
||||||
void SetupMOD();
|
void SetupMOD();
|
||||||
static void AdminRelaunch();
|
|
||||||
static void Relaunch();
|
|
||||||
static std::string QueryValue(HKEY& hKey, const char* Name);
|
static std::string QueryValue(HKEY& hKey, const char* Name);
|
||||||
|
|
||||||
public: // Getters and Setters
|
public: // Getters and Setters
|
||||||
@@ -54,11 +52,9 @@ class Launcher {
|
|||||||
|
|
||||||
private: // functions
|
private: // functions
|
||||||
void HandleIPC(const std::string& Data);
|
void HandleIPC(const std::string& Data);
|
||||||
std::string GetLocalAppdata();
|
|
||||||
void UpdatePresence();
|
void UpdatePresence();
|
||||||
void RichPresence();
|
void RichPresence();
|
||||||
void WindowsInit();
|
void WindowsInit();
|
||||||
void UpdateCheck();
|
|
||||||
void ResetMods();
|
void ResetMods();
|
||||||
void EnableMP();
|
void EnableMP();
|
||||||
void ListenIPC();
|
void ListenIPC();
|
||||||
@@ -68,7 +64,7 @@ class Launcher {
|
|||||||
static inline std::thread EntryThread{};
|
static inline std::thread EntryThread{};
|
||||||
static inline VersionParser SupportedVersion{"0.25.4.0"};
|
static inline VersionParser SupportedVersion{"0.25.4.0"};
|
||||||
static inline std::string Version{"2.0"};
|
static inline std::string Version{"2.0"};
|
||||||
static inline std::string FullVersion{Version + ".1"};
|
static inline std::string FullVersion{Version + ".99"};
|
||||||
|
|
||||||
private: // variables
|
private: // variables
|
||||||
uint32_t GamePID{0};
|
uint32_t GamePID{0};
|
||||||
@@ -87,9 +83,7 @@ class Launcher {
|
|||||||
std::string DiscordMessage{};
|
std::string DiscordMessage{};
|
||||||
Server ServerHandler{this};
|
Server ServerHandler{this};
|
||||||
std::string TargetBuild{"default"};
|
std::string TargetBuild{"default"};
|
||||||
std::string GameConfigPath{};
|
std::string LauncherCache{};
|
||||||
std::string ProfileConfigPath{};
|
|
||||||
std::string CacheConfigPath{};
|
|
||||||
static inline std::atomic<bool> Shutdown{false}, Exit{false};
|
static inline std::atomic<bool> Shutdown{false}, Exit{false};
|
||||||
std::unique_ptr<IPC> IPCToGame{};
|
std::unique_ptr<IPC> IPCToGame{};
|
||||||
std::unique_ptr<IPC> IPCFromGame{};
|
std::unique_ptr<IPC> IPCFromGame{};
|
||||||
@@ -102,10 +96,8 @@ class ShutdownException : public std::runtime_error {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct UIData {
|
struct UIData {
|
||||||
static inline std::string GamePath, ProfilePath, CachePath, Build, PublicKey, UserRole, Username;
|
static inline std::string GamePath, ProfilePath, CachePath, Build, PublicKey, UserRole, Username, GameVer;
|
||||||
static inline bool LoginAuth{false}, Console{false};
|
static inline bool LoginAuth{false}, Console{false};
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void UpdateKey(const std::string& newKey);
|
void UpdateKey(const std::string& newKey);
|
||||||
|
|||||||
@@ -10,4 +10,7 @@
|
|||||||
class Log {
|
class Log {
|
||||||
public:
|
public:
|
||||||
static void Init();
|
static void Init();
|
||||||
|
static void ConsoleOutput(bool enable);
|
||||||
|
private:
|
||||||
|
static inline el::Configurations Conf{};
|
||||||
};
|
};
|
||||||
|
|||||||
+9
-3
@@ -25,15 +25,21 @@ void Launcher::LoadConfig() {
|
|||||||
for (char& c : TargetBuild) c = char(tolower(c));
|
for (char& c : TargetBuild) c = char(tolower(c));
|
||||||
} else LOG(ERROR) << "Failed to get 'Build' string from config";
|
} else LOG(ERROR) << "Failed to get 'Build' string from config";
|
||||||
|
|
||||||
if (GamePath.is_string()) GameConfigPath = GamePath.as_string()->get();
|
if (GamePath.is_string()) BeamRoot = GamePath.as_string()->get();
|
||||||
else LOG(ERROR) << "Failed to get 'GamePath' string from config";
|
else LOG(ERROR) << "Failed to get 'GamePath' string from config";
|
||||||
|
|
||||||
if (ProfilePath.is_string()) ProfileConfigPath = ProfilePath.as_string()->get();
|
if (ProfilePath.is_string()) {
|
||||||
|
BeamUserPath = ProfilePath.as_string()->get();
|
||||||
|
if (!BeamUserPath.empty()) {
|
||||||
|
MPUserPath = BeamUserPath + "mods\\multiplayer";
|
||||||
|
}
|
||||||
|
}
|
||||||
else LOG(ERROR) << "Failed to get 'ProfilePath' string from config";
|
else LOG(ERROR) << "Failed to get 'ProfilePath' string from config";
|
||||||
|
|
||||||
if (CachePath.is_string()) CacheConfigPath = CachePath.as_string()->get();
|
if (CachePath.is_string()) LauncherCache = CachePath.as_string()->get();
|
||||||
else LOG(ERROR) << "Failed to get 'CachePath' string from config";
|
else LOG(ERROR) << "Failed to get 'CachePath' string from config";
|
||||||
|
|
||||||
|
BeamVersion = UIData::GameVer;
|
||||||
} else {
|
} else {
|
||||||
LOG(FATAL) << "Failed to find config on disk!";
|
LOG(FATAL) << "Failed to find config on disk!";
|
||||||
throw ShutdownException("Fatal Error");
|
throw ShutdownException("Fatal Error");
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ Launcher::Launcher() :
|
|||||||
WindowsInit();
|
WindowsInit();
|
||||||
SetUnhandledExceptionFilter(CrashHandler);
|
SetUnhandledExceptionFilter(CrashHandler);
|
||||||
LOG(INFO) << "Starting Launcher V" << FullVersion;
|
LOG(INFO) << "Starting Launcher V" << FullVersion;
|
||||||
UpdateCheck();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Launcher::Abort() {
|
void Launcher::Abort() {
|
||||||
@@ -184,72 +183,6 @@ std::string Launcher::QueryValue(HKEY& hKey, const char* Name) {
|
|||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
std::string Launcher::GetLocalAppdata() {
|
|
||||||
PWSTR folderPath = nullptr;
|
|
||||||
|
|
||||||
HRESULT hr =
|
|
||||||
SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, nullptr, &folderPath);
|
|
||||||
|
|
||||||
if (!SUCCEEDED(hr)) {
|
|
||||||
LOG(FATAL) << "Failed to get path of localAppData";
|
|
||||||
throw ShutdownException("Fatal Error");
|
|
||||||
}
|
|
||||||
|
|
||||||
_bstr_t bstrPath(folderPath);
|
|
||||||
std::string Path((char*)bstrPath);
|
|
||||||
CoTaskMemFree(folderPath);
|
|
||||||
|
|
||||||
if (!Path.empty()) {
|
|
||||||
Path += "\\BeamNG.drive\\";
|
|
||||||
VersionParser GameVer(BeamVersion);
|
|
||||||
Path += GameVer.split[0] + '.' + GameVer.split[1] + '\\';
|
|
||||||
return Path;
|
|
||||||
}
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
void Launcher::QueryRegistry() {
|
|
||||||
HKEY BeamNG;
|
|
||||||
LONG RegRes =
|
|
||||||
RegOpenKeyExA(HKEY_CURRENT_USER, R"(Software\BeamNG\BeamNG.drive)", 0,
|
|
||||||
KEY_READ, &BeamNG);
|
|
||||||
if (RegRes == ERROR_SUCCESS) {
|
|
||||||
BeamRoot = QueryValue(BeamNG, "rootpath");
|
|
||||||
BeamVersion = QueryValue(BeamNG, "version");
|
|
||||||
BeamUserPath = QueryValue(BeamNG, "userpath_override");
|
|
||||||
RegCloseKey(BeamNG);
|
|
||||||
if (BeamUserPath.empty() && !BeamVersion.empty()) {
|
|
||||||
BeamUserPath = GetLocalAppdata();
|
|
||||||
} else if (!BeamUserPath.empty() && !BeamVersion.empty()) {
|
|
||||||
VersionParser GameVer(BeamVersion);
|
|
||||||
BeamUserPath += GameVer.split[0] + '.' + GameVer.split[1] + '\\';
|
|
||||||
}
|
|
||||||
if (!BeamUserPath.empty()) {
|
|
||||||
MPUserPath = BeamUserPath + "mods\\multiplayer";
|
|
||||||
}
|
|
||||||
if (!BeamRoot.empty() && !BeamVersion.empty() && !BeamUserPath.empty())
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
LOG(FATAL)
|
|
||||||
<< "Please launch the game at least once, failed to read registry "
|
|
||||||
"key Software\\BeamNG\\BeamNG.drive";
|
|
||||||
throw ShutdownException("Fatal Error");
|
|
||||||
}
|
|
||||||
|
|
||||||
void Launcher::AdminRelaunch() {
|
|
||||||
system("cls");
|
|
||||||
ShellExecuteA(nullptr, "runas", fs::current_path().string().c_str(), nullptr,
|
|
||||||
nullptr, SW_SHOWNORMAL);
|
|
||||||
ShowWindow(GetConsoleWindow(), 0);
|
|
||||||
throw ShutdownException("Relaunching");
|
|
||||||
}
|
|
||||||
|
|
||||||
void Launcher::Relaunch() {
|
|
||||||
ShellExecuteA(nullptr, "open", fs::current_path().string().c_str(), nullptr,
|
|
||||||
nullptr, SW_SHOWNORMAL);
|
|
||||||
ShowWindow(GetConsoleWindow(), 0);
|
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
|
||||||
throw ShutdownException("Relaunching");
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string& Launcher::getFullVersion() {
|
const std::string& Launcher::getFullVersion() {
|
||||||
return FullVersion;
|
return FullVersion;
|
||||||
|
|||||||
+6
-1
@@ -7,13 +7,13 @@
|
|||||||
INITIALIZE_EASYLOGGINGPP
|
INITIALIZE_EASYLOGGINGPP
|
||||||
using namespace el;
|
using namespace el;
|
||||||
void Log::Init() {
|
void Log::Init() {
|
||||||
Configurations Conf;
|
|
||||||
Conf.setToDefault();
|
Conf.setToDefault();
|
||||||
std::string DFormat(
|
std::string DFormat(
|
||||||
"%datetime{[%d/%M/%y %H:%m:%s]} %fbase:%line [%level] %msg");
|
"%datetime{[%d/%M/%y %H:%m:%s]} %fbase:%line [%level] %msg");
|
||||||
Conf.setGlobally(ConfigurationType::Format,
|
Conf.setGlobally(ConfigurationType::Format,
|
||||||
"%datetime{[%d/%M/%y %H:%m:%s]} [%level] %msg");
|
"%datetime{[%d/%M/%y %H:%m:%s]} [%level] %msg");
|
||||||
Conf.setGlobally(ConfigurationType::LogFlushThreshold, "2");
|
Conf.setGlobally(ConfigurationType::LogFlushThreshold, "2");
|
||||||
|
Conf.setGlobally(ConfigurationType::ToStandardOutput, "false");
|
||||||
Conf.set(Level::Verbose, ConfigurationType::Format, DFormat);
|
Conf.set(Level::Verbose, ConfigurationType::Format, DFormat);
|
||||||
Conf.set(Level::Debug, ConfigurationType::Format, DFormat);
|
Conf.set(Level::Debug, ConfigurationType::Format, DFormat);
|
||||||
Conf.set(Level::Trace, ConfigurationType::Format, DFormat);
|
Conf.set(Level::Trace, ConfigurationType::Format, DFormat);
|
||||||
@@ -25,3 +25,8 @@ void Log::Init() {
|
|||||||
Loggers::addFlag(LoggingFlag::HierarchicalLogging);
|
Loggers::addFlag(LoggingFlag::HierarchicalLogging);
|
||||||
Loggers::setLoggingLevel(Level::Global);
|
Loggers::setLoggingLevel(Level::Global);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Log::ConsoleOutput(bool enable) {
|
||||||
|
Conf.setGlobally(ConfigurationType::ToStandardOutput, enable ? "true":"false");
|
||||||
|
Loggers::reconfigureAllLoggers(Conf);
|
||||||
|
}
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ bool HTTP::ProgressBar(size_t c, size_t t) {
|
|||||||
if (isDownload) {
|
if (isDownload) {
|
||||||
static double progress_bar_adv;
|
static double progress_bar_adv;
|
||||||
progress_bar_adv = round(double(c) / double(t) * 25);
|
progress_bar_adv = round(double(c) / double(t) * 25);
|
||||||
|
if (UIData::Console) {
|
||||||
std::cout << "\r";
|
std::cout << "\r";
|
||||||
std::cout << "Progress: [ ";
|
std::cout << "Progress: [ ";
|
||||||
std::cout << round(double(c) / double(t) * 100);
|
std::cout << round(double(c) / double(t) * 100);
|
||||||
@@ -96,6 +97,7 @@ bool HTTP::ProgressBar(size_t c, size_t t) {
|
|||||||
for (i = 0; i < 25 - progress_bar_adv; i++) std::cout << ".";
|
for (i = 0; i < 25 - progress_bar_adv; i++) std::cout << ".";
|
||||||
std::cout << "]";
|
std::cout << "]";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (Launcher::Terminated()) {
|
if (Launcher::Terminated()) {
|
||||||
CliRef.load()->stop();
|
CliRef.load()->stop();
|
||||||
std::cout << '\n';
|
std::cout << '\n';
|
||||||
@@ -114,7 +116,11 @@ bool HTTP::Download(const std::string& IP, const std::string& Path, DownloadProg
|
|||||||
isDownload = false;
|
isDownload = false;
|
||||||
|
|
||||||
if (Ret.empty()) return false;
|
if (Ret.empty()) return false;
|
||||||
|
|
||||||
|
if (UIData::Console) {
|
||||||
std::cout << "\n";
|
std::cout << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
std::ofstream File(Path, std::ios::binary);
|
std::ofstream File(Path, std::ios::binary);
|
||||||
if (File.is_open()) {
|
if (File.is_open()) {
|
||||||
File << Ret;
|
File << Ret;
|
||||||
|
|||||||
@@ -34,56 +34,6 @@ bool VersionParser::operator==(const VersionParser& rhs) const noexcept {
|
|||||||
return std::is_eq(*this <=> rhs);
|
return std::is_eq(*this <=> rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Launcher::UpdateCheck() {
|
|
||||||
std::string link;
|
|
||||||
std::string HTTP =
|
|
||||||
HTTP::Get("https://beammp.com/builds/launcher?version=true");
|
|
||||||
bool fallback = false;
|
|
||||||
if (HTTP.find_first_of("0123456789") == std::string::npos) {
|
|
||||||
HTTP =
|
|
||||||
HTTP::Get("https://backup1.beammp.com/builds/launcher?version=true");
|
|
||||||
fallback = true;
|
|
||||||
if (HTTP.find_first_of("0123456789") == std::string::npos) {
|
|
||||||
LOG(FATAL) << "Primary Servers Offline! sorry for the inconvenience!";
|
|
||||||
throw ShutdownException("Fatal Error");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (fallback) {
|
|
||||||
link = "https://backup1.beammp.com/builds/launcher?download=true";
|
|
||||||
} else link = "https://beammp.com/builds/launcher?download=true";
|
|
||||||
|
|
||||||
std::string EP(CurrentPath.string()),
|
|
||||||
Back(CurrentPath.parent_path().string() + "\\BeamMP-Launcher.back");
|
|
||||||
|
|
||||||
if (fs::exists(Back)) remove(Back.c_str());
|
|
||||||
std::string RemoteVer;
|
|
||||||
for (char& c : HTTP) {
|
|
||||||
if (std::isdigit(c) || c == '.') {
|
|
||||||
RemoteVer += c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (VersionParser(RemoteVer) > VersionParser(FullVersion)) {
|
|
||||||
system("cls");
|
|
||||||
LOG(INFO) << "Update found! Downloading...";
|
|
||||||
if (std::rename(EP.c_str(), Back.c_str())) {
|
|
||||||
LOG(ERROR) << "Failed to create a backup!";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!HTTP::Download(link, EP)) {
|
|
||||||
LOG(ERROR) << "Launcher Update failed! trying again...";
|
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(2));
|
|
||||||
|
|
||||||
if (!HTTP::Download(link, EP)) {
|
|
||||||
LOG(ERROR) << "Launcher Update failed!";
|
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
|
||||||
AdminRelaunch();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Relaunch();
|
|
||||||
} else LOG(INFO) << "Launcher version is up to date";
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t DirCount(const std::filesystem::path& path) {
|
size_t DirCount(const std::filesystem::path& path) {
|
||||||
return (size_t)std::distance(std::filesystem::directory_iterator{path},
|
return (size_t)std::distance(std::filesystem::directory_iterator{path},
|
||||||
std::filesystem::directory_iterator{});
|
std::filesystem::directory_iterator{});
|
||||||
|
|||||||
+44
-11
@@ -401,6 +401,7 @@ bool MyApp::OnInit() {
|
|||||||
CheckKey();
|
CheckKey();
|
||||||
|
|
||||||
WindowsConsole(UIData::Console);
|
WindowsConsole(UIData::Console);
|
||||||
|
Log::ConsoleOutput(UIData::Console);
|
||||||
|
|
||||||
auto* MainFrame = new MyMainFrame();
|
auto* MainFrame = new MyMainFrame();
|
||||||
MyMainFrame::MainFrameInstance = MainFrame;
|
MyMainFrame::MainFrameInstance = MainFrame;
|
||||||
@@ -504,6 +505,8 @@ std::string GetPictureName() {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////// Progress Bar Function ///////////
|
||||||
bool ProgressBar (size_t c, size_t t) {
|
bool ProgressBar (size_t c, size_t t) {
|
||||||
int Percent = int(round(double(c) / double(t) * 100));
|
int Percent = int(round(double(c) / double(t) * 100));
|
||||||
MyMainFrame::MainFrameInstance->UpdateBar->SetValue(Percent);
|
MyMainFrame::MainFrameInstance->UpdateBar->SetValue(Percent);
|
||||||
@@ -511,6 +514,24 @@ bool ProgressBar (size_t c, size_t t) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////// Relaunch Functions ///////////
|
||||||
|
void AdminRelaunch(const std::string& executable) {
|
||||||
|
system("cls");
|
||||||
|
ShellExecuteA(nullptr, "runas", executable.c_str(), nullptr,
|
||||||
|
nullptr, SW_SHOWNORMAL);
|
||||||
|
ShowWindow(GetConsoleWindow(), 0);
|
||||||
|
throw ShutdownException("Launcher Relaunching");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Relaunch(const std::string& executable) {
|
||||||
|
ShellExecuteA(nullptr, "open", executable.c_str(), nullptr,
|
||||||
|
nullptr, SW_SHOWNORMAL);
|
||||||
|
ShowWindow(GetConsoleWindow(), 0);
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
|
throw ShutdownException("Launcher Relaunching");
|
||||||
|
}
|
||||||
|
|
||||||
/////////// Update Check Function ///////////
|
/////////// Update Check Function ///////////
|
||||||
void UpdateCheck() {
|
void UpdateCheck() {
|
||||||
std::string link;
|
std::string link;
|
||||||
@@ -525,11 +546,12 @@ void UpdateCheck() {
|
|||||||
if (fallback) {
|
if (fallback) {
|
||||||
link = "https://backup1.beammp.com/builds/launcher?download=true";
|
link = "https://backup1.beammp.com/builds/launcher?download=true";
|
||||||
} else link = "https://beammp.com/builds/launcher?download=true";
|
} else link = "https://beammp.com/builds/launcher?download=true";
|
||||||
auto CurrentPath = fs::current_path();
|
const auto CurrentPath = fs::current_path();
|
||||||
std::string EP(CurrentPath.append("BeamMP-Launcher.exe").string()), Back(CurrentPath.append("BeamMP-Launcher.back").string());
|
std::string EP((CurrentPath/"BeamMP-Launcher.exe").string()), Tmp(EP + ".tmp");
|
||||||
LOG(INFO) <<EP + " AND " + Back;
|
std::string Back((CurrentPath/"BeamMP-Launcher.back").string());
|
||||||
|
|
||||||
if (fs::exists(Back)) remove(Back.c_str());
|
if (fs::exists(Back)) remove(Back.c_str());
|
||||||
|
|
||||||
std::string RemoteVer;
|
std::string RemoteVer;
|
||||||
for (char& c : HTTP) {
|
for (char& c : HTTP) {
|
||||||
if (std::isdigit(c) || c == '.') {
|
if (std::isdigit(c) || c == '.') {
|
||||||
@@ -540,24 +562,28 @@ void UpdateCheck() {
|
|||||||
if (VersionParser(RemoteVer) > VersionParser(Launcher::FullVersion)) {
|
if (VersionParser(RemoteVer) > VersionParser(Launcher::FullVersion)) {
|
||||||
system("cls");
|
system("cls");
|
||||||
MyMainFrame::MainFrameInstance->txtUpdate->SetLabel("Downloading...");
|
MyMainFrame::MainFrameInstance->txtUpdate->SetLabel("Downloading...");
|
||||||
if (std::rename(EP.c_str(), Back.c_str())) {
|
|
||||||
wxMessageBox("Failed to create a backup!", "Error");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!HTTP::Download(link, EP, ProgressBar)) {
|
|
||||||
|
if (!HTTP::Download(link, Tmp, ProgressBar)) {
|
||||||
wxMessageBox("Launcher Update failed! trying again...", "Error");
|
wxMessageBox("Launcher Update failed! trying again...", "Error");
|
||||||
|
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(2));
|
std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||||
|
|
||||||
if (!HTTP::Download(link, EP, ProgressBar)) {
|
if (!HTTP::Download(link, Tmp, ProgressBar)) {
|
||||||
wxMessageBox("Launcher Update failed!", "Error");
|
wxMessageBox("Launcher Update failed!", "Error");
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||||
Launcher::AdminRelaunch();
|
AdminRelaunch(EP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Launcher::Relaunch();
|
|
||||||
} else MyMainFrame::MainFrameInstance->txtUpdate->SetLabel("BeamMP V" + Launcher::FullVersion);
|
|
||||||
|
|
||||||
|
MyMainFrame::MainFrameInstance->Destroy();
|
||||||
|
|
||||||
|
if (std::rename(EP.c_str(), Back.c_str()) || std::rename(Tmp.c_str(), EP.c_str())) {
|
||||||
|
LOG(ERROR) << "Failed to create a backup!";
|
||||||
|
}
|
||||||
|
|
||||||
|
Relaunch(EP);
|
||||||
|
} else MyMainFrame::MainFrameInstance->txtUpdate->SetLabel("BeamMP V" + Launcher::FullVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////// TestFrame Function ///////////
|
/////////// TestFrame Function ///////////
|
||||||
@@ -781,6 +807,7 @@ void MyMainFrame::GameVersionLabel() {
|
|||||||
std::string read = jsonRead();
|
std::string read = jsonRead();
|
||||||
if (!read.empty()) {
|
if (!read.empty()) {
|
||||||
txtGameVersion->SetLabel(read);
|
txtGameVersion->SetLabel(read);
|
||||||
|
UIData::GameVer = read;
|
||||||
VersionParser CurrentVersion(read);
|
VersionParser CurrentVersion(read);
|
||||||
if (CurrentVersion > Launcher::SupportedVersion)
|
if (CurrentVersion > Launcher::SupportedVersion)
|
||||||
txtGameVersion->SetForegroundColour(wxColour(255, 173, 0));
|
txtGameVersion->SetForegroundColour(wxColour(255, 173, 0));
|
||||||
@@ -790,6 +817,7 @@ void MyMainFrame::GameVersionLabel() {
|
|||||||
} else {
|
} else {
|
||||||
txtGameVersion->SetLabel(wxT("NA"));
|
txtGameVersion->SetLabel(wxT("NA"));
|
||||||
txtGameVersion->SetForegroundColour("red");
|
txtGameVersion->SetForegroundColour("red");
|
||||||
|
UIData::GameVer = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -831,6 +859,10 @@ void MyMainFrame::OnClickSettings(wxCommandEvent& event WXUNUSED(event)) {
|
|||||||
/////////// OnClick Launch Event ///////////
|
/////////// OnClick Launch Event ///////////
|
||||||
void MyMainFrame::OnClickLaunch(wxCommandEvent& event WXUNUSED(event)) {
|
void MyMainFrame::OnClickLaunch(wxCommandEvent& event WXUNUSED(event)) {
|
||||||
static bool FirstTime = true;
|
static bool FirstTime = true;
|
||||||
|
if(UIData::GameVer.empty()) {
|
||||||
|
wxMessageBox("Game path is invalid please check settings", "Error");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (Launcher::EntryThread.joinable()) Launcher::EntryThread.join();
|
if (Launcher::EntryThread.joinable()) Launcher::EntryThread.join();
|
||||||
Launcher::EntryThread = std::thread([&]() {
|
Launcher::EntryThread = std::thread([&]() {
|
||||||
entry();
|
entry();
|
||||||
@@ -889,6 +921,7 @@ void MyAccountFrame::OnClickLogout(wxCommandEvent& event WXUNUSED(event)) {
|
|||||||
/////////// OnClick Console Event ///////////
|
/////////// OnClick Console Event ///////////
|
||||||
void MySettingsFrame::OnClickConsole(wxCommandEvent& event) {
|
void MySettingsFrame::OnClickConsole(wxCommandEvent& event) {
|
||||||
WindowsConsole(checkConsole->IsChecked());
|
WindowsConsole(checkConsole->IsChecked());
|
||||||
|
Log::ConsoleOutput(checkConsole->IsChecked());
|
||||||
bool status = event.IsChecked();
|
bool status = event.IsChecked();
|
||||||
UpdateConfig("Console", status);
|
UpdateConfig("Console", status);
|
||||||
UIData::Console = status;
|
UIData::Console = status;
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ void entry() {
|
|||||||
launcher.RunDiscordRPC();
|
launcher.RunDiscordRPC();
|
||||||
launcher.LoadConfig(); // check if json (issue)
|
launcher.LoadConfig(); // check if json (issue)
|
||||||
launcher.CheckKey();
|
launcher.CheckKey();
|
||||||
launcher.QueryRegistry();
|
|
||||||
// UI call
|
// UI call
|
||||||
// launcher.SetupMOD();
|
// launcher.SetupMOD();
|
||||||
launcher.LaunchGame();
|
launcher.LaunchGame();
|
||||||
|
|||||||
Reference in New Issue
Block a user