diff --git a/launcher/include/launchercore.h b/launcher/include/launchercore.h index bb023d2..723d608 100755 --- a/launcher/include/launchercore.h +++ b/launcher/include/launchercore.h @@ -106,7 +106,7 @@ public: /* * Launches the game using the provided authentication. */ - void launchGame(const Profile &settings, const LoginAuth &auth); + void launchGame(Profile &settings, const LoginAuth &auth); /* * This just wraps it in wine if needed. @@ -190,17 +190,17 @@ private: /* * Begins the game executable, but calls to Dalamud if needed. */ - void beginGameExecutable(const Profile &settings, const LoginAuth &auth); + void beginGameExecutable(Profile &settings, const LoginAuth &auth); /* * Starts a vanilla game session with no Dalamud injection. */ - void beginVanillaGame(const QString &gameExecutablePath, const Profile &profile, const LoginAuth &auth); + void beginVanillaGame(const QString &gameExecutablePath, Profile &profile, const LoginAuth &auth); /* * Starts a game session with Dalamud injected. */ - void beginDalamudGame(const QString &gameExecutablePath, const Profile &profile, const LoginAuth &auth); + void beginDalamudGame(const QString &gameExecutablePath, Profile &profile, const LoginAuth &auth); /* * Returns the game arguments needed to properly launch the game. This encrypts it too if needed, and it's already diff --git a/launcher/include/profile.h b/launcher/include/profile.h index 343b11e..9fdd75e 100644 --- a/launcher/include/profile.h +++ b/launcher/include/profile.h @@ -41,6 +41,7 @@ class Profile : public QObject Q_PROPERTY(QString expansionVersionText READ expansionVersionText NOTIFY gameInstallChanged) Q_PROPERTY(QString dalamudVersionText READ dalamudVersionText NOTIFY gameInstallChanged) Q_PROPERTY(QString wineVersionText READ wineVersionText NOTIFY wineChanged) + Q_PROPERTY(bool loggedIn READ loggedIn NOTIFY loggedInChanged) public: explicit Profile(LauncherCore &launcher, const QString &key, QObject *parent = nullptr); @@ -148,6 +149,9 @@ public: BootData *bootData(); GameData *gameData(); + bool loggedIn() const; + void setLoggedIn(bool value); + Q_SIGNALS: void gameInstallChanged(); void nameChanged(); @@ -171,6 +175,7 @@ Q_SIGNALS: void encryptedArgumentsChanged(); void accountChanged(); void wineChanged(); + void loggedInChanged(); private: QString m_uuid; @@ -190,5 +195,7 @@ private: int m_dalamudAssetVersion = -1; QString m_runtimeVersion; + bool m_loggedIn = false; + LauncherCore &m_launcher; }; \ No newline at end of file diff --git a/launcher/src/launchercore.cpp b/launcher/src/launchercore.cpp index 632a8d0..49353d9 100755 --- a/launcher/src/launchercore.cpp +++ b/launcher/src/launchercore.cpp @@ -56,7 +56,7 @@ void LauncherCore::buildRequest(const Profile &settings, QNetworkRequest &reques request.setRawHeader(QByteArrayLiteral("Accept-Language"), QByteArrayLiteral("en-us")); } -void LauncherCore::launchGame(const Profile &profile, const LoginAuth &auth) +void LauncherCore::launchGame(Profile &profile, const LoginAuth &auth) { m_steamApi->setLauncherMode(false); @@ -87,7 +87,7 @@ QCoro::Task<> LauncherCore::beginLogin(LoginInformation &info) assetUpdater->deleteLater(); } -void LauncherCore::beginGameExecutable(const Profile &profile, const LoginAuth &auth) +void LauncherCore::beginGameExecutable(Profile &profile, const LoginAuth &auth) { Q_EMIT stageChanged(i18n("Launching game...")); @@ -104,14 +104,17 @@ void LauncherCore::beginGameExecutable(const Profile &profile, const LoginAuth & beginVanillaGame(gameExectuable, profile, auth); } - successfulLaunch(); + Q_EMIT successfulLaunch(); } -void LauncherCore::beginVanillaGame(const QString &gameExecutablePath, const Profile &profile, const LoginAuth &auth) +void LauncherCore::beginVanillaGame(const QString &gameExecutablePath, Profile &profile, const LoginAuth &auth) { + profile.setLoggedIn(true); + auto gameProcess = new QProcess(this); gameProcess->setProcessEnvironment(QProcessEnvironment::systemEnvironment()); - connect(gameProcess, &QProcess::finished, this, [this](int exitCode) { + connect(gameProcess, &QProcess::finished, this, [this, &profile](int exitCode) { + profile.setLoggedIn(false); Q_UNUSED(exitCode) Q_EMIT gameClosed(); }); @@ -121,8 +124,10 @@ void LauncherCore::beginVanillaGame(const QString &gameExecutablePath, const Pro launchExecutable(profile, gameProcess, {gameExecutablePath, args}, true, true); } -void LauncherCore::beginDalamudGame(const QString &gameExecutablePath, const Profile &profile, const LoginAuth &auth) +void LauncherCore::beginDalamudGame(const QString &gameExecutablePath, Profile &profile, const LoginAuth &auth) { + profile.setLoggedIn(true); + const QDir dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); const QDir configDir = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation); const QDir stateDir = Utility::stateDirectory(); @@ -151,7 +156,8 @@ void LauncherCore::beginDalamudGame(const QString &gameExecutablePath, const Pro const QString dalamudInjector = dalamudInstallDir.absoluteFilePath(QStringLiteral("Dalamud.Injector.exe")); auto dalamudProcess = new QProcess(this); - connect(dalamudProcess, &QProcess::finished, this, [this](int exitCode) { + connect(dalamudProcess, &QProcess::finished, this, [this, &profile](int exitCode) { + profile.setLoggedIn(false); Q_UNUSED(exitCode) Q_EMIT gameClosed(); }); diff --git a/launcher/src/profile.cpp b/launcher/src/profile.cpp index 800f218..c6c2ab3 100644 --- a/launcher/src/profile.cpp +++ b/launcher/src/profile.cpp @@ -574,3 +574,16 @@ GameData *Profile::gameData() { return m_gameData; } + +bool Profile::loggedIn() const +{ + return m_loggedIn; +} + +void Profile::setLoggedIn(const bool value) +{ + if (m_loggedIn != value) { + m_loggedIn = value; + Q_EMIT loggedInChanged(); + } +} diff --git a/launcher/ui/Main.qml b/launcher/ui/Main.qml index 9ea2910..a86600a 100644 --- a/launcher/ui/Main.qml +++ b/launcher/ui/Main.qml @@ -22,6 +22,8 @@ Kirigami.ApplicationWindow { visible: true title: LauncherCore.isSteam ? "Astra (Steam)" : "Astra" + property bool checkedAutoLogin: false + pageStack.initialPage: Kirigami.Page { Kirigami.LoadingPlaceholder { anchors.centerIn: parent @@ -46,8 +48,9 @@ Kirigami.ApplicationWindow { profile: LauncherCore.currentProfile }) } else { - if (LauncherCore.autoLoginProfile) { + if (LauncherCore.autoLoginProfile && !checkedAutoLogin) { pageStack.layers.replace(Qt.createComponent("zone.xiv.astra", "AutoLoginPage")) + checkedAutoLogin = true; } else { pageStack.layers.replace(Qt.createComponent("zone.xiv.astra", "MainPage")) } diff --git a/launcher/ui/Pages/AutoLoginPage.qml b/launcher/ui/Pages/AutoLoginPage.qml index 942f592..3b09eb1 100644 --- a/launcher/ui/Pages/AutoLoginPage.qml +++ b/launcher/ui/Pages/AutoLoginPage.qml @@ -37,6 +37,7 @@ Kirigami.Page { interval: 5000 running: true onTriggered: { + autoLoginTimer.stop(); LauncherCore.autoLogin(LauncherCore.autoLoginProfile); pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "StatusPage")); } diff --git a/launcher/ui/Pages/LoginPage.qml b/launcher/ui/Pages/LoginPage.qml index 81724a8..07b2056 100644 --- a/launcher/ui/Pages/LoginPage.qml +++ b/launcher/ui/Pages/LoginPage.qml @@ -31,6 +31,10 @@ QQC2.Control { return false } + if (LauncherCore.currentProfile.loggedIn) { + return false; + } + return true; }