aboutsummaryrefslogtreecommitdiff
path: root/launcher/modplatform/legacy_ftb
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/modplatform/legacy_ftb')
-rw-r--r--launcher/modplatform/legacy_ftb/PackFetchTask.cpp4
-rw-r--r--launcher/modplatform/legacy_ftb/PackHelpers.h22
-rw-r--r--launcher/modplatform/legacy_ftb/PackInstallTask.cpp90
-rw-r--r--launcher/modplatform/legacy_ftb/PackInstallTask.h27
-rw-r--r--launcher/modplatform/legacy_ftb/PrivatePackManager.cpp21
-rw-r--r--launcher/modplatform/legacy_ftb/PrivatePackManager.h30
6 files changed, 68 insertions, 126 deletions
diff --git a/launcher/modplatform/legacy_ftb/PackFetchTask.cpp b/launcher/modplatform/legacy_ftb/PackFetchTask.cpp
index a8a0fc2c..6d27357a 100644
--- a/launcher/modplatform/legacy_ftb/PackFetchTask.cpp
+++ b/launcher/modplatform/legacy_ftb/PackFetchTask.cpp
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
*
* This program is free software: you can redistribute it and/or modify
@@ -37,8 +37,8 @@
#include "PrivatePackManager.h"
#include <QDomDocument>
-#include "BuildConfig.h"
#include "Application.h"
+#include "BuildConfig.h"
namespace LegacyFTB {
diff --git a/launcher/modplatform/legacy_ftb/PackHelpers.h b/launcher/modplatform/legacy_ftb/PackHelpers.h
index 566210d0..4fb53553 100644
--- a/launcher/modplatform/legacy_ftb/PackHelpers.h
+++ b/launcher/modplatform/legacy_ftb/PackHelpers.h
@@ -1,22 +1,16 @@
#pragma once
#include <QList>
+#include <QMetaType>
#include <QString>
#include <QStringList>
-#include <QMetaType>
namespace LegacyFTB {
-//Header for structs etc...
-enum class PackType
-{
- Public,
- ThirdParty,
- Private
-};
+// Header for structs etc...
+enum class PackType { Public, ThirdParty, Private };
-struct Modpack
-{
+struct Modpack {
QString name;
QString description;
QString author;
@@ -26,9 +20,9 @@ struct Modpack
QString mods;
QString logo;
- //Technical data
+ // Technical data
QString dir;
- QString file; //<- Url in the xml, but doesn't make much sense
+ QString file; //<- Url in the xml, but doesn't make much sense
bool bugged = false;
bool broken = false;
@@ -39,7 +33,7 @@ struct Modpack
typedef QList<Modpack> ModpackList;
-}
+} // namespace LegacyFTB
-//We need it for the proxy model
+// We need it for the proxy model
Q_DECLARE_METATYPE(LegacyFTB::Modpack)
diff --git a/launcher/modplatform/legacy_ftb/PackInstallTask.cpp b/launcher/modplatform/legacy_ftb/PackInstallTask.cpp
index 36c142ac..91c821f0 100644
--- a/launcher/modplatform/legacy_ftb/PackInstallTask.cpp
+++ b/launcher/modplatform/legacy_ftb/PackInstallTask.cpp
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
*
* This program is free software: you can redistribute it and/or modify
@@ -37,16 +37,16 @@
#include <QtConcurrent>
-#include "MMCZip.h"
#include "BaseInstance.h"
#include "FileSystem.h"
-#include "settings/INISettingsObject.h"
+#include "MMCZip.h"
+#include "minecraft/GradleSpecifier.h"
#include "minecraft/MinecraftInstance.h"
#include "minecraft/PackProfile.h"
-#include "minecraft/GradleSpecifier.h"
+#include "settings/INISettingsObject.h"
-#include "BuildConfig.h"
#include "Application.h"
+#include "BuildConfig.h"
namespace LegacyFTB {
@@ -65,6 +65,7 @@ void PackInstallTask::executeTask()
void PackInstallTask::downloadPack()
{
setStatus(tr("Downloading zip for %1").arg(m_pack.name));
+ setProgress(1, 4);
setAbortable(false);
archivePath = QString("%1/%2/%3").arg(m_pack.dir, m_version.replace(".", "_"), m_pack.file);
@@ -78,11 +79,10 @@ void PackInstallTask::downloadPack()
}
netJobContainer->addNetAction(Net::Download::makeFile(url, archivePath));
- connect(netJobContainer.get(), &NetJob::succeeded, this, &PackInstallTask::onDownloadSucceeded);
- connect(netJobContainer.get(), &NetJob::failed, this, &PackInstallTask::onDownloadFailed);
- connect(netJobContainer.get(), &NetJob::progress, this, &PackInstallTask::onDownloadProgress);
- connect(netJobContainer.get(), &NetJob::stepProgress, this, &PackInstallTask::propogateStepProgress);
- connect(netJobContainer.get(), &NetJob::aborted, this, &PackInstallTask::onDownloadAborted);
+ connect(netJobContainer.get(), &NetJob::succeeded, this, &PackInstallTask::unzip);
+ connect(netJobContainer.get(), &NetJob::failed, this, &PackInstallTask::emitFailed);
+ connect(netJobContainer.get(), &NetJob::stepProgress, this, &PackInstallTask::propagateStepProgress);
+ connect(netJobContainer.get(), &NetJob::aborted, this, &PackInstallTask::emitAborted);
netJobContainer->start();
@@ -90,27 +90,6 @@ void PackInstallTask::downloadPack()
progress(1, 4);
}
-void PackInstallTask::onDownloadSucceeded()
-{
- unzip();
-}
-
-void PackInstallTask::onDownloadFailed(QString reason)
-{
- emitFailed(reason);
-}
-
-void PackInstallTask::onDownloadProgress(qint64 current, qint64 total)
-{
- progress(current, total * 4);
- setStatus(tr("Downloading zip for %1 (%2%)").arg(m_pack.name).arg(current / 10));
-}
-
-void PackInstallTask::onDownloadAborted()
-{
- emitAborted();
-}
-
void PackInstallTask::unzip()
{
setStatus(tr("Extracting modpack"));
@@ -120,16 +99,17 @@ void PackInstallTask::unzip()
QDir extractDir(m_stagingPath);
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));
return;
}
#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
- 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
connect(&m_extractFutureWatcher, &QFutureWatcher<QStringList>::finished, this, &PackInstallTask::onUnzipFinished);
connect(&m_extractFutureWatcher, &QFutureWatcher<QStringList>::canceled, this, &PackInstallTask::onUnzipCanceled);
@@ -151,11 +131,9 @@ void PackInstallTask::install()
setStatus(tr("Installing modpack"));
progress(3, 4);
QDir unzipMcDir(m_stagingPath + "/unzip/minecraft");
- if(unzipMcDir.exists())
- {
- //ok, found minecraft dir, move contents to instance dir
- if(!QDir().rename(m_stagingPath + "/unzip/minecraft", m_stagingPath + "/.minecraft"))
- {
+ if (unzipMcDir.exists()) {
+ // ok, found minecraft dir, move contents to instance dir
+ if (!QDir().rename(m_stagingPath + "/unzip/minecraft", m_stagingPath + "/.minecraft")) {
emitFailed(tr("Failed to move unzipped Minecraft!"));
return;
}
@@ -172,23 +150,20 @@ void PackInstallTask::install()
bool fallback = true;
- //handle different versions
+ // handle different versions
QFile packJson(m_stagingPath + "/.minecraft/pack.json");
QDir jarmodDir = QDir(m_stagingPath + "/unzip/instMods");
- if(packJson.exists())
- {
+ if (packJson.exists()) {
packJson.open(QIODevice::ReadOnly | QIODevice::Text);
QJsonDocument doc = QJsonDocument::fromJson(packJson.readAll());
packJson.close();
- //we only care about the libs
+ // we only care about the libs
QJsonArray libs = doc.object().value("libraries").toArray();
- foreach (const QJsonValue &value, libs)
- {
+ foreach (const QJsonValue& value, libs) {
QString nameValue = value.toObject().value("name").toString();
- if(!nameValue.startsWith("net.minecraftforge"))
- {
+ if (!nameValue.startsWith("net.minecraftforge")) {
continue;
}
@@ -199,16 +174,13 @@ void PackInstallTask::install()
fallback = false;
break;
}
-
}
- if(jarmodDir.exists())
- {
+ if (jarmodDir.exists()) {
qDebug() << "Found jarmods, installing...";
QStringList jarmods;
- for (auto info: jarmodDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files))
- {
+ for (auto info : jarmodDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files)) {
qDebug() << "Jarmod:" << info.fileName();
jarmods.push_back(info.absoluteFilePath());
}
@@ -217,12 +189,11 @@ void PackInstallTask::install()
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");
- if(fallback)
- {
- //TODO: Some fallback mechanism... or just keep failing!
+ if (fallback) {
+ // TODO: Some fallback mechanism... or just keep failing!
emitFailed(tr("No installation method found!"));
return;
}
@@ -232,8 +203,7 @@ void PackInstallTask::install()
progress(4, 4);
instance.setName(name());
- if(m_instIcon == "default")
- {
+ if (m_instIcon == "default") {
m_instIcon = "ftb_logo";
}
instance.setIconKey(m_instIcon);
@@ -252,4 +222,4 @@ bool PackInstallTask::abort()
return InstanceTask::abort();
}
-}
+} // namespace LegacyFTB
diff --git a/launcher/modplatform/legacy_ftb/PackInstallTask.h b/launcher/modplatform/legacy_ftb/PackInstallTask.h
index da791e06..30ff4859 100644
--- a/launcher/modplatform/legacy_ftb/PackInstallTask.h
+++ b/launcher/modplatform/legacy_ftb/PackInstallTask.h
@@ -1,12 +1,12 @@
#pragma once
-#include "InstanceTask.h"
-#include "net/NetJob.h"
#include <quazip/quazip.h>
#include <quazip/quazipdir.h>
+#include "InstanceTask.h"
+#include "PackHelpers.h"
#include "meta/Index.h"
#include "meta/Version.h"
#include "meta/VersionList.h"
-#include "PackHelpers.h"
+#include "net/NetJob.h"
#include "net/NetJob.h"
@@ -14,36 +14,31 @@
namespace LegacyFTB {
-class PackInstallTask : public InstanceTask
-{
+class PackInstallTask : public InstanceTask {
Q_OBJECT
-public:
+ public:
explicit PackInstallTask(shared_qobject_ptr<QNetworkAccessManager> network, Modpack pack, QString version);
- virtual ~PackInstallTask(){}
+ virtual ~PackInstallTask() {}
bool canAbort() const override { return true; }
bool abort() override;
-protected:
+ protected:
//! Entry point for tasks.
virtual void executeTask() override;
-private:
+ private:
void downloadPack();
void unzip();
void install();
-private slots:
- void onDownloadSucceeded();
- void onDownloadFailed(QString reason);
- void onDownloadProgress(qint64 current, qint64 total);
- void onDownloadAborted();
+ private slots:
void onUnzipFinished();
void onUnzipCanceled();
-private: /* data */
+ private: /* data */
shared_qobject_ptr<QNetworkAccessManager> m_network;
bool abortable = false;
std::unique_ptr<QuaZip> m_packZip;
@@ -56,4 +51,4 @@ private: /* data */
QString m_version;
};
-}
+} // namespace LegacyFTB
diff --git a/launcher/modplatform/legacy_ftb/PrivatePackManager.cpp b/launcher/modplatform/legacy_ftb/PrivatePackManager.cpp
index 1a81f026..2ae35132 100644
--- a/launcher/modplatform/legacy_ftb/PrivatePackManager.cpp
+++ b/launcher/modplatform/legacy_ftb/PrivatePackManager.cpp
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
*
* This program is free software: you can redistribute it and/or modify
@@ -43,8 +43,7 @@ namespace LegacyFTB {
void PrivatePackManager::load()
{
- try
- {
+ try {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
auto foo = QString::fromUtf8(FS::read(m_filename)).split('\n', Qt::SkipEmptyParts);
currentPacks = QSet<QString>(foo.begin(), foo.end());
@@ -53,9 +52,7 @@ void PrivatePackManager::load()
#endif
dirty = false;
- }
- catch(...)
- {
+ } catch (...) {
currentPacks = {};
qWarning() << "Failed to read third party FTB pack codes from" << m_filename;
}
@@ -63,20 +60,16 @@ void PrivatePackManager::load()
void PrivatePackManager::save() const
{
- if(!dirty)
- {
+ if (!dirty) {
return;
}
- try
- {
+ try {
QStringList list = currentPacks.values();
FS::write(m_filename, list.join('\n').toUtf8());
dirty = false;
- }
- catch(...)
- {
+ } catch (...) {
qWarning() << "Failed to write third party FTB pack codes to" << m_filename;
}
}
-}
+} // namespace LegacyFTB
diff --git a/launcher/modplatform/legacy_ftb/PrivatePackManager.h b/launcher/modplatform/legacy_ftb/PrivatePackManager.h
index 0e814646..be811f83 100644
--- a/launcher/modplatform/legacy_ftb/PrivatePackManager.h
+++ b/launcher/modplatform/legacy_ftb/PrivatePackManager.h
@@ -1,43 +1,33 @@
#pragma once
+#include <QFile>
#include <QSet>
#include <QString>
-#include <QFile>
namespace LegacyFTB {
-class PrivatePackManager
-{
-public:
- ~PrivatePackManager()
- {
- save();
- }
+class PrivatePackManager {
+ public:
+ ~PrivatePackManager() { save(); }
void load();
void save() const;
- bool empty() const
- {
- return currentPacks.empty();
- }
- const QSet<QString> &getCurrentPackCodes() const
- {
- return currentPacks;
- }
- void add(const QString &code)
+ bool empty() const { return currentPacks.empty(); }
+ const QSet<QString>& getCurrentPackCodes() const { return currentPacks; }
+ void add(const QString& code)
{
currentPacks.insert(code);
dirty = true;
}
- void remove(const QString &code)
+ void remove(const QString& code)
{
currentPacks.remove(code);
dirty = true;
}
-private:
+ private:
QSet<QString> currentPacks;
QString m_filename = "private_packs.txt";
mutable bool dirty = false;
};
-}
+} // namespace LegacyFTB