From 9eb9ddc6680244f2c10fa3ac50fbbeffefd2db29 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Sun, 20 Feb 2022 17:51:26 +0100 Subject: [PATCH 1/8] feat: initial Quilt support --- launcher/minecraft/ComponentUpdateTask.cpp | 9 +++++++ launcher/ui/pages/instance/VersionPage.cpp | 30 ++++++++++++++++++++++ launcher/ui/pages/instance/VersionPage.h | 1 + launcher/ui/pages/instance/VersionPage.ui | 9 +++++++ 4 files changed, 49 insertions(+) diff --git a/launcher/minecraft/ComponentUpdateTask.cpp b/launcher/minecraft/ComponentUpdateTask.cpp index 8bc05a1b..a856662a 100644 --- a/launcher/minecraft/ComponentUpdateTask.cpp +++ b/launcher/minecraft/ComponentUpdateTask.cpp @@ -600,6 +600,15 @@ void ComponentUpdateTask::resolveDependencies(bool checkOnly) component->m_version = (*minecraft)->getVersion(); } } + else if (add.uid == "org.quiltmc.quilt-mappings") + { + auto minecraft = std::find_if(components.begin(), components.end(), [](ComponentPtr & cmp){ + return cmp->getID() == "net.minecraft"; + }); + if(minecraft != components.end()) { + component->m_version = (*minecraft)->getVersion() + "+build.1"; + } + } } // HACK HACK HACK HACK FIXME: this is a placeholder for deciding what version to use. For now, it is hardcoded. // ############################################################################################################ diff --git a/launcher/ui/pages/instance/VersionPage.cpp b/launcher/ui/pages/instance/VersionPage.cpp index ed37dd1a..c8857017 100644 --- a/launcher/ui/pages/instance/VersionPage.cpp +++ b/launcher/ui/pages/instance/VersionPage.cpp @@ -243,6 +243,9 @@ void VersionPage::updateVersionControls() bool supportsFabric = minecraftVersion >= Version("1.14"); ui->actionInstall_Fabric->setEnabled(controlsEnabled && supportsFabric); + bool supportsQuilt = minecraftVersion >= Version("1.17.1"); + ui->actionInstall_Quilt->setEnabled(controlsEnabled && supportsQuilt); + bool supportsLiteLoader = minecraftVersion <= Version("1.12.2"); ui->actionInstall_LiteLoader->setEnabled(controlsEnabled && supportsLiteLoader); @@ -498,6 +501,33 @@ void VersionPage::on_actionInstall_Fabric_triggered() } } +void VersionPage::on_actionInstall_Quilt_triggered() +{ + auto vlist = APPLICATION->metadataIndex()->get("org.quiltmc.quilt-loader"); + if(!vlist) + { + return; + } + VersionSelectDialog vselect(vlist.get(), tr("Select Quilt Loader version"), this); + vselect.setEmptyString(tr("No Quilt Loader versions are currently available.")); + vselect.setEmptyErrorString(tr("Couldn't load or download the Quilt Loader version lists!")); + + auto currentVersion = m_profile->getComponentVersion("org.quiltmc.quilt-loader"); + if(!currentVersion.isEmpty()) + { + vselect.setCurrentVersion(currentVersion); + } + + if (vselect.exec() && vselect.selectedVersion()) + { + auto vsn = vselect.selectedVersion(); + m_profile->setComponentVersion("org.quiltmc.quilt-loader", vsn->descriptor()); + m_profile->resolve(Net::Mode::Online); + preselect(m_profile->rowCount(QModelIndex())-1); + m_container->refreshContainer(); + } +} + void VersionPage::on_actionAdd_Empty_triggered() { NewComponentDialog compdialog(QString(), QString(), this); diff --git a/launcher/ui/pages/instance/VersionPage.h b/launcher/ui/pages/instance/VersionPage.h index 2d37af43..979311fc 100644 --- a/launcher/ui/pages/instance/VersionPage.h +++ b/launcher/ui/pages/instance/VersionPage.h @@ -73,6 +73,7 @@ private slots: void on_actionChange_version_triggered(); void on_actionInstall_Forge_triggered(); void on_actionInstall_Fabric_triggered(); + void on_actionInstall_Quilt_triggered(); void on_actionAdd_Empty_triggered(); void on_actionInstall_LiteLoader_triggered(); void on_actionReload_triggered(); diff --git a/launcher/ui/pages/instance/VersionPage.ui b/launcher/ui/pages/instance/VersionPage.ui index a4990ff3..489f7218 100644 --- a/launcher/ui/pages/instance/VersionPage.ui +++ b/launcher/ui/pages/instance/VersionPage.ui @@ -107,6 +107,7 @@ + @@ -192,6 +193,14 @@ Install the Fabric Loader package. + + + Install Quilt + + + Install the Quilt Loader package. + + Install LiteLoader From 9349232bd4e6879ab11a3e8aaf5b3e056fdca2d9 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Sun, 20 Feb 2022 20:22:12 +0100 Subject: [PATCH 2/8] refactor: dynamically get best version for intermediary mappings --- launcher/minecraft/ComponentUpdateTask.cpp | 51 +++++++++++++--------- launcher/minecraft/ComponentUpdateTask.h | 2 + 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/launcher/minecraft/ComponentUpdateTask.cpp b/launcher/minecraft/ComponentUpdateTask.cpp index a856662a..a0559232 100644 --- a/launcher/minecraft/ComponentUpdateTask.cpp +++ b/launcher/minecraft/ComponentUpdateTask.cpp @@ -2,7 +2,6 @@ #include "PackProfile_p.h" #include "PackProfile.h" -#include "Component.h" #include "meta/Index.h" #include "meta/VersionList.h" #include "meta/Version.h" @@ -495,6 +494,31 @@ static bool getTrivialComponentChanges(const ComponentIndex & index, const Requi return succeeded; } +QString ComponentUpdateTask::findBestComponentVersion(const ComponentPtr component) +{ + auto & components = d->m_list->d->components; + auto versions = component->getVersionList(); + versions->load(d->netmode); + + for (auto & version : versions->versions()) { + if (version->isRecommended()) { // only look at recommended versions + bool requirementsMet = true; + for (auto req : version->requires()) { + auto requirementMet = std::any_of(components.begin(), components.end(), [&req](ComponentPtr & cmp){ + return cmp->getID() == req.uid && cmp->getVersion() == req.equalsVersion; + }); + if (!requirementMet) { + requirementsMet = false; + } + } + + if (requirementsMet) // return first recommended version that meets all requirements + return version->version(); + } + } + return nullptr; +} + // FIXME, TODO: decouple dependency resolution from loading // FIXME: This works directly with the PackProfile internals. It shouldn't! It needs richer data types than PackProfile uses. // FIXME: throw all this away and use a graph @@ -591,27 +615,14 @@ void ComponentUpdateTask::resolveDependencies(bool checkOnly) { component->m_version = "3.1.2"; } - else if (add.uid == "net.fabricmc.intermediary") - { - auto minecraft = std::find_if(components.begin(), components.end(), [](ComponentPtr & cmp){ - return cmp->getID() == "net.minecraft"; - }); - if(minecraft != components.end()) { - component->m_version = (*minecraft)->getVersion(); - } - } - else if (add.uid == "org.quiltmc.quilt-mappings") - { - auto minecraft = std::find_if(components.begin(), components.end(), [](ComponentPtr & cmp){ - return cmp->getID() == "net.minecraft"; - }); - if(minecraft != components.end()) { - component->m_version = (*minecraft)->getVersion() + "+build.1"; - } - } - } // HACK HACK HACK HACK FIXME: this is a placeholder for deciding what version to use. For now, it is hardcoded. // ############################################################################################################ +// below is not ugly anymore + else if (add.uid == "net.fabricmc.intermediary" || add.uid == "org.quiltmc.quilt-mappings") + { + component->m_version = findBestComponentVersion(component); + } + } } component->m_dependencyOnly = true; // FIXME: this should not work directly with the component list diff --git a/launcher/minecraft/ComponentUpdateTask.h b/launcher/minecraft/ComponentUpdateTask.h index 4274cabb..4fcbbca8 100644 --- a/launcher/minecraft/ComponentUpdateTask.h +++ b/launcher/minecraft/ComponentUpdateTask.h @@ -2,6 +2,7 @@ #include "tasks/Task.h" #include "net/Mode.h" +#include "Component.h" #include class PackProfile; @@ -26,6 +27,7 @@ protected: private: void loadComponents(); + QString findBestComponentVersion(ComponentPtr component); void resolveDependencies(bool checkOnly); void remoteLoadSucceeded(size_t index); From 74cdf5350de1649955814d6bcd596d8abfe9c5e2 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Sun, 20 Feb 2022 20:33:13 +0100 Subject: [PATCH 3/8] fix: restrict quilt-mappings versions to MC version --- launcher/ui/pages/instance/VersionPage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/ui/pages/instance/VersionPage.cpp b/launcher/ui/pages/instance/VersionPage.cpp index c8857017..6b9c82a2 100644 --- a/launcher/ui/pages/instance/VersionPage.cpp +++ b/launcher/ui/pages/instance/VersionPage.cpp @@ -395,7 +395,7 @@ void VersionPage::on_actionChange_version_triggered() return; } VersionSelectDialog vselect(list.get(), tr("Change %1 version").arg(name), this); - if (uid == "net.fabricmc.intermediary") + if (uid == "net.fabricmc.intermediary" || uid == "org.quiltmc.quilt-mappings") { vselect.setEmptyString(tr("No intermediary mappings versions are currently available.")); vselect.setEmptyErrorString(tr("Couldn't load or download the intermediary mappings version lists!")); From 35cfb41a9c8cf1328f3d2d14022cf51cbfc67f1f Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Sun, 20 Feb 2022 20:55:26 +0100 Subject: [PATCH 4/8] fix: check for Quilt as Fabric-compatible loader --- launcher/InstanceImportTask.cpp | 1 + launcher/minecraft/PackProfile.cpp | 17 +++++++++++++++++ launcher/minecraft/PackProfile.h | 3 +++ launcher/minecraft/mod/LocalModParseTask.cpp | 2 +- launcher/modplatform/ModAPI.h | 2 +- launcher/modplatform/flame/FlameModIndex.cpp | 1 + launcher/modplatform/modrinth/ModrinthAPI.h | 6 ++++-- launcher/ui/pages/instance/ModFolderPage.cpp | 8 +++++--- launcher/ui/pages/modplatform/ModModel.cpp | 15 ++++++--------- launcher/ui/pages/modplatform/ModModel.h | 1 - launcher/ui/pages/modplatform/ModPage.cpp | 16 +++++++++++++++- 11 files changed, 54 insertions(+), 18 deletions(-) diff --git a/launcher/InstanceImportTask.cpp b/launcher/InstanceImportTask.cpp index a825e8d4..eeca29c6 100644 --- a/launcher/InstanceImportTask.cpp +++ b/launcher/InstanceImportTask.cpp @@ -241,6 +241,7 @@ void InstanceImportTask::processFlame() QString forgeVersion; QString fabricVersion; + // TODO: is Quilt relevant here? for(auto &loader: pack.minecraft.modLoaders) { auto id = loader.id; diff --git a/launcher/minecraft/PackProfile.cpp b/launcher/minecraft/PackProfile.cpp index d516e555..9889727e 100644 --- a/launcher/minecraft/PackProfile.cpp +++ b/launcher/minecraft/PackProfile.cpp @@ -970,3 +970,20 @@ void PackProfile::disableInteraction(bool disable) } } } + +ModAPI::ModLoaderType PackProfile::getModLoader() +{ + if (!getComponentVersion("net.minecraftforge").isEmpty()) + { + return ModAPI::Forge; + } + else if (!getComponentVersion("net.fabricmc.fabric-loader").isEmpty()) + { + return ModAPI::Fabric; + } + else if (!getComponentVersion("org.quiltmc.quilt-loader").isEmpty()) + { + return ModAPI::Quilt; + } + return ModAPI::Any; +} diff --git a/launcher/minecraft/PackProfile.h b/launcher/minecraft/PackProfile.h index 989d1c6a..ab4cd5c8 100644 --- a/launcher/minecraft/PackProfile.h +++ b/launcher/minecraft/PackProfile.h @@ -28,6 +28,7 @@ #include "BaseVersion.h" #include "MojangDownloadInfo.h" #include "net/Mode.h" +#include "modplatform/ModAPI.h" class MinecraftInstance; struct PackProfileData; @@ -117,6 +118,8 @@ public: // todo(merged): is this the best approach void appendComponent(ComponentPtr component); + ModAPI::ModLoaderType getModLoader(); + private: void scheduleSave(); bool saveIsScheduled() const; diff --git a/launcher/minecraft/mod/LocalModParseTask.cpp b/launcher/minecraft/mod/LocalModParseTask.cpp index 757a2187..f01da8ae 100644 --- a/launcher/minecraft/mod/LocalModParseTask.cpp +++ b/launcher/minecraft/mod/LocalModParseTask.cpp @@ -391,7 +391,7 @@ void LocalModParseTask::processAsZip() zip.close(); return; } - else if (zip.setCurrentFile("fabric.mod.json")) + else if (zip.setCurrentFile("fabric.mod.json")) // TODO: Support quilt.mod.json { if (!file.open(QIODevice::ReadOnly)) { diff --git a/launcher/modplatform/ModAPI.h b/launcher/modplatform/ModAPI.h index ae6ac80f..1e38cf62 100644 --- a/launcher/modplatform/ModAPI.h +++ b/launcher/modplatform/ModAPI.h @@ -15,7 +15,7 @@ class ModAPI { virtual ~ModAPI() = default; // https://docs.curseforge.com/?http#tocS_ModLoaderType - enum ModLoaderType { Any = 0, Forge = 1, Cauldron = 2, LiteLoader = 3, Fabric = 4 }; + enum ModLoaderType { Any = 0, Forge = 1, Cauldron = 2, LiteLoader = 3, Fabric = 4, Quilt = 5 }; struct SearchArgs { int offset; diff --git a/launcher/modplatform/flame/FlameModIndex.cpp b/launcher/modplatform/flame/FlameModIndex.cpp index 2c3adee4..e86b64dd 100644 --- a/launcher/modplatform/flame/FlameModIndex.cpp +++ b/launcher/modplatform/flame/FlameModIndex.cpp @@ -69,6 +69,7 @@ void FlameMod::loadIndexedPackVersions(ModPlatform::IndexedPack& pack, for (auto m : modules) { auto fname = Json::requireString(m.toObject(), "foldername"); // FIXME: This does not work properly when a mod supports more than one mod loader, since + // FIXME: This also doesn't deal with Quilt mods at the moment // they bundle the meta files for all of them in the same arquive, even when that version // doesn't support the given mod loader. if (hasFabric) { diff --git a/launcher/modplatform/modrinth/ModrinthAPI.h b/launcher/modplatform/modrinth/ModrinthAPI.h index 30952e99..711649d9 100644 --- a/launcher/modplatform/modrinth/ModrinthAPI.h +++ b/launcher/modplatform/modrinth/ModrinthAPI.h @@ -55,11 +55,13 @@ class ModrinthAPI : public NetworkModAPI { { switch (modLoader) { case Any: - return "fabric, forge"; + return "fabric, forge, quilt"; case Forge: return "forge"; case Fabric: return "fabric"; + case Quilt: + return "quilt"; default: return ""; } @@ -67,7 +69,7 @@ class ModrinthAPI : public NetworkModAPI { inline auto validateModLoader(ModLoaderType modLoader) const -> bool { - return modLoader == Any || modLoader == Forge || modLoader == Fabric; + return modLoader == Any || modLoader == Forge || modLoader == Fabric || modLoader == Quilt; } }; diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp index fcb6022d..6acf94c7 100644 --- a/launcher/ui/pages/instance/ModFolderPage.cpp +++ b/launcher/ui/pages/instance/ModFolderPage.cpp @@ -56,6 +56,8 @@ #include "minecraft/VersionFilterData.h" #include "minecraft/PackProfile.h" +#include "modplatform/ModAPI.h" + #include "Version.h" #include "ui/dialogs/ProgressDialog.h" #include "tasks/SequentialTask.h" @@ -388,9 +390,9 @@ void ModFolderPage::on_actionInstall_mods_triggered() if(m_inst->typeName() != "Minecraft"){ return; //this is a null instance or a legacy instance } - bool hasFabric = !((MinecraftInstance *)m_inst)->getPackProfile()->getComponentVersion("net.fabricmc.fabric-loader").isEmpty(); - bool hasForge = !((MinecraftInstance *)m_inst)->getPackProfile()->getComponentVersion("net.minecraftforge").isEmpty(); - if (!hasFabric && !hasForge) { + QStringList modLoaders = {"net.minecraftforge", "net.fabricmc.fabric-loader", "org.quiltmc.quilt-loader"}; + auto profile = ((MinecraftInstance *)m_inst)->getPackProfile(); + if (profile->getModLoader() == ModAPI::Any) { QMessageBox::critical(this,tr("Error"),tr("Please install a mod loader first!")); return; } diff --git a/launcher/ui/pages/modplatform/ModModel.cpp b/launcher/ui/pages/modplatform/ModModel.cpp index 01b5d247..f75d2847 100644 --- a/launcher/ui/pages/modplatform/ModModel.cpp +++ b/launcher/ui/pages/modplatform/ModModel.cpp @@ -61,14 +61,18 @@ auto ListModel::data(const QModelIndex& index, int role) const -> QVariant void ListModel::requestModVersions(ModPlatform::IndexedPack const& current) { + auto profile = (dynamic_cast((dynamic_cast(parent()))->m_instance))->getPackProfile(); + m_parent->apiProvider()->getVersions(this, - { current.addonId.toString(), getMineVersions(), hasFabric() ? ModAPI::ModLoaderType::Fabric : ModAPI::ModLoaderType::Forge }); + { current.addonId.toString(), getMineVersions(), profile->getModLoader() }); } void ListModel::performPaginatedSearch() { + auto profile = (dynamic_cast((dynamic_cast(parent()))->m_instance))->getPackProfile(); + m_parent->apiProvider()->searchMods(this, - { nextSearchOffset, currentSearchTerm, getSorts()[currentSort], hasFabric() ? ModAPI::Fabric : ModAPI::Forge, getMineVersions().at(0) }); + { nextSearchOffset, currentSearchTerm, getSorts()[currentSort], profile->getModLoader(), getMineVersions().at(0) }); } void ListModel::searchWithTerm(const QString& term, const int sort) @@ -218,13 +222,6 @@ void ListModel::versionRequestSucceeded(QJsonDocument doc, QString addonId) } // namespace ModPlatform /******** Helpers ********/ -auto ModPlatform::ListModel::hasFabric() const -> bool -{ - return !(dynamic_cast((dynamic_cast(parent()))->m_instance)) - ->getPackProfile() - ->getComponentVersion("net.fabricmc.fabric-loader") - .isEmpty(); -} auto ModPlatform::ListModel::getMineVersions() const -> QList { diff --git a/launcher/ui/pages/modplatform/ModModel.h b/launcher/ui/pages/modplatform/ModModel.h index 64cfa71e..dbadbeee 100644 --- a/launcher/ui/pages/modplatform/ModModel.h +++ b/launcher/ui/pages/modplatform/ModModel.h @@ -62,7 +62,6 @@ class ListModel : public QAbstractListModel { void requestLogo(QString file, QString url); - inline auto hasFabric() const -> bool; inline auto getMineVersions() const -> QList; protected: diff --git a/launcher/ui/pages/modplatform/ModPage.cpp b/launcher/ui/pages/modplatform/ModPage.cpp index 3a116d3c..95e385cc 100644 --- a/launcher/ui/pages/modplatform/ModPage.cpp +++ b/launcher/ui/pages/modplatform/ModPage.cpp @@ -136,7 +136,21 @@ void ModPage::updateModVersions() auto packProfile = (dynamic_cast(m_instance))->getPackProfile(); QString mcVersion = packProfile->getComponentVersion("net.minecraft"); - QString loaderString = (packProfile->getComponentVersion("net.minecraftforge").isEmpty()) ? "fabric" : "forge"; + + QString loaderString; + switch (packProfile->getModLoader()) { + case ModAPI::Forge: + loaderString = "forge"; + break; + case ModAPI::Fabric: + loaderString = "fabric"; + break; + case ModAPI::Quilt: + loaderString = "quilt"; + break; + default: + break; + } for (int i = 0; i < current.versions.size(); i++) { auto version = current.versions[i]; From 89125fde22d39aed93ab516956b3a4e30cca7a88 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Sat, 9 Apr 2022 14:56:07 +0200 Subject: [PATCH 5/8] refactor: switch Quilt mappings to hashed MojMap --- launcher/minecraft/ComponentUpdateTask.cpp | 39 +++++----------------- launcher/ui/pages/instance/VersionPage.cpp | 2 +- 2 files changed, 10 insertions(+), 31 deletions(-) diff --git a/launcher/minecraft/ComponentUpdateTask.cpp b/launcher/minecraft/ComponentUpdateTask.cpp index a0559232..0095c613 100644 --- a/launcher/minecraft/ComponentUpdateTask.cpp +++ b/launcher/minecraft/ComponentUpdateTask.cpp @@ -494,31 +494,6 @@ static bool getTrivialComponentChanges(const ComponentIndex & index, const Requi return succeeded; } -QString ComponentUpdateTask::findBestComponentVersion(const ComponentPtr component) -{ - auto & components = d->m_list->d->components; - auto versions = component->getVersionList(); - versions->load(d->netmode); - - for (auto & version : versions->versions()) { - if (version->isRecommended()) { // only look at recommended versions - bool requirementsMet = true; - for (auto req : version->requires()) { - auto requirementMet = std::any_of(components.begin(), components.end(), [&req](ComponentPtr & cmp){ - return cmp->getID() == req.uid && cmp->getVersion() == req.equalsVersion; - }); - if (!requirementMet) { - requirementsMet = false; - } - } - - if (requirementsMet) // return first recommended version that meets all requirements - return version->version(); - } - } - return nullptr; -} - // FIXME, TODO: decouple dependency resolution from loading // FIXME: This works directly with the PackProfile internals. It shouldn't! It needs richer data types than PackProfile uses. // FIXME: throw all this away and use a graph @@ -615,13 +590,17 @@ void ComponentUpdateTask::resolveDependencies(bool checkOnly) { component->m_version = "3.1.2"; } + else if (add.uid == "net.fabricmc.intermediary" || add.uid == "org.quiltmc.hashed") + { + auto minecraft = std::find_if(components.begin(), components.end(), [](ComponentPtr & cmp){ + return cmp->getID() == "net.minecraft"; + }); + if(minecraft != components.end()) { + component->m_version = (*minecraft)->getVersion(); + } + } // HACK HACK HACK HACK FIXME: this is a placeholder for deciding what version to use. For now, it is hardcoded. // ############################################################################################################ -// below is not ugly anymore - else if (add.uid == "net.fabricmc.intermediary" || add.uid == "org.quiltmc.quilt-mappings") - { - component->m_version = findBestComponentVersion(component); - } } } component->m_dependencyOnly = true; diff --git a/launcher/ui/pages/instance/VersionPage.cpp b/launcher/ui/pages/instance/VersionPage.cpp index 6b9c82a2..7264f362 100644 --- a/launcher/ui/pages/instance/VersionPage.cpp +++ b/launcher/ui/pages/instance/VersionPage.cpp @@ -395,7 +395,7 @@ void VersionPage::on_actionChange_version_triggered() return; } VersionSelectDialog vselect(list.get(), tr("Change %1 version").arg(name), this); - if (uid == "net.fabricmc.intermediary" || uid == "org.quiltmc.quilt-mappings") + if (uid == "net.fabricmc.intermediary" || uid == "org.quiltmc.hashed") { vselect.setEmptyString(tr("No intermediary mappings versions are currently available.")); vselect.setEmptyErrorString(tr("Couldn't load or download the intermediary mappings version lists!")); From 14a0e8586222dcb2fa4af9b89c49276aaea84347 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Thu, 14 Apr 2022 16:50:04 +0200 Subject: [PATCH 6/8] fix: remove unused code --- launcher/minecraft/ComponentUpdateTask.cpp | 3 ++- launcher/minecraft/ComponentUpdateTask.h | 2 -- launcher/ui/pages/instance/ModFolderPage.cpp | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/launcher/minecraft/ComponentUpdateTask.cpp b/launcher/minecraft/ComponentUpdateTask.cpp index 0095c613..ff7ed0af 100644 --- a/launcher/minecraft/ComponentUpdateTask.cpp +++ b/launcher/minecraft/ComponentUpdateTask.cpp @@ -2,6 +2,7 @@ #include "PackProfile_p.h" #include "PackProfile.h" +#include "Component.h" #include "meta/Index.h" #include "meta/VersionList.h" #include "meta/Version.h" @@ -599,9 +600,9 @@ void ComponentUpdateTask::resolveDependencies(bool checkOnly) component->m_version = (*minecraft)->getVersion(); } } + } // HACK HACK HACK HACK FIXME: this is a placeholder for deciding what version to use. For now, it is hardcoded. // ############################################################################################################ - } } component->m_dependencyOnly = true; // FIXME: this should not work directly with the component list diff --git a/launcher/minecraft/ComponentUpdateTask.h b/launcher/minecraft/ComponentUpdateTask.h index 4fcbbca8..4274cabb 100644 --- a/launcher/minecraft/ComponentUpdateTask.h +++ b/launcher/minecraft/ComponentUpdateTask.h @@ -2,7 +2,6 @@ #include "tasks/Task.h" #include "net/Mode.h" -#include "Component.h" #include class PackProfile; @@ -27,7 +26,6 @@ protected: private: void loadComponents(); - QString findBestComponentVersion(ComponentPtr component); void resolveDependencies(bool checkOnly); void remoteLoadSucceeded(size_t index); diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp index 6acf94c7..46235462 100644 --- a/launcher/ui/pages/instance/ModFolderPage.cpp +++ b/launcher/ui/pages/instance/ModFolderPage.cpp @@ -390,7 +390,6 @@ void ModFolderPage::on_actionInstall_mods_triggered() if(m_inst->typeName() != "Minecraft"){ return; //this is a null instance or a legacy instance } - QStringList modLoaders = {"net.minecraftforge", "net.fabricmc.fabric-loader", "org.quiltmc.quilt-loader"}; auto profile = ((MinecraftInstance *)m_inst)->getPackProfile(); if (profile->getModLoader() == ModAPI::Any) { QMessageBox::critical(this,tr("Error"),tr("Please install a mod loader first!")); From 18ac109e5abb86eebd254931efeea3630371a0bb Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Thu, 14 Apr 2022 17:20:07 +0200 Subject: [PATCH 7/8] fix: support Quilt from Minecraft 1.14 onwards --- launcher/ui/pages/instance/VersionPage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/ui/pages/instance/VersionPage.cpp b/launcher/ui/pages/instance/VersionPage.cpp index 7264f362..23e2367b 100644 --- a/launcher/ui/pages/instance/VersionPage.cpp +++ b/launcher/ui/pages/instance/VersionPage.cpp @@ -243,7 +243,7 @@ void VersionPage::updateVersionControls() bool supportsFabric = minecraftVersion >= Version("1.14"); ui->actionInstall_Fabric->setEnabled(controlsEnabled && supportsFabric); - bool supportsQuilt = minecraftVersion >= Version("1.17.1"); + bool supportsQuilt = minecraftVersion >= Version("1.14"); ui->actionInstall_Quilt->setEnabled(controlsEnabled && supportsQuilt); bool supportsLiteLoader = minecraftVersion <= Version("1.12.2"); From 9fb5674233c21775fac76cf96cd2a77c4098e908 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Thu, 14 Apr 2022 21:55:03 +0200 Subject: [PATCH 8/8] refactor: cleanup ModLoaderType --- launcher/minecraft/PackProfile.cpp | 2 +- launcher/modplatform/ModAPI.h | 20 ++++++++++++++++- launcher/modplatform/modrinth/ModrinthAPI.h | 19 +++++----------- launcher/ui/pages/instance/ModFolderPage.cpp | 2 +- launcher/ui/pages/modplatform/ModPage.cpp | 23 +++++--------------- 5 files changed, 31 insertions(+), 35 deletions(-) diff --git a/launcher/minecraft/PackProfile.cpp b/launcher/minecraft/PackProfile.cpp index 9889727e..d53f41e1 100644 --- a/launcher/minecraft/PackProfile.cpp +++ b/launcher/minecraft/PackProfile.cpp @@ -985,5 +985,5 @@ ModAPI::ModLoaderType PackProfile::getModLoader() { return ModAPI::Quilt; } - return ModAPI::Any; + return ModAPI::Unspecified; } diff --git a/launcher/modplatform/ModAPI.h b/launcher/modplatform/ModAPI.h index 1e38cf62..1a562172 100644 --- a/launcher/modplatform/ModAPI.h +++ b/launcher/modplatform/ModAPI.h @@ -15,7 +15,7 @@ class ModAPI { virtual ~ModAPI() = default; // https://docs.curseforge.com/?http#tocS_ModLoaderType - enum ModLoaderType { Any = 0, Forge = 1, Cauldron = 2, LiteLoader = 3, Fabric = 4, Quilt = 5 }; + enum ModLoaderType { Unspecified = 0, Forge = 1, Cauldron = 2, LiteLoader = 3, Fabric = 4, Quilt = 5 }; struct SearchArgs { int offset; @@ -35,4 +35,22 @@ class ModAPI { }; virtual void getVersions(CallerType* caller, VersionSearchArgs&& args) const = 0; + + static auto getModLoaderString(ModLoaderType type) -> const QString { + switch (type) { + case Unspecified: + break; + case Forge: + return "forge"; + case Cauldron: + return "cauldron"; + case LiteLoader: + return "liteloader"; + case Fabric: + return "fabric"; + case Quilt: + return "quilt"; + } + return ""; + } }; diff --git a/launcher/modplatform/modrinth/ModrinthAPI.h b/launcher/modplatform/modrinth/ModrinthAPI.h index 711649d9..eefa4a85 100644 --- a/launcher/modplatform/modrinth/ModrinthAPI.h +++ b/launcher/modplatform/modrinth/ModrinthAPI.h @@ -51,25 +51,16 @@ class ModrinthAPI : public NetworkModAPI { return s; } - inline auto getModLoaderString(ModLoaderType modLoader) const -> QString + static auto getModLoaderString(ModLoaderType type) -> const QString { - switch (modLoader) { - case Any: - return "fabric, forge, quilt"; - case Forge: - return "forge"; - case Fabric: - return "fabric"; - case Quilt: - return "quilt"; - default: - return ""; - } + if (type == Unspecified) + return "fabric, forge, quilt"; + return ModAPI::getModLoaderString(type); } inline auto validateModLoader(ModLoaderType modLoader) const -> bool { - return modLoader == Any || modLoader == Forge || modLoader == Fabric || modLoader == Quilt; + return modLoader == Unspecified || modLoader == Forge || modLoader == Fabric || modLoader == Quilt; } }; diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp index 46235462..8113fe85 100644 --- a/launcher/ui/pages/instance/ModFolderPage.cpp +++ b/launcher/ui/pages/instance/ModFolderPage.cpp @@ -391,7 +391,7 @@ void ModFolderPage::on_actionInstall_mods_triggered() return; //this is a null instance or a legacy instance } auto profile = ((MinecraftInstance *)m_inst)->getPackProfile(); - if (profile->getModLoader() == ModAPI::Any) { + if (profile->getModLoader() == ModAPI::Unspecified) { QMessageBox::critical(this,tr("Error"),tr("Please install a mod loader first!")); return; } diff --git a/launcher/ui/pages/modplatform/ModPage.cpp b/launcher/ui/pages/modplatform/ModPage.cpp index 95e385cc..eabd8379 100644 --- a/launcher/ui/pages/modplatform/ModPage.cpp +++ b/launcher/ui/pages/modplatform/ModPage.cpp @@ -68,7 +68,7 @@ void ModPage::onSelectionChanged(QModelIndex first, QModelIndex second) text = name; else text = "" + name + ""; - + if (!current.authors.empty()) { auto authorToStr = [](ModPlatform::ModpackAuthor& author) -> QString { if (author.url.isEmpty()) { return author.name; } @@ -128,7 +128,7 @@ void ModPage::onModSelected() void ModPage::retranslate() { - ui->retranslateUi(this); + ui->retranslateUi(this); } void ModPage::updateModVersions() @@ -137,26 +137,13 @@ void ModPage::updateModVersions() QString mcVersion = packProfile->getComponentVersion("net.minecraft"); - QString loaderString; - switch (packProfile->getModLoader()) { - case ModAPI::Forge: - loaderString = "forge"; - break; - case ModAPI::Fabric: - loaderString = "fabric"; - break; - case ModAPI::Quilt: - loaderString = "quilt"; - break; - default: - break; - } + QString loaderString = ModAPI::getModLoaderString(packProfile->getModLoader()); for (int i = 0; i < current.versions.size(); i++) { auto version = current.versions[i]; //NOTE: Flame doesn't care about loaderString, so passing it changes nothing. - if (!validateVersion(version, mcVersion, loaderString)) { - continue; + if (!validateVersion(version, mcVersion, loaderString)) { + continue; } ui->versionSelectionBox->addItem(version.version, QVariant(i)); }