mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
fix self install flow and progress bar
This commit is contained in:
parent
d54bb02f47
commit
5e81f3684f
4 changed files with 48 additions and 41 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue