Merge pull request #1560 from Trial97/curse_multiple_loaders2
Add suport for flame multiple loaders
This commit is contained in:
@ -43,9 +43,6 @@
|
||||
#include "FileSystem.h"
|
||||
|
||||
#include "MainWindow.h"
|
||||
#include "modplatform/ModIndex.h"
|
||||
#include "modplatform/flame/FlameModIndex.h"
|
||||
#include "ui/dialogs/ExportToModListDialog.h"
|
||||
#include "ui_MainWindow.h"
|
||||
|
||||
#include <QDir>
|
||||
@ -92,17 +89,14 @@
|
||||
#include <news/NewsChecker.h>
|
||||
#include <tools/BaseProfiler.h>
|
||||
#include <updater/ExternalUpdater.h>
|
||||
#include "InstancePageProvider.h"
|
||||
#include "InstanceWindow.h"
|
||||
#include "JavaCommon.h"
|
||||
#include "LaunchController.h"
|
||||
|
||||
#include "ui/dialogs/AboutDialog.h"
|
||||
#include "ui/dialogs/CopyInstanceDialog.h"
|
||||
#include "ui/dialogs/CustomMessageBox.h"
|
||||
#include "ui/dialogs/EditAccountDialog.h"
|
||||
#include "ui/dialogs/ExportInstanceDialog.h"
|
||||
#include "ui/dialogs/ExportPackDialog.h"
|
||||
#include "ui/dialogs/ExportToModListDialog.h"
|
||||
#include "ui/dialogs/IconPickerDialog.h"
|
||||
#include "ui/dialogs/ImportResourceDialog.h"
|
||||
#include "ui/dialogs/NewInstanceDialog.h"
|
||||
@ -115,17 +109,22 @@
|
||||
#include "ui/themes/ThemeManager.h"
|
||||
#include "ui/widgets/LabeledToolButton.h"
|
||||
|
||||
#include "minecraft/PackProfile.h"
|
||||
#include "minecraft/VersionFile.h"
|
||||
#include "minecraft/WorldList.h"
|
||||
#include "minecraft/mod/ModFolderModel.h"
|
||||
#include "minecraft/mod/ResourcePackFolderModel.h"
|
||||
#include "minecraft/mod/ShaderPackFolderModel.h"
|
||||
#include "minecraft/mod/TexturePackFolderModel.h"
|
||||
#include "minecraft/mod/tasks/LocalResourceParse.h"
|
||||
|
||||
#include "modplatform/ModIndex.h"
|
||||
#include "modplatform/flame/FlameAPI.h"
|
||||
#include "modplatform/flame/FlameModIndex.h"
|
||||
|
||||
#include "KonamiCode.h"
|
||||
|
||||
#include "InstanceCopyTask.h"
|
||||
#include "InstanceImportTask.h"
|
||||
|
||||
#include "Json.h"
|
||||
|
||||
|
@ -5,8 +5,6 @@
|
||||
#include "ScrollMessageBox.h"
|
||||
#include "ui_ReviewMessageBox.h"
|
||||
|
||||
#include "FileSystem.h"
|
||||
#include "Json.h"
|
||||
#include "Markdown.h"
|
||||
|
||||
#include "tasks/ConcurrentTask.h"
|
||||
@ -30,9 +28,9 @@ static std::list<Version> mcVersions(BaseInstance* inst)
|
||||
return { static_cast<MinecraftInstance*>(inst)->getPackProfile()->getComponent("net.minecraft")->getVersion() };
|
||||
}
|
||||
|
||||
static std::optional<ResourceAPI::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,
|
||||
|
@ -279,7 +279,7 @@ QList<BasePage*> ModDownloadDialog::getPages()
|
||||
{
|
||||
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))
|
||||
pages.append(ModrinthModPage::create(this, *m_instance));
|
||||
|
@ -33,7 +33,7 @@ ResourceAPI::SearchArgs ModModel::createSearchArguments()
|
||||
|
||||
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)
|
||||
@ -48,7 +48,7 @@ ResourceAPI::VersionSearchArgs ModModel::createVersionsArguments(QModelIndex& en
|
||||
if (!m_filter->versions.empty())
|
||||
versions = m_filter->versions;
|
||||
|
||||
return { pack, versions, profile->getModLoaders() };
|
||||
return { pack, versions, profile->getSupportedModLoaders() };
|
||||
}
|
||||
|
||||
ResourceAPI::ProjectInfoArgs ModModel::createInfoArguments(QModelIndex& entry)
|
||||
|
@ -124,8 +124,7 @@ void ModPage::updateVersionList()
|
||||
auto version = current_pack->versions[i];
|
||||
bool valid = false;
|
||||
for (auto& mcVer : m_filter->versions) {
|
||||
// NOTE: Flame doesn't care about loader, so passing it changes nothing.
|
||||
if (validateVersion(version, mcVer.toString(), packProfile->getModLoaders())) {
|
||||
if (validateVersion(version, mcVer.toString(), packProfile->getSupportedModLoaders())) {
|
||||
valid = true;
|
||||
break;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ class ModPage : public ResourcePage {
|
||||
|
||||
virtual auto validateVersion(ModPlatform::IndexedVersion& ver,
|
||||
QString mineVer,
|
||||
std::optional<ResourceAPI::ModLoaderTypes> loaders = {}) const -> bool = 0;
|
||||
std::optional<ModPlatform::ModLoaderTypes> loaders = {}) const -> bool = 0;
|
||||
|
||||
[[nodiscard]] bool supportsFiltering() const override { return true; };
|
||||
auto getFilter() const -> const std::shared_ptr<ModFilterWidget::Filter> { return m_filter; }
|
||||
|
@ -3,6 +3,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
#include "ShaderPackPage.h"
|
||||
#include "modplatform/ModIndex.h"
|
||||
#include "ui_ResourcePage.h"
|
||||
|
||||
#include "ShaderPackModel.h"
|
||||
@ -48,7 +49,7 @@ void ShaderPackResourcePage::addResourceToPage(ModPlatform::IndexedPack::Ptr pac
|
||||
const std::shared_ptr<ResourceFolderModel> base_model)
|
||||
{
|
||||
QString custom_target_folder;
|
||||
if (version.loaders.contains(QStringLiteral("canvas")))
|
||||
if (version.loaders & ModPlatform::Cauldron)
|
||||
custom_target_folder = QStringLiteral("resourcepacks");
|
||||
m_model->addPack(pack, version, base_model, false, custom_target_folder);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ void FlameModModel::loadIndexedPackVersions(ModPlatform::IndexedPack& m, QJsonAr
|
||||
|
||||
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
|
||||
|
@ -68,10 +68,10 @@ FlameModPage::FlameModPage(ModDownloadDialog* dialog, BaseInstance& instance) :
|
||||
|
||||
auto FlameModPage::validateVersion(ModPlatform::IndexedVersion& ver,
|
||||
QString mineVer,
|
||||
std::optional<ResourceAPI::ModLoaderTypes> loaders) const -> bool
|
||||
std::optional<ModPlatform::ModLoaderTypes> loaders) const -> bool
|
||||
{
|
||||
Q_UNUSED(loaders);
|
||||
return ver.mcVersion.contains(mineVer) && !ver.downloadUrl.isEmpty();
|
||||
return ver.mcVersion.contains(mineVer) && !ver.downloadUrl.isEmpty() &&
|
||||
(!loaders.has_value() || !ver.loaders || loaders.value() & ver.loaders);
|
||||
}
|
||||
|
||||
bool FlameModPage::optedOut(ModPlatform::IndexedVersion& ver) const
|
||||
|
@ -95,7 +95,7 @@ class FlameModPage : public ModPage {
|
||||
|
||||
bool validateVersion(ModPlatform::IndexedVersion& ver,
|
||||
QString mineVer,
|
||||
std::optional<ResourceAPI::ModLoaderTypes> loaders = {}) const override;
|
||||
std::optional<ModPlatform::ModLoaderTypes> loaders = {}) const override;
|
||||
bool optedOut(ModPlatform::IndexedVersion& ver) const override;
|
||||
|
||||
void openUrl(const QUrl& url) override;
|
||||
|
@ -39,12 +39,12 @@ void ModrinthModModel::loadExtraPackInfo(ModPlatform::IndexedPack& m, QJsonObjec
|
||||
|
||||
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
|
||||
{
|
||||
return ::Modrinth::loadDependencyVersions(m, arr);
|
||||
return ::Modrinth::loadDependencyVersions(m, arr, &m_base_instance);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
::Modrinth::loadIndexedPackVersions(m, arr, APPLICATION->network(), &m_base_instance);
|
||||
::Modrinth::loadIndexedPackVersions(m, arr, &m_base_instance);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
::Modrinth::loadIndexedPackVersions(m, arr, APPLICATION->network(), &m_base_instance);
|
||||
::Modrinth::loadIndexedPackVersions(m, arr, &m_base_instance);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
::Modrinth::loadIndexedPackVersions(m, arr, APPLICATION->network(), &m_base_instance);
|
||||
::Modrinth::loadIndexedPackVersions(m, arr, &m_base_instance);
|
||||
}
|
||||
|
||||
auto ModrinthShaderPackModel::documentToArray(QJsonDocument& obj) const -> QJsonArray
|
||||
|
@ -65,21 +65,9 @@ ModrinthModPage::ModrinthModPage(ModDownloadDialog* dialog, BaseInstance& instan
|
||||
|
||||
auto ModrinthModPage::validateVersion(ModPlatform::IndexedVersion& ver,
|
||||
QString mineVer,
|
||||
std::optional<ResourceAPI::ModLoaderTypes> loaders) const -> bool
|
||||
std::optional<ModPlatform::ModLoaderTypes> loaders) const -> bool
|
||||
{
|
||||
auto loaderCompatible = !loaders.has_value();
|
||||
|
||||
if (!loaderCompatible) {
|
||||
auto loaderStrings = ModrinthAPI::getModLoaderStrings(loaders.value());
|
||||
for (auto remoteLoader : ver.loaders) {
|
||||
if (loaderStrings.contains(remoteLoader)) {
|
||||
loaderCompatible = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ver.mcVersion.contains(mineVer) && loaderCompatible;
|
||||
return ver.mcVersion.contains(mineVer) && (!loaders.has_value() || !ver.loaders || loaders.value() & ver.loaders);
|
||||
}
|
||||
|
||||
ModrinthResourcePackPage::ModrinthResourcePackPage(ResourcePackDownloadDialog* dialog, BaseInstance& instance)
|
||||
|
@ -93,7 +93,7 @@ class ModrinthModPage : public ModPage {
|
||||
|
||||
[[nodiscard]] inline auto helpPage() const -> QString override { return "Mod-platform"; }
|
||||
|
||||
auto validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, std::optional<ResourceAPI::ModLoaderTypes> loaders = {}) const
|
||||
auto validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, std::optional<ModPlatform::ModLoaderTypes> loaders = {}) const
|
||||
-> bool override;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user