diff options
Diffstat (limited to 'launcher/modplatform')
55 files changed, 1732 insertions, 874 deletions
diff --git a/launcher/modplatform/EnsureMetadataTask.cpp b/launcher/modplatform/EnsureMetadataTask.cpp index 93b5ce76..c3eadd06 100644 --- a/launcher/modplatform/EnsureMetadataTask.cpp +++ b/launcher/modplatform/EnsureMetadataTask.cpp @@ -145,7 +145,8 @@ void EnsureMetadataTask::executeTask() connect(project_task.get(), &Task::finished, this, [=] { invalidade_leftover(); project_task->deleteLater(); - m_current_task = nullptr; + if (m_current_task) + m_current_task.reset(); }); m_current_task = project_task; @@ -154,7 +155,8 @@ void EnsureMetadataTask::executeTask() connect(version_task.get(), &Task::finished, [=] { version_task->deleteLater(); - m_current_task = nullptr; + if (m_current_task) + m_current_task.reset(); }); if (m_mods.size() > 1) 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 3e1f473e..2e0d9e37 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" @@ -138,11 +138,17 @@ auto ProviderCapabilities::hash(ResourceProvider p, QIODevice* device, QString t } QCryptographicHash hash(algo); - if(!hash.addData(device)) + if (!hash.addData(device)) qCritical() << "Failed to read JAR to create hash!"; Q_ASSERT(hash.result().length() == hash.hashLength(algo)); return { hash.result().toHex() }; } +QString getMetaURL(ResourceProvider provider, QVariant projectID) +{ + return ((provider == ModPlatform::ResourceProvider::FLAME) ? "https://www.curseforge.com/projects/" : "https://modrinth.com/mod/") + + projectID.toString(); +} + } // namespace ModPlatform diff --git a/launcher/modplatform/ModIndex.h b/launcher/modplatform/ModIndex.h index 4ed9e7eb..e430f2b0 100644 --- a/launcher/modplatform/ModIndex.h +++ b/launcher/modplatform/ModIndex.h @@ -159,6 +159,7 @@ struct IndexedPack { return std::any_of(versions.constBegin(), versions.constEnd(), [](auto const& v) { return v.is_currently_selected; }); } }; +QString getMetaURL(ResourceProvider provider, QVariant projectID); struct OverrideDep { QString quilt; @@ -175,6 +176,7 @@ 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..ef220977 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 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..f0198481 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,27 @@ #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 "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 +71,7 @@ PackInstallTask::PackInstallTask(UserInteractionSupport *support, QString packNa bool PackInstallTask::abort() { - if(abortable) - { + if (abortable) { return jobPtr->abort(); } return false; @@ -110,12 +109,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 +122,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 +153,9 @@ void PackInstallTask::onDownloadSucceeded() deleteExistingFiles(); } - if(m_version.noConfigs) { + if (m_version.noConfigs) { downloadMods(); - } - else { + } else { installConfigs(); } } @@ -212,11 +207,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 +331,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 +351,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 +369,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 +406,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 +423,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->data()->libraries) { GradleSpecifier lib(library->rawName()); exempt.append(lib); } @@ -458,8 +449,7 @@ bool PackInstallTask::createLibrariesComponent(QString instanceRoot, std::shared auto target_id = "org.multimc.atlauncher." + id; auto patchDir = FS::PathCombine(instanceRoot, "patches"); - if(!FS::ensureFolderPathExists(patchDir)) - { + if (!FS::ensureFolderPathExists(patchDir)) { return false; } auto patchFileName = FS::PathCombine(patchDir, target_id + ".json"); @@ -468,38 +458,24 @@ bool PackInstallTask::createLibrariesComponent(QString instanceRoot, std::shared f->name = m_pack_name + " " + m_version_name + " (libraries)"; const static QMap<QString, QString> liteLoaderMap = { - { "61179803bcd5fb7790789b790908663d", "1.12-SNAPSHOT" }, - { "1420785ecbfed5aff4a586c5c9dd97eb", "1.12.2-SNAPSHOT" }, - { "073f68e2fcb518b91fd0d99462441714", "1.6.2_03" }, - { "10a15b52fc59b1bfb9c05b56de1097d6", "1.6.2_02" }, - { "b52f90f08303edd3d4c374e268a5acf1", "1.6.2_04" }, - { "ea747e24e03e24b7cad5bc8a246e0319", "1.6.2_01" }, - { "55785ccc82c07ff0ba038fe24be63ea2", "1.7.10_01" }, - { "63ada46e033d0cb6782bada09ad5ca4e", "1.7.10_04" }, - { "7983e4b28217c9ae8569074388409c86", "1.7.10_03" }, - { "c09882458d74fe0697c7681b8993097e", "1.7.10_02" }, - { "db7235aefd407ac1fde09a7baba50839", "1.7.10_00" }, - { "6e9028816027f53957bd8fcdfabae064", "1.8" }, - { "5e732dc446f9fe2abe5f9decaec40cde", "1.10-SNAPSHOT" }, - { "3a98b5ed95810bf164e71c1a53be568d", "1.11.2-SNAPSHOT" }, - { "ba8e6285966d7d988a96496f48cbddaa", "1.8.9-SNAPSHOT" }, - { "8524af3ac3325a82444cc75ae6e9112f", "1.11-SNAPSHOT" }, - { "53639d52340479ccf206a04f5e16606f", "1.5.2_01" }, - { "1fcdcf66ce0a0806b7ad8686afdce3f7", "1.6.4_00" }, - { "531c116f71ae2b11033f9a11a0f8e668", "1.6.4_01" }, - { "4009eeb99c9068f608d3483a6439af88", "1.7.2_03" }, - { "66f343354b8417abce1a10d557d2c6e9", "1.7.2_04" }, - { "ab554c21f28fbc4ae9b098bcb5f4cceb", "1.7.2_05" }, - { "e1d76a05a3723920e2f80a5e66c45f16", "1.7.2_02" }, - { "00318cb0c787934d523f63cdfe8ddde4", "1.9-SNAPSHOT" }, - { "986fd1ee9525cb0dcab7609401cef754", "1.9.4-SNAPSHOT" }, - { "571ad5e6edd5ff40259570c9be588bb5", "1.9.4" }, - { "1cdd72f7232e45551f16cc8ffd27ccf3", "1.10.2-SNAPSHOT" }, - { "8a7c21f32d77ee08b393dd3921ced8eb", "1.10.2" }, - { "b9bef8abc8dc309069aeba6fbbe58980", "1.12.1-SNAPSHOT" } + { "61179803bcd5fb7790789b790908663d", "1.12-SNAPSHOT" }, { "1420785ecbfed5aff4a586c5c9dd97eb", "1.12.2-SNAPSHOT" }, + { "073f68e2fcb518b91fd0d99462441714", "1.6.2_03" }, { "10a15b52fc59b1bfb9c05b56de1097d6", "1.6.2_02" }, + { "b52f90f08303edd3d4c374e268a5acf1", "1.6.2_04" }, { "ea747e24e03e24b7cad5bc8a246e0319", "1.6.2_01" }, + { "55785ccc82c07ff0ba038fe24be63ea2", "1.7.10_01" }, { "63ada46e033d0cb6782bada09ad5ca4e", "1.7.10_04" }, + { "7983e4b28217c9ae8569074388409c86", "1.7.10_03" }, { "c09882458d74fe0697c7681b8993097e", "1.7.10_02" }, + { "db7235aefd407ac1fde09a7baba50839", "1.7.10_00" }, { "6e9028816027f53957bd8fcdfabae064", "1.8" }, + { "5e732dc446f9fe2abe5f9decaec40cde", "1.10-SNAPSHOT" }, { "3a98b5ed95810bf164e71c1a53be568d", "1.11.2-SNAPSHOT" }, + { "ba8e6285966d7d988a96496f48cbddaa", "1.8.9-SNAPSHOT" }, { "8524af3ac3325a82444cc75ae6e9112f", "1.11-SNAPSHOT" }, + { "53639d52340479ccf206a04f5e16606f", "1.5.2_01" }, { "1fcdcf66ce0a0806b7ad8686afdce3f7", "1.6.4_00" }, + { "531c116f71ae2b11033f9a11a0f8e668", "1.6.4_01" }, { "4009eeb99c9068f608d3483a6439af88", "1.7.2_03" }, + { "66f343354b8417abce1a10d557d2c6e9", "1.7.2_04" }, { "ab554c21f28fbc4ae9b098bcb5f4cceb", "1.7.2_05" }, + { "e1d76a05a3723920e2f80a5e66c45f16", "1.7.2_02" }, { "00318cb0c787934d523f63cdfe8ddde4", "1.9-SNAPSHOT" }, + { "986fd1ee9525cb0dcab7609401cef754", "1.9.4-SNAPSHOT" }, { "571ad5e6edd5ff40259570c9be588bb5", "1.9.4" }, + { "1cdd72f7232e45551f16cc8ffd27ccf3", "1.10.2-SNAPSHOT" }, { "8a7c21f32d77ee08b393dd3921ced8eb", "1.10.2" }, + { "b9bef8abc8dc309069aeba6fbbe58980", "1.12.1-SNAPSHOT" } }; - for(const auto & lib : m_version.libraries) { + for (const auto& lib : m_version.libraries) { // If the library is LiteLoader, we need to ignore it and handle it separately. if (liteLoaderMap.contains(lib.md5)) { auto ver = getComponentVersion("com.mumfrey.liteloader", liteLoaderMap.value(lib.md5)); @@ -513,18 +489,19 @@ bool PackInstallTask::createLibrariesComponent(QString instanceRoot, std::shared GradleSpecifier libSpecifier(libName); bool libExempt = false; - for(const auto & existingLib : exempt) { - if(libSpecifier.matchName(existingLib)) { + for (con |
