From d54bb02f477ce1259019520f89b140a3c5c65a80 Mon Sep 17 00:00:00 2001 From: luiscuenca Date: Sat, 27 Jul 2019 08:53:32 -0700 Subject: [PATCH 1/5] Fix installer process windows --- launchers/win32/LauncherDlg.cpp | 13 +++++++------ launchers/win32/LauncherManager.cpp | 11 +++++++++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/launchers/win32/LauncherDlg.cpp b/launchers/win32/LauncherDlg.cpp index d7d214842d..a82056bab0 100644 --- a/launchers/win32/LauncherDlg.cpp +++ b/launchers/win32/LauncherDlg.cpp @@ -702,13 +702,14 @@ void CLauncherDlg::OnTimer(UINT_PTR nIDEvent) { _splashStep = SPLASH_DURATION; setDrawDialog(DrawStep::DrawProcessUpdate); theApp._manager.updateProgress(LauncherManager::ProcessType::Uninstall, 0.0f); + } else if (theApp._manager.shouldSkipSplashScreen()) { + theApp._manager.updateProgress(LauncherManager::ProcessType::Uninstall, 1.0f); + setDrawDialog(DrawStep::DrawProcessFinishUpdate); + _splashStep = SPLASH_DURATION; + _showSplash = false; } else { - if (theApp._manager.shouldSkipSplashScreen()) { - _splashStep = SPLASH_DURATION; - } else { - theApp._manager.addToLog(_T("Start splash screen")); - setDrawDialog(DrawStep::DrawLogo); - } + theApp._manager.addToLog(_T("Start splash screen")); + setDrawDialog(DrawStep::DrawLogo); } } else if (_splashStep > SPLASH_DURATION && !theApp._manager.needsToWait()) { _showSplash = false; diff --git a/launchers/win32/LauncherManager.cpp b/launchers/win32/LauncherManager.cpp index d7d92a18fb..00bfe34957 100644 --- a/launchers/win32/LauncherManager.cpp +++ b/launchers/win32/LauncherManager.cpp @@ -611,11 +611,18 @@ void LauncherManager::onFileDownloaded(ProcessType type) { } void LauncherManager::restartNewLauncher() { + CString tempPath; + LauncherManager::getAndCreatePaths(LauncherManager::PathType::Temp_Directory, tempPath); + tempPath += "hql.exe"; + CString installPath; + LauncherManager::getAndCreatePaths(LauncherManager::PathType::Launcher_Directory, installPath); + installPath += LAUNCHER_EXE_FILENAME; + CopyFile(installPath, tempPath, false); closeLog(); if (_willContinueUpdating) { - LauncherUtils::launchApplication(_tempLauncherPath, _T(" --restart --noUpdate --continueUpdating")); + LauncherUtils::launchApplication(tempPath, _T(" --restart --noUpdate --continueUpdating")); } else { - LauncherUtils::launchApplication(_tempLauncherPath, _T(" --restart --noUpdate --skipSplash")); + LauncherUtils::launchApplication(tempPath, _T(" --restart --noUpdate --skipSplash")); } Sleep(500); } From 5e81f3684f18956e7684ae11d7beb902ad5da3b9 Mon Sep 17 00:00:00 2001 From: luiscuenca Date: Sat, 27 Jul 2019 20:57:43 -0700 Subject: [PATCH 2/5] fix self install flow and progress bar --- launchers/win32/LauncherApp.cpp | 13 +++++------ launchers/win32/LauncherDlg.cpp | 11 +++++---- launchers/win32/LauncherManager.cpp | 35 +++++++++++++++-------------- launchers/win32/LauncherManager.h | 30 ++++++++++++++----------- 4 files changed, 48 insertions(+), 41 deletions(-) diff --git a/launchers/win32/LauncherApp.cpp b/launchers/win32/LauncherApp.cpp index 841a0bee3b..eb3c275a77 100644 --- a/launchers/win32/LauncherApp.cpp +++ b/launchers/win32/LauncherApp.cpp @@ -42,8 +42,7 @@ BOOL CLauncherApp::InitInstance() { bool uninstalling = false; bool restarting = false; bool noUpdate = false; - bool continueUpdating = false; - bool skipSplash = false; + CLauncherDlg::DrawStep startScreen = CLauncherDlg::DrawStep::DrawLogo; if (iNumOfArgs > 1) { for (int i = 1; i < iNumOfArgs; i++) { CString curArg = CString(pArgs[i]); @@ -53,10 +52,10 @@ BOOL CLauncherApp::InitInstance() { restarting = true; } else if (curArg.Compare(_T("--noUpdate")) == 0) { noUpdate = true; - } else if (curArg.Compare(_T("--continueUpdating")) == 0) { - continueUpdating = true; - } else if (curArg.Compare(_T("--skipSplash")) == 0) { - skipSplash = true; + } else if (curArg.Compare(_T("--startScreen")) == 0) { + if (i + 1 < iNumOfArgs) { + startScreen = (CLauncherDlg::DrawStep)_wtoi(pArgs[i + 1]); + } } } } @@ -71,7 +70,7 @@ BOOL CLauncherApp::InitInstance() { if (uninstalling) { _manager.uninstall(); } else { - _manager.init(!noUpdate, continueUpdating, skipSplash); + _manager.init(!noUpdate, startScreen); } if (!_manager.hasFailed() && !_manager.installLauncher()) { return FALSE; diff --git a/launchers/win32/LauncherDlg.cpp b/launchers/win32/LauncherDlg.cpp index a82056bab0..b5e144a52f 100644 --- a/launchers/win32/LauncherDlg.cpp +++ b/launchers/win32/LauncherDlg.cpp @@ -357,7 +357,7 @@ void CLauncherDlg::drawVoxel(CHwndRenderTarget* pRenderTarget) { } void CLauncherDlg::drawProgress(CHwndRenderTarget* pRenderTarget, float progress, const D2D1::ColorF& color) { - auto size = pRenderTarget->GetPixelSize(); + auto size = pRenderTarget->GetSize(); if (progress == 0.0f) { return; } else { @@ -693,16 +693,19 @@ void CLauncherDlg::OnTimer(UINT_PTR nIDEvent) { } } } + + DrawStep startStep = theApp._manager.getStartScreen(); if (_showSplash) { if (_splashStep == 0) { if (theApp._manager.needsUninstall()) { theApp._manager.addToLog(_T("Waiting to uninstall")); setDrawDialog(DrawStep::DrawProcessUninstall); - } else if (theApp._manager.shouldContinueUpdating()) { - _splashStep = SPLASH_DURATION; + } else if (startStep == DrawStep::DrawProcessUpdate) { setDrawDialog(DrawStep::DrawProcessUpdate); theApp._manager.updateProgress(LauncherManager::ProcessType::Uninstall, 0.0f); - } else if (theApp._manager.shouldSkipSplashScreen()) { + } else if (startStep == DrawStep::DrawLoginLogin) { + _splashStep = SPLASH_DURATION; + } else if (startStep == DrawStep::DrawProcessFinishUpdate) { theApp._manager.updateProgress(LauncherManager::ProcessType::Uninstall, 1.0f); setDrawDialog(DrawStep::DrawProcessFinishUpdate); _splashStep = SPLASH_DURATION; diff --git a/launchers/win32/LauncherManager.cpp b/launchers/win32/LauncherManager.cpp index 00bfe34957..0ab7bc6a4b 100644 --- a/launchers/win32/LauncherManager.cpp +++ b/launchers/win32/LauncherManager.cpp @@ -16,22 +16,24 @@ LauncherManager::LauncherManager() { + int tokenPos = 0; + _launcherVersion = CString(LAUNCHER_BUILD_VERSION).Tokenize(_T("-"), tokenPos); } LauncherManager::~LauncherManager() { } -void LauncherManager::init(BOOL allowUpdate, BOOL continueUpdating, BOOL skipSplashScreen) { +void LauncherManager::init(BOOL allowUpdate, CLauncherDlg::DrawStep startScreen) { initLog(); - int tokenPos = 0; _updateLauncherAllowed = allowUpdate; - _continueUpdating = continueUpdating; - _skipSplashScreen = skipSplashScreen; - _shouldWait = !skipSplashScreen; - if (_continueUpdating) { + _startScreen = startScreen; + CString msg; + msg.Format(_T("Start Screen: %d"), (int)startScreen); + addToLog(msg); + _shouldWait = _startScreen == CLauncherDlg::DrawStep::DrawLogo; + if (_startScreen == CLauncherDlg::DrawStep::DrawProcessUpdate) { _progressOffset = CONTINUE_UPDATING_GLOBAL_OFFSET; } - _launcherVersion = CString(LAUNCHER_BUILD_VERSION).Tokenize(_T("-"), tokenPos); addToLog(_T("Launcher is running version: " + _launcherVersion)); addToLog(_T("Getting most recent builds")); getMostRecentBuilds(_latestLauncherURL, _latestLauncherVersion, _latestApplicationURL, _latestVersion); @@ -432,6 +434,7 @@ void LauncherManager::onMostRecentBuildsReceived(const CString& response, Launch addToLog(updatingMsg); _shouldUpdateLauncher = TRUE; _shouldDownloadLauncher = TRUE; + _willLogin = !isInstalled; _willContinueUpdating = isInstalled && newInterfaceVersion; } else { if (_updateLauncherAllowed) { @@ -611,19 +614,17 @@ void LauncherManager::onFileDownloaded(ProcessType type) { } void LauncherManager::restartNewLauncher() { - CString tempPath; - LauncherManager::getAndCreatePaths(LauncherManager::PathType::Temp_Directory, tempPath); - tempPath += "hql.exe"; - CString installPath; - LauncherManager::getAndCreatePaths(LauncherManager::PathType::Launcher_Directory, installPath); - installPath += LAUNCHER_EXE_FILENAME; - CopyFile(installPath, tempPath, false); closeLog(); + CLauncherDlg::DrawStep startScreen = CLauncherDlg::DrawStep::DrawProcessFinishUpdate; if (_willContinueUpdating) { - LauncherUtils::launchApplication(tempPath, _T(" --restart --noUpdate --continueUpdating")); - } else { - LauncherUtils::launchApplication(tempPath, _T(" --restart --noUpdate --skipSplash")); + startScreen = CLauncherDlg::DrawStep::DrawProcessUpdate; + } else if (_willLogin) { + startScreen = CLauncherDlg::DrawStep::DrawLoginLogin; } + CStringW params; + params.Format(_T(" --restart --noUpdate --startScreen %d"), (int)startScreen); + LPTSTR par = params.GetBuffer(); + LauncherUtils::launchApplication(_tempLauncherPath, par); Sleep(500); } diff --git a/launchers/win32/LauncherManager.h b/launchers/win32/LauncherManager.h index 108327469d..d63c07316f 100644 --- a/launchers/win32/LauncherManager.h +++ b/launchers/win32/LauncherManager.h @@ -11,6 +11,7 @@ #pragma once #include "LauncherUtils.h" +#include "LauncherDlg.h" const CString DIRECTORY_NAME_APP = _T("HQ"); const CString DIRECTORY_NAME_DOWNLOADS = _T("downloads"); @@ -27,8 +28,7 @@ const float DOWNLOAD_APPLICATION_UPDATE_WEIGHT = 0.75f; const float EXTRACT_APPLICATION_UPDATE_WEIGHT = 0.25f; const float CONTINUE_UPDATING_GLOBAL_OFFSET = 0.2f; -class LauncherManager -{ +class LauncherManager { public: enum PathType { Running_Path = 0, @@ -57,22 +57,25 @@ public: UnzipApplication, Uninstall }; + LauncherManager(); ~LauncherManager(); - void init(BOOL allowUpdate, BOOL continueUpdating, BOOL skipSplashScreen); + void init(BOOL allowUpdate, CLauncherDlg::DrawStep startScreen); BOOL initLog(); BOOL addToLog(const CString& line); void closeLog(); void saveErrorLog(); BOOL getAndCreatePaths(PathType type, CString& outPath); BOOL getInstalledVersion(const CString& path, CString& version); - BOOL isApplicationInstalled(CString& version, CString& domain, + BOOL isApplicationInstalled(CString& version, CString& domain, CString& content, bool& loggedIn); LauncherUtils::ResponseError getAccessTokenForCredentials(const CString& username, const CString& password); - void getMostRecentBuilds(CString& launcherUrlOut, CString& launcherVersionOut, - CString& interfaceUrlOut, CString& interfaceVersionOut); + void getMostRecentBuilds(CString& launcherUrlOut, + CString& launcherVersionOut, + CString& interfaceUrlOut, + CString& interfaceVersionOut); LauncherUtils::ResponseError readOrganizationJSON(const CString& hash); - LauncherUtils::ResponseError readConfigJSON(CString& version, CString& domain, + LauncherUtils::ResponseError readConfigJSON(CString& version, CString& domain, CString& content, bool& loggedIn); BOOL createConfigJSON(); BOOL createApplicationRegistryKeys(int size); @@ -90,7 +93,6 @@ public: const CString& getVersion() const { return _version; } BOOL shouldShutDown() const { return _shouldShutdown; } BOOL shouldLaunch() const { return _shouldLaunch; } - BOOL shouldSkipSplashScreen() const { return _skipSplashScreen; } BOOL needsUpdate() const { return _shouldUpdate; } BOOL needsSelfUpdate() const { return _shouldUpdateLauncher; } BOOL needsSelfDownload() const { return _shouldDownloadLauncher; } @@ -98,14 +100,17 @@ public: BOOL needsInstall() const { return _shouldInstall; } BOOL needsToWait() const { return _shouldWait; } BOOL needsRestartNewLauncher() const { return _shouldRestartNewLauncher; } - BOOL shouldContinueUpdating() const { return _continueUpdating; } BOOL willContinueUpdating() const { return _willContinueUpdating; } + CLauncherDlg::DrawStep getStartScreen() { return _startScreen; } void setDisplayName(const CString& displayName) { _displayName = displayName; } bool isLoggedIn() const { return _loggedIn; } bool hasFailed() const { return _hasFailed; } void setFailed(bool hasFailed) { _hasFailed = hasFailed; } const CString& getLatestInterfaceURL() const { return _latestApplicationURL; } - void uninstall() { _shouldUninstall = true; _shouldWait = false; }; + void uninstall() { + _shouldUninstall = true; + _shouldWait = false; + }; BOOL downloadFile(ProcessType type, const CString& url, CString& localPath); BOOL downloadContent(); @@ -149,11 +154,10 @@ private: BOOL _shouldDownloadLauncher { FALSE }; BOOL _updateLauncherAllowed { TRUE }; BOOL _shouldRestartNewLauncher { FALSE }; - BOOL _continueUpdating { FALSE }; + BOOL _willLogin { FALSE }; BOOL _willContinueUpdating { FALSE }; - BOOL _skipSplashScreen { FALSE }; + CLauncherDlg::DrawStep _startScreen; float _progressOffset { 0.0f }; float _progress { 0.0f }; CStdioFile _logFile; }; - From 8fde82dafcd774ee5f7e3a762719e2c5c4dc25c6 Mon Sep 17 00:00:00 2001 From: luiscuenca Date: Mon, 29 Jul 2019 07:57:54 -0700 Subject: [PATCH 3/5] Renamed variables --- launchers/win32/LauncherManager.cpp | 8 ++++---- launchers/win32/LauncherManager.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/launchers/win32/LauncherManager.cpp b/launchers/win32/LauncherManager.cpp index 0ab7bc6a4b..ed459bc48b 100644 --- a/launchers/win32/LauncherManager.cpp +++ b/launchers/win32/LauncherManager.cpp @@ -434,8 +434,8 @@ void LauncherManager::onMostRecentBuildsReceived(const CString& response, Launch addToLog(updatingMsg); _shouldUpdateLauncher = TRUE; _shouldDownloadLauncher = TRUE; - _willLogin = !isInstalled; - _willContinueUpdating = isInstalled && newInterfaceVersion; + _keepLoggingIn = !isInstalled; + _keepUpdating = isInstalled && newInterfaceVersion; } else { if (_updateLauncherAllowed) { addToLog(_T("Already running most recent build. Launching interface.exe")); @@ -616,9 +616,9 @@ void LauncherManager::onFileDownloaded(ProcessType type) { void LauncherManager::restartNewLauncher() { closeLog(); CLauncherDlg::DrawStep startScreen = CLauncherDlg::DrawStep::DrawProcessFinishUpdate; - if (_willContinueUpdating) { + if (_keepUpdating) { startScreen = CLauncherDlg::DrawStep::DrawProcessUpdate; - } else if (_willLogin) { + } else if (_keepLoggingIn) { startScreen = CLauncherDlg::DrawStep::DrawLoginLogin; } CStringW params; diff --git a/launchers/win32/LauncherManager.h b/launchers/win32/LauncherManager.h index d63c07316f..1246aff0bb 100644 --- a/launchers/win32/LauncherManager.h +++ b/launchers/win32/LauncherManager.h @@ -100,7 +100,7 @@ public: BOOL needsInstall() const { return _shouldInstall; } BOOL needsToWait() const { return _shouldWait; } BOOL needsRestartNewLauncher() const { return _shouldRestartNewLauncher; } - BOOL willContinueUpdating() const { return _willContinueUpdating; } + BOOL willContinueUpdating() const { return _keepUpdating; } CLauncherDlg::DrawStep getStartScreen() { return _startScreen; } void setDisplayName(const CString& displayName) { _displayName = displayName; } bool isLoggedIn() const { return _loggedIn; } @@ -154,8 +154,8 @@ private: BOOL _shouldDownloadLauncher { FALSE }; BOOL _updateLauncherAllowed { TRUE }; BOOL _shouldRestartNewLauncher { FALSE }; - BOOL _willLogin { FALSE }; - BOOL _willContinueUpdating { FALSE }; + BOOL _keepLoggingIn { FALSE }; + BOOL _keepUpdating { FALSE }; CLauncherDlg::DrawStep _startScreen; float _progressOffset { 0.0f }; float _progress { 0.0f }; From 677e0218efc630f9828caf2f2e0e370bbccbf693 Mon Sep 17 00:00:00 2001 From: luiscuenca Date: Tue, 30 Jul 2019 07:29:47 -0700 Subject: [PATCH 4/5] Pass a string as parameter to continue action --- launchers/win32/LauncherApp.cpp | 8 ++--- launchers/win32/LauncherDlg.cpp | 8 ++--- launchers/win32/LauncherManager.cpp | 53 +++++++++++++++++++++++------ launchers/win32/LauncherManager.h | 14 ++++++-- 4 files changed, 62 insertions(+), 21 deletions(-) diff --git a/launchers/win32/LauncherApp.cpp b/launchers/win32/LauncherApp.cpp index eb3c275a77..ff63841c5a 100644 --- a/launchers/win32/LauncherApp.cpp +++ b/launchers/win32/LauncherApp.cpp @@ -42,7 +42,7 @@ BOOL CLauncherApp::InitInstance() { bool uninstalling = false; bool restarting = false; bool noUpdate = false; - CLauncherDlg::DrawStep startScreen = CLauncherDlg::DrawStep::DrawLogo; + LauncherManager::ContinueActionOnStart continueAction = LauncherManager::ContinueActionOnStart::ContinueNone; if (iNumOfArgs > 1) { for (int i = 1; i < iNumOfArgs; i++) { CString curArg = CString(pArgs[i]); @@ -52,9 +52,9 @@ BOOL CLauncherApp::InitInstance() { restarting = true; } else if (curArg.Compare(_T("--noUpdate")) == 0) { noUpdate = true; - } else if (curArg.Compare(_T("--startScreen")) == 0) { + } else if (curArg.Compare(_T("--continueAction")) == 0) { if (i + 1 < iNumOfArgs) { - startScreen = (CLauncherDlg::DrawStep)_wtoi(pArgs[i + 1]); + continueAction = LauncherManager::getContinueActionFromParam(pArgs[i + 1]); } } } @@ -70,7 +70,7 @@ BOOL CLauncherApp::InitInstance() { if (uninstalling) { _manager.uninstall(); } else { - _manager.init(!noUpdate, startScreen); + _manager.init(!noUpdate, continueAction); } if (!_manager.hasFailed() && !_manager.installLauncher()) { return FALSE; diff --git a/launchers/win32/LauncherDlg.cpp b/launchers/win32/LauncherDlg.cpp index b5e144a52f..928bf7010f 100644 --- a/launchers/win32/LauncherDlg.cpp +++ b/launchers/win32/LauncherDlg.cpp @@ -694,18 +694,18 @@ void CLauncherDlg::OnTimer(UINT_PTR nIDEvent) { } } - DrawStep startStep = theApp._manager.getStartScreen(); + LauncherManager::ContinueActionOnStart continueAction = theApp._manager.getContinueAction(); if (_showSplash) { if (_splashStep == 0) { if (theApp._manager.needsUninstall()) { theApp._manager.addToLog(_T("Waiting to uninstall")); setDrawDialog(DrawStep::DrawProcessUninstall); - } else if (startStep == DrawStep::DrawProcessUpdate) { + } else if (continueAction == LauncherManager::ContinueActionOnStart::ContinueUpdate) { setDrawDialog(DrawStep::DrawProcessUpdate); theApp._manager.updateProgress(LauncherManager::ProcessType::Uninstall, 0.0f); - } else if (startStep == DrawStep::DrawLoginLogin) { + } else if (continueAction == LauncherManager::ContinueActionOnStart::ContinueLogIn) { _splashStep = SPLASH_DURATION; - } else if (startStep == DrawStep::DrawProcessFinishUpdate) { + } else if (continueAction == LauncherManager::ContinueActionOnStart::ContinueFinish) { theApp._manager.updateProgress(LauncherManager::ProcessType::Uninstall, 1.0f); setDrawDialog(DrawStep::DrawProcessFinishUpdate); _splashStep = SPLASH_DURATION; diff --git a/launchers/win32/LauncherManager.cpp b/launchers/win32/LauncherManager.cpp index ed459bc48b..46d65852e7 100644 --- a/launchers/win32/LauncherManager.cpp +++ b/launchers/win32/LauncherManager.cpp @@ -23,15 +23,15 @@ LauncherManager::LauncherManager() { LauncherManager::~LauncherManager() { } -void LauncherManager::init(BOOL allowUpdate, CLauncherDlg::DrawStep startScreen) { +void LauncherManager::init(BOOL allowUpdate, ContinueActionOnStart continueAction) { initLog(); _updateLauncherAllowed = allowUpdate; - _startScreen = startScreen; + _continueAction = continueAction; CString msg; - msg.Format(_T("Start Screen: %d"), (int)startScreen); + msg.Format(_T("Start Screen: %s"), getContinueActionParam(continueAction)); addToLog(msg); - _shouldWait = _startScreen == CLauncherDlg::DrawStep::DrawLogo; - if (_startScreen == CLauncherDlg::DrawStep::DrawProcessUpdate) { + _shouldWait = _continueAction == ContinueActionOnStart::ContinueNone; + if (_continueAction == ContinueActionOnStart::ContinueUpdate) { _progressOffset = CONTINUE_UPDATING_GLOBAL_OFFSET; } addToLog(_T("Launcher is running version: " + _launcherVersion)); @@ -39,6 +39,32 @@ void LauncherManager::init(BOOL allowUpdate, CLauncherDlg::DrawStep startScreen) getMostRecentBuilds(_latestLauncherURL, _latestLauncherVersion, _latestApplicationURL, _latestVersion); } +CString LauncherManager::getContinueActionParam(LauncherManager::ContinueActionOnStart continueAction) { + switch (continueAction) { + case LauncherManager::ContinueActionOnStart::ContinueNone: + return _T(""); + case LauncherManager::ContinueActionOnStart::ContinueLogIn: + return _T("LogIn"); + case LauncherManager::ContinueActionOnStart::ContinueUpdate: + return _T("Update"); + case LauncherManager::ContinueActionOnStart::ContinueFinish: + return _T("Finish"); + default: + return _T(""); + } +} + +LauncherManager::ContinueActionOnStart LauncherManager::getContinueActionFromParam(const CString& param) { + if (param.Compare(_T("LogIn")) == 0) { + return ContinueActionOnStart::ContinueLogIn; + } else if (param.Compare(_T("Update")) == 0) { + return ContinueActionOnStart::ContinueUpdate; + } else if (param.Compare(_T("Finish")) == 0) { + return ContinueActionOnStart::ContinueFinish; + } else { + return ContinueActionOnStart::ContinueNone; + } +} BOOL LauncherManager::initLog() { CString logPath; auto result = getAndCreatePaths(PathType::Launcher_Directory, logPath); @@ -614,17 +640,24 @@ void LauncherManager::onFileDownloaded(ProcessType type) { } void LauncherManager::restartNewLauncher() { + CString tempPath; + LauncherManager::getAndCreatePaths(LauncherManager::PathType::Temp_Directory, tempPath); + tempPath += "hql.exe"; + CString installPath; + LauncherManager::getAndCreatePaths(LauncherManager::PathType::Launcher_Directory, installPath); + installPath += LAUNCHER_EXE_FILENAME; + CopyFile(installPath, tempPath, false); closeLog(); - CLauncherDlg::DrawStep startScreen = CLauncherDlg::DrawStep::DrawProcessFinishUpdate; + ContinueActionOnStart continueAction = ContinueActionOnStart::ContinueFinish; if (_keepUpdating) { - startScreen = CLauncherDlg::DrawStep::DrawProcessUpdate; + continueAction = ContinueActionOnStart::ContinueUpdate; } else if (_keepLoggingIn) { - startScreen = CLauncherDlg::DrawStep::DrawLoginLogin; + continueAction = ContinueActionOnStart::ContinueLogIn; } CStringW params; - params.Format(_T(" --restart --noUpdate --startScreen %d"), (int)startScreen); + params.Format(_T(" --restart --noUpdate --continueAction %s"), getContinueActionParam(continueAction)); LPTSTR par = params.GetBuffer(); - LauncherUtils::launchApplication(_tempLauncherPath, par); + LauncherUtils::launchApplication(tempPath, par); Sleep(500); } diff --git a/launchers/win32/LauncherManager.h b/launchers/win32/LauncherManager.h index 1246aff0bb..5169edfa75 100644 --- a/launchers/win32/LauncherManager.h +++ b/launchers/win32/LauncherManager.h @@ -57,10 +57,18 @@ public: UnzipApplication, Uninstall }; + enum ContinueActionOnStart { + ContinueNone = 0, + ContinueLogIn, + ContinueUpdate, + ContinueFinish + }; LauncherManager(); ~LauncherManager(); - void init(BOOL allowUpdate, CLauncherDlg::DrawStep startScreen); + void init(BOOL allowUpdate, ContinueActionOnStart continueAction); + static CString getContinueActionParam(ContinueActionOnStart continueAction); + static ContinueActionOnStart getContinueActionFromParam(const CString& param); BOOL initLog(); BOOL addToLog(const CString& line); void closeLog(); @@ -101,7 +109,7 @@ public: BOOL needsToWait() const { return _shouldWait; } BOOL needsRestartNewLauncher() const { return _shouldRestartNewLauncher; } BOOL willContinueUpdating() const { return _keepUpdating; } - CLauncherDlg::DrawStep getStartScreen() { return _startScreen; } + ContinueActionOnStart getContinueAction() { return _continueAction; } void setDisplayName(const CString& displayName) { _displayName = displayName; } bool isLoggedIn() const { return _loggedIn; } bool hasFailed() const { return _hasFailed; } @@ -156,7 +164,7 @@ private: BOOL _shouldRestartNewLauncher { FALSE }; BOOL _keepLoggingIn { FALSE }; BOOL _keepUpdating { FALSE }; - CLauncherDlg::DrawStep _startScreen; + ContinueActionOnStart _continueAction; float _progressOffset { 0.0f }; float _progress { 0.0f }; CStdioFile _logFile; From 9fbacd49da4346c3fd63d1574297ad7ee892d7c8 Mon Sep 17 00:00:00 2001 From: luiscuenca Date: Tue, 30 Jul 2019 14:19:26 -0700 Subject: [PATCH 5/5] Delete testing code --- launchers/win32/LauncherManager.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/launchers/win32/LauncherManager.cpp b/launchers/win32/LauncherManager.cpp index 46d65852e7..49ae058ef5 100644 --- a/launchers/win32/LauncherManager.cpp +++ b/launchers/win32/LauncherManager.cpp @@ -640,13 +640,6 @@ void LauncherManager::onFileDownloaded(ProcessType type) { } void LauncherManager::restartNewLauncher() { - CString tempPath; - LauncherManager::getAndCreatePaths(LauncherManager::PathType::Temp_Directory, tempPath); - tempPath += "hql.exe"; - CString installPath; - LauncherManager::getAndCreatePaths(LauncherManager::PathType::Launcher_Directory, installPath); - installPath += LAUNCHER_EXE_FILENAME; - CopyFile(installPath, tempPath, false); closeLog(); ContinueActionOnStart continueAction = ContinueActionOnStart::ContinueFinish; if (_keepUpdating) { @@ -656,8 +649,7 @@ void LauncherManager::restartNewLauncher() { } CStringW params; params.Format(_T(" --restart --noUpdate --continueAction %s"), getContinueActionParam(continueAction)); - LPTSTR par = params.GetBuffer(); - LauncherUtils::launchApplication(tempPath, par); + LauncherUtils::launchApplication(_tempLauncherPath, params.GetBuffer()); Sleep(500); }