disabled lax deps
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
4081c51573
commit
a4978946d5
@ -259,9 +259,9 @@ void GetModDependenciesTask::removePack(const QVariant addonId)
|
||||
#endif
|
||||
}
|
||||
|
||||
QHash<QString, QStringList> GetModDependenciesTask::getRequiredBy()
|
||||
auto GetModDependenciesTask::getExtraInfo() -> QHash<QString, PackDependencyExtraInfo>
|
||||
{
|
||||
QHash<QString, QStringList> rby;
|
||||
QHash<QString, PackDependencyExtraInfo> rby;
|
||||
auto fullList = m_selected + m_pack_dependencies;
|
||||
for (auto& mod : fullList) {
|
||||
auto addonId = mod->pack->addonId;
|
||||
@ -283,7 +283,7 @@ QHash<QString, QStringList> GetModDependenciesTask::getRequiredBy()
|
||||
req.append(smod->pack->name);
|
||||
}
|
||||
}
|
||||
rby[addonId.toString()] = req;
|
||||
rby[addonId.toString()] = { maybeInstalled(mod), req };
|
||||
}
|
||||
return rby;
|
||||
}
|
||||
@ -335,7 +335,7 @@ bool GetModDependenciesTask::isLocalyInstalled(std::shared_ptr<PackDependency> p
|
||||
}) != m_pack_dependencies.end(); // check loaded dependencies
|
||||
}
|
||||
|
||||
bool GetModDependenciesTask::isLaxInstalled(std::shared_ptr<PackDependency> pDep)
|
||||
bool GetModDependenciesTask::maybeInstalled(std::shared_ptr<PackDependency> pDep)
|
||||
{
|
||||
return std::find_if(m_mods_file_names.begin(), m_mods_file_names.end(), [pDep](QString i) {
|
||||
return !i.isEmpty() && laxCompare(i, pDep->version.fileName, true);
|
||||
|
@ -50,6 +50,11 @@ class GetModDependenciesTask : public SequentialTask {
|
||||
}
|
||||
};
|
||||
|
||||
struct PackDependencyExtraInfo {
|
||||
bool maybe_installed;
|
||||
QStringList required_by;
|
||||
};
|
||||
|
||||
struct Provider {
|
||||
ModPlatform::ResourceProvider name;
|
||||
std::shared_ptr<ResourceDownload::ModModel> mod;
|
||||
@ -62,7 +67,7 @@ class GetModDependenciesTask : public SequentialTask {
|
||||
QList<std::shared_ptr<PackDependency>> selected);
|
||||
|
||||
auto getDependecies() const -> QList<std::shared_ptr<PackDependency>> { return m_pack_dependencies; }
|
||||
QHash<QString, QStringList> getRequiredBy();
|
||||
QHash<QString, PackDependencyExtraInfo> getExtraInfo();
|
||||
|
||||
protected slots:
|
||||
Task::Ptr prepareDependencyTask(const ModPlatform::Dependency&, const ModPlatform::ResourceProvider, int);
|
||||
@ -74,7 +79,7 @@ class GetModDependenciesTask : public SequentialTask {
|
||||
void removePack(const QVariant addonId);
|
||||
|
||||
bool isLocalyInstalled(std::shared_ptr<PackDependency> pDep);
|
||||
bool isLaxInstalled(std::shared_ptr<PackDependency> pDep);
|
||||
bool maybeInstalled(std::shared_ptr<PackDependency> pDep);
|
||||
|
||||
private:
|
||||
QList<std::shared_ptr<PackDependency>> m_pack_dependencies;
|
||||
|
@ -28,6 +28,7 @@ class CheckUpdateTask : public Task {
|
||||
QString changelog;
|
||||
ModPlatform::ResourceProvider provider;
|
||||
shared_qobject_ptr<ResourceDownloadTask> download;
|
||||
bool enabled = true;
|
||||
|
||||
public:
|
||||
UpdatableMod(QString name,
|
||||
@ -37,7 +38,8 @@ class CheckUpdateTask : public Task {
|
||||
std::optional<ModPlatform::IndexedVersionType> new_v_type,
|
||||
QString changelog,
|
||||
ModPlatform::ResourceProvider p,
|
||||
shared_qobject_ptr<ResourceDownloadTask> t)
|
||||
shared_qobject_ptr<ResourceDownloadTask> t,
|
||||
bool enabled = true)
|
||||
: name(name)
|
||||
, old_hash(old_h)
|
||||
, old_version(old_v)
|
||||
@ -46,6 +48,7 @@ class CheckUpdateTask : public Task {
|
||||
, changelog(changelog)
|
||||
, provider(p)
|
||||
, download(t)
|
||||
, enabled(enabled)
|
||||
{}
|
||||
};
|
||||
|
||||
|
@ -212,19 +212,25 @@ void ModUpdateDialog::checkCandidates()
|
||||
}
|
||||
static FlameAPI api;
|
||||
|
||||
auto getRequiredBy = depTask->getRequiredBy();
|
||||
auto dependencyExtraInfo = depTask->getExtraInfo();
|
||||
|
||||
for (auto dep : depTask->getDependecies()) {
|
||||
auto changelog = dep->version.changelog;
|
||||
if (dep->pack->provider == ModPlatform::ResourceProvider::FLAME)
|
||||
changelog = api.getModFileChangelog(dep->version.addonId.toInt(), dep->version.fileId.toInt());
|
||||
auto download_task = makeShared<ResourceDownloadTask>(dep->pack, dep->version, m_mod_model);
|
||||
CheckUpdateTask::UpdatableMod updatable = {
|
||||
dep->pack->name, dep->version.hash, "", dep->version.version, dep->version.version_type,
|
||||
changelog, dep->pack->provider, download_task
|
||||
};
|
||||
auto extraInfo = dependencyExtraInfo.value(dep->version.addonId.toString());
|
||||
CheckUpdateTask::UpdatableMod updatable = { dep->pack->name,
|
||||
dep->version.hash,
|
||||
"",
|
||||
dep->version.version,
|
||||
dep->version.version_type,
|
||||
changelog,
|
||||
dep->pack->provider,
|
||||
download_task,
|
||||
!extraInfo.maybe_installed };
|
||||
|
||||
appendMod(updatable, getRequiredBy.value(dep->version.addonId.toString()));
|
||||
appendMod(updatable, extraInfo.required_by);
|
||||
m_tasks.insert(updatable.name, updatable.download);
|
||||
}
|
||||
}
|
||||
@ -404,7 +410,10 @@ void ModUpdateDialog::onMetadataFailed(Mod* mod, bool try_others, ModPlatform::R
|
||||
void ModUpdateDialog::appendMod(CheckUpdateTask::UpdatableMod const& info, QStringList requiredBy)
|
||||
{
|
||||
auto item_top = new QTreeWidgetItem(ui->modTreeWidget);
|
||||
item_top->setCheckState(0, Qt::CheckState::Checked);
|
||||
item_top->setCheckState(0, info.enabled ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
|
||||
if (!info.enabled) {
|
||||
item_top->setToolTip(0, tr("Mod was disabled as it may be already instaled."));
|
||||
}
|
||||
item_top->setText(0, info.name);
|
||||
item_top->setExpanded(true);
|
||||
|
||||
|
@ -132,7 +132,7 @@ void ResourceDownloadDialog::confirm()
|
||||
auto confirm_dialog = ReviewMessageBox::create(this, tr("Confirm %1 to download").arg(resourcesString()));
|
||||
confirm_dialog->retranslateUi(resourcesString());
|
||||
|
||||
QHash<QString, QStringList> getRequiredBy;
|
||||
QHash<QString, GetModDependenciesTask::PackDependencyExtraInfo> dependencyExtraInfo;
|
||||
if (auto task = getModDependenciesTask(); task) {
|
||||
connect(task.get(), &Task::failed, this,
|
||||
[&](QString reason) { CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->exec(); });
|
||||
@ -157,7 +157,7 @@ void ResourceDownloadDialog::confirm()
|
||||
} else {
|
||||
for (auto dep : task->getDependecies())
|
||||
addResource(dep->pack, dep->version);
|
||||
getRequiredBy = task->getRequiredBy();
|
||||
dependencyExtraInfo = task->getExtraInfo();
|
||||
}
|
||||
}
|
||||
|
||||
@ -166,9 +166,10 @@ void ResourceDownloadDialog::confirm()
|
||||
return QString::compare(a->getName(), b->getName(), Qt::CaseInsensitive) < 0;
|
||||
});
|
||||
for (auto& task : selected) {
|
||||
auto extraInfo = dependencyExtraInfo.value(task->getPack()->addonId.toString());
|
||||
confirm_dialog->appendResource({ task->getName(), task->getFilename(), task->getCustomPath(),
|
||||
ProviderCaps.name(task->getProvider()), getRequiredBy.value(task->getPack()->addonId.toString()),
|
||||
task->getVersion().version_type.toString() });
|
||||
ProviderCaps.name(task->getProvider()), extraInfo.required_by,
|
||||
task->getVersion().version_type.toString(), !extraInfo.maybe_installed });
|
||||
}
|
||||
|
||||
if (confirm_dialog->exec()) {
|
||||
|
@ -34,8 +34,11 @@ auto ReviewMessageBox::create(QWidget* parent, QString&& title, QString&& icon)
|
||||
void ReviewMessageBox::appendResource(ResourceInformation&& info)
|
||||
{
|
||||
auto itemTop = new QTreeWidgetItem(ui->modTreeWidget);
|
||||
itemTop->setCheckState(0, Qt::CheckState::Checked);
|
||||
itemTop->setCheckState(0, info.enabled ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
|
||||
itemTop->setText(0, info.name);
|
||||
if (!info.enabled) {
|
||||
itemTop->setToolTip(0, tr("Mod was disabled as it may be already instaled."));
|
||||
}
|
||||
|
||||
auto filenameItem = new QTreeWidgetItem(itemTop);
|
||||
filenameItem->setText(0, tr("Filename: %1").arg(info.filename));
|
||||
|
@ -19,6 +19,7 @@ class ReviewMessageBox : public QDialog {
|
||||
QString provider;
|
||||
QStringList required_by;
|
||||
QString version_type;
|
||||
bool enabled = true;
|
||||
};
|
||||
|
||||
void appendResource(ResourceInformation&& info);
|
||||
|
Loading…
Reference in New Issue
Block a user