1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-20 11:47:46 +00:00

Show a nice download prompt when updating boot

This commit is contained in:
Joshua Goins 2022-03-17 11:41:02 -04:00
parent 06c9658e94
commit 6dd7f600d9
4 changed files with 27 additions and 5 deletions

View file

@ -72,7 +72,7 @@ struct AppSettings {
};
struct LoginInformation {
const ProfileSettings* settings = nullptr;
ProfileSettings* settings = nullptr;
QString username, password, oneTimePassword;
};

View file

@ -1,5 +1,6 @@
#pragma once
#include <QProgressDialog>
#include "launchercore.h"
class SquareLauncher;
@ -11,6 +12,8 @@ public:
void bootCheck(LoginInformation& info);
private:
QProgressDialog* dialog;
LauncherCore& window;
SquareLauncher& launcher;
};

View file

@ -46,7 +46,7 @@ int main(int argc, char* argv[]) {
}
}
if(parser.isSet(autologinOption)) {
const auto profile = c.getProfile(c.defaultProfileIndex);
auto profile = c.getProfile(c.defaultProfileIndex);
if(!profile.rememberUsername || !profile.rememberPassword) {
qInfo() << "Profile does not have a username and/or password saved, autologin disabled.";
@ -93,7 +93,9 @@ int main(int argc, char* argv[]) {
auto installButton = messageBox->addButton("Install Game", QMessageBox::HelpRole);
c.connect(installButton, &QPushButton::clicked, [&c, messageBox] {
installGame(c, [messageBox] {
installGame(c, [messageBox, &c] {
c.readGameVersion();
messageBox->close();
});
});

View file

@ -15,6 +15,10 @@ SquareBoot::SquareBoot(LauncherCore& window, SquareLauncher& launcher) : window(
}
void SquareBoot::bootCheck(LoginInformation& info) {
dialog = new QProgressDialog();
dialog->setLabelText("Checking the FINAL FANTASY XIV Updater/Launcher version.");
dialog->show();
QUrlQuery query;
query.addQueryItem("time", QDateTime::currentDateTimeUtc().toString("yyyy-MM-dd-HH-mm"));
@ -38,8 +42,12 @@ void SquareBoot::bootCheck(LoginInformation& info) {
const QString response = reply->readAll();
if(response.isEmpty()) {
dialog->hide();
launcher.getStored(info);
} else {
dialog->setLabelText("Updating the FINAL FANTASY XIV Updater/Launcher version.");
// TODO: move this out into a dedicated function, we need to use this for regular game patches later on
// TODO: create a nice progress window like ffxivboot has
// TODO: improve flow when updating boot, maybe do at launch ala official launcher?
@ -56,8 +64,17 @@ void SquareBoot::bootCheck(LoginInformation& info) {
QString name = patchParts[4];
QString url = patchParts[5];
// TODO: show bytes recieved/total in the progress window, and speed
dialog->setLabelText("Updating the FINAL FANTASY XIV Updater/Launcher version.\nDownloading ffxivboot - " + name);
dialog->setMinimum(0);
dialog->setMaximum(length);
QNetworkRequest patchRequest(url);
auto patchReply = window.mgr->get(patchRequest);
connect(patchReply, &QNetworkReply::downloadProgress, [=](int recieved, int total) {
dialog->setValue(recieved);
});
connect(patchReply, &QNetworkReply::finished, [=] {
const QString dataDir =
QStandardPaths::writableLocation(QStandardPaths::TempLocation);
@ -75,9 +92,9 @@ void SquareBoot::bootCheck(LoginInformation& info) {
processPatch((dataDir + "/" + name + ".patch").toStdString(), (info.settings->gamePath + "/boot").toStdString());
auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, "Successfully updated", "ffxivboot is now updated to " + name);
info.settings->bootVersion = name;
messageBox->show();
launcher.getStored(info);
});
}
}