2022-05-02 18:33:21 +01:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
/*
|
|
|
|
* PolyMC - Minecraft Launcher
|
2022-05-15 12:20:05 +01:00
|
|
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
2022-05-02 18:33:21 +01:00
|
|
|
* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
|
2020-06-07 16:46:12 +01:00
|
|
|
*
|
2022-05-02 18:33:21 +01:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, version 3.
|
2020-06-07 16:46:12 +01:00
|
|
|
*
|
2022-05-02 18:33:21 +01:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2020-06-07 16:46:12 +01:00
|
|
|
*
|
2022-05-02 18:33:21 +01:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following copyright and
|
|
|
|
* permission notice:
|
|
|
|
*
|
|
|
|
* Copyright 2013-2021 MultiMC Contributors
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2020-06-07 16:46:12 +01:00
|
|
|
*/
|
|
|
|
|
2016-10-02 23:55:54 +01:00
|
|
|
#include "InstanceImportTask.h"
|
2022-04-22 02:12:14 +01:00
|
|
|
#include <QtConcurrentRun>
|
|
|
|
#include "Application.h"
|
2016-10-02 23:55:54 +01:00
|
|
|
#include "BaseInstance.h"
|
|
|
|
#include "FileSystem.h"
|
|
|
|
#include "MMCZip.h"
|
|
|
|
#include "NullInstance.h"
|
2022-04-22 02:12:14 +01:00
|
|
|
#include "icons/IconList.h"
|
2019-05-31 20:52:58 +01:00
|
|
|
#include "icons/IconUtils.h"
|
2022-04-22 02:12:14 +01:00
|
|
|
#include "settings/INISettingsObject.h"
|
2017-04-21 21:23:31 +01:00
|
|
|
|
2017-04-22 17:51:04 +01:00
|
|
|
// FIXME: this does not belong here, it's Minecraft/Flame specific
|
2022-04-22 02:12:14 +01:00
|
|
|
#include <quazip/quazipdir.h>
|
|
|
|
#include "Json.h"
|
2017-07-24 08:01:37 +01:00
|
|
|
#include "minecraft/MinecraftInstance.h"
|
2020-06-27 11:02:31 +01:00
|
|
|
#include "minecraft/PackProfile.h"
|
2018-03-16 22:33:58 +00:00
|
|
|
#include "modplatform/flame/FileResolvingTask.h"
|
|
|
|
#include "modplatform/flame/PackManifest.h"
|
2022-01-31 14:25:36 +00:00
|
|
|
#include "modplatform/modrinth/ModrinthPackManifest.h"
|
2020-06-07 16:46:12 +01:00
|
|
|
#include "modplatform/technic/TechnicPackProcessor.h"
|
2016-10-02 23:55:54 +01:00
|
|
|
|
2021-11-21 22:21:12 +00:00
|
|
|
#include "Application.h"
|
2022-05-16 02:16:52 +01:00
|
|
|
#include "icons/IconList.h"
|
2022-01-31 14:25:36 +00:00
|
|
|
#include "net/ChecksumValidator.h"
|
|
|
|
|
2022-05-16 02:16:52 +01:00
|
|
|
#include "ui/dialogs/CustomMessageBox.h"
|
2022-05-28 20:53:12 +01:00
|
|
|
#include "ui/dialogs/ScrollMessageBox.h"
|
2022-05-16 02:16:52 +01:00
|
|
|
|
2022-01-31 14:25:36 +00:00
|
|
|
#include <algorithm>
|
2021-11-21 22:21:12 +00:00
|
|
|
|
2022-05-16 02:16:52 +01:00
|
|
|
InstanceImportTask::InstanceImportTask(const QUrl sourceUrl, QWidget* parent)
|
2016-10-02 23:55:54 +01:00
|
|
|
{
|
2018-07-15 13:51:05 +01:00
|
|
|
m_sourceUrl = sourceUrl;
|
2022-05-16 02:16:52 +01:00
|
|
|
m_parent = parent;
|
2016-10-02 23:55:54 +01:00
|
|
|
}
|
|
|
|
|
2022-04-07 22:56:34 +01:00
|
|
|
bool InstanceImportTask::abort()
|
|
|
|
{
|
2022-05-28 00:41:57 +01:00
|
|
|
if (m_filesNetJob)
|
|
|
|
m_filesNetJob->abort();
|
2022-04-07 22:56:34 +01:00
|
|
|
m_extractFuture.cancel();
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-10-02 23:55:54 +01:00
|
|
|
void InstanceImportTask::executeTask()
|
|
|
|
{
|
2018-07-15 13:51:05 +01:00
|
|
|
if (m_sourceUrl.isLocalFile())
|
|
|
|
{
|
|
|
|
m_archivePath = m_sourceUrl.toLocalFile();
|
|
|
|
processZipPack();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
setStatus(tr("Downloading modpack:\n%1").arg(m_sourceUrl.toString()));
|
|
|
|
m_downloadRequired = true;
|
2016-10-02 23:55:54 +01:00
|
|
|
|
2018-07-15 13:51:05 +01:00
|
|
|
const QString path = m_sourceUrl.host() + '/' + m_sourceUrl.path();
|
2021-11-21 22:21:12 +00:00
|
|
|
auto entry = APPLICATION->metacache()->resolveEntry("general", path);
|
2018-07-15 13:51:05 +01:00
|
|
|
entry->setStale(true);
|
2021-12-31 04:27:59 +00:00
|
|
|
m_filesNetJob = new NetJob(tr("Modpack download"), APPLICATION->network());
|
2018-07-15 13:51:05 +01:00
|
|
|
m_filesNetJob->addNetAction(Net::Download::makeCached(m_sourceUrl, entry));
|
|
|
|
m_archivePath = entry->getFullPath();
|
|
|
|
auto job = m_filesNetJob.get();
|
|
|
|
connect(job, &NetJob::succeeded, this, &InstanceImportTask::downloadSucceeded);
|
|
|
|
connect(job, &NetJob::progress, this, &InstanceImportTask::downloadProgressChanged);
|
|
|
|
connect(job, &NetJob::failed, this, &InstanceImportTask::downloadFailed);
|
2021-12-31 04:27:59 +00:00
|
|
|
m_filesNetJob->start();
|
2018-07-15 13:51:05 +01:00
|
|
|
}
|
2016-10-02 23:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void InstanceImportTask::downloadSucceeded()
|
|
|
|
{
|
2018-07-15 13:51:05 +01:00
|
|
|
processZipPack();
|
|
|
|
m_filesNetJob.reset();
|
2016-10-02 23:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void InstanceImportTask::downloadFailed(QString reason)
|
|
|
|
{
|
2018-07-15 13:51:05 +01:00
|
|
|
emitFailed(reason);
|
|
|
|
m_filesNetJob.reset();
|
2016-10-02 23:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void InstanceImportTask::downloadProgressChanged(qint64 current, qint64 total)
|
|
|
|
{
|
2018-07-15 13:51:05 +01:00
|
|
|
setProgress(current / 2, total);
|
2016-10-02 23:55:54 +01:00
|
|
|
}
|
|
|
|
|
2017-09-04 07:17:25 +01:00
|
|
|
void InstanceImportTask::processZipPack()
|
2016-10-02 23:55:54 +01:00
|
|
|
{
|
2018-07-15 13:51:05 +01:00
|
|
|
setStatus(tr("Extracting modpack"));
|
|
|
|
QDir extractDir(m_stagingPath);
|
|
|
|
qDebug() << "Attempting to create instance from" << m_archivePath;
|
2016-10-26 17:12:33 +01:00
|
|
|
|
2018-07-15 13:51:05 +01:00
|
|
|
// open the zip and find relevant files in it
|
|
|
|
m_packZip.reset(new QuaZip(m_archivePath));
|
|
|
|
if (!m_packZip->open(QuaZip::mdUnzip))
|
|
|
|
{
|
|
|
|
emitFailed(tr("Unable to open supplied modpack zip file."));
|
|
|
|
return;
|
|
|
|
}
|
2017-09-04 07:17:25 +01:00
|
|
|
|
2022-05-24 20:43:38 +01:00
|
|
|
QuaZipDir packZipDir(m_packZip.get());
|
|
|
|
|
|
|
|
// https://docs.modrinth.com/docs/modpacks/format_definition/#storage
|
|
|
|
bool modrinthFound = packZipDir.exists("/modrinth.index.json");
|
|
|
|
bool technicFound = packZipDir.exists("/bin/modpack.jar") || packZipDir.exists("/bin/version.json");
|
2018-07-15 13:51:05 +01:00
|
|
|
QString root;
|
2022-05-24 20:43:38 +01:00
|
|
|
|
|
|
|
// NOTE: Prioritize modpack platforms that aren't searched for recursively.
|
|
|
|
// Especially Flame has a very common filename for its manifest, which may appear inside overrides for example
|
|
|
|
if(modrinthFound)
|
2018-07-15 13:51:05 +01:00
|
|
|
{
|
2022-05-24 20:43:38 +01:00
|
|
|
// process as Modrinth pack
|
|
|
|
qDebug() << "Modrinth:" << modrinthFound;
|
|
|
|
m_modpackType = ModpackType::Modrinth;
|
2018-07-15 13:51:05 +01:00
|
|
|
}
|
2020-06-07 16:46:12 +01:00
|
|
|
else if (technicFound)
|
|
|
|
{
|
|
|
|
// process as Technic pack
|
|
|
|
qDebug() << "Technic:" << technicFound;
|
|
|
|
extractDir.mkpath(".minecraft");
|
|
|
|
extractDir.cd(".minecraft");
|
|
|
|
m_modpackType = ModpackType::Technic;
|
|
|
|
}
|
2022-05-24 20:43:38 +01:00
|
|
|
else
|
2022-01-31 14:25:36 +00:00
|
|
|
{
|
2022-05-24 20:43:38 +01:00
|
|
|
QString mmcRoot = MMCZip::findFolderOfFileInZip(m_packZip.get(), "instance.cfg");
|
|
|
|
QString flameRoot = MMCZip::findFolderOfFileInZip(m_packZip.get(), "manifest.json");
|
|
|
|
|
2022-05-29 13:16:13 +01:00
|
|
|
if (!mmcRoot.isNull())
|
2022-05-24 20:43:38 +01:00
|
|
|
{
|
|
|
|
// process as MultiMC instance/pack
|
|
|
|
qDebug() << "MultiMC:" << mmcRoot;
|
|
|
|
root = mmcRoot;
|
|
|
|
m_modpackType = ModpackType::MultiMC;
|
|
|
|
}
|
2022-05-29 13:16:13 +01:00
|
|
|
else if(!flameRoot.isNull())
|
2022-05-24 20:43:38 +01:00
|
|
|
{
|
|
|
|
// process as Flame pack
|
|
|
|
qDebug() << "Flame:" << flameRoot;
|
|
|
|
root = flameRoot;
|
|
|
|
m_modpackType = ModpackType::Flame;
|
|
|
|
}
|
2022-01-31 14:25:36 +00:00
|
|
|
}
|
2018-07-15 13:51:05 +01:00
|
|
|
if(m_modpackType == ModpackType::Unknown)
|
|
|
|
{
|
|
|
|
emitFailed(tr("Archive does not contain a recognized modpack type."));
|
|
|
|
return;
|
|
|
|
}
|
2017-09-04 07:17:25 +01:00
|
|
|
|
2018-07-15 13:51:05 +01:00
|
|
|
// make sure we extract just the pack
|
|
|
|
m_extractFuture = QtConcurrent::run(QThreadPool::globalInstance(), MMCZip::extractSubDir, m_packZip.get(), root, extractDir.absolutePath());
|
|
|
|
connect(&m_extractFutureWatcher, &QFutureWatcher<QStringList>::finished, this, &InstanceImportTask::extractFinished);
|
|
|
|
connect(&m_extractFutureWatcher, &QFutureWatcher<QStringList>::canceled, this, &InstanceImportTask::extractAborted);
|
|
|
|
m_extractFutureWatcher.setFuture(m_extractFuture);
|
2016-10-26 17:12:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void InstanceImportTask::extractFinished()
|
|
|
|
{
|
2018-07-15 13:51:05 +01:00
|
|
|
m_packZip.reset();
|
2021-02-09 04:04:23 +00:00
|
|
|
if (!m_extractFuture.result())
|
2018-07-15 13:51:05 +01:00
|
|
|
{
|
|
|
|
emitFailed(tr("Failed to extract modpack"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
QDir extractDir(m_stagingPath);
|
2017-04-21 21:23:31 +01:00
|
|
|
|
2018-07-15 13:51:05 +01:00
|
|
|
qDebug() << "Fixing permissions for extracted pack files...";
|
|
|
|
QDirIterator it(extractDir, QDirIterator::Subdirectories);
|
|
|
|
while (it.hasNext())
|
|
|
|
{
|
|
|
|
auto filepath = it.next();
|
|
|
|
QFileInfo file(filepath);
|
|
|
|
auto permissions = QFile::permissions(filepath);
|
|
|
|
auto origPermissions = permissions;
|
|
|
|
if(file.isDir())
|
|
|
|
{
|
|
|
|
// Folder +rwx for current user
|
|
|
|
permissions |= QFileDevice::Permission::ReadUser | QFileDevice::Permission::WriteUser | QFileDevice::Permission::ExeUser;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// File +rw for current user
|
|
|
|
permissions |= QFileDevice::Permission::ReadUser | QFileDevice::Permission::WriteUser;
|
|
|
|
}
|
|
|
|
if(origPermissions != permissions)
|
|
|
|
{
|
|
|
|
if(!QFile::setPermissions(filepath, permissions))
|
|
|
|
{
|
|
|
|
logWarning(tr("Could not fix permissions for %1").arg(filepath));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug() << "Fixed" << filepath;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-04-21 21:23:31 +01:00
|
|
|
|
2018-07-15 13:51:05 +01:00
|
|
|
switch(m_modpackType)
|
|
|
|
{
|
|
|
|
case ModpackType::MultiMC:
|
|
|
|
processMultiMC();
|
|
|
|
return;
|
2020-06-07 16:46:12 +01:00
|
|
|
case ModpackType::Technic:
|
|
|
|
processTechnic();
|
|
|
|
return;
|
2022-01-31 14:25:36 +00:00
|
|
|
case ModpackType::Flame:
|
|
|
|
processFlame();
|
|
|
|
return;
|
|
|
|
case ModpackType::Modrinth:
|
|
|
|
processModrinth();
|
|
|
|
return;
|
2018-07-15 13:51:05 +01:00
|
|
|
case ModpackType::Unknown:
|
|
|
|
emitFailed(tr("Archive does not contain a recognized modpack type."));
|
|
|
|
return;
|
|
|
|
}
|
2017-04-20 04:22:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void InstanceImportTask::extractAborted()
|
|
|
|
{
|
2018-07-15 13:51:05 +01:00
|
|
|
emitFailed(tr("Instance import has been aborted."));
|
|
|
|
return;
|
2017-04-20 04:22:04 +01:00
|
|
|
}
|
|
|
|
|
2017-09-04 07:17:25 +01:00
|
|
|
void InstanceImportTask::processFlame()
|
2017-04-20 04:22:04 +01:00
|
|
|
{
|
2018-07-15 13:51:05 +01:00
|
|
|
const static QMap<QString,QString> forgemap = {
|
|
|
|
{"1.2.5", "3.4.9.171"},
|
|
|
|
{"1.4.2", "6.0.1.355"},
|
|
|
|
{"1.4.7", "6.6.2.534"},
|
|
|
|
{"1.5.2", "7.8.1.737"}
|
|
|
|
};
|
|
|
|
Flame::Manifest pack;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
QString configPath = FS::PathCombine(m_stagingPath, "manifest.json");
|
|
|
|
Flame::loadManifest(pack, configPath);
|
|
|
|
QFile::remove(configPath);
|
|
|
|
}
|
|
|
|
catch (const JSONValidationError &e)
|
|
|
|
{
|
|
|
|
emitFailed(tr("Could not understand pack manifest:\n") + e.cause());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(!pack.overrides.isEmpty())
|
|
|
|
{
|
|
|
|
QString overridePath = FS::PathCombine(m_stagingPath, pack.overrides);
|
|
|
|
if (QFile::exists(overridePath))
|
|
|
|
{
|
|
|
|
QString mcPath = FS::PathCombine(m_stagingPath, "minecraft");
|
|
|
|
if (!QFile::rename(overridePath, mcPath))
|
|
|
|
{
|
|
|
|
emitFailed(tr("Could not rename the overrides folder:\n") + pack.overrides);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
logWarning(tr("The specified overrides folder (%1) is missing. Maybe the modpack was already used before?").arg(pack.overrides));
|
|
|
|
}
|
|
|
|
}
|
2017-04-21 21:23:31 +01:00
|
|
|
|
2018-07-15 13:51:05 +01:00
|
|
|
QString forgeVersion;
|
2021-06-09 20:48:46 +01:00
|
|
|
QString fabricVersion;
|
2022-02-20 19:55:26 +00:00
|
|
|
// TODO: is Quilt relevant here?
|
2018-07-15 13:51:05 +01:00
|
|
|
for(auto &loader: pack.minecraft.modLoaders)
|
|
|
|
{
|
|
|
|
auto id = loader.id;
|
|
|
|
if(id.startsWith("forge-"))
|
|
|
|
{
|
|
|
|
id.remove("forge-");
|
|
|
|
forgeVersion = id;
|
|
|
|
continue;
|
|
|
|
}
|
2021-06-09 20:48:46 +01:00
|
|
|
if(id.startsWith("fabric-"))
|
|
|
|
{
|
|
|
|
id.remove("fabric-");
|
|
|
|
fabricVersion = id;
|
|
|
|
continue;
|
|
|
|
}
|
2018-07-15 13:51:05 +01:00
|
|
|
logWarning(tr("Unknown mod loader in manifest: %1").arg(id));
|
|
|
|
}
|
2017-04-21 21:23:31 +01:00
|
|
|
|
2018-07-15 13:51:05 +01:00
|
|
|
QString configPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
|
|
|
auto instanceSettings = std::make_shared<INISettingsObject>(configPath);
|
|
|
|
MinecraftInstance instance(m_globalSettings, instanceSettings, m_stagingPath);
|
|
|
|
auto mcVersion = pack.minecraft.version;
|
|
|
|
// Hack to correct some 'special sauce'...
|
|
|
|
if(mcVersion.endsWith('.'))
|
|
|
|
{
|
|
|
|
mcVersion.remove(QRegExp("[.]+$"));
|
|
|
|
logWarning(tr("Mysterious trailing dots removed from Minecraft version while importing pack."));
|
|
|
|
}
|
2020-06-27 11:02:31 +01:00
|
|
|
auto components = instance.getPackProfile();
|
2018-07-15 13:51:05 +01:00
|
|
|
components->buildingFromScratch();
|
|
|
|
components->setComponentVersion("net.minecraft", mcVersion, true);
|
|
|
|
if(!forgeVersion.isEmpty())
|
|
|
|
{
|
|
|
|
// FIXME: dirty, nasty, hack. Proper solution requires dependency resolution and knowledge of the metadata.
|
|
|
|
if(forgeVersion == "recommended")
|
|
|
|
{
|
|
|
|
if(forgemap.contains(mcVersion))
|
|
|
|
{
|
|
|
|
forgeVersion = forgemap[mcVersion];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-03-18 12:19:09 +00:00
|
|
|
logWarning(tr("Could not map recommended Forge version for Minecraft %1").arg(mcVersion));
|
2018-07-15 13:51:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
components->setComponentVersion("net.minecraftforge", forgeVersion);
|
|
|
|
}
|
2021-06-09 20:48:46 +01:00
|
|
|
if(!fabricVersion.isEmpty())
|
|
|
|
{
|
|
|
|
components->setComponentVersion("net.fabricmc.fabric-loader", fabricVersion);
|
|
|
|
}
|
2018-07-15 13:51:05 +01:00
|
|
|
if (m_instIcon != "default")
|
|
|
|
{
|
|
|
|
instance.setIconKey(m_instIcon);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(pack.name.contains("Direwolf20"))
|
|
|
|
{
|
|
|
|
instance.setIconKey("steve");
|
|
|
|
}
|
|
|
|
else if(pack.name.contains("FTB") || pack.name.contains("Feed The Beast"))
|
|
|
|
{
|
|
|
|
instance.setIconKey("ftb_logo");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// default to something other than the MultiMC default to distinguish these
|
|
|
|
instance.setIconKey("flame");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
QString jarmodsPath = FS::PathCombine(m_stagingPath, "minecraft", "jarmods");
|
|
|
|
QFileInfo jarmodsInfo(jarmodsPath);
|
|
|
|
if(jarmodsInfo.isDir())
|
|
|
|
{
|
|
|
|
// install all the jar mods
|
|
|
|
qDebug() << "Found jarmods:";
|
|
|
|
QDir jarmodsDir(jarmodsPath);
|
|
|
|
QStringList jarMods;
|
|
|
|
for (auto info: jarmodsDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files))
|
|
|
|
{
|
|
|
|
qDebug() << info.fileName();
|
|
|
|
jarMods.push_back(info.absoluteFilePath());
|
|
|
|
}
|
2020-06-27 11:02:31 +01:00
|
|
|
auto profile = instance.getPackProfile();
|
2018-07-15 13:51:05 +01:00
|
|
|
profile->installJarMods(jarMods);
|
|
|
|
// nuke the original files
|
|
|
|
FS::deletePath(jarmodsPath);
|
|
|
|
}
|
|
|
|
instance.setName(m_instName);
|
2021-11-21 22:21:12 +00:00
|
|
|
m_modIdResolver = new Flame::FileResolvingTask(APPLICATION->network(), pack);
|
2018-07-15 13:51:05 +01:00
|
|
|
connect(m_modIdResolver.get(), &Flame::FileResolvingTask::succeeded, [&]()
|
|
|
|
{
|
|
|
|
auto results = m_modIdResolver->getResults();
|
2022-05-28 20:53:12 +01:00
|
|
|
//first check for blocked mods
|
|
|
|
QString text;
|
|
|
|
auto anyBlocked = false;
|
|
|
|
for(const auto& result: results.files.values()) {
|
|
|
|
if (!result.resolved || result.url.isEmpty()) {
|
|
|
|
text += QString("%1: <a href='%2'>%2</a><br/>").arg(result.fileName, result.websiteUrl);
|
|
|
|
anyBlocked = true;
|
2018-07-15 13:51:05 +01:00
|
|
|
}
|
2022-05-28 20:53:12 +01:00
|
|
|
}
|
|
|
|
if(anyBlocked) {
|
|
|
|
qWarning() << "Blocked mods found, displaying mod list";
|
|
|
|
|
|
|
|
auto message_dialog = new ScrollMessageBox(m_parent,
|
|
|
|
tr("Blocked mods found"),
|
|
|
|
tr("The following mods were blocked on third party launchers.<br/>"
|
|
|
|
"You will need to manually download them and add them to the modpack"),
|
|
|
|
text);
|
|
|
|
message_dialog->setModal(true);
|
2022-06-23 11:58:27 +01:00
|
|
|
|
|
|
|
if (message_dialog->exec()) {
|
2022-05-28 20:53:12 +01:00
|
|
|
m_filesNetJob = new NetJob(tr("Mod download"), APPLICATION->network());
|
|
|
|
for (const auto &result: m_modIdResolver->getResults().files) {
|
|
|
|
QString filename = result.fileName;
|
|
|
|
if (!result.required) {
|
|
|
|
filename += ".disabled";
|
|
|
|
}
|
2017-12-30 17:57:46 +00:00
|
|
|
|
2022-05-28 20:53:12 +01:00
|
|
|
auto relpath = FS::PathCombine("minecraft", result.targetFolder, filename);
|
|
|
|
auto path = FS::PathCombine(m_stagingPath, relpath);
|
2017-12-30 17:57:46 +00:00
|
|
|
|
2022-05-28 20:53:12 +01:00
|
|
|
switch (result.type) {
|
|
|
|
case Flame::File::Type::Folder: {
|
|
|
|
logWarning(tr("This 'Folder' may need extracting: %1").arg(relpath));
|
|
|
|
// fall-through intentional, we treat these as plain old mods and dump them wherever.
|
|
|
|
}
|
|
|
|
case Flame::File::Type::SingleFile:
|
|
|
|
case Flame::File::Type::Mod: {
|
|
|
|
if (!result.url.isEmpty()) {
|
|
|
|
qDebug() << "Will download" << result.url << "to" << path;
|
|
|
|
auto dl = Net::Download::makeFile(result.url, path);
|
|
|
|
m_filesNetJob->addNetAction(dl);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Flame::File::Type::Modpack:
|
|
|
|
logWarning(
|
|
|
|
tr("Nesting modpacks in modpacks is not implemented, nothing was downloaded: %1").arg(
|
|
|
|
relpath));
|
|
|
|
break;
|
|
|
|
case Flame::File::Type::Cmod2:
|
|
|
|
case Flame::File::Type::Ctoc:
|
|
|
|
case Flame::File::Type::Unknown:
|
|
|
|
logWarning(tr("Unrecognized/unhandled PackageType for: %1").arg(relpath));
|
|
|
|
break;
|
|
|
|
}
|
2018-07-15 13:51:05 +01:00
|
|
|
}
|
2022-05-28 20:53:12 +01:00
|
|
|
m_modIdResolver.reset();
|
|
|
|
connect(m_filesNetJob.get(), &NetJob::succeeded, this, [&]() {
|
|
|
|
m_filesNetJob.reset();
|
|
|
|
emitSucceeded();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
connect(m_filesNetJob.get(), &NetJob::failed, [&](QString reason) {
|
|
|
|
m_filesNetJob.reset();
|
|
|
|
emitFailed(reason);
|
|
|
|
});
|
|
|
|
connect(m_filesNetJob.get(), &NetJob::progress, [&](qint64 current, qint64 total) {
|
|
|
|
setProgress(current, total);
|
|
|
|
});
|
|
|
|
setStatus(tr("Downloading mods..."));
|
|
|
|
m_filesNetJob->start();
|
2022-06-23 11:58:27 +01:00
|
|
|
} else {
|
|
|
|
m_modIdResolver.reset();
|
|
|
|
emitFailed("Canceled");
|
|
|
|
}
|
|
|
|
} else {
|
2022-05-28 20:53:12 +01:00
|
|
|
//TODO extract to function ?
|
|
|
|
m_filesNetJob = new NetJob(tr("Mod download"), APPLICATION->network());
|
|
|
|
for (const auto &result: m_modIdResolver->getResults().files) {
|
|
|
|
QString filename = result.fileName;
|
|
|
|
if (!result.required) {
|
|
|
|
filename += ".disabled";
|
|
|
|
}
|
|
|
|
|
|
|
|
auto relpath = FS::PathCombine("minecraft", result.targetFolder, filename);
|
|
|
|
auto path = FS::PathCombine(m_stagingPath, relpath);
|
|
|
|
|
|
|
|
switch (result.type) {
|
|
|
|
case Flame::File::Type::Folder: {
|
|
|
|
logWarning(tr("This 'Folder' may need extracting: %1").arg(relpath));
|
|
|
|
// fall-through intentional, we treat these as plain old mods and dump them wherever.
|
|
|
|
}
|
|
|
|
case Flame::File::Type::SingleFile:
|
|
|
|
case Flame::File::Type::Mod: {
|
|
|
|
if (!result.url.isEmpty()) {
|
|
|
|
qDebug() << "Will download" << result.url << "to" << path;
|
|
|
|
auto dl = Net::Download::makeFile(result.url, path);
|
|
|
|
m_filesNetJob->addNetAction(dl);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Flame::File::Type::Modpack:
|
|
|
|
logWarning(
|
|
|
|
tr("Nesting modpacks in modpacks is not implemented, nothing was downloaded: %1").arg(
|
|
|
|
relpath));
|
|
|
|
break;
|
|
|
|
case Flame::File::Type::Cmod2:
|
|
|
|
case Flame::File::Type::Ctoc:
|
|
|
|
case Flame::File::Type::Unknown:
|
|
|
|
logWarning(tr("Unrecognized/unhandled PackageType for: %1").arg(relpath));
|
|
|
|
break;
|
2018-07-15 13:51:05 +01:00
|
|
|
}
|
|
|
|
}
|
2022-05-28 20:53:12 +01:00
|
|
|
m_modIdResolver.reset();
|
|
|
|
connect(m_filesNetJob.get(), &NetJob::succeeded, this, [&]() {
|
|
|
|
m_filesNetJob.reset();
|
|
|
|
emitSucceeded();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
connect(m_filesNetJob.get(), &NetJob::failed, [&](QString reason) {
|
|
|
|
m_filesNetJob.reset();
|
|
|
|
emitFailed(reason);
|
|
|
|
});
|
|
|
|
connect(m_filesNetJob.get(), &NetJob::progress, [&](qint64 current, qint64 total) {
|
|
|
|
setProgress(current, total);
|
|
|
|
});
|
|
|
|
setStatus(tr("Downloading mods..."));
|
|
|
|
m_filesNetJob->start();
|
2018-07-15 13:51:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
connect(m_modIdResolver.get(), &Flame::FileResolvingTask::failed, [&](QString reason)
|
|
|
|
{
|
|
|
|
m_modIdResolver.reset();
|
|
|
|
emitFailed(tr("Unable to resolve mod IDs:\n") + reason);
|
|
|
|
});
|
|
|
|
connect(m_modIdResolver.get(), &Flame::FileResolvingTask::progress, [&](qint64 current, qint64 total)
|
|
|
|
{
|
|
|
|
setProgress(current, total);
|
|
|
|
});
|
|
|
|
connect(m_modIdResolver.get(), &Flame::FileResolvingTask::status, [&](QString status)
|
|
|
|
{
|
|
|
|
setStatus(status);
|
|
|
|
});
|
|
|
|
m_modIdResolver->start();
|
2017-04-20 04:22:04 +01:00
|
|
|
}
|
|
|
|
|
2020-06-07 16:46:12 +01:00
|
|
|
void InstanceImportTask::processTechnic()
|
|
|
|
{
|
|
|
|
shared_qobject_ptr<Technic::TechnicPackProcessor> packProcessor = new Technic::TechnicPackProcessor();
|
|
|
|
connect(packProcessor.get(), &Technic::TechnicPackProcessor::succeeded, this, &InstanceImportTask::emitSucceeded);
|
|
|
|
connect(packProcessor.get(), &Technic::TechnicPackProcessor::failed, this, &InstanceImportTask::emitFailed);
|
|
|
|
packProcessor->run(m_globalSettings, m_instName, m_instIcon, m_stagingPath);
|
|
|
|
}
|
|
|
|
|
2017-09-04 07:17:25 +01:00
|
|
|
void InstanceImportTask::processMultiMC()
|
2017-04-20 04:22:04 +01:00
|
|
|
{
|
2018-07-15 13:51:05 +01:00
|
|
|
QString configPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
|
|
|
auto instanceSettings = std::make_shared<INISettingsObject>(configPath);
|
2016-10-02 23:55:54 +01:00
|
|
|
|
2018-07-15 13:51:05 +01:00
|
|
|
NullInstance instance(m_globalSettings, instanceSettings, m_stagingPath);
|
2016-10-02 23:55:54 +01:00
|
|
|
|
2018-07-15 13:51:05 +01:00
|
|
|
// reset time played on import... because packs.
|
|
|
|
instance.resetTimePlayed();
|
2016-10-02 23:55:54 +01:00
|
|
|
|
2018-07-15 13:51:05 +01:00
|
|
|
// set a new nice name
|
|
|
|
instance.setName(m_instName);
|
2016-10-02 23:55:54 +01:00
|
|
|
|
2018-07-15 13:51:05 +01:00
|
|
|
// if the icon was specified by user, use that. otherwise pull icon from the pack
|
2022-05-16 02:16:52 +01:00
|
|
|
if (m_instIcon != "default") {
|
2018-07-15 13:51:05 +01:00
|
|
|
instance.setIconKey(m_instIcon);
|
2022-05-16 02:16:52 +01:00
|
|
|
} else {
|
2018-07-15 13:51:05 +01:00
|
|
|
m_instIcon = instance.iconKey();
|
2019-05-31 20:52:58 +01:00
|
|
|
|
|
|
|
auto importIconPath = IconUtils::findBestIconIn(instance.instanceRoot(), m_instIcon);
|
2022-05-16 02:16:52 +01:00
|
|
|
if (!importIconPath.isNull() && QFile::exists(importIconPath)) {
|
2018-07-15 13:51:05 +01:00
|
|
|
// import icon
|
2021-11-21 22:21:12 +00:00
|
|
|
auto iconList = APPLICATION->icons();
|
2022-05-16 02:16:52 +01:00
|
|
|
if (iconList->iconFileExists(m_instIcon)) {
|
2018-07-15 13:51:05 +01:00
|
|
|
iconList->deleteIcon(m_instIcon);
|
|
|
|
}
|
2022-05-16 02:16:52 +01:00
|
|
|
iconList->installIcons({ importIconPath });
|
2018-07-15 13:51:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
emitSucceeded();
|
2016-10-02 23:55:54 +01:00
|
|
|
}
|
2022-01-31 14:25:36 +00:00
|
|
|
|
2022-06-09 23:53:29 +01:00
|
|
|
// https://docs.modrinth.com/docs/modpacks/format_definition/
|
2022-05-16 02:16:52 +01:00
|
|
|
void InstanceImportTask::processModrinth()
|
|
|
|
{
|
2022-01-31 14:25:36 +00:00
|
|
|
std::vector<Modrinth::File> files;
|
2022-05-15 11:06:01 +01:00
|
|
|
QString minecraftVersion, fabricVersion, quiltVersion, forgeVersion;
|
2022-05-16 02:16:52 +01:00
|
|
|
try {
|
2022-01-31 14:25:36 +00:00
|
|
|
QString indexPath = FS::PathCombine(m_stagingPath, "modrinth.index.json");
|
|
|
|
auto doc = Json::requireDocument(indexPath);
|
|
|
|
auto obj = Json::requireObject(doc, "modrinth.index.json");
|
|
|
|
int formatVersion = Json::requireInteger(obj, "formatVersion", "modrinth.index.json");
|
2022-05-16 02:16:52 +01:00
|
|
|
if (formatVersion == 1) {
|
2022-01-31 14:25:36 +00:00
|
|
|
auto game = Json::requireString(obj, "game", "modrinth.index.json");
|
2022-05-16 02:16:52 +01:00
|
|
|
if (game != "minecraft") {
|
2022-01-31 14:25:36 +00:00
|
|
|
throw JSONValidationError("Unknown game: " + game);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto jsonFiles = Json::requireIsArrayOf<QJsonObject>(obj, "files", "modrinth.index.json");
|
2022-05-16 02:16:52 +01:00
|
|
|
bool had_optional = false;
|
2022-06-09 23:53:29 +01:00
|
|
|
for (auto modInfo : jsonFiles) {
|
2022-05-16 02:16:52 +01:00
|
|
|
Modrinth::File file;
|
2022-05-28 20:53:12 +01:00
|
|
|
file.path = Json::requireString(modInfo, "path");
|
2022-05-16 02:16:52 +01:00
|
|
|
|
2022-05-28 20:53:12 +01:00
|
|
|
auto env = Json::ensureObject(modInfo, "env");
|
2022-06-09 23:53:29 +01:00
|
|
|
// 'env' field is optional
|
|
|
|
if (!env.isEmpty()) {
|
|
|
|
QString support = Json::ensureString(env, "client", "unsupported");
|
|
|
|
if (support == "unsupported") {
|
|
|
|
continue;
|
|
|
|
} else if (support == "optional") {
|
|
|
|
// TODO: Make a review dialog for choosing which ones the user wants!
|
|
|
|
if (!had_optional) {
|
|
|
|
had_optional = true;
|
|
|
|
auto info = CustomMessageBox::selectable(
|
|
|
|
m_parent, tr("Optional mod detected!"),
|
|
|
|
tr("One or more mods from this modpack are optional. They will be downloaded, but disabled by default!"),
|
|
|
|
QMessageBox::Information);
|
|
|
|
info->exec();
|
|
|
|
}
|
2022-05-16 02:16:52 +01:00
|
|
|
|
2022-06-09 23:53:29 +01:00
|
|
|
if (file.path.endsWith(".jar"))
|
|
|
|
file.path += ".disabled";
|
|
|
|
}
|
2022-05-16 02:16:52 +01:00
|
|
|
}
|
|
|
|
|
2022-05-28 20:53:12 +01:00
|
|
|
QJsonObject hashes = Json::requireObject(modInfo, "hashes");
|
2022-05-16 02:16:52 +01:00
|
|
|
QString hash;
|
|
|
|
QCryptographicHash::Algorithm hashAlgorithm;
|
|
|
|
hash = Json::ensureString(hashes, "sha1");
|
|
|
|
hashAlgorithm = QCryptographicHash::Sha1;
|
|
|
|
if (hash.isEmpty()) {
|
|
|
|
hash = Json::ensureString(hashes, "sha512");
|
|
|
|
hashAlgorithm = QCryptographicHash::Sha512;
|
|
|
|
if (hash.isEmpty()) {
|
|
|
|
hash = Json::ensureString(hashes, "sha256");
|
|
|
|
hashAlgorithm = QCryptographicHash::Sha256;
|
|
|
|
if (hash.isEmpty()) {
|
|
|
|
throw JSONValidationError("No hash found for: " + file.path);
|
|
|
|
}
|
2022-01-31 14:25:36 +00:00
|
|
|
}
|
2022-05-16 02:16:52 +01:00
|
|
|
}
|
|
|
|
file.hash = QByteArray::fromHex(hash.toLatin1());
|
|
|
|
file.hashAlgorithm = hashAlgorithm;
|
2022-06-09 23:54:50 +01:00
|
|
|
|
2022-05-16 21:05:54 +01:00
|
|
|
// Do not use requireUrl, which uses StrictMode, instead use QUrl's default TolerantMode
|
|
|
|
// (as Modrinth seems to incorrectly handle spaces)
|
2022-06-09 23:54:50 +01:00
|
|
|
|
|
|
|
auto download_arr = Json::ensureArray(modInfo, "downloads");
|
|
|
|
for(auto download : download_arr) {
|
|
|
|
qWarning() << download.toString();
|
|
|
|
bool is_last = download.toString() == download_arr.last().toString();
|
|
|
|
|
|
|
|
auto download_url = QUrl(download.toString());
|
|
|
|
|
|
|
|
if (!download_url.isValid()) {
|
|
|
|
qDebug() << QString("Download URL (%1) for %2 is not a correctly formatted URL")
|
|
|
|
.arg(download_url.toString(), file.path);
|
|
|
|
if(is_last && file.downloads.isEmpty())
|
|
|
|
throw JSONValidationError(tr("Download URL for %1 is not a correctly formatted URL").arg(file.path));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
file.downloads.push_back(download_url);
|
|
|
|
}
|
2022-05-28 18:12:00 +01:00
|
|
|
}
|
2022-05-28 13:19:53 +01:00
|
|
|
|
2022-05-16 02:16:52 +01:00
|
|
|
files.push_back(file);
|
|
|
|
}
|
2022-01-31 14:25:36 +00:00
|
|
|
|
|
|
|
auto dependencies = Json::requireObject(obj, "dependencies", "modrinth.index.json");
|
2022-05-16 02:16:52 +01:00
|
|
|
for (auto it = dependencies.begin(), end = dependencies.end(); it != end; ++it) {
|
2022-01-31 14:25:36 +00:00
|
|
|
QString name = it.key();
|
2022-05-16 02:16:52 +01:00
|
|
|
if (name == "minecraft") {
|
2022-01-31 14:25:36 +00:00
|
|
|
minecraftVersion = Json::requireString(*it, "Minecraft version");
|
2022-05-16 21:05:54 +01:00
|
|
|
}
|
|
|
|
else if (name == "fabric-loader") {
|
2022-01-31 14:25:36 +00:00
|
|
|
fabricVersion = Json::requireString(*it, "Fabric Loader version");
|
2022-05-16 21:05:54 +01:00
|
|
|
}
|
|
|
|
else if (name == "quilt-loader") {
|
2022-05-15 11:06:01 +01:00
|
|
|
quiltVersion = Json::requireString(*it, "Quilt Loader version");
|
2022-05-16 21:05:54 +01:00
|
|
|
}
|
|
|
|
else if (name == "forge") {
|
2022-01-31 14:25:36 +00:00
|
|
|
forgeVersion = Json::requireString(*it, "Forge version");
|
2022-05-16 21:05:54 +01:00
|
|
|
}
|
|
|
|
else {
|
2022-01-31 14:25:36 +00:00
|
|
|
throw JSONValidationError("Unknown dependency type: " + name);
|
|
|
|
}
|
|
|
|
}
|
2022-05-16 02:16:52 +01:00
|
|
|
} else {
|
2022-01-31 14:25:36 +00:00
|
|
|
throw JSONValidationError(QStringLiteral("Unknown format version: %s").arg(formatVersion));
|
|
|
|
}
|
|
|
|
QFile::remove(indexPath);
|
2022-05-16 02:16:52 +01:00
|
|
|
} catch (const JSONValidationError& e) {
|
2022-01-31 14:25:36 +00:00
|
|
|
emitFailed(tr("Could not understand pack index:\n") + e.cause());
|
|
|
|
return;
|
|
|
|
}
|
2022-06-11 17:43:09 +01:00
|
|
|
|
|
|
|
auto mcPath = FS::PathCombine(m_stagingPath, ".minecraft");
|
2022-05-16 21:05:54 +01:00
|
|
|
|
2022-06-11 17:43:09 +01:00
|
|
|
auto override_path = FS::PathCombine(m_stagingPath, "overrides");
|
|
|
|
if (QFile::exists(override_path)) {
|
|
|
|
if (!QFile::rename(override_path, mcPath)) {
|
2022-01-31 14:25:36 +00:00
|
|
|
emitFailed(tr("Could not rename the overrides folder:\n") + "overrides");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-11 17:43:09 +01:00
|
|
|
// Do client overrides
|
|
|
|
auto client_override_path = FS::PathCombine(m_stagingPath, "client-overrides");
|
|
|
|
if (QFile::exists(client_override_path)) {
|
|
|
|
if (!FS::overrideFolder(mcPath, client_override_path)) {
|
|
|
|
emitFailed(tr("Could not rename the client overrides folder:\n") + "client overrides");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-31 14:25:36 +00:00
|
|
|
QString configPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
|
|
|
auto instanceSettings = std::make_shared<INISettingsObject>(configPath);
|
|
|
|
MinecraftInstance instance(m_globalSettings, instanceSettings, m_stagingPath);
|
|
|
|
auto components = instance.getPackProfile();
|
|
|
|
components->buildingFromScratch();
|
|
|
|
components->setComponentVersion("net.minecraft", minecraftVersion, true);
|
|
|
|
if (!fabricVersion.isEmpty())
|
|
|
|
components->setComponentVersion("net.fabricmc.fabric-loader", fabricVersion, true);
|
2022-05-15 11:06:01 +01:00
|
|
|
if (!quiltVersion.isEmpty())
|
|
|
|
components->setComponentVersion("org.quiltmc.quilt-loader", quiltVersion, true);
|
2022-01-31 14:25:36 +00:00
|
|
|
if (!forgeVersion.isEmpty())
|
|
|
|
components->setComponentVersion("net.minecraftforge", forgeVersion, true);
|
|
|
|
if (m_instIcon != "default")
|
|
|
|
{
|
|
|
|
instance.setIconKey(m_instIcon);
|
|
|
|
}
|
2022-05-15 15:09:45 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
instance.setIconKey("modrinth");
|
|
|
|
}
|
2022-01-31 14:25:36 +00:00
|
|
|
instance.setName(m_instName);
|
|
|
|
instance.saveNow();
|
|
|
|
|
|
|
|
m_filesNetJob = new NetJob(tr("Mod download"), APPLICATION->network());
|
2022-06-09 23:54:50 +01:00
|
|
|
for (auto file : files)
|
2022-01-31 14:25:36 +00:00
|
|
|
{
|
|
|
|
auto path = FS::PathCombine(m_stagingPath, ".minecraft", file.path);
|
2022-06-09 23:54:50 +01:00
|
|
|
qDebug() << "Will try to download" << file.downloads.front() << "to" << path;
|
2022-06-11 18:19:51 +01:00
|
|
|
auto dl = Net::Download::makeFile(file.downloads.dequeue(), path);
|
2022-01-31 14:25:36 +00:00
|
|
|
dl->addValidator(new Net::ChecksumValidator(file.hashAlgorithm, file.hash));
|
|
|
|
m_filesNetJob->addNetAction(dl);
|
2022-06-09 23:54:50 +01:00
|
|
|
|
2022-06-11 18:31:50 +01:00
|
|
|
if (file.downloads.size() > 0) {
|
2022-06-09 23:54:50 +01:00
|
|
|
// FIXME: This really needs to be put into a ConcurrentTask of
|
|
|
|
// MultipleOptionsTask's , once those exist :)
|
|
|
|
connect(dl.get(), &NetAction::failed, [this, &file, path, dl]{
|
|
|
|
auto dl = Net::Download::makeFile(file.downloads.dequeue(), path);
|
|
|
|
dl->addValidator(new Net::ChecksumValidator(file.hashAlgorithm, file.hash));
|
|
|
|
m_filesNetJob->addNetAction(dl);
|
|
|
|
dl->succeeded();
|
|
|
|
});
|
|
|
|
}
|
2022-01-31 14:25:36 +00:00
|
|
|
}
|
|
|
|
connect(m_filesNetJob.get(), &NetJob::succeeded, this, [&]()
|
|
|
|
{
|
|
|
|
m_filesNetJob.reset();
|
|
|
|
emitSucceeded();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
connect(m_filesNetJob.get(), &NetJob::failed, [&](const QString &reason)
|
|
|
|
{
|
|
|
|
m_filesNetJob.reset();
|
|
|
|
emitFailed(reason);
|
|
|
|
});
|
|
|
|
connect(m_filesNetJob.get(), &NetJob::progress, [&](qint64 current, qint64 total)
|
|
|
|
{
|
|
|
|
setProgress(current, total);
|
|
|
|
});
|
|
|
|
setStatus(tr("Downloading mods..."));
|
|
|
|
m_filesNetJob->start();
|
|
|
|
}
|