From efed2991f2215e8302dedae31eac1e501dfc5a40 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Mon, 27 Mar 2023 00:32:24 +0300 Subject: [PATCH] Show human-readable mod names for list of dependencies --- launcher/modManager/cmodlistview_moc.cpp | 33 +++++++++++++++++++----- launcher/modManager/cmodlistview_moc.h | 3 +++ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/launcher/modManager/cmodlistview_moc.cpp b/launcher/modManager/cmodlistview_moc.cpp index 144d0e9ea..cacf05ec2 100644 --- a/launcher/modManager/cmodlistview_moc.cpp +++ b/launcher/modManager/cmodlistview_moc.cpp @@ -213,6 +213,25 @@ QString CModListView::genChangelogText(CModEntry & mod) return result; } +QStringList CModListView::getModNames(QStringList input) +{ + QStringList result; + + for (auto const & modID : input) + { + auto mod = modModel->getMod(modID); + + QString modName = mod.getValue("name").toString(); + + if (modName.isEmpty()) + result += modID; + else + result += modName; + } + + return result; +} + QString CModListView::genModInfoText(CModEntry & mod) { QString prefix = "

%1: "; // shared prefix @@ -290,9 +309,9 @@ QString CModListView::genModInfoText(CModEntry & mod) if(needToShowSupportedLanguages) result += replaceIfNotEmpty(supportedLanguages, lineTemplate.arg(tr("Languages"))); - result += replaceIfNotEmpty(mod.getValue("depends"), lineTemplate.arg(tr("Required mods"))); - result += replaceIfNotEmpty(mod.getValue("conflicts"), lineTemplate.arg(tr("Conflicting mods"))); - result += replaceIfNotEmpty(mod.getValue("description"), textTemplate.arg(tr("Description"))); + result += replaceIfNotEmpty(getModNames(mod.getValue("depends").toStringList()), lineTemplate.arg(tr("Required mods"))); + result += replaceIfNotEmpty(getModNames(mod.getValue("conflicts").toStringList()), lineTemplate.arg(tr("Conflicting mods"))); + result += replaceIfNotEmpty(getModNames(mod.getValue("description").toStringList()), textTemplate.arg(tr("Description"))); result += "

"; // to get some empty space @@ -304,12 +323,12 @@ QString CModListView::genModInfoText(CModEntry & mod) QString notes; - notes += replaceIfNotEmpty(findInvalidDependencies(mod.getName()), listTemplate.arg(unknownDeps)); - notes += replaceIfNotEmpty(findBlockingMods(mod.getName()), listTemplate.arg(blockingMods)); + notes += replaceIfNotEmpty(getModNames(findInvalidDependencies(mod.getName())), listTemplate.arg(unknownDeps)); + notes += replaceIfNotEmpty(getModNames(findBlockingMods(mod.getName())), listTemplate.arg(blockingMods)); if(mod.isEnabled()) - notes += replaceIfNotEmpty(findDependentMods(mod.getName(), true), listTemplate.arg(hasActiveDependentMods)); + notes += replaceIfNotEmpty(getModNames(findDependentMods(mod.getName(), true)), listTemplate.arg(hasActiveDependentMods)); if(mod.isInstalled()) - notes += replaceIfNotEmpty(findDependentMods(mod.getName(), false), listTemplate.arg(hasDependentMods)); + notes += replaceIfNotEmpty(getModNames(findDependentMods(mod.getName(), false)), listTemplate.arg(hasDependentMods)); if(mod.getName().contains('.')) notes += noteTemplate.arg(thisIsSubmod); diff --git a/launcher/modManager/cmodlistview_moc.h b/launcher/modManager/cmodlistview_moc.h index 985762ab8..7b3b0f3dc 100644 --- a/launcher/modManager/cmodlistview_moc.h +++ b/launcher/modManager/cmodlistview_moc.h @@ -47,6 +47,9 @@ class CModListView : public QWidget void checkManagerErrors(); + /// replace mod ID's with proper human-readable mod names + QStringList getModNames(QStringList input); + // find mods unknown to mod list (not present in repo and not installed) QStringList findInvalidDependencies(QString mod); // find mods that block enabling of this mod: conflicting with this mod or one of required mods