diff options
Diffstat (limited to 'launcher/minecraft/PackProfile.cpp')
-rw-r--r-- | launcher/minecraft/PackProfile.cpp | 53 |
1 files changed, 34 insertions, 19 deletions
diff --git a/launcher/minecraft/PackProfile.cpp b/launcher/minecraft/PackProfile.cpp index 82fc779e..9e42c5dd 100644 --- a/launcher/minecraft/PackProfile.cpp +++ b/launcher/minecraft/PackProfile.cpp @@ -58,14 +58,14 @@ #include "ComponentUpdateTask.h" #include "PackProfile.h" #include "PackProfile_p.h" +#include "minecraft/mod/Mod.h" +#include "modplatform/ModIndex.h" -#include "Application.h" -#include "modplatform/ResourceAPI.h" - -static const QMap<QString, ResourceAPI::ModLoaderType> modloaderMapping{ { "net.minecraftforge", ResourceAPI::Forge }, - { "net.fabricmc.fabric-loader", ResourceAPI::Fabric }, - { "org.quiltmc.quilt-loader", ResourceAPI::Quilt }, - { "com.mumfrey.liteloader", ResourceAPI::LiteLoader } }; +static const QMap<QString, ModPlatform::ModLoaderType> modloaderMapping{ { "net.neoforged", ModPlatform::NeoForge }, + { "net.minecraftforge", ModPlatform::Forge }, + { "net.fabricmc.fabric-loader", ModPlatform::Fabric }, + { "org.quiltmc.quilt-loader", ModPlatform::Quilt }, + { "com.mumfrey.liteloader", ModPlatform::LiteLoader } }; PackProfile::PackProfile(MinecraftInstance* instance) : QAbstractListModel() { @@ -204,10 +204,10 @@ static bool loadPackProfile(PackProfile* parent, } auto orderArray = Json::requireArray(obj.value("components")); for (auto item : orderArray) { - auto obj = Json::requireObject(item, "Component must be an object."); - container.append(componentFromJsonV1(parent, componentJsonPattern, obj)); + auto comp_obj = Json::requireObject(item, "Component must be an object."); + container.append(componentFromJsonV1(parent, componentJsonPattern, comp_obj)); } - } catch (const JSONValidationError& err) { + } catch ([[maybe_unused]] const JSONValidationError& err) { qCritical() << "Couldn't parse" << componentsFile.fileName() << ": bad file format"; container.clear(); return false; @@ -377,7 +377,7 @@ void PackProfile::insertComponent(size_t index, ComponentPtr component) qWarning() << "Attempt to add a component that is already present!"; return; } - beginInsertRows(QModelIndex(), index, index); + beginInsertRows(QModelIndex(), static_cast<int>(index), static_cast<int>(index)); d->components.insert(index, component); d->componentIndex[id] = component; endInsertRows(); @@ -389,7 +389,7 @@ void PackProfile::componentDataChanged() { auto objPtr = qobject_cast<Component*>(sender()); if (!objPtr) { - qWarning() << "PackProfile got dataChenged signal from a non-Component!"; + qWarning() << "PackProfile got dataChanged signal from a non-Component!"; return; } if (objPtr->getID() == "net.minecraft") { @@ -405,7 +405,7 @@ void PackProfile::componentDataChanged() } index++; } - qWarning() << "PackProfile got dataChenged signal from a Component which does not belong to it!"; + qWarning() << "PackProfile got dataChanged signal from a Component which does not belong to it!"; } bool PackProfile::remove(const int index) @@ -483,9 +483,9 @@ ComponentPtr PackProfile::getComponent(const QString& id) return (*iter); } -ComponentPtr PackProfile::getComponent(int index) +ComponentPtr PackProfile::getComponent(size_t index) { - if (index < 0 || index >= d->components.size()) { + if (index >= static_cast<size_t>(d->components.size())) { return nullptr; } return d->components[index]; @@ -547,7 +547,7 @@ QVariant PackProfile::data(const QModelIndex& index, int role) const return QVariant(); } -bool PackProfile::setData(const QModelIndex& index, const QVariant& value, int role) +bool PackProfile::setData(const QModelIndex& index, [[maybe_unused]] const QVariant& value, int role) { if (!index.isValid() || index.row() < 0 || index.row() >= rowCount(index.parent())) { return false; @@ -989,12 +989,12 @@ void PackProfile::disableInteraction(bool disable) } } -std::optional<ResourceAPI::ModLoaderTypes> PackProfile::getModLoaders() +std::optional<ModPlatform::ModLoaderTypes> PackProfile::getModLoaders() { - ResourceAPI::ModLoaderTypes result; + ModPlatform::ModLoaderTypes result; bool has_any_loader = false; - QMapIterator<QString, ResourceAPI::ModLoaderType> i(modloaderMapping); + QMapIterator<QString, ModPlatform::ModLoaderType> i(modloaderMapping); while (i.hasNext()) { i.next(); @@ -1008,3 +1008,18 @@ std::optional<ResourceAPI::ModLoaderTypes> PackProfile::getModLoaders() return {}; return result; } + +std::optional<ModPlatform::ModLoaderTypes> PackProfile::getSupportedModLoaders() +{ + auto loadersOpt = getModLoaders(); + if (!loadersOpt.has_value()) + return loadersOpt; + auto loaders = loadersOpt.value(); + // TODO: remove this or add version condition once Quilt drops official Fabric support + if (loaders & ModPlatform::Quilt) + loaders |= ModPlatform::Fabric; + // TODO: remove this or add version condition once NeoForge drops official Forge support + if (loaders & ModPlatform::NeoForge) + loaders |= ModPlatform::Forge; + return loaders; +} |