mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-07 06:02:28 +02:00
Pass a string as parameter to continue action
This commit is contained in:
parent
8fde82dafc
commit
677e0218ef
4 changed files with 62 additions and 21 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue