Added fallback for quilt if the API or Kotilin is not present
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
b62e4c0cc7
commit
3e3be9ae6f
@ -31,7 +31,6 @@
|
|||||||
#include "tasks/ConcurrentTask.h"
|
#include "tasks/ConcurrentTask.h"
|
||||||
#include "tasks/SequentialTask.h"
|
#include "tasks/SequentialTask.h"
|
||||||
#include "ui/pages/modplatform/ModModel.h"
|
#include "ui/pages/modplatform/ModModel.h"
|
||||||
#include "ui/pages/modplatform/ResourceModel.h"
|
|
||||||
#include "ui/pages/modplatform/flame/FlameResourceModels.h"
|
#include "ui/pages/modplatform/flame/FlameResourceModels.h"
|
||||||
#include "ui/pages/modplatform/modrinth/ModrinthResourceModels.h"
|
#include "ui/pages/modplatform/modrinth/ModrinthResourceModels.h"
|
||||||
|
|
||||||
@ -192,6 +191,16 @@ Task::Ptr GetModDependenciesTask::prepareDependencyTask(const ModPlatform::Depen
|
|||||||
}
|
}
|
||||||
pDep->version = provider.mod->loadDependencyVersions(dep, arr);
|
pDep->version = provider.mod->loadDependencyVersions(dep, arr);
|
||||||
if (!pDep->version.addonId.isValid()) {
|
if (!pDep->version.addonId.isValid()) {
|
||||||
|
if (m_loaderType & ResourceAPI::Quilt) { // falback for quilt
|
||||||
|
auto overide = ModPlatform::getOverrideDeps();
|
||||||
|
auto over = std::find_if(overide.cbegin(), overide.cend(),
|
||||||
|
[dep, provider](auto o) { return o.provider == provider.name && dep.addonId == o.quilt; });
|
||||||
|
if (over != overide.cend()) {
|
||||||
|
removePack(dep.addonId);
|
||||||
|
addTask(prepareDependencyTask({ over->fabric, dep.type }, provider.name, level));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
qWarning() << "Error while reading mod version empty ";
|
qWarning() << "Error while reading mod version empty ";
|
||||||
qDebug() << doc;
|
qDebug() << doc;
|
||||||
return;
|
return;
|
||||||
@ -213,18 +222,7 @@ Task::Ptr GetModDependenciesTask::prepareDependencyTask(const ModPlatform::Depen
|
|||||||
pDep->pack->addonId = pDep->version.addonId;
|
pDep->pack->addonId = pDep->version.addonId;
|
||||||
auto dep = getOverride({ pDep->version.addonId, pDep->dependency.type }, provider.name);
|
auto dep = getOverride({ pDep->version.addonId, pDep->dependency.type }, provider.name);
|
||||||
if (dep.addonId != pDep->version.addonId) {
|
if (dep.addonId != pDep->version.addonId) {
|
||||||
auto toRemoveID = pDep->version.addonId;
|
removePack(pDep->version.addonId);
|
||||||
|
|
||||||
auto pred = [toRemoveID](const std::shared_ptr<PackDependency>& v) { return v->pack->addonId == toRemoveID; };
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 1, 0)
|
|
||||||
m_pack_dependencies.removeIf(pred);
|
|
||||||
#else
|
|
||||||
for (auto it = m_pack_dependencies.begin(); it != m_pack_dependencies.end();)
|
|
||||||
if (pred(*it))
|
|
||||||
it = m_pack_dependencies.erase(it);
|
|
||||||
else
|
|
||||||
++it;
|
|
||||||
#endif
|
|
||||||
addTask(prepareDependencyTask(dep, provider.name, level));
|
addTask(prepareDependencyTask(dep, provider.name, level));
|
||||||
} else
|
} else
|
||||||
addTask(getProjectInfoTask(pDep));
|
addTask(getProjectInfoTask(pDep));
|
||||||
@ -238,3 +236,17 @@ Task::Ptr GetModDependenciesTask::prepareDependencyTask(const ModPlatform::Depen
|
|||||||
tasks->addTask(version);
|
tasks->addTask(version);
|
||||||
return tasks;
|
return tasks;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void GetModDependenciesTask::removePack(const QVariant addonId)
|
||||||
|
{
|
||||||
|
auto pred = [addonId](const std::shared_ptr<PackDependency>& v) { return v->pack->addonId == addonId; };
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 1, 0)
|
||||||
|
m_pack_dependencies.removeIf(pred);
|
||||||
|
#else
|
||||||
|
for (auto it = m_pack_dependencies.begin(); it != m_pack_dependencies.end();)
|
||||||
|
if (pred(*it))
|
||||||
|
it = m_pack_dependencies.erase(it);
|
||||||
|
else
|
||||||
|
++it;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
@ -70,6 +70,7 @@ class GetModDependenciesTask : public SequentialTask {
|
|||||||
void prepare();
|
void prepare();
|
||||||
Task::Ptr getProjectInfoTask(std::shared_ptr<PackDependency> pDep);
|
Task::Ptr getProjectInfoTask(std::shared_ptr<PackDependency> pDep);
|
||||||
ModPlatform::Dependency getOverride(const ModPlatform::Dependency&, const ModPlatform::ResourceProvider providerName);
|
ModPlatform::Dependency getOverride(const ModPlatform::Dependency&, const ModPlatform::ResourceProvider providerName);
|
||||||
|
void removePack(const QVariant addonId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<std::shared_ptr<PackDependency>> m_pack_dependencies;
|
QList<std::shared_ptr<PackDependency>> m_pack_dependencies;
|
||||||
|
Loading…
Reference in New Issue
Block a user