Added loaders check on versions load
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
		| @@ -2,14 +2,14 @@ | |||||||
|  |  | ||||||
| #include "Component.h" | #include "Component.h" | ||||||
| #include "ComponentUpdateTask_p.h" | #include "ComponentUpdateTask_p.h" | ||||||
| #include "OneSixVersionFormat.h" |  | ||||||
| #include "PackProfile.h" | #include "PackProfile.h" | ||||||
| #include "PackProfile_p.h" | #include "PackProfile_p.h" | ||||||
| #include "Version.h" | #include "Version.h" | ||||||
| #include "cassert" | #include "cassert" | ||||||
| #include "meta/Index.h" | #include "meta/Index.h" | ||||||
| #include "meta/Version.h" | #include "meta/Version.h" | ||||||
| #include "meta/VersionList.h" | #include "minecraft/OneSixVersionFormat.h" | ||||||
|  | #include "minecraft/ProfileUtils.h" | ||||||
| #include "net/Mode.h" | #include "net/Mode.h" | ||||||
|  |  | ||||||
| #include "Application.h" | #include "Application.h" | ||||||
|   | |||||||
| @@ -58,9 +58,8 @@ | |||||||
| #include "ComponentUpdateTask.h" | #include "ComponentUpdateTask.h" | ||||||
| #include "PackProfile.h" | #include "PackProfile.h" | ||||||
| #include "PackProfile_p.h" | #include "PackProfile_p.h" | ||||||
|  | #include "minecraft/mod/Mod.h" | ||||||
| #include "Application.h" | #include "modplatform/ModIndex.h" | ||||||
| #include "modplatform/ResourceAPI.h" |  | ||||||
|  |  | ||||||
| static const QMap<QString, ModPlatform::ModLoaderType> modloaderMapping{ { "net.neoforged", ModPlatform::NeoForge }, | static const QMap<QString, ModPlatform::ModLoaderType> modloaderMapping{ { "net.neoforged", ModPlatform::NeoForge }, | ||||||
|                                                                          { "net.minecraftforge", ModPlatform::Forge }, |                                                                          { "net.minecraftforge", ModPlatform::Forge }, | ||||||
| @@ -1009,3 +1008,18 @@ std::optional<ModPlatform::ModLoaderTypes> PackProfile::getModLoaders() | |||||||
|         return {}; |         return {}; | ||||||
|     return result; |     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; | ||||||
|  | } | ||||||
|   | |||||||
| @@ -45,13 +45,9 @@ | |||||||
| #include <QString> | #include <QString> | ||||||
| #include <memory> | #include <memory> | ||||||
|  |  | ||||||
| #include "BaseVersion.h" |  | ||||||
| #include "Component.h" | #include "Component.h" | ||||||
| #include "LaunchProfile.h" | #include "LaunchProfile.h" | ||||||
| #include "Library.h" | #include "modplatform/ModIndex.h" | ||||||
| #include "MojangDownloadInfo.h" |  | ||||||
| #include "ProfileUtils.h" |  | ||||||
| #include "modplatform/ResourceAPI.h" |  | ||||||
| #include "net/Mode.h" | #include "net/Mode.h" | ||||||
|  |  | ||||||
| class MinecraftInstance; | class MinecraftInstance; | ||||||
| @@ -147,6 +143,8 @@ class PackProfile : public QAbstractListModel { | |||||||
|     void appendComponent(ComponentPtr component); |     void appendComponent(ComponentPtr component); | ||||||
|  |  | ||||||
|     std::optional<ModPlatform::ModLoaderTypes> getModLoaders(); |     std::optional<ModPlatform::ModLoaderTypes> getModLoaders(); | ||||||
|  |     // this returns aditional loaders(Quilt supports fabric and NeoForge supports Forge) | ||||||
|  |     std::optional<ModPlatform::ModLoaderTypes> getSupportedModLoaders(); | ||||||
|  |  | ||||||
|    private: |    private: | ||||||
|     void scheduleSave(); |     void scheduleSave(); | ||||||
|   | |||||||
| @@ -41,7 +41,8 @@ static Version mcVersion(BaseInstance* inst) | |||||||
|  |  | ||||||
| static ModPlatform::ModLoaderTypes mcLoaders(BaseInstance* inst) | static ModPlatform::ModLoaderTypes mcLoaders(BaseInstance* inst) | ||||||
| { | { | ||||||
|     return static_cast<MinecraftInstance*>(inst)->getPackProfile()->getModLoaders().value(); |     return static_cast<MinecraftInstance*>(inst)->getPackProfile()->getSupportedModLoaders().value_or( | ||||||
|  |         ModPlatform::ModLoaderTypes::fromInt(0)); | ||||||
| } | } | ||||||
|  |  | ||||||
| GetModDependenciesTask::GetModDependenciesTask(QObject* parent, | GetModDependenciesTask::GetModDependenciesTask(QObject* parent, | ||||||
|   | |||||||
| @@ -6,7 +6,6 @@ | |||||||
| #include "FlameModIndex.h" | #include "FlameModIndex.h" | ||||||
|  |  | ||||||
| #include "Application.h" | #include "Application.h" | ||||||
| #include "BuildConfig.h" |  | ||||||
| #include "Json.h" | #include "Json.h" | ||||||
| #include "net/ApiDownload.h" | #include "net/ApiDownload.h" | ||||||
| #include "net/ApiUpload.h" | #include "net/ApiUpload.h" | ||||||
| @@ -131,19 +130,13 @@ auto FlameAPI::getLatestVersion(VersionSearchArgs&& args) -> ModPlatform::Indexe | |||||||
|             auto obj = Json::requireObject(doc); |             auto obj = Json::requireObject(doc); | ||||||
|             auto arr = Json::requireArray(obj, "data"); |             auto arr = Json::requireArray(obj, "data"); | ||||||
|  |  | ||||||
|             QJsonObject latest_file_obj; |  | ||||||
|             ModPlatform::IndexedVersion ver_tmp; |  | ||||||
|  |  | ||||||
|             for (auto file : arr) { |             for (auto file : arr) { | ||||||
|                 auto file_obj = Json::requireObject(file); |                 auto file_obj = Json::requireObject(file); | ||||||
|                 auto file_tmp = FlameMod::loadIndexedPackVersion(file_obj); |                 auto file_tmp = FlameMod::loadIndexedPackVersion(file_obj); | ||||||
|                 if (file_tmp.date > ver_tmp.date) { |                 if (file_tmp.date > ver.date && (!args.loaders.has_value() || args.loaders.value() & file_tmp.loaders)) | ||||||
|                     ver_tmp = file_tmp; |                     ver = file_tmp; | ||||||
|                     latest_file_obj = file_obj; |  | ||||||
|                 } |  | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             ver = FlameMod::loadIndexedPackVersion(latest_file_obj); |  | ||||||
|         } catch (Json::JsonException& e) { |         } catch (Json::JsonException& e) { | ||||||
|             qCritical() << "Failed to parse response from a version request."; |             qCritical() << "Failed to parse response from a version request."; | ||||||
|             qCritical() << e.what(); |             qCritical() << e.what(); | ||||||
|   | |||||||
| @@ -48,15 +48,29 @@ class FlameAPI : public NetworkResourceAPI { | |||||||
|             return 1; |             return 1; | ||||||
|         if (loaders & ModPlatform::Fabric) |         if (loaders & ModPlatform::Fabric) | ||||||
|             return 4; |             return 4; | ||||||
|         // TODO: remove this once Quilt drops official Fabric support |         if (loaders & ModPlatform::Quilt) | ||||||
|         if (loaders & ModPlatform::Quilt)  // NOTE: Most if not all Fabric mods should work *currently* |             return 5; | ||||||
|             return 4;                      // FIXME: implement multiple loaders filter (this should be 5) |         if (loaders & ModPlatform::NeoForge) | ||||||
|         // TODO: remove this once NeoForge drops official Forge support |             return 6; | ||||||
|         if (loaders & ModPlatform::NeoForge)  // NOTE: Most if not all Forge mods should work *currently* |  | ||||||
|             return 1;                         // FIXME: implement multiple loaders filter (this should be 6) |  | ||||||
|         return 0; |         return 0; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     static auto getModLoaderStrings(const ModPlatform::ModLoaderTypes types) -> const QStringList | ||||||
|  |     { | ||||||
|  |         QStringList l; | ||||||
|  |         for (auto loader : { ModPlatform::NeoForge, ModPlatform::Forge, ModPlatform::Fabric, ModPlatform::Quilt }) { | ||||||
|  |             if (types & loader) { | ||||||
|  |                 l << QString::number(getMappedModLoader(loader)); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         return l; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     static auto getModLoaderFilters(ModPlatform::ModLoaderTypes types) -> const QString | ||||||
|  |     { | ||||||
|  |         return "[" + getModLoaderStrings(types).join(',') + "]"; | ||||||
|  |     } | ||||||
|  |  | ||||||
|    private: |    private: | ||||||
|     [[nodiscard]] std::optional<QString> getSearchURL(SearchArgs const& args) const override |     [[nodiscard]] std::optional<QString> getSearchURL(SearchArgs const& args) const override | ||||||
|     { |     { | ||||||
| @@ -73,7 +87,7 @@ class FlameAPI : public NetworkResourceAPI { | |||||||
|             get_arguments.append(QString("sortField=%1").arg(args.sorting.value().index)); |             get_arguments.append(QString("sortField=%1").arg(args.sorting.value().index)); | ||||||
|         get_arguments.append("sortOrder=desc"); |         get_arguments.append("sortOrder=desc"); | ||||||
|         if (args.loaders.has_value()) |         if (args.loaders.has_value()) | ||||||
|             get_arguments.append(QString("modLoaderType=%1").arg(getMappedModLoader(args.loaders.value()))); |             get_arguments.append(QString("modLoaderTypes=%1").arg(getModLoaderFilters(args.loaders.value()))); | ||||||
|         get_arguments.append(gameVersionStr); |         get_arguments.append(gameVersionStr); | ||||||
|  |  | ||||||
|         return "https://api.curseforge.com/v1/mods/search?gameId=432&" + get_arguments.join('&'); |         return "https://api.curseforge.com/v1/mods/search?gameId=432&" + get_arguments.join('&'); | ||||||
| @@ -92,23 +106,6 @@ class FlameAPI : public NetworkResourceAPI { | |||||||
|         QStringList get_parameters; |         QStringList get_parameters; | ||||||
|         if (args.mcVersions.has_value()) |         if (args.mcVersions.has_value()) | ||||||
|             get_parameters.append(QString("gameVersion=%1").arg(args.mcVersions.value().front().toString())); |             get_parameters.append(QString("gameVersion=%1").arg(args.mcVersions.value().front().toString())); | ||||||
|  |  | ||||||
|         if (args.loaders.has_value()) { |  | ||||||
|             int mappedModLoader = getMappedModLoader(args.loaders.value()); |  | ||||||
|  |  | ||||||
|             if (args.loaders.value() & ModPlatform::Quilt) { |  | ||||||
|                 auto overide = ModPlatform::getOverrideDeps(); |  | ||||||
|                 auto over = std::find_if(overide.cbegin(), overide.cend(), [addonId](auto dep) { |  | ||||||
|                     return dep.provider == ModPlatform::ResourceProvider::FLAME && addonId == dep.quilt; |  | ||||||
|                 }); |  | ||||||
|                 if (over != overide.cend()) { |  | ||||||
|                     mappedModLoader = 5; |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             get_parameters.append(QString("modLoaderType=%1").arg(mappedModLoader)); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return url + get_parameters.join('&'); |         return url + get_parameters.join('&'); | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5,13 +5,11 @@ | |||||||
| #include <MurmurHash2.h> | #include <MurmurHash2.h> | ||||||
| #include <memory> | #include <memory> | ||||||
|  |  | ||||||
| #include "FileSystem.h" |  | ||||||
| #include "Json.h" | #include "Json.h" | ||||||
|  |  | ||||||
| #include "ResourceDownloadTask.h" | #include "ResourceDownloadTask.h" | ||||||
|  |  | ||||||
| #include "minecraft/mod/ModFolderModel.h" | #include "minecraft/mod/ModFolderModel.h" | ||||||
| #include "minecraft/mod/ResourceFolderModel.h" |  | ||||||
|  |  | ||||||
| #include "net/ApiDownload.h" | #include "net/ApiDownload.h" | ||||||
|  |  | ||||||
|   | |||||||
| @@ -81,6 +81,7 @@ void FlameMod::loadIndexedPackVersions(ModPlatform::IndexedPack& pack, | |||||||
|     QVector<ModPlatform::IndexedVersion> unsortedVersions; |     QVector<ModPlatform::IndexedVersion> unsortedVersions; | ||||||
|     auto profile = (dynamic_cast<const MinecraftInstance*>(inst))->getPackProfile(); |     auto profile = (dynamic_cast<const MinecraftInstance*>(inst))->getPackProfile(); | ||||||
|     QString mcVersion = profile->getComponentVersion("net.minecraft"); |     QString mcVersion = profile->getComponentVersion("net.minecraft"); | ||||||
|  |     auto loaders = profile->getSupportedModLoaders(); | ||||||
|  |  | ||||||
|     for (auto versionIter : arr) { |     for (auto versionIter : arr) { | ||||||
|         auto obj = versionIter.toObject(); |         auto obj = versionIter.toObject(); | ||||||
| @@ -89,7 +90,8 @@ void FlameMod::loadIndexedPackVersions(ModPlatform::IndexedPack& pack, | |||||||
|         if (!file.addonId.isValid()) |         if (!file.addonId.isValid()) | ||||||
|             file.addonId = pack.addonId; |             file.addonId = pack.addonId; | ||||||
|  |  | ||||||
|         if (file.fileId.isValid())  // Heuristic to check if the returned value is valid |         if (file.fileId.isValid() && | ||||||
|  |             (!loaders.has_value() || loaders.value() & file.loaders))  // Heuristic to check if the returned value is valid | ||||||
|             unsortedVersions.append(file); |             unsortedVersions.append(file); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -186,8 +188,11 @@ auto FlameMod::loadIndexedPackVersion(QJsonObject& obj, bool load_changelog) -> | |||||||
|     return file; |     return file; | ||||||
| } | } | ||||||
|  |  | ||||||
| ModPlatform::IndexedVersion FlameMod::loadDependencyVersions(const ModPlatform::Dependency& m, QJsonArray& arr) | ModPlatform::IndexedVersion FlameMod::loadDependencyVersions(const ModPlatform::Dependency& m, QJsonArray& arr, const BaseInstance* inst) | ||||||
| { | { | ||||||
|  |     auto profile = (dynamic_cast<const MinecraftInstance*>(inst))->getPackProfile(); | ||||||
|  |     QString mcVersion = profile->getComponentVersion("net.minecraft"); | ||||||
|  |     auto loaders = profile->getSupportedModLoaders(); | ||||||
|     QVector<ModPlatform::IndexedVersion> versions; |     QVector<ModPlatform::IndexedVersion> versions; | ||||||
|     for (auto versionIter : arr) { |     for (auto versionIter : arr) { | ||||||
|         auto obj = versionIter.toObject(); |         auto obj = versionIter.toObject(); | ||||||
| @@ -196,7 +201,8 @@ ModPlatform::IndexedVersion FlameMod::loadDependencyVersions(const ModPlatform:: | |||||||
|         if (!file.addonId.isValid()) |         if (!file.addonId.isValid()) | ||||||
|             file.addonId = m.addonId; |             file.addonId = m.addonId; | ||||||
|  |  | ||||||
|         if (file.fileId.isValid())  // Heuristic to check if the returned value is valid |         if (file.fileId.isValid() && | ||||||
|  |             (!loaders.has_value() || loaders.value() & file.loaders))  // Heuristic to check if the returned value is valid | ||||||
|             versions.append(file); |             versions.append(file); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -19,5 +19,5 @@ void loadIndexedPackVersions(ModPlatform::IndexedPack& pack, | |||||||
|                              const shared_qobject_ptr<QNetworkAccessManager>& network, |                              const shared_qobject_ptr<QNetworkAccessManager>& network, | ||||||
|                              const BaseInstance* inst); |                              const BaseInstance* inst); | ||||||
| auto loadIndexedPackVersion(QJsonObject& obj, bool load_changelog = false) -> ModPlatform::IndexedVersion; | auto loadIndexedPackVersion(QJsonObject& obj, bool load_changelog = false) -> ModPlatform::IndexedVersion; | ||||||
| auto loadDependencyVersions(const ModPlatform::Dependency& m, QJsonArray& arr) -> ModPlatform::IndexedVersion; | auto loadDependencyVersions(const ModPlatform::Dependency& m, QJsonArray& arr, const BaseInstance* inst) -> ModPlatform::IndexedVersion; | ||||||
| }  // namespace FlameMod | }  // namespace FlameMod | ||||||
| @@ -44,11 +44,6 @@ class ModrinthAPI : public NetworkResourceAPI { | |||||||
|                 l << getModLoaderString(loader); |                 l << getModLoaderString(loader); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         if ((types & ModPlatform::NeoForge) && |  | ||||||
|             (~types & ModPlatform::Forge))  // Add Forge if NeoForge is in use, if Forge isn't already there |  | ||||||
|             l << getModLoaderString(ModPlatform::Forge); |  | ||||||
|         if ((types & ModPlatform::Quilt) && (~types & ModPlatform::Fabric))  // Add Fabric if Quilt is in use, if Fabric isn't already there |  | ||||||
|             l << getModLoaderString(ModPlatform::Fabric); |  | ||||||
|         return l; |         return l; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -11,7 +11,6 @@ | |||||||
| #include "tasks/ConcurrentTask.h" | #include "tasks/ConcurrentTask.h" | ||||||
|  |  | ||||||
| #include "minecraft/mod/ModFolderModel.h" | #include "minecraft/mod/ModFolderModel.h" | ||||||
| #include "minecraft/mod/ResourceFolderModel.h" |  | ||||||
|  |  | ||||||
| static ModrinthAPI api; | static ModrinthAPI api; | ||||||
| static ModPlatform::ProviderCapabilities ProviderCaps; | static ModPlatform::ProviderCapabilities ProviderCaps; | ||||||
|   | |||||||
| @@ -93,19 +93,19 @@ void Modrinth::loadExtraPackData(ModPlatform::IndexedPack& pack, QJsonObject& ob | |||||||
|     pack.extraDataLoaded = true; |     pack.extraDataLoaded = true; | ||||||
| } | } | ||||||
|  |  | ||||||
| void Modrinth::loadIndexedPackVersions(ModPlatform::IndexedPack& pack, | void Modrinth::loadIndexedPackVersions(ModPlatform::IndexedPack& pack, QJsonArray& arr, const BaseInstance* inst) | ||||||
|                                        QJsonArray& arr, |  | ||||||
|                                        [[maybe_unused]] const shared_qobject_ptr<QNetworkAccessManager>& network, |  | ||||||
|                                        const BaseInstance* inst) |  | ||||||
| { | { | ||||||
|     QVector<ModPlatform::IndexedVersion> unsortedVersions; |     QVector<ModPlatform::IndexedVersion> unsortedVersions; | ||||||
|     QString mcVersion = (static_cast<const MinecraftInstance*>(inst))->getPackProfile()->getComponentVersion("net.minecraft"); |     auto profile = (dynamic_cast<const MinecraftInstance*>(inst))->getPackProfile(); | ||||||
|  |     QString mcVersion = profile->getComponentVersion("net.minecraft"); | ||||||
|  |     auto loaders = profile->getSupportedModLoaders(); | ||||||
|  |  | ||||||
|     for (auto versionIter : arr) { |     for (auto versionIter : arr) { | ||||||
|         auto obj = versionIter.toObject(); |         auto obj = versionIter.toObject(); | ||||||
|         auto file = loadIndexedPackVersion(obj); |         auto file = loadIndexedPackVersion(obj); | ||||||
|  |  | ||||||
|         if (file.fileId.isValid())  // Heuristic to check if the returned value is valid |         if (file.fileId.isValid() && | ||||||
|  |             (!loaders.has_value() || loaders.value() & file.loaders))  // Heuristic to check if the returned value is valid | ||||||
|             unsortedVersions.append(file); |             unsortedVersions.append(file); | ||||||
|     } |     } | ||||||
|     auto orderSortPredicate = [](const ModPlatform::IndexedVersion& a, const ModPlatform::IndexedVersion& b) -> bool { |     auto orderSortPredicate = [](const ModPlatform::IndexedVersion& a, const ModPlatform::IndexedVersion& b) -> bool { | ||||||
| @@ -229,15 +229,20 @@ auto Modrinth::loadIndexedPackVersion(QJsonObject& obj, QString preferred_hash_t | |||||||
|     return {}; |     return {}; | ||||||
| } | } | ||||||
|  |  | ||||||
| auto Modrinth::loadDependencyVersions([[maybe_unused]] const ModPlatform::Dependency& m, QJsonArray& arr) -> ModPlatform::IndexedVersion | auto Modrinth::loadDependencyVersions([[maybe_unused]] const ModPlatform::Dependency& m, QJsonArray& arr, const BaseInstance* inst) | ||||||
|  |     -> ModPlatform::IndexedVersion | ||||||
| { | { | ||||||
|     QVector<ModPlatform::IndexedVersion> versions; |     auto profile = (dynamic_cast<const MinecraftInstance*>(inst))->getPackProfile(); | ||||||
|  |     QString mcVersion = profile->getComponentVersion("net.minecraft"); | ||||||
|  |     auto loaders = profile->getSupportedModLoaders(); | ||||||
|  |  | ||||||
|  |     QVector<ModPlatform::IndexedVersion> versions; | ||||||
|     for (auto versionIter : arr) { |     for (auto versionIter : arr) { | ||||||
|         auto obj = versionIter.toObject(); |         auto obj = versionIter.toObject(); | ||||||
|         auto file = loadIndexedPackVersion(obj); |         auto file = loadIndexedPackVersion(obj); | ||||||
|  |  | ||||||
|         if (file.fileId.isValid())  // Heuristic to check if the returned value is valid |         if (file.fileId.isValid() && | ||||||
|  |             (!loaders.has_value() || loaders.value() & file.loaders))  // Heuristic to check if the returned value is valid | ||||||
|             versions.append(file); |             versions.append(file); | ||||||
|     } |     } | ||||||
|     auto orderSortPredicate = [](const ModPlatform::IndexedVersion& a, const ModPlatform::IndexedVersion& b) -> bool { |     auto orderSortPredicate = [](const ModPlatform::IndexedVersion& a, const ModPlatform::IndexedVersion& b) -> bool { | ||||||
|   | |||||||
| @@ -26,11 +26,8 @@ namespace Modrinth { | |||||||
|  |  | ||||||
| void loadIndexedPack(ModPlatform::IndexedPack& m, QJsonObject& obj); | void loadIndexedPack(ModPlatform::IndexedPack& m, QJsonObject& obj); | ||||||
| void loadExtraPackData(ModPlatform::IndexedPack& m, QJsonObject& obj); | void loadExtraPackData(ModPlatform::IndexedPack& m, QJsonObject& obj); | ||||||
| void loadIndexedPackVersions(ModPlatform::IndexedPack& pack, | void loadIndexedPackVersions(ModPlatform::IndexedPack& pack, QJsonArray& arr, const BaseInstance* inst); | ||||||
|                              QJsonArray& arr, |  | ||||||
|                              const shared_qobject_ptr<QNetworkAccessManager>& network, |  | ||||||
|                              const BaseInstance* inst); |  | ||||||
| auto loadIndexedPackVersion(QJsonObject& obj, QString hash_type = "sha512", QString filename_prefer = "") -> ModPlatform::IndexedVersion; | auto loadIndexedPackVersion(QJsonObject& obj, QString hash_type = "sha512", QString filename_prefer = "") -> ModPlatform::IndexedVersion; | ||||||
| auto loadDependencyVersions(const ModPlatform::Dependency& m, QJsonArray& arr) -> ModPlatform::IndexedVersion; | auto loadDependencyVersions(const ModPlatform::Dependency& m, QJsonArray& arr, const BaseInstance* inst) -> ModPlatform::IndexedVersion; | ||||||
|  |  | ||||||
| }  // namespace Modrinth | }  // namespace Modrinth | ||||||
|   | |||||||
| @@ -43,7 +43,6 @@ | |||||||
| #include "FileSystem.h" | #include "FileSystem.h" | ||||||
|  |  | ||||||
| #include "MainWindow.h" | #include "MainWindow.h" | ||||||
| #include "ui/dialogs/ExportToModListDialog.h" |  | ||||||
| #include "ui_MainWindow.h" | #include "ui_MainWindow.h" | ||||||
|  |  | ||||||
| #include <QDir> | #include <QDir> | ||||||
| @@ -90,17 +89,14 @@ | |||||||
| #include <news/NewsChecker.h> | #include <news/NewsChecker.h> | ||||||
| #include <tools/BaseProfiler.h> | #include <tools/BaseProfiler.h> | ||||||
| #include <updater/ExternalUpdater.h> | #include <updater/ExternalUpdater.h> | ||||||
| #include "InstancePageProvider.h" |  | ||||||
| #include "InstanceWindow.h" | #include "InstanceWindow.h" | ||||||
| #include "JavaCommon.h" |  | ||||||
| #include "LaunchController.h" |  | ||||||
|  |  | ||||||
| #include "ui/dialogs/AboutDialog.h" | #include "ui/dialogs/AboutDialog.h" | ||||||
| #include "ui/dialogs/CopyInstanceDialog.h" | #include "ui/dialogs/CopyInstanceDialog.h" | ||||||
| #include "ui/dialogs/CustomMessageBox.h" | #include "ui/dialogs/CustomMessageBox.h" | ||||||
| #include "ui/dialogs/EditAccountDialog.h" |  | ||||||
| #include "ui/dialogs/ExportInstanceDialog.h" | #include "ui/dialogs/ExportInstanceDialog.h" | ||||||
| #include "ui/dialogs/ExportPackDialog.h" | #include "ui/dialogs/ExportPackDialog.h" | ||||||
|  | #include "ui/dialogs/ExportToModListDialog.h" | ||||||
| #include "ui/dialogs/IconPickerDialog.h" | #include "ui/dialogs/IconPickerDialog.h" | ||||||
| #include "ui/dialogs/ImportResourceDialog.h" | #include "ui/dialogs/ImportResourceDialog.h" | ||||||
| #include "ui/dialogs/NewInstanceDialog.h" | #include "ui/dialogs/NewInstanceDialog.h" | ||||||
| @@ -113,9 +109,13 @@ | |||||||
| #include "ui/themes/ThemeManager.h" | #include "ui/themes/ThemeManager.h" | ||||||
| #include "ui/widgets/LabeledToolButton.h" | #include "ui/widgets/LabeledToolButton.h" | ||||||
|  |  | ||||||
|  | #include "minecraft/PackProfile.h" | ||||||
|  | #include "minecraft/VersionFile.h" | ||||||
| #include "minecraft/WorldList.h" | #include "minecraft/WorldList.h" | ||||||
| #include "minecraft/mod/ModFolderModel.h" | #include "minecraft/mod/ModFolderModel.h" | ||||||
|  | #include "minecraft/mod/ResourcePackFolderModel.h" | ||||||
| #include "minecraft/mod/ShaderPackFolderModel.h" | #include "minecraft/mod/ShaderPackFolderModel.h" | ||||||
|  | #include "minecraft/mod/TexturePackFolderModel.h" | ||||||
| #include "minecraft/mod/tasks/LocalResourceParse.h" | #include "minecraft/mod/tasks/LocalResourceParse.h" | ||||||
|  |  | ||||||
| #include "modplatform/flame/FlameAPI.h" | #include "modplatform/flame/FlameAPI.h" | ||||||
| @@ -123,7 +123,6 @@ | |||||||
| #include "KonamiCode.h" | #include "KonamiCode.h" | ||||||
|  |  | ||||||
| #include "InstanceCopyTask.h" | #include "InstanceCopyTask.h" | ||||||
| #include "InstanceImportTask.h" |  | ||||||
|  |  | ||||||
| #include "Json.h" | #include "Json.h" | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5,8 +5,6 @@ | |||||||
| #include "ScrollMessageBox.h" | #include "ScrollMessageBox.h" | ||||||
| #include "ui_ReviewMessageBox.h" | #include "ui_ReviewMessageBox.h" | ||||||
|  |  | ||||||
| #include "FileSystem.h" |  | ||||||
| #include "Json.h" |  | ||||||
| #include "Markdown.h" | #include "Markdown.h" | ||||||
|  |  | ||||||
| #include "tasks/ConcurrentTask.h" | #include "tasks/ConcurrentTask.h" | ||||||
| @@ -32,7 +30,7 @@ static std::list<Version> mcVersions(BaseInstance* inst) | |||||||
|  |  | ||||||
| static std::optional<ModPlatform::ModLoaderTypes> mcLoaders(BaseInstance* inst) | static std::optional<ModPlatform::ModLoaderTypes> mcLoaders(BaseInstance* inst) | ||||||
| { | { | ||||||
|     return { static_cast<MinecraftInstance*>(inst)->getPackProfile()->getModLoaders() }; |     return { static_cast<MinecraftInstance*>(inst)->getPackProfile()->getSupportedModLoaders() }; | ||||||
| } | } | ||||||
|  |  | ||||||
| ModUpdateDialog::ModUpdateDialog(QWidget* parent, | ModUpdateDialog::ModUpdateDialog(QWidget* parent, | ||||||
|   | |||||||
| @@ -279,7 +279,7 @@ QList<BasePage*> ModDownloadDialog::getPages() | |||||||
| { | { | ||||||
|     QList<BasePage*> pages; |     QList<BasePage*> pages; | ||||||
|  |  | ||||||
|     auto loaders = static_cast<MinecraftInstance*>(m_instance)->getPackProfile()->getModLoaders().value(); |     auto loaders = static_cast<MinecraftInstance*>(m_instance)->getPackProfile()->getSupportedModLoaders().value(); | ||||||
|  |  | ||||||
|     if (ModrinthAPI::validateModLoaders(loaders)) |     if (ModrinthAPI::validateModLoaders(loaders)) | ||||||
|         pages.append(ModrinthModPage::create(this, *m_instance)); |         pages.append(ModrinthModPage::create(this, *m_instance)); | ||||||
|   | |||||||
| @@ -33,7 +33,7 @@ ResourceAPI::SearchArgs ModModel::createSearchArguments() | |||||||
|  |  | ||||||
|     auto sort = getCurrentSortingMethodByIndex(); |     auto sort = getCurrentSortingMethodByIndex(); | ||||||
|  |  | ||||||
|     return { ModPlatform::ResourceType::MOD, m_next_search_offset, m_search_term, sort, profile->getModLoaders(), versions }; |     return { ModPlatform::ResourceType::MOD, m_next_search_offset, m_search_term, sort, profile->getSupportedModLoaders(), versions }; | ||||||
| } | } | ||||||
|  |  | ||||||
| ResourceAPI::VersionSearchArgs ModModel::createVersionsArguments(QModelIndex& entry) | ResourceAPI::VersionSearchArgs ModModel::createVersionsArguments(QModelIndex& entry) | ||||||
| @@ -48,7 +48,7 @@ ResourceAPI::VersionSearchArgs ModModel::createVersionsArguments(QModelIndex& en | |||||||
|     if (!m_filter->versions.empty()) |     if (!m_filter->versions.empty()) | ||||||
|         versions = m_filter->versions; |         versions = m_filter->versions; | ||||||
|  |  | ||||||
|     return { pack, versions, profile->getModLoaders() }; |     return { pack, versions, profile->getSupportedModLoaders() }; | ||||||
| } | } | ||||||
|  |  | ||||||
| ResourceAPI::ProjectInfoArgs ModModel::createInfoArguments(QModelIndex& entry) | ResourceAPI::ProjectInfoArgs ModModel::createInfoArguments(QModelIndex& entry) | ||||||
|   | |||||||
| @@ -124,7 +124,7 @@ void ModPage::updateVersionList() | |||||||
|         auto version = current_pack->versions[i]; |         auto version = current_pack->versions[i]; | ||||||
|         bool valid = false; |         bool valid = false; | ||||||
|         for (auto& mcVer : m_filter->versions) { |         for (auto& mcVer : m_filter->versions) { | ||||||
|             if (validateVersion(version, mcVer.toString(), packProfile->getModLoaders())) { |             if (validateVersion(version, mcVer.toString(), packProfile->getSupportedModLoaders())) { | ||||||
|                 valid = true; |                 valid = true; | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -31,7 +31,7 @@ void FlameModModel::loadIndexedPackVersions(ModPlatform::IndexedPack& m, QJsonAr | |||||||
|  |  | ||||||
| auto FlameModModel::loadDependencyVersions(const ModPlatform::Dependency& m, QJsonArray& arr) -> ModPlatform::IndexedVersion | auto FlameModModel::loadDependencyVersions(const ModPlatform::Dependency& m, QJsonArray& arr) -> ModPlatform::IndexedVersion | ||||||
| { | { | ||||||
|     return FlameMod::loadDependencyVersions(m, arr); |     return FlameMod::loadDependencyVersions(m, arr, &m_base_instance); | ||||||
| } | } | ||||||
|  |  | ||||||
| auto FlameModModel::documentToArray(QJsonDocument& obj) const -> QJsonArray | auto FlameModModel::documentToArray(QJsonDocument& obj) const -> QJsonArray | ||||||
|   | |||||||
| @@ -39,12 +39,12 @@ void ModrinthModModel::loadExtraPackInfo(ModPlatform::IndexedPack& m, QJsonObjec | |||||||
|  |  | ||||||
| void ModrinthModModel::loadIndexedPackVersions(ModPlatform::IndexedPack& m, QJsonArray& arr) | void ModrinthModModel::loadIndexedPackVersions(ModPlatform::IndexedPack& m, QJsonArray& arr) | ||||||
| { | { | ||||||
|     ::Modrinth::loadIndexedPackVersions(m, arr, APPLICATION->network(), &m_base_instance); |     ::Modrinth::loadIndexedPackVersions(m, arr, &m_base_instance); | ||||||
| } | } | ||||||
|  |  | ||||||
| auto ModrinthModModel::loadDependencyVersions(const ModPlatform::Dependency& m, QJsonArray& arr) -> ModPlatform::IndexedVersion | auto ModrinthModModel::loadDependencyVersions(const ModPlatform::Dependency& m, QJsonArray& arr) -> ModPlatform::IndexedVersion | ||||||
| { | { | ||||||
|     return ::Modrinth::loadDependencyVersions(m, arr); |     return ::Modrinth::loadDependencyVersions(m, arr, &m_base_instance); | ||||||
| } | } | ||||||
|  |  | ||||||
| auto ModrinthModModel::documentToArray(QJsonDocument& obj) const -> QJsonArray | auto ModrinthModModel::documentToArray(QJsonDocument& obj) const -> QJsonArray | ||||||
| @@ -66,7 +66,7 @@ void ModrinthResourcePackModel::loadExtraPackInfo(ModPlatform::IndexedPack& m, Q | |||||||
|  |  | ||||||
| void ModrinthResourcePackModel::loadIndexedPackVersions(ModPlatform::IndexedPack& m, QJsonArray& arr) | void ModrinthResourcePackModel::loadIndexedPackVersions(ModPlatform::IndexedPack& m, QJsonArray& arr) | ||||||
| { | { | ||||||
|     ::Modrinth::loadIndexedPackVersions(m, arr, APPLICATION->network(), &m_base_instance); |     ::Modrinth::loadIndexedPackVersions(m, arr, &m_base_instance); | ||||||
| } | } | ||||||
|  |  | ||||||
| auto ModrinthResourcePackModel::documentToArray(QJsonDocument& obj) const -> QJsonArray | auto ModrinthResourcePackModel::documentToArray(QJsonDocument& obj) const -> QJsonArray | ||||||
| @@ -88,7 +88,7 @@ void ModrinthTexturePackModel::loadExtraPackInfo(ModPlatform::IndexedPack& m, QJ | |||||||
|  |  | ||||||
| void ModrinthTexturePackModel::loadIndexedPackVersions(ModPlatform::IndexedPack& m, QJsonArray& arr) | void ModrinthTexturePackModel::loadIndexedPackVersions(ModPlatform::IndexedPack& m, QJsonArray& arr) | ||||||
| { | { | ||||||
|     ::Modrinth::loadIndexedPackVersions(m, arr, APPLICATION->network(), &m_base_instance); |     ::Modrinth::loadIndexedPackVersions(m, arr, &m_base_instance); | ||||||
| } | } | ||||||
|  |  | ||||||
| auto ModrinthTexturePackModel::documentToArray(QJsonDocument& obj) const -> QJsonArray | auto ModrinthTexturePackModel::documentToArray(QJsonDocument& obj) const -> QJsonArray | ||||||
| @@ -110,7 +110,7 @@ void ModrinthShaderPackModel::loadExtraPackInfo(ModPlatform::IndexedPack& m, QJs | |||||||
|  |  | ||||||
| void ModrinthShaderPackModel::loadIndexedPackVersions(ModPlatform::IndexedPack& m, QJsonArray& arr) | void ModrinthShaderPackModel::loadIndexedPackVersions(ModPlatform::IndexedPack& m, QJsonArray& arr) | ||||||
| { | { | ||||||
|     ::Modrinth::loadIndexedPackVersions(m, arr, APPLICATION->network(), &m_base_instance); |     ::Modrinth::loadIndexedPackVersions(m, arr, &m_base_instance); | ||||||
| } | } | ||||||
|  |  | ||||||
| auto ModrinthShaderPackModel::documentToArray(QJsonDocument& obj) const -> QJsonArray | auto ModrinthShaderPackModel::documentToArray(QJsonDocument& obj) const -> QJsonArray | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Trial97
					Trial97