1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-22 12:47:44 +00:00

Introduce LauncherCore::login, which removes the wierd if-else checks

For some reason the login call sites required them to handle whether or
not the profile was Sapphire or not, which is stupid.
This commit is contained in:
Joshua Goins 2022-09-05 16:05:39 -04:00
parent bf87010aca
commit ce7854626f
5 changed files with 20 additions and 16 deletions

View file

@ -59,11 +59,7 @@ bool CMDInterface::parse(QCommandLineParser& parser, LauncherCore& core) {
info->username = username; info->username = username;
info->password = password; info->password = password;
if (profile.isSapphire) { core.login(*info);
core.sapphireLauncher->login(profile.lobbyURL, *info);
} else {
core.squareBoot->bootCheck(*info);
}
} }
return true; return true;

View file

@ -153,6 +153,14 @@ public:
int addProfile(); int addProfile();
int deleteProfile(QString name); int deleteProfile(QString name);
/*
* Begins the login process, and may call SquareBoot or SapphireLauncher depending on the profile type.
* It's designed to be opaque as possible to the caller.
*
* The login process is asynchronous.
*/
void login(LoginInformation& loginInformation);
/* /*
* Launches the game using the provided authentication. * Launches the game using the provided authentication.
*/ */

View file

@ -723,3 +723,11 @@ void LauncherCore::readGameData(ProfileSettings& profile) {
physis_gamedata_free_sheet_header(exh); physis_gamedata_free_sheet_header(exh);
} }
} }
void LauncherCore::login(LoginInformation& loginInformation) {
if (loginInformation.settings->isSapphire) {
sapphireLauncher->login(loginInformation.settings->lobbyURL, loginInformation);
} else {
squareBoot->checkGateStatus(&loginInformation);
}
}

View file

@ -93,11 +93,7 @@ AutoLoginWindow::AutoLoginWindow(ProfileSettings& profile, LauncherCore& core, Q
free (totp); free (totp);
} }
if (profile.isSapphire) { core.login(*info);
core.sapphireLauncher->login(profile.lobbyURL, *info);
} else {
core.squareBoot->bootCheck(*info);
}
close(); close();
autologinTimer->stop(); autologinTimer->stop();

View file

@ -263,7 +263,7 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo
connect(core.assetUpdater, &AssetUpdater::finishedUpdating, [=] { connect(core.assetUpdater, &AssetUpdater::finishedUpdating, [=] {
auto& profile = currentProfile(); auto& profile = currentProfile();
LoginInformation* info = new LoginInformation(); auto info = new LoginInformation();
info->settings = &profile; info->settings = &profile;
info->username = usernameEdit->text(); info->username = usernameEdit->text();
info->password = passwordEdit->text(); info->password = passwordEdit->text();
@ -287,11 +287,7 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo
} }
#endif #endif
if (currentProfile().isSapphire) { this->core.login(*info);
this->core.sapphireLauncher->login(currentProfile().lobbyURL, *info);
} else {
this->core.squareBoot->checkGateStatus(info);
}
}); });
connect(loginButton, &QPushButton::released, [=] { connect(loginButton, &QPushButton::released, [=] {