aboutsummaryrefslogtreecommitdiff
path: root/launcher/modplatform
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/modplatform')
-rw-r--r--launcher/modplatform/CheckUpdateTask.h17
-rw-r--r--launcher/modplatform/EnsureMetadataTask.h5
-rw-r--r--launcher/modplatform/ModIndex.cpp30
-rw-r--r--launcher/modplatform/ModIndex.h5
-rw-r--r--launcher/modplatform/ResourceAPI.h18
-rw-r--r--launcher/modplatform/atlauncher/ATLPackIndex.cpp11
-rw-r--r--launcher/modplatform/atlauncher/ATLPackIndex.h15
-rw-r--r--launcher/modplatform/atlauncher/ATLPackInstallTask.cpp388
-rw-r--r--launcher/modplatform/atlauncher/ATLPackInstallTask.h2
-rw-r--r--launcher/modplatform/atlauncher/ATLPackManifest.cpp116
-rw-r--r--launcher/modplatform/atlauncher/ATLPackManifest.h50
-rw-r--r--launcher/modplatform/atlauncher/ATLShareCode.cpp4
-rw-r--r--launcher/modplatform/atlauncher/ATLShareCode.h6
-rw-r--r--launcher/modplatform/flame/FileResolvingTask.cpp16
-rw-r--r--launcher/modplatform/flame/FlameAPI.cpp16
-rw-r--r--launcher/modplatform/flame/FlameCheckUpdate.cpp6
-rw-r--r--launcher/modplatform/flame/FlameCheckUpdate.h5
-rw-r--r--launcher/modplatform/flame/FlameInstanceCreationTask.cpp11
-rw-r--r--launcher/modplatform/flame/FlameModIndex.cpp6
-rw-r--r--launcher/modplatform/flame/FlamePackExportTask.cpp134
-rw-r--r--launcher/modplatform/flame/FlamePackExportTask.h7
-rw-r--r--launcher/modplatform/flame/FlamePackIndex.cpp9
-rw-r--r--launcher/modplatform/flame/PackManifest.cpp7
-rw-r--r--launcher/modplatform/flame/PackManifest.h36
-rw-r--r--launcher/modplatform/helpers/NetworkResourceAPI.cpp10
-rw-r--r--launcher/modplatform/import_ftb/PackHelpers.cpp87
-rw-r--r--launcher/modplatform/import_ftb/PackHelpers.h55
-rw-r--r--launcher/modplatform/import_ftb/PackInstallTask.cpp99
-rw-r--r--launcher/modplatform/import_ftb/PackInstallTask.h49
-rw-r--r--launcher/modplatform/legacy_ftb/PackFetchTask.cpp10
-rw-r--r--launcher/modplatform/legacy_ftb/PackHelpers.h22
-rw-r--r--launcher/modplatform/legacy_ftb/PackInstallTask.cpp8
-rw-r--r--launcher/modplatform/legacy_ftb/PrivatePackManager.cpp21
-rw-r--r--launcher/modplatform/legacy_ftb/PrivatePackManager.h30
-rw-r--r--launcher/modplatform/modrinth/ModrinthAPI.cpp13
-rw-r--r--launcher/modplatform/modrinth/ModrinthCheckUpdate.h5
-rw-r--r--launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp31
-rw-r--r--launcher/modplatform/modrinth/ModrinthInstanceCreationTask.h5
-rw-r--r--launcher/modplatform/modrinth/ModrinthPackExportTask.cpp94
-rw-r--r--launcher/modplatform/modrinth/ModrinthPackExportTask.h5
-rw-r--r--launcher/modplatform/modrinth/ModrinthPackIndex.cpp8
-rw-r--r--launcher/modplatform/modrinth/ModrinthPackIndex.h2
-rw-r--r--launcher/modplatform/modrinth/ModrinthPackManifest.cpp27
-rw-r--r--launcher/modplatform/modrinth/ModrinthPackManifest.h11
-rw-r--r--launcher/modplatform/packwiz/Packwiz.cpp14
-rw-r--r--launcher/modplatform/packwiz/Packwiz.h54
-rw-r--r--launcher/modplatform/technic/SingleZipPackInstallTask.cpp45
-rw-r--r--launcher/modplatform/technic/SingleZipPackInstallTask.h16
-rw-r--r--launcher/modplatform/technic/SolderPackInstallTask.cpp45
-rw-r--r--launcher/modplatform/technic/SolderPackInstallTask.h2
-rw-r--r--launcher/modplatform/technic/SolderPackManifest.cpp4
-rw-r--r--launcher/modplatform/technic/SolderPackManifest.h6
-rw-r--r--launcher/modplatform/technic/TechnicPackProcessor.cpp108
-rw-r--r--launcher/modplatform/technic/TechnicPackProcessor.h29
54 files changed, 957 insertions, 878 deletions
diff --git a/launcher/modplatform/CheckUpdateTask.h b/launcher/modplatform/CheckUpdateTask.h
index f7582b8f..6d968ea4 100644
--- a/launcher/modplatform/CheckUpdateTask.h
+++ b/launcher/modplatform/CheckUpdateTask.h
@@ -1,8 +1,8 @@
#pragma once
#include "minecraft/mod/Mod.h"
-#include "modplatform/ResourceAPI.h"
#include "modplatform/ModIndex.h"
+#include "modplatform/ResourceAPI.h"
#include "tasks/Task.h"
class ResourceDownloadTask;
@@ -12,8 +12,11 @@ class CheckUpdateTask : public Task {
Q_OBJECT
public:
- CheckUpdateTask(QList<Mod*>& mods, std::list<Version>& mcVersions, std::optional<ResourceAPI::ModLoaderTypes> loaders, std::shared_ptr<ModFolderModel> mods_folder)
- : Task(nullptr), m_mods(mods), m_game_versions(mcVersions), m_loaders(loaders), m_mods_folder(mods_folder) {};
+ CheckUpdateTask(QList<Mod*>& mods,
+ std::list<Version>& mcVersions,
+ std::optional<ResourceAPI::ModLoaderTypes> loaders,
+ std::shared_ptr<ModFolderModel> mods_folder)
+ : Task(nullptr), m_mods(mods), m_game_versions(mcVersions), m_loaders(loaders), m_mods_folder(mods_folder){};
struct UpdatableMod {
QString name;
@@ -25,7 +28,13 @@ class CheckUpdateTask : public Task {
shared_qobject_ptr<ResourceDownloadTask> download;
public:
- UpdatableMod(QString name, QString old_h, QString old_v, QString new_v, QString changelog, ModPlatform::ResourceProvider p, shared_qobject_ptr<ResourceDownloadTask> t)
+ UpdatableMod(QString name,
+ QString old_h,
+ QString old_v,
+ QString new_v,
+ QString changelog,
+ ModPlatform::ResourceProvider p,
+ shared_qobject_ptr<ResourceDownloadTask> t)
: name(name), old_hash(old_h), old_version(old_v), new_version(new_v), changelog(changelog), provider(p), download(t)
{}
};
diff --git a/launcher/modplatform/EnsureMetadataTask.h b/launcher/modplatform/EnsureMetadataTask.h
index 03cae4e4..2f276e5a 100644
--- a/launcher/modplatform/EnsureMetadataTask.h
+++ b/launcher/modplatform/EnsureMetadataTask.h
@@ -35,10 +35,7 @@ class EnsureMetadataTask : public Task {
auto flameProjectsTask() -> Task::Ptr;
// Helpers
- enum class RemoveFromList {
- Yes,
- No
- };
+ enum class RemoveFromList { Yes, No };
void emitReady(Mod*, QString key = {}, RemoveFromList = RemoveFromList::Yes);
void emitFail(Mod*, QString key = {}, RemoveFromList = RemoveFromList::Yes);
diff --git a/launcher/modplatform/ModIndex.cpp b/launcher/modplatform/ModIndex.cpp
index a1c4d891..350a9f10 100644
--- a/launcher/modplatform/ModIndex.cpp
+++ b/launcher/modplatform/ModIndex.cpp
@@ -1,20 +1,20 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
-* PolyMC - Minecraft Launcher
-* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
-*
-* 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.
-*
-* 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.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <https://www.gnu.org/licenses/>.
-*/
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
#include "modplatform/ModIndex.h"
diff --git a/launcher/modplatform/ModIndex.h b/launcher/modplatform/ModIndex.h
index 2aa91602..cad21703 100644
--- a/launcher/modplatform/ModIndex.h
+++ b/launcher/modplatform/ModIndex.h
@@ -113,7 +113,7 @@ struct IndexedPack {
ExtraPackData extraData;
// For internal use, not provided by APIs
- [[nodiscard]] bool isVersionSelected(size_t index) const
+ [[nodiscard]] bool isVersionSelected(int index) const
{
if (!versionsLoaded)
return false;
@@ -144,7 +144,8 @@ inline auto getOverrideDeps() -> QList<OverrideDep>
{ "qvIfYCYJ", "P7dR8mSH", "API", ModPlatform::ResourceProvider::MODRINTH },
{ "lwVhp9o5", "Ha28R6CL", "KotlinLibraries", ModPlatform::ResourceProvider::MODRINTH } };
-};
+}
+
QString getMetaURL(ResourceProvider provider, QVariant projectID);
} // namespace ModPlatform
diff --git a/launcher/modplatform/ResourceAPI.h b/launcher/modplatform/ResourceAPI.h
index d3277761..a92217a0 100644
--- a/launcher/modplatform/ResourceAPI.h
+++ b/launcher/modplatform/ResourceAPI.h
@@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: GPL-3.0-only AND Apache-2.0
/*
- * 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
@@ -128,28 +128,30 @@ class ResourceAPI {
public slots:
[[nodiscard]] virtual Task::Ptr searchProjects(SearchArgs&&, SearchCallbacks&&) const
{
- qWarning() << "TODO";
+ qWarning() << "TODO: ResourceAPI::searchProjects";
return nullptr;
}
- [[nodiscard]] virtual Task::Ptr getProject(QString addonId, std::shared_ptr<QByteArray> response) const
+ [[nodiscard]] virtual Task::Ptr getProject([[maybe_unused]] QString addonId,
+ [[maybe_unused]] std::shared_ptr<QByteArray> response) const
{
- qWarning() << "TODO";
+ qWarning() << "TODO: ResourceAPI::getProject";
return nullptr;
}
- [[nodiscard]] virtual Task::Ptr getProjects(QStringList addonIds, std::shared_ptr<QByteArray> response) const
+ [[nodiscard]] virtual Task::Ptr getProjects([[maybe_unused]] QStringList addonIds,
+ [[maybe_unused]] std::shared_ptr<QByteArray> response) const
{
- qWarning() << "TODO";
+ qWarning() << "TODO: ResourceAPI::getProjects";
return nullptr;
}
[[nodiscard]] virtual Task::Ptr getProjectInfo(ProjectInfoArgs&&, ProjectInfoCallbacks&&) const
{
- qWarning() << "TODO";
+ qWarning() << "TODO: ResourceAPI::getProjectInfo";
return nullptr;
}
[[nodiscard]] virtual Task::Ptr getProjectVersions(VersionSearchArgs&&, VersionSearchCallbacks&&) const
{
- qWarning() << "TODO";
+ qWarning() << "TODO: ResourceAPI::getProjectVersions";
return nullptr;
}
diff --git a/launcher/modplatform/atlauncher/ATLPackIndex.cpp b/launcher/modplatform/atlauncher/ATLPackIndex.cpp
index e649c43a..3be16973 100644
--- a/launcher/modplatform/atlauncher/ATLPackIndex.cpp
+++ b/launcher/modplatform/atlauncher/ATLPackIndex.cpp
@@ -21,23 +21,20 @@
#include "Json.h"
-static void loadIndexedVersion(ATLauncher::IndexedVersion & v, QJsonObject & obj)
+static void loadIndexedVersion(ATLauncher::IndexedVersion& v, QJsonObject& obj)
{
v.version = Json::requireString(obj, "version");
v.minecraft = Json::requireString(obj, "minecraft");
}
-void ATLauncher::loadIndexedPack(ATLauncher::IndexedPack & m, QJsonObject & obj)
+void ATLauncher::loadIndexedPack(ATLauncher::IndexedPack& m, QJsonObject& obj)
{
m.id = Json::requireInteger(obj, "id");
m.position = Json::requireInteger(obj, "position");
m.name = Json::requireString(obj, "name");
- m.type = Json::requireString(obj, "type") == "private" ?
- ATLauncher::PackType::Private :
- ATLauncher::PackType::Public;
+ m.type = Json::requireString(obj, "type") == "private" ? ATLauncher::PackType::Private : ATLauncher::PackType::Public;
auto versionsArr = Json::requireArray(obj, "versions");
- for (const auto versionRaw : versionsArr)
- {
+ for (const auto versionRaw : versionsArr) {
auto versionObj = Json::requireObject(versionRaw);
ATLauncher::IndexedVersion version;
loadIndexedVersion(version, versionObj);
diff --git a/launcher/modplatform/atlauncher/ATLPackIndex.h b/launcher/modplatform/atlauncher/ATLPackIndex.h
index 337b80b8..8d18c671 100644
--- a/launcher/modplatform/atlauncher/ATLPackIndex.h
+++ b/launcher/modplatform/atlauncher/ATLPackIndex.h
@@ -18,21 +18,18 @@
#include "ATLPackManifest.h"
+#include <QMetaType>
#include <QString>
#include <QVector>
-#include <QMetaType>
-namespace ATLauncher
-{
+namespace ATLauncher {
-struct IndexedVersion
-{
+struct IndexedVersion {
QString version;
QString minecraft;
};
-struct IndexedPack
-{
+struct IndexedPack {
int id;
int position;
QString name;
@@ -44,7 +41,7 @@ struct IndexedPack
QString safeName;
};
-void loadIndexedPack(IndexedPack & m, QJsonObject & obj);
-}
+void loadIndexedPack(IndexedPack& m, QJsonObject& obj);
+} // namespace ATLauncher
Q_DECLARE_METATYPE(ATLauncher::IndexedPack)
diff --git a/launcher/modplatform/atlauncher/ATLPackInstallTask.cpp b/launcher/modplatform/atlauncher/ATLPackInstallTask.cpp
index 22ea02da..e5771b7c 100644
--- a/launcher/modplatform/atlauncher/ATLPackInstallTask.cpp
+++ b/launcher/modplatform/atlauncher/ATLPackInstallTask.cpp
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
*
* This program is free software: you can redistribute it and/or modify
@@ -40,27 +40,29 @@
#include <quazip/quazip.h>
-#include "MMCZip.h"
-#include "minecraft/OneSixVersionFormat.h"
-#include "Version.h"
-#include "net/ChecksumValidator.h"
#include "FileSystem.h"
#include "Json.h"
-#include "minecraft/MinecraftInstance.h"
-#include "minecraft/PackProfile.h"
-#include "settings/INISettingsObject.h"
+#include "MMCZip.h"
+#include "Version.h"
#include "meta/Index.h"
#include "meta/Version.h"
#include "meta/VersionList.h"
+#include "minecraft/MinecraftInstance.h"
+#include "minecraft/OneSixVersionFormat.h"
+#include "minecraft/PackProfile.h"
+#include "net/ChecksumValidator.h"
+#include "settings/INISettingsObject.h"
+
+#include "net/ApiDownload.h"
-#include "BuildConfig.h"
#include "Application.h"
+#include "BuildConfig.h"
namespace ATLauncher {
static Meta::Version::Ptr getComponentVersion(const QString& uid, const QString& version);
-PackInstallTask::PackInstallTask(UserInteractionSupport *support, QString packName, QString version, InstallMode installMode)
+PackInstallTask::PackInstallTask(UserInteractionSupport* support, QString packName, QString version, InstallMode installMode)
{
m_support = support;
m_pack_name = packName;
@@ -71,8 +73,7 @@ PackInstallTask::PackInstallTask(UserInteractionSupport *support, QString packNa
bool PackInstallTask::abort()
{
- if(abortable)
- {
+ if (abortable) {
return jobPtr->abort();
}
return false;
@@ -84,7 +85,7 @@ void PackInstallTask::executeTask()
NetJob::Ptr netJob{ new NetJob("ATLauncher::VersionFetch", APPLICATION->network()) };
auto searchUrl =
QString(BuildConfig.ATL_DOWNLOAD_SERVER_URL + "packs/%1/versions/%2/Configs.json").arg(m_pack_safe_name).arg(m_version_name);
- netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), response));
+ netJob->addNetAction(Net::ApiDownload::makeByteArray(QUrl(searchUrl), response));
QObject::connect(netJob.get(), &NetJob::succeeded, this, &PackInstallTask::onDownloadSucceeded);
QObject::connect(netJob.get(), &NetJob::failed, this, &PackInstallTask::onDownloadFailed);
@@ -110,12 +111,9 @@ void PackInstallTask::onDownloadSucceeded()
auto obj = doc.object();
ATLauncher::PackVersion version;
- try
- {
+ try {
ATLauncher::loadVersion(version, obj);
- }
- catch (const JSONValidationError &e)
- {
+ } catch (const JSONValidationError& e) {
emitFailed(tr("Could not understand pack manifest:\n") + e.cause());
return;
}
@@ -126,20 +124,20 @@ void PackInstallTask::onDownloadSucceeded()
bool resetDirectory;
switch (m_install_mode) {
- case InstallMode::Reinstall:
- case InstallMode::Update:
- message = m_version.messages.update;
- resetDirectory = true;
- break;
-
- case InstallMode::Install:
- message = m_version.messages.install;
- resetDirectory = false;
- break;
-
- default:
- emitFailed(tr("Unsupported installation mode"));
- return;
+ case InstallMode::Reinstall:
+ case InstallMode::Update:
+ message = m_version.messages.update;
+ resetDirectory = true;
+ break;
+
+ case InstallMode::Install:
+ message = m_version.messages.install;
+ resetDirectory = false;
+ break;
+
+ default:
+ emitFailed(tr("Unsupported installation mode"));
+ return;
}
// Display message if one exists
@@ -157,10 +155,9 @@ void PackInstallTask::onDownloadSucceeded()
deleteExistingFiles();
}
- if(m_version.noConfigs) {
+ if (m_version.noConfigs) {
downloadMods();
- }
- else {
+ } else {
installConfigs();
}
}
@@ -212,11 +209,9 @@ void PackInstallTask::deleteExistingFiles()
if (base == "root") {
return minecraftPath;
- }
- else if (base == "config") {
+ } else if (base == "config") {
return FS::PathCombine(minecraftPath, "config");
- }
- else {
+ } else {
qWarning() << "Unrecognised base path" << base;
return minecraftPath;
}
@@ -338,19 +333,18 @@ QString PackInstallTask::getDirForModType(ModType type, QString raw)
QString PackInstallTask::getVersionForLoader(QString uid)
{
- if(m_version.loader.recommended || m_version.loader.latest || m_version.loader.choose) {
+ if (m_version.loader.recommended || m_version.loader.latest || m_version.loader.choose) {
auto vlist = APPLICATION->metadataIndex()->get(uid);
- if(!vlist)
- {
+ if (!vlist) {
emitFailed(tr("Failed to get local metadata index for %1").arg(uid));
return Q_NULLPTR;
}
- if(!vlist->isLoaded()) {
+ if (!vlist->isLoaded()) {
vlist->load(Net::Mode::Online);
}
- if(m_version.loader.recommended || m_version.loader.latest) {
+ if (m_version.loader.recommended || m_version.loader.latest) {
for (int i = 0; i < vlist->versions().size(); i++) {
auto version = vlist->versions().at(i);
auto reqs = version->requiredSet();
@@ -359,16 +353,17 @@ QString PackInstallTask::getVersionForLoader(QString uid)
// not all mod loaders depend on a given Minecraft version, so we won't do this
// filtering for those loaders.
if (m_version.loader.type != "fabric") {
- auto iter = std::find_if(reqs.begin(), reqs.end(), [](const Meta::Require &req) {
- return req.uid == "net.minecraft";
- });
- if (iter == reqs.end()) continue;
- if (iter->equalsVersion != m_version.minecraft) continue;
+ auto iter = std::find_if(reqs.begin(), reqs.end(), [](const Meta::Require& req) { return req.uid == "net.minecraft"; });
+ if (iter == reqs.end())
+ continue;
+ if (iter->equalsVersion != m_version.minecraft)
+ continue;
}
if (m_version.loader.recommended) {
// first recommended build we find, we use.
- if (!version->isRecommended()) continue;
+ if (!version->isRecommended())
+ continue;
}
return version->descriptor();
@@ -376,8 +371,7 @@ QString PackInstallTask::getVersionForLoader(QString uid)
emitFailed(tr("Failed to find version for %1 loader").arg(m_version.loader.type));
return Q_NULLPTR;
- }
- else if(m_version.loader.choose) {
+ } else if (m_version.loader.choose) {
// Fabric Loader doesn't depend on a given Minecraft version.
if (m_version.loader.type == "fabric") {
return m_support->chooseVersion(vlist, Q_NULLPTR);
@@ -414,15 +408,14 @@ QString PackInstallTask::detectLibrary(VersionLibrary library)
return group + ":" + artefact + ":" + version;
}
- if(library.file.contains("-")) {
+ if (library.file.contains("-")) {
auto lastSlash = library.file.lastIndexOf("-");
auto name = library.file.mid(0, lastSlash);
auto version = library.file.mid(lastSlash + 1).remove(".jar");
- if(name == QString("guava")) {
+ if (name == QString("guava")) {
return "com.google.guava:guava:" + version;
- }
- else if(name == QString("commons-lang3")) {
+ } else if (name == QString("commons-lang3")) {
return "org.apache.commons:commons-lang3:" + version;
}
}
@@ -432,22 +425,22 @@ QString PackInstallTask::detectLibrary(VersionLibrary library)
bool PackInstallTask::createLibrariesComponent(QString instanceRoot, std::shared_ptr<PackProfile> profile)
{
- if(m_version.libraries.isEmpty()) {
+ if (m_version.libraries.isEmpty()) {
return true;
}
QList<GradleSpecifier> exempt;
- for(const auto & componentUid : componentsToInstall.keys()) {
+ for (const auto& componentUid : componentsToInstall.keys()) {
auto componentVersion = componentsToInstall.value(componentUid);
- for(const auto & library : componentVersion->data()->libraries) {
+ for (const auto& library : componentVersion->data()->libraries) {
GradleSpecifier lib(library->rawName());
exempt.append(lib);
}
}
{
- for(const auto & library : minecraftVersion->data()->libraries) {
+ for (const auto& library : minecraftVersion->d