Small fixes
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
319ce8c19f
commit
1bdde1f947
@ -33,7 +33,7 @@
|
|||||||
#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"
|
||||||
|
|
||||||
static Version mcVersions(BaseInstance* inst)
|
static Version mcVersion(BaseInstance* inst)
|
||||||
{
|
{
|
||||||
return static_cast<MinecraftInstance*>(inst)->getPackProfile()->getComponent("net.minecraft")->getVersion();
|
return static_cast<MinecraftInstance*>(inst)->getPackProfile()->getComponent("net.minecraft")->getVersion();
|
||||||
}
|
}
|
||||||
@ -53,7 +53,7 @@ GetModDependenciesTask::GetModDependenciesTask(QObject* parent,
|
|||||||
std::make_shared<FlameAPI>() }
|
std::make_shared<FlameAPI>() }
|
||||||
, m_modrinth_provider{ ModPlatform::ResourceProvider::MODRINTH, std::make_shared<ResourceDownload::ModrinthModModel>(*instance),
|
, m_modrinth_provider{ ModPlatform::ResourceProvider::MODRINTH, std::make_shared<ResourceDownload::ModrinthModModel>(*instance),
|
||||||
std::make_shared<ModrinthAPI>() }
|
std::make_shared<ModrinthAPI>() }
|
||||||
, m_version(mcVersions(instance))
|
, m_version(mcVersion(instance))
|
||||||
, m_loaderType(mcLoaders(instance))
|
, m_loaderType(mcLoaders(instance))
|
||||||
{
|
{
|
||||||
for (auto mod : folder->allMods())
|
for (auto mod : folder->allMods())
|
||||||
@ -74,33 +74,38 @@ void GetModDependenciesTask::prepare()
|
|||||||
QList<ModPlatform::Dependency> GetModDependenciesTask::getDependenciesForVersion(const ModPlatform::IndexedVersion& version,
|
QList<ModPlatform::Dependency> GetModDependenciesTask::getDependenciesForVersion(const ModPlatform::IndexedVersion& version,
|
||||||
const ModPlatform::ResourceProvider providerName)
|
const ModPlatform::ResourceProvider providerName)
|
||||||
{
|
{
|
||||||
auto c_dependencies = QList<ModPlatform::Dependency>();
|
QList<ModPlatform::Dependency> c_dependencies;
|
||||||
for (auto ver_dep : version.dependencies) {
|
for (auto ver_dep : version.dependencies) {
|
||||||
if (ver_dep.type == ModPlatform::DependencyType::REQUIRED) {
|
if (ver_dep.type != ModPlatform::DependencyType::REQUIRED)
|
||||||
if (auto dep = std::find_if(c_dependencies.begin(), c_dependencies.end(),
|
continue;
|
||||||
[&ver_dep](const ModPlatform::Dependency& i) { return i.addonId == ver_dep.addonId; });
|
|
||||||
dep == c_dependencies.end()) { // check the current dependency list
|
if (auto dep = std::find_if(c_dependencies.begin(), c_dependencies.end(),
|
||||||
if (auto dep = std::find_if(m_selected.begin(), m_selected.end(),
|
[&ver_dep](const ModPlatform::Dependency& i) { return i.addonId == ver_dep.addonId; });
|
||||||
[&ver_dep, providerName](std::shared_ptr<PackDependency> i) {
|
dep != c_dependencies.end())
|
||||||
return i->pack->addonId == ver_dep.addonId && i->pack->provider == providerName;
|
continue; // check the current dependency list
|
||||||
});
|
|
||||||
dep == m_selected.end()) { // check the selected versions
|
if (auto dep = std::find_if(m_selected.begin(), m_selected.end(),
|
||||||
if (auto dep = std::find_if(m_mods.begin(), m_mods.end(),
|
[&ver_dep, providerName](std::shared_ptr<PackDependency> i) {
|
||||||
[&ver_dep, providerName](std::shared_ptr<Metadata::ModStruct> i) {
|
return i->pack->addonId == ver_dep.addonId && i->pack->provider == providerName;
|
||||||
return i->project_id == ver_dep.addonId && i->provider == providerName;
|
});
|
||||||
});
|
dep != m_selected.end())
|
||||||
dep == m_mods.end()) { // check the existing mods
|
continue; // check the selected versions
|
||||||
if (auto dep = std::find_if(m_pack_dependencies.begin(), m_pack_dependencies.end(),
|
|
||||||
[&ver_dep, providerName](std::shared_ptr<PackDependency> i) {
|
if (auto dep = std::find_if(m_mods.begin(), m_mods.end(),
|
||||||
return i->pack->addonId == ver_dep.addonId && i->pack->provider == providerName;
|
[&ver_dep, providerName](std::shared_ptr<Metadata::ModStruct> i) {
|
||||||
});
|
return i->project_id == ver_dep.addonId && i->provider == providerName;
|
||||||
dep == m_pack_dependencies.end()) { // check loaded dependencies
|
});
|
||||||
c_dependencies.append(ver_dep);
|
dep != m_mods.end())
|
||||||
}
|
continue; // check the existing mods
|
||||||
}
|
|
||||||
}
|
if (auto dep = std::find_if(m_pack_dependencies.begin(), m_pack_dependencies.end(),
|
||||||
}
|
[&ver_dep, providerName](std::shared_ptr<PackDependency> i) {
|
||||||
}
|
return i->pack->addonId == ver_dep.addonId && i->pack->provider == providerName;
|
||||||
|
});
|
||||||
|
dep != m_pack_dependencies.end()) // check loaded dependencies
|
||||||
|
continue;
|
||||||
|
|
||||||
|
c_dependencies.append(ver_dep);
|
||||||
}
|
}
|
||||||
return c_dependencies;
|
return c_dependencies;
|
||||||
};
|
};
|
||||||
|
@ -42,7 +42,7 @@ class GetModDependenciesTask : public SequentialTask {
|
|||||||
ModPlatform::Dependency dependency;
|
ModPlatform::Dependency dependency;
|
||||||
ModPlatform::IndexedPack::Ptr pack;
|
ModPlatform::IndexedPack::Ptr pack;
|
||||||
ModPlatform::IndexedVersion version;
|
ModPlatform::IndexedVersion version;
|
||||||
PackDependency(){};
|
PackDependency() = default;
|
||||||
PackDependency(const ModPlatform::IndexedPack::Ptr p, const ModPlatform::IndexedVersion& v)
|
PackDependency(const ModPlatform::IndexedPack::Ptr p, const ModPlatform::IndexedVersion& v)
|
||||||
{
|
{
|
||||||
pack = p;
|
pack = p;
|
||||||
|
@ -34,7 +34,7 @@ enum class ResourceProvider { MODRINTH, FLAME };
|
|||||||
|
|
||||||
enum class ResourceType { MOD, RESOURCE_PACK, SHADER_PACK };
|
enum class ResourceType { MOD, RESOURCE_PACK, SHADER_PACK };
|
||||||
|
|
||||||
enum class DependencyType { REQUIRED, OPTIONAL, INCOMPATIBLE, EMBEDDED, TOOL, INCLUDE };
|
enum class DependencyType { REQUIRED, OPTIONAL, INCOMPATIBLE, EMBEDDED, TOOL, INCLUDE, UNKNOWN };
|
||||||
|
|
||||||
class ProviderCapabilities {
|
class ProviderCapabilities {
|
||||||
public:
|
public:
|
||||||
|
@ -115,14 +115,6 @@ class ResourceAPI {
|
|||||||
ModPlatform::Dependency dependency;
|
ModPlatform::Dependency dependency;
|
||||||
Version mcVersion;
|
Version mcVersion;
|
||||||
ModLoaderTypes loader;
|
ModLoaderTypes loader;
|
||||||
|
|
||||||
DependencySearchArgs(DependencySearchArgs const&) = default;
|
|
||||||
void operator=(DependencySearchArgs other)
|
|
||||||
{
|
|
||||||
dependency = other.dependency;
|
|
||||||
mcVersion = other.mcVersion;
|
|
||||||
loader = other.loader;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DependencySearchCallbacks {
|
struct DependencySearchCallbacks {
|
||||||
|
@ -160,6 +160,10 @@ auto FlameMod::loadIndexedPackVersion(QJsonObject& obj, bool load_changelog) ->
|
|||||||
case 6: // Include
|
case 6: // Include
|
||||||
dependency.type = ModPlatform::DependencyType::INCLUDE;
|
dependency.type = ModPlatform::DependencyType::INCLUDE;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
dependency.type = ModPlatform::DependencyType::UNKNOWN;
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
file.dependencies.append(dependency);
|
file.dependencies.append(dependency);
|
||||||
}
|
}
|
||||||
@ -172,7 +176,7 @@ auto FlameMod::loadIndexedPackVersion(QJsonObject& obj, bool load_changelog) ->
|
|||||||
|
|
||||||
ModPlatform::IndexedVersion FlameMod::loadDependencyVersions(const ModPlatform::Dependency& m, QJsonArray& arr)
|
ModPlatform::IndexedVersion FlameMod::loadDependencyVersions(const ModPlatform::Dependency& m, QJsonArray& arr)
|
||||||
{
|
{
|
||||||
QVector<ModPlatform::IndexedVersion> unsortedVersions;
|
QVector<ModPlatform::IndexedVersion> versions;
|
||||||
for (auto versionIter : arr) {
|
for (auto versionIter : arr) {
|
||||||
auto obj = versionIter.toObject();
|
auto obj = versionIter.toObject();
|
||||||
|
|
||||||
@ -181,13 +185,13 @@ ModPlatform::IndexedVersion FlameMod::loadDependencyVersions(const ModPlatform::
|
|||||||
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()) // Heuristic to check if the returned value is valid
|
||||||
unsortedVersions.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 {
|
||||||
// dates are in RFC 3339 format
|
// dates are in RFC 3339 format
|
||||||
return a.date > b.date;
|
return a.date > b.date;
|
||||||
};
|
};
|
||||||
std::sort(unsortedVersions.begin(), unsortedVersions.end(), orderSortPredicate);
|
std::sort(versions.begin(), versions.end(), orderSortPredicate);
|
||||||
return unsortedVersions.front();
|
return versions.front();
|
||||||
};
|
};
|
||||||
|
@ -156,6 +156,8 @@ auto Modrinth::loadIndexedPackVersion(QJsonObject& obj, QString preferred_hash_t
|
|||||||
dependency.type = ModPlatform::DependencyType::INCOMPATIBLE;
|
dependency.type = ModPlatform::DependencyType::INCOMPATIBLE;
|
||||||
else if (depType == "embedded")
|
else if (depType == "embedded")
|
||||||
dependency.type = ModPlatform::DependencyType::EMBEDDED;
|
dependency.type = ModPlatform::DependencyType::EMBEDDED;
|
||||||
|
else
|
||||||
|
dependency.type = ModPlatform::DependencyType::UNKNOWN;
|
||||||
|
|
||||||
file.dependencies.append(dependency);
|
file.dependencies.append(dependency);
|
||||||
}
|
}
|
||||||
@ -218,19 +220,19 @@ auto Modrinth::loadIndexedPackVersion(QJsonObject& obj, QString preferred_hash_t
|
|||||||
|
|
||||||
auto Modrinth::loadDependencyVersions(const ModPlatform::Dependency& m, QJsonArray& arr) -> ModPlatform::IndexedVersion
|
auto Modrinth::loadDependencyVersions(const ModPlatform::Dependency& m, QJsonArray& arr) -> ModPlatform::IndexedVersion
|
||||||
{
|
{
|
||||||
QVector<ModPlatform::IndexedVersion> unsortedVersions;
|
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()) // Heuristic to check if the returned value is valid
|
||||||
unsortedVersions.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 {
|
||||||
// dates are in RFC 3339 format
|
// dates are in RFC 3339 format
|
||||||
return a.date > b.date;
|
return a.date > b.date;
|
||||||
};
|
};
|
||||||
std::sort(unsortedVersions.begin(), unsortedVersions.end(), orderSortPredicate);
|
std::sort(versions.begin(), versions.end(), orderSortPredicate);
|
||||||
return unsortedVersions.length() != 0 ? unsortedVersions.front() : ModPlatform::IndexedVersion();
|
return versions.length() != 0 ? versions.front() : ModPlatform::IndexedVersion();
|
||||||
}
|
}
|
@ -125,7 +125,7 @@ void ResourceDownloadDialog::connectButtons()
|
|||||||
|
|
||||||
static ModPlatform::ProviderCapabilities ProviderCaps;
|
static ModPlatform::ProviderCapabilities ProviderCaps;
|
||||||
|
|
||||||
QStringList getReqiredBy(QList<ResourceDownloadDialog::DownloadTaskPtr> tasks, QVariant addonId)
|
QStringList getRequiredBy(QList<ResourceDownloadDialog::DownloadTaskPtr> tasks, QVariant addonId)
|
||||||
{
|
{
|
||||||
auto req = QStringList();
|
auto req = QStringList();
|
||||||
for (auto& task : tasks) {
|
for (auto& task : tasks) {
|
||||||
@ -167,10 +167,10 @@ void ResourceDownloadDialog::confirm()
|
|||||||
if (ret == QDialog::DialogCode::Rejected) {
|
if (ret == QDialog::DialogCode::Rejected) {
|
||||||
QMetaObject::invokeMethod(this, "reject", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(this, "reject", Qt::QueuedConnection);
|
||||||
return;
|
return;
|
||||||
} else
|
} else {
|
||||||
for (auto dep : task->getDependecies()) {
|
for (auto dep : task->getDependecies())
|
||||||
addResource(dep->pack, dep->version);
|
addResource(dep->pack, dep->version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto selected = getTasks();
|
auto selected = getTasks();
|
||||||
@ -179,7 +179,7 @@ void ResourceDownloadDialog::confirm()
|
|||||||
});
|
});
|
||||||
for (auto& task : selected) {
|
for (auto& task : selected) {
|
||||||
confirm_dialog->appendResource({ task->getName(), task->getFilename(), task->getCustomPath(),
|
confirm_dialog->appendResource({ task->getName(), task->getFilename(), task->getCustomPath(),
|
||||||
ProviderCaps.name(task->getProvider()), getReqiredBy(selected, task->getPack()->addonId) });
|
ProviderCaps.name(task->getProvider()), getRequiredBy(selected, task->getPack()->addonId) });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (confirm_dialog->exec()) {
|
if (confirm_dialog->exec()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user