From 6dd7f600d906e6baaaab7d35d689e1fcd39e92d8 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Thu, 17 Mar 2022 11:41:02 -0400 Subject: [PATCH] Show a nice download prompt when updating boot --- include/launchercore.h | 2 +- include/squareboot.h | 3 +++ src/main.cpp | 6 ++++-- src/squareboot.cpp | 21 +++++++++++++++++++-- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/include/launchercore.h b/include/launchercore.h index 1bfb8ba..5ba9b6a 100755 --- a/include/launchercore.h +++ b/include/launchercore.h @@ -72,7 +72,7 @@ struct AppSettings { }; struct LoginInformation { - const ProfileSettings* settings = nullptr; + ProfileSettings* settings = nullptr; QString username, password, oneTimePassword; }; diff --git a/include/squareboot.h b/include/squareboot.h index 3b47740..d83f652 100644 --- a/include/squareboot.h +++ b/include/squareboot.h @@ -1,5 +1,6 @@ #pragma once +#include #include "launchercore.h" class SquareLauncher; @@ -11,6 +12,8 @@ public: void bootCheck(LoginInformation& info); private: + QProgressDialog* dialog; + LauncherCore& window; SquareLauncher& launcher; }; \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 37b7cf7..0ac6ee6 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -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(); }); }); diff --git a/src/squareboot.cpp b/src/squareboot.cpp index 58c258e..3e220b0 100644 --- a/src/squareboot.cpp +++ b/src/squareboot.cpp @@ -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); }); } }