mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-20 19:57:45 +00:00
Support cancelling and resuming asset updating
This commit is contained in:
parent
d939d26280
commit
a6502fe9d5
2 changed files with 25 additions and 0 deletions
|
@ -49,4 +49,6 @@ private:
|
||||||
QJsonArray remoteDalamudAssetArray;
|
QJsonArray remoteDalamudAssetArray;
|
||||||
|
|
||||||
QString dataDir;
|
QString dataDir;
|
||||||
|
|
||||||
|
bool wantsCancel = false;
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,6 +35,10 @@ AssetUpdater::AssetUpdater(LauncherCore& launcher) : launcher(launcher) {
|
||||||
|
|
||||||
dialog = new QProgressDialog("Updating assets...", "Cancel", 0, 0);
|
dialog = new QProgressDialog("Updating assets...", "Cancel", 0, 0);
|
||||||
|
|
||||||
|
connect(dialog, &QProgressDialog::canceled, [this] {
|
||||||
|
wantsCancel = true;
|
||||||
|
});
|
||||||
|
|
||||||
dataDir =
|
dataDir =
|
||||||
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||||
}
|
}
|
||||||
|
@ -46,6 +50,9 @@ void AssetUpdater::update(const ProfileSettings& profile) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wantsCancel = false;
|
||||||
|
dialog->show();
|
||||||
|
|
||||||
// first, we want to collect all of the remote versions
|
// first, we want to collect all of the remote versions
|
||||||
|
|
||||||
qInfo() << "Starting update sequence...";
|
qInfo() << "Starting update sequence...";
|
||||||
|
@ -54,6 +61,9 @@ void AssetUpdater::update(const ProfileSettings& profile) {
|
||||||
// dalamud assets
|
// dalamud assets
|
||||||
{
|
{
|
||||||
// we want to prevent logging in before we actually check the version
|
// we want to prevent logging in before we actually check the version
|
||||||
|
dalamudAssetNeededFilenames.clear();
|
||||||
|
remoteDalamudAssetVersion = -1;
|
||||||
|
|
||||||
dalamudAssetNeededFilenames.append("dummy");
|
dalamudAssetNeededFilenames.append("dummy");
|
||||||
|
|
||||||
// first we want to fetch the list of assets required
|
// first we want to fetch the list of assets required
|
||||||
|
@ -101,6 +111,9 @@ void AssetUpdater::update(const ProfileSettings& profile) {
|
||||||
{
|
{
|
||||||
QNetworkRequest request(dalamudVersionManifestURL);
|
QNetworkRequest request(dalamudVersionManifestURL);
|
||||||
|
|
||||||
|
remoteDalamudVersion.clear();
|
||||||
|
remoteRuntimeVersion.clear();
|
||||||
|
|
||||||
auto reply = launcher.mgr->get(request);
|
auto reply = launcher.mgr->get(request);
|
||||||
connect(reply, &QNetworkReply::finished, [this, profile, reply] {
|
connect(reply, &QNetworkReply::finished, [this, profile, reply] {
|
||||||
dialog->setLabelText("Checking for Dalamud updates...");
|
dialog->setLabelText("Checking for Dalamud updates...");
|
||||||
|
@ -173,6 +186,9 @@ void AssetUpdater::beginInstall() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssetUpdater::checkIfDalamudAssetsDone() {
|
void AssetUpdater::checkIfDalamudAssetsDone() {
|
||||||
|
if(wantsCancel)
|
||||||
|
return;
|
||||||
|
|
||||||
if(dalamudAssetNeededFilenames.empty()) {
|
if(dalamudAssetNeededFilenames.empty()) {
|
||||||
qInfo() << "Finished downloading Dalamud assets.";
|
qInfo() << "Finished downloading Dalamud assets.";
|
||||||
|
|
||||||
|
@ -188,6 +204,9 @@ void AssetUpdater::checkIfDalamudAssetsDone() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssetUpdater::checkIfFinished() {
|
void AssetUpdater::checkIfFinished() {
|
||||||
|
if(wantsCancel)
|
||||||
|
return;
|
||||||
|
|
||||||
if (doneDownloadingDalamud &&
|
if (doneDownloadingDalamud &&
|
||||||
doneDownloadingNativelauncher &&
|
doneDownloadingNativelauncher &&
|
||||||
doneDownloadingRuntimeCore &&
|
doneDownloadingRuntimeCore &&
|
||||||
|
@ -203,7 +222,11 @@ void AssetUpdater::checkIfFinished() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssetUpdater::checkIfCheckingIsDone() {
|
void AssetUpdater::checkIfCheckingIsDone() {
|
||||||
|
if(wantsCancel)
|
||||||
|
return;
|
||||||
|
|
||||||
if(remoteDalamudVersion.isEmpty() || remoteRuntimeVersion.isEmpty() || remoteDalamudAssetVersion == -1) {
|
if(remoteDalamudVersion.isEmpty() || remoteRuntimeVersion.isEmpty() || remoteDalamudAssetVersion == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue