Updated required_by as dependency
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
8b14b946e2
commit
107b470289
@ -65,7 +65,7 @@ void GetModDependenciesTask::prepare()
|
|||||||
{
|
{
|
||||||
for (auto sel : m_selected) {
|
for (auto sel : m_selected) {
|
||||||
for (auto dep : getDependenciesForVersion(sel->version, sel->pack.provider)) {
|
for (auto dep : getDependenciesForVersion(sel->version, sel->pack.provider)) {
|
||||||
addTask(prepareDependencyTask(dep, sel->pack.provider, sel->pack.addonId, 20));
|
addTask(prepareDependencyTask(dep, sel->pack.provider, 20));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,8 +95,6 @@ QList<ModPlatform::Dependency> GetModDependenciesTask::getDependenciesForVersion
|
|||||||
});
|
});
|
||||||
dep == m_pack_dependencies.end()) { // check loaded dependencies
|
dep == m_pack_dependencies.end()) { // check loaded dependencies
|
||||||
c_dependencies.append(ver_dep);
|
c_dependencies.append(ver_dep);
|
||||||
} else { // already there just append the required_by
|
|
||||||
dep->get()->version.required_by.append(version.addonId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,13 +106,11 @@ QList<ModPlatform::Dependency> GetModDependenciesTask::getDependenciesForVersion
|
|||||||
|
|
||||||
Task::Ptr GetModDependenciesTask::prepareDependencyTask(const ModPlatform::Dependency& dep,
|
Task::Ptr GetModDependenciesTask::prepareDependencyTask(const ModPlatform::Dependency& dep,
|
||||||
const ModPlatform::ResourceProvider providerName,
|
const ModPlatform::ResourceProvider providerName,
|
||||||
QVariant required_by,
|
|
||||||
int level)
|
int level)
|
||||||
{
|
{
|
||||||
auto pDep = std::make_shared<PackDependency>();
|
auto pDep = std::make_shared<PackDependency>();
|
||||||
pDep->dependency = dep;
|
pDep->dependency = dep;
|
||||||
pDep->pack = { dep.addonId, providerName };
|
pDep->pack = { dep.addonId, providerName };
|
||||||
pDep->version.required_by.append(required_by);
|
|
||||||
m_pack_dependencies.append(pDep);
|
m_pack_dependencies.append(pDep);
|
||||||
auto provider = providerName == m_flame_provider.name ? m_flame_provider : m_modrinth_provider;
|
auto provider = providerName == m_flame_provider.name ? m_flame_provider : m_modrinth_provider;
|
||||||
|
|
||||||
@ -145,7 +141,7 @@ Task::Ptr GetModDependenciesTask::prepareDependencyTask(const ModPlatform::Depen
|
|||||||
ResourceAPI::DependencySearchArgs args = { dep, m_version, m_loaderType };
|
ResourceAPI::DependencySearchArgs args = { dep, m_version, m_loaderType };
|
||||||
ResourceAPI::DependencySearchCallbacks callbacks;
|
ResourceAPI::DependencySearchCallbacks callbacks;
|
||||||
|
|
||||||
callbacks.on_succeed = [dep, provider, pDep, level, required_by, this](auto& doc, auto& pack) {
|
callbacks.on_succeed = [dep, provider, pDep, level, this](auto& doc, auto& pack) {
|
||||||
try {
|
try {
|
||||||
QJsonArray arr;
|
QJsonArray arr;
|
||||||
if (dep.version.length() != 0 && doc.isObject()) {
|
if (dep.version.length() != 0 && doc.isObject()) {
|
||||||
@ -153,7 +149,6 @@ Task::Ptr GetModDependenciesTask::prepareDependencyTask(const ModPlatform::Depen
|
|||||||
} else {
|
} else {
|
||||||
arr = doc.isObject() ? Json::ensureArray(doc.object(), "data") : doc.array();
|
arr = doc.isObject() ? Json::ensureArray(doc.object(), "data") : doc.array();
|
||||||
}
|
}
|
||||||
auto required_by = pDep->version.required_by;
|
|
||||||
pDep->version = provider.mod->loadDependencyVersions(dep, arr);
|
pDep->version = provider.mod->loadDependencyVersions(dep, arr);
|
||||||
if (!pDep->version.addonId.isValid()) {
|
if (!pDep->version.addonId.isValid()) {
|
||||||
qWarning() << "Error while reading mod version empty ";
|
qWarning() << "Error while reading mod version empty ";
|
||||||
@ -161,7 +156,6 @@ Task::Ptr GetModDependenciesTask::prepareDependencyTask(const ModPlatform::Depen
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pDep->version.is_currently_selected = true;
|
pDep->version.is_currently_selected = true;
|
||||||
pDep->version.required_by = required_by;
|
|
||||||
pDep->pack.versions = { pDep->version };
|
pDep->pack.versions = { pDep->version };
|
||||||
pDep->pack.versionsLoaded = true;
|
pDep->pack.versionsLoaded = true;
|
||||||
|
|
||||||
@ -175,7 +169,7 @@ Task::Ptr GetModDependenciesTask::prepareDependencyTask(const ModPlatform::Depen
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (auto dep : getDependenciesForVersion(pDep->version, provider.name)) {
|
for (auto dep : getDependenciesForVersion(pDep->version, provider.name)) {
|
||||||
addTask(prepareDependencyTask(dep, provider.name, pDep->pack.addonId, level - 1));
|
addTask(prepareDependencyTask(dep, provider.name, level - 1));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ class GetModDependenciesTask : public SequentialTask {
|
|||||||
auto getDependecies() const -> QList<std::shared_ptr<PackDependency>> { return m_pack_dependencies; }
|
auto getDependecies() const -> QList<std::shared_ptr<PackDependency>> { return m_pack_dependencies; }
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
Task::Ptr prepareDependencyTask(const ModPlatform::Dependency&, const ModPlatform::ResourceProvider, QVariant, int);
|
Task::Ptr prepareDependencyTask(const ModPlatform::Dependency&, const ModPlatform::ResourceProvider, int);
|
||||||
QList<ModPlatform::Dependency> getDependenciesForVersion(const ModPlatform::IndexedVersion&,
|
QList<ModPlatform::Dependency> getDependenciesForVersion(const ModPlatform::IndexedVersion&,
|
||||||
const ModPlatform::ResourceProvider providerName);
|
const ModPlatform::ResourceProvider providerName);
|
||||||
void prepare();
|
void prepare();
|
||||||
|
@ -78,7 +78,6 @@ struct IndexedVersion {
|
|||||||
|
|
||||||
// For internal use, not provided by APIs
|
// For internal use, not provided by APIs
|
||||||
bool is_currently_selected = false;
|
bool is_currently_selected = false;
|
||||||
QList<QVariant> required_by;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ExtraPackData {
|
struct ExtraPackData {
|
||||||
|
@ -125,16 +125,17 @@ void ResourceDownloadDialog::connectButtons()
|
|||||||
|
|
||||||
static ModPlatform::ProviderCapabilities ProviderCaps;
|
static ModPlatform::ProviderCapabilities ProviderCaps;
|
||||||
|
|
||||||
QStringList getReqiredBy(QList<ResourceDownloadDialog::DownloadTaskPtr> tasks, QList<QVariant> req_by)
|
QStringList getReqiredBy(QList<ResourceDownloadDialog::DownloadTaskPtr> tasks, QVariant addonId)
|
||||||
{
|
{
|
||||||
auto req = QStringList();
|
auto req = QStringList();
|
||||||
for (auto r : req_by) {
|
for (auto& task : tasks) {
|
||||||
for (auto& task : tasks) {
|
auto deps = task->getVersion().dependencies;
|
||||||
auto selected = task->getPack();
|
if (auto dep = std::find_if(deps.begin(), deps.end(),
|
||||||
if (selected.addonId == r) {
|
[addonId](const ModPlatform::Dependency& d) {
|
||||||
req.append(selected.name);
|
return d.addonId == addonId && d.type == ModPlatform::DependencyType::REQUIRED;
|
||||||
break;
|
});
|
||||||
}
|
dep) {
|
||||||
|
req.append(task->getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return req;
|
return req;
|
||||||
@ -178,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->getVersion().required_by) });
|
ProviderCaps.name(task->getProvider()), getReqiredBy(selected, task->getPack().addonId) });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (confirm_dialog->exec()) {
|
if (confirm_dialog->exec()) {
|
||||||
|
@ -62,12 +62,17 @@ void ReviewMessageBox::appendResource(ResourceInformation&& info)
|
|||||||
|
|
||||||
if (!info.required_by.isEmpty()) {
|
if (!info.required_by.isEmpty()) {
|
||||||
auto requiredByItem = new QTreeWidgetItem(itemTop);
|
auto requiredByItem = new QTreeWidgetItem(itemTop);
|
||||||
QString req;
|
if (info.required_by.length() == 1) {
|
||||||
if (info.required_by.length() == 1)
|
requiredByItem->setText(0, tr("Required by: %1").arg(info.required_by.back()));
|
||||||
req = info.required_by.back();
|
} else {
|
||||||
else
|
requiredByItem->setText(0, tr("Required by:"));
|
||||||
req = QString("[%1]").arg(info.required_by.join(", "));
|
auto i = 0;
|
||||||
requiredByItem->setText(0, tr("Required by: %1").arg(req));
|
for (auto req : info.required_by) {
|
||||||
|
auto reqItem = new QTreeWidgetItem(requiredByItem);
|
||||||
|
reqItem->setText(0, req);
|
||||||
|
reqItem->insertChildren(i++, { reqItem });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
itemTop->insertChildren(childIndx++, { requiredByItem });
|
itemTop->insertChildren(childIndx++, { requiredByItem });
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user