format
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
3becd4386b
commit
b0a018d823
@ -37,16 +37,16 @@
|
|||||||
|
|
||||||
#include <QtConcurrent>
|
#include <QtConcurrent>
|
||||||
|
|
||||||
#include "MMCZip.h"
|
|
||||||
#include "BaseInstance.h"
|
#include "BaseInstance.h"
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
#include "settings/INISettingsObject.h"
|
#include "MMCZip.h"
|
||||||
|
#include "minecraft/GradleSpecifier.h"
|
||||||
#include "minecraft/MinecraftInstance.h"
|
#include "minecraft/MinecraftInstance.h"
|
||||||
#include "minecraft/PackProfile.h"
|
#include "minecraft/PackProfile.h"
|
||||||
#include "minecraft/GradleSpecifier.h"
|
#include "settings/INISettingsObject.h"
|
||||||
|
|
||||||
#include "BuildConfig.h"
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
#include "BuildConfig.h"
|
||||||
|
|
||||||
namespace LegacyFTB {
|
namespace LegacyFTB {
|
||||||
|
|
||||||
@ -120,16 +120,17 @@ void PackInstallTask::unzip()
|
|||||||
QDir extractDir(m_stagingPath);
|
QDir extractDir(m_stagingPath);
|
||||||
|
|
||||||
m_packZip.reset(new QuaZip(archivePath));
|
m_packZip.reset(new QuaZip(archivePath));
|
||||||
if(!m_packZip->open(QuaZip::mdUnzip))
|
if (!m_packZip->open(QuaZip::mdUnzip)) {
|
||||||
{
|
|
||||||
emitFailed(tr("Failed to open modpack file %1!").arg(archivePath));
|
emitFailed(tr("Failed to open modpack file %1!").arg(archivePath));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
m_extractFuture = QtConcurrent::run(QThreadPool::globalInstance(), QOverload<QString, QString>::of(MMCZip::extractDir), archivePath, extractDir.absolutePath() + "/unzip");
|
m_extractFuture = QtConcurrent::run(QThreadPool::globalInstance(), QOverload<QString, QString>::of(MMCZip::extractDir), archivePath,
|
||||||
|
extractDir.absolutePath() + "/unzip");
|
||||||
#else
|
#else
|
||||||
m_extractFuture = QtConcurrent::run(QThreadPool::globalInstance(), MMCZip::extractDir, archivePath, extractDir.absolutePath() + "/unzip");
|
m_extractFuture =
|
||||||
|
QtConcurrent::run(QThreadPool::globalInstance(), MMCZip::extractDir, archivePath, extractDir.absolutePath() + "/unzip");
|
||||||
#endif
|
#endif
|
||||||
connect(&m_extractFutureWatcher, &QFutureWatcher<QStringList>::finished, this, &PackInstallTask::onUnzipFinished);
|
connect(&m_extractFutureWatcher, &QFutureWatcher<QStringList>::finished, this, &PackInstallTask::onUnzipFinished);
|
||||||
connect(&m_extractFutureWatcher, &QFutureWatcher<QStringList>::canceled, this, &PackInstallTask::onUnzipCanceled);
|
connect(&m_extractFutureWatcher, &QFutureWatcher<QStringList>::canceled, this, &PackInstallTask::onUnzipCanceled);
|
||||||
@ -151,11 +152,9 @@ void PackInstallTask::install()
|
|||||||
setStatus(tr("Installing modpack"));
|
setStatus(tr("Installing modpack"));
|
||||||
progress(3, 4);
|
progress(3, 4);
|
||||||
QDir unzipMcDir(m_stagingPath + "/unzip/minecraft");
|
QDir unzipMcDir(m_stagingPath + "/unzip/minecraft");
|
||||||
if(unzipMcDir.exists())
|
if (unzipMcDir.exists()) {
|
||||||
{
|
// ok, found minecraft dir, move contents to instance dir
|
||||||
//ok, found minecraft dir, move contents to instance dir
|
if (!QDir().rename(m_stagingPath + "/unzip/minecraft", m_stagingPath + "/.minecraft")) {
|
||||||
if(!QDir().rename(m_stagingPath + "/unzip/minecraft", m_stagingPath + "/.minecraft"))
|
|
||||||
{
|
|
||||||
emitFailed(tr("Failed to move unzipped Minecraft!"));
|
emitFailed(tr("Failed to move unzipped Minecraft!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -172,23 +171,20 @@ void PackInstallTask::install()
|
|||||||
|
|
||||||
bool fallback = true;
|
bool fallback = true;
|
||||||
|
|
||||||
//handle different versions
|
// handle different versions
|
||||||
QFile packJson(m_stagingPath + "/.minecraft/pack.json");
|
QFile packJson(m_stagingPath + "/.minecraft/pack.json");
|
||||||
QDir jarmodDir = QDir(m_stagingPath + "/unzip/instMods");
|
QDir jarmodDir = QDir(m_stagingPath + "/unzip/instMods");
|
||||||
if(packJson.exists())
|
if (packJson.exists()) {
|
||||||
{
|
|
||||||
packJson.open(QIODevice::ReadOnly | QIODevice::Text);
|
packJson.open(QIODevice::ReadOnly | QIODevice::Text);
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(packJson.readAll());
|
QJsonDocument doc = QJsonDocument::fromJson(packJson.readAll());
|
||||||
packJson.close();
|
packJson.close();
|
||||||
|
|
||||||
//we only care about the libs
|
// we only care about the libs
|
||||||
QJsonArray libs = doc.object().value("libraries").toArray();
|
QJsonArray libs = doc.object().value("libraries").toArray();
|
||||||
|
|
||||||
foreach (const QJsonValue &value, libs)
|
foreach (const QJsonValue& value, libs) {
|
||||||
{
|
|
||||||
QString nameValue = value.toObject().value("name").toString();
|
QString nameValue = value.toObject().value("name").toString();
|
||||||
if(!nameValue.startsWith("net.minecraftforge"))
|
if (!nameValue.startsWith("net.minecraftforge")) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,16 +195,13 @@ void PackInstallTask::install()
|
|||||||
fallback = false;
|
fallback = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(jarmodDir.exists())
|
if (jarmodDir.exists()) {
|
||||||
{
|
|
||||||
qDebug() << "Found jarmods, installing...";
|
qDebug() << "Found jarmods, installing...";
|
||||||
|
|
||||||
QStringList jarmods;
|
QStringList jarmods;
|
||||||
for (auto info: jarmodDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files))
|
for (auto info : jarmodDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files)) {
|
||||||
{
|
|
||||||
qDebug() << "Jarmod:" << info.fileName();
|
qDebug() << "Jarmod:" << info.fileName();
|
||||||
jarmods.push_back(info.absoluteFilePath());
|
jarmods.push_back(info.absoluteFilePath());
|
||||||
}
|
}
|
||||||
@ -217,12 +210,11 @@ void PackInstallTask::install()
|
|||||||
fallback = false;
|
fallback = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//just nuke unzip directory, it s not needed anymore
|
// just nuke unzip directory, it s not needed anymore
|
||||||
FS::deletePath(m_stagingPath + "/unzip");
|
FS::deletePath(m_stagingPath + "/unzip");
|
||||||
|
|
||||||
if(fallback)
|
if (fallback) {
|
||||||
{
|
// TODO: Some fallback mechanism... or just keep failing!
|
||||||
//TODO: Some fallback mechanism... or just keep failing!
|
|
||||||
emitFailed(tr("No installation method found!"));
|
emitFailed(tr("No installation method found!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -232,8 +224,7 @@ void PackInstallTask::install()
|
|||||||
progress(4, 4);
|
progress(4, 4);
|
||||||
|
|
||||||
instance.setName(name());
|
instance.setName(name());
|
||||||
if(m_instIcon == "default")
|
if (m_instIcon == "default") {
|
||||||
{
|
|
||||||
m_instIcon = "ftb_logo";
|
m_instIcon = "ftb_logo";
|
||||||
}
|
}
|
||||||
instance.setIconKey(m_instIcon);
|
instance.setIconKey(m_instIcon);
|
||||||
@ -252,4 +243,4 @@ bool PackInstallTask::abort()
|
|||||||
return InstanceTask::abort();
|
return InstanceTask::abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace LegacyFTB
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "InstanceTask.h"
|
|
||||||
#include "net/NetJob.h"
|
|
||||||
#include <quazip/quazip.h>
|
#include <quazip/quazip.h>
|
||||||
#include <quazip/quazipdir.h>
|
#include <quazip/quazipdir.h>
|
||||||
|
#include "InstanceTask.h"
|
||||||
|
#include "PackHelpers.h"
|
||||||
#include "meta/Index.h"
|
#include "meta/Index.h"
|
||||||
#include "meta/Version.h"
|
#include "meta/Version.h"
|
||||||
#include "meta/VersionList.h"
|
#include "meta/VersionList.h"
|
||||||
#include "PackHelpers.h"
|
#include "net/NetJob.h"
|
||||||
|
|
||||||
#include "net/NetJob.h"
|
#include "net/NetJob.h"
|
||||||
|
|
||||||
@ -14,27 +14,26 @@
|
|||||||
|
|
||||||
namespace LegacyFTB {
|
namespace LegacyFTB {
|
||||||
|
|
||||||
class PackInstallTask : public InstanceTask
|
class PackInstallTask : public InstanceTask {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PackInstallTask(shared_qobject_ptr<QNetworkAccessManager> network, Modpack pack, QString version);
|
explicit PackInstallTask(shared_qobject_ptr<QNetworkAccessManager> network, Modpack pack, QString version);
|
||||||
virtual ~PackInstallTask(){}
|
virtual ~PackInstallTask() {}
|
||||||
|
|
||||||
bool canAbort() const override { return true; }
|
bool canAbort() const override { return true; }
|
||||||
bool abort() override;
|
bool abort() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Entry point for tasks.
|
//! Entry point for tasks.
|
||||||
virtual void executeTask() override;
|
virtual void executeTask() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void downloadPack();
|
void downloadPack();
|
||||||
void unzip();
|
void unzip();
|
||||||
void install();
|
void install();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onDownloadSucceeded();
|
void onDownloadSucceeded();
|
||||||
void onDownloadFailed(QString reason);
|
void onDownloadFailed(QString reason);
|
||||||
void onDownloadProgress(qint64 current, qint64 total);
|
void onDownloadProgress(qint64 current, qint64 total);
|
||||||
@ -43,7 +42,7 @@ private slots:
|
|||||||
void onUnzipFinished();
|
void onUnzipFinished();
|
||||||
void onUnzipCanceled();
|
void onUnzipCanceled();
|
||||||
|
|
||||||
private: /* data */
|
private: /* data */
|
||||||
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
||||||
bool abortable = false;
|
bool abortable = false;
|
||||||
std::unique_ptr<QuaZip> m_packZip;
|
std::unique_ptr<QuaZip> m_packZip;
|
||||||
@ -56,4 +55,4 @@ private: /* data */
|
|||||||
QString m_version;
|
QString m_version;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace LegacyFTB
|
||||||
|
Loading…
Reference in New Issue
Block a user