mirror of
https://github.com/redstrate/Astra.git
synced 2025-05-11 20:47:45 +00:00
Prompt for updates before actually downloading them
This is to prevent "surprise" situations, such as: * You have a limited internet connection, and the game updates out of the blue. * Your installation is invalid, and Astra decides to suddenly redownload the entire game.
This commit is contained in:
parent
d1ef676e7d
commit
6f499927be
3 changed files with 48 additions and 4 deletions
|
@ -163,6 +163,8 @@ Q_SIGNALS:
|
|||
void autoLoginProfileChanged();
|
||||
void cachedLogoImageChanged();
|
||||
void showWindow();
|
||||
void requiresUpdate(QString message);
|
||||
void updateDecided(bool allowUpdate);
|
||||
|
||||
protected:
|
||||
friend class Patcher;
|
||||
|
|
|
@ -3,8 +3,10 @@
|
|||
|
||||
#include "squareenixlogin.h"
|
||||
|
||||
#include <KFormat>
|
||||
#include <KLocalizedString>
|
||||
#include <KSandbox>
|
||||
#include <QCoroSignal>
|
||||
#include <QDesktopServices>
|
||||
#include <QFile>
|
||||
#include <QNetworkReply>
|
||||
|
@ -187,15 +189,27 @@ QCoro::Task<bool> SquareEnixLogin::checkBootUpdates()
|
|||
if (!patchList.isEmpty()) {
|
||||
qDebug(ASTRA_LOG) << "Boot patch list:" << patchList;
|
||||
|
||||
const std::string patchListStd = patchList.toStdString();
|
||||
const auto parsedPatchList = physis_parse_patchlist(PatchListType::Boot, patchListStd.c_str());
|
||||
|
||||
if (!m_info->profile->config()->allowPatching()) {
|
||||
Q_EMIT m_launcher.loginError(
|
||||
i18n("You require an update to play, but you have the “Allow Updates” option checked - so the login was canceled."));
|
||||
co_return false;
|
||||
}
|
||||
|
||||
const qint64 neededSpace = parsedPatchList.patch_length;
|
||||
KFormat format;
|
||||
QString neededSpaceStr = format.formatByteSize(neededSpace);
|
||||
Q_EMIT m_launcher.requiresUpdate(
|
||||
i18n("The boot components require an update, which will download %1 of data. Do you still want to continue?", neededSpaceStr));
|
||||
const bool wantsToUpdate = co_await qCoro(&m_launcher, &LauncherCore::updateDecided);
|
||||
if (!wantsToUpdate) {
|
||||
co_return false;
|
||||
}
|
||||
|
||||
m_patcher = new Patcher(m_launcher, m_info->profile->config()->gamePath() + QStringLiteral("/boot"), *m_info->profile->bootData(), this);
|
||||
const std::string patchListStd = patchList.toStdString();
|
||||
const bool hasPatched = co_await m_patcher->patch(physis_parse_patchlist(PatchListType::Boot, patchListStd.c_str()));
|
||||
const bool hasPatched = co_await m_patcher->patch(parsedPatchList);
|
||||
if (hasPatched) {
|
||||
// update game version information
|
||||
m_info->profile->readGameVersion();
|
||||
|
@ -394,9 +408,21 @@ QCoro::Task<bool> SquareEnixLogin::registerSession()
|
|||
co_return false;
|
||||
}
|
||||
|
||||
m_patcher = new Patcher(m_launcher, m_info->profile->config()->gamePath() + QStringLiteral("/game"), *m_info->profile->gameData(), this);
|
||||
std::string bodyStd = body.toStdString();
|
||||
const bool hasPatched = co_await m_patcher->patch(physis_parse_patchlist(PatchListType::Game, bodyStd.c_str()));
|
||||
const auto parsedPatchList = physis_parse_patchlist(PatchListType::Game, bodyStd.c_str());
|
||||
|
||||
const qint64 neededSpace = parsedPatchList.patch_length;
|
||||
KFormat format;
|
||||
QString neededSpaceStr = format.formatByteSize(neededSpace);
|
||||
Q_EMIT m_launcher.requiresUpdate(
|
||||
i18n("The game require an update, which will download %1 of data. Do you still want to continue?", neededSpaceStr));
|
||||
const bool wantsToUpdate = co_await qCoro(&m_launcher, &LauncherCore::updateDecided);
|
||||
if (!wantsToUpdate) {
|
||||
co_return false;
|
||||
}
|
||||
|
||||
m_patcher = new Patcher(m_launcher, m_info->profile->config()->gamePath() + QStringLiteral("/game"), *m_info->profile->gameData(), this);
|
||||
const bool hasPatched = co_await m_patcher->patch(parsedPatchList);
|
||||
m_patcher->deleteLater();
|
||||
if (!hasPatched) {
|
||||
co_return false;
|
||||
|
|
|
@ -55,6 +55,16 @@ Kirigami.Page {
|
|||
onRejected: applicationWindow().checkSetup()
|
||||
}
|
||||
|
||||
Kirigami.PromptDialog {
|
||||
id: updateRequiredDialog
|
||||
|
||||
showCloseButton: false
|
||||
standardButtons: Kirigami.Dialog.Yes | Kirigami.Dialog.Cancel
|
||||
|
||||
onAccepted: LauncherCore.updateDecided(true)
|
||||
onRejected: LauncherCore.updateDecided(false)
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: LauncherCore
|
||||
|
||||
|
@ -90,5 +100,11 @@ Kirigami.Page {
|
|||
dalamudErrorDialog.subtitle = i18n("An error occurred while updating Dalamud:\n\n%1.\n\nWould you like to disable Dalamud?", message);
|
||||
dalamudErrorDialog.open();
|
||||
}
|
||||
|
||||
function onRequiresUpdate(message: string): void {
|
||||
updateDialog.title = i18n("Update Required");
|
||||
updateDialog.subtitle = message;
|
||||
updateDialog.open();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue