From 9bf7106905681fd56a4e14e438935c909269655c Mon Sep 17 00:00:00 2001 From: nordsoft Date: Thu, 29 Sep 2022 18:21:29 +0400 Subject: [PATCH] Add compatibility info --- launcher/modManager/cmodlist.cpp | 3 --- launcher/modManager/cmodlistview_moc.cpp | 30 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/launcher/modManager/cmodlist.cpp b/launcher/modManager/cmodlist.cpp index b54c697ed..79a9ced39 100644 --- a/launcher/modManager/cmodlist.cpp +++ b/launcher/modManager/cmodlist.cpp @@ -118,9 +118,6 @@ bool CModEntry::isUpdateable() const bool CModEntry::isCompatible() const { - if(!isInstalled()) - return false; - auto compatibility = localData["compatibility"].toMap(); return ::isCompatible(compatibility["min"].toString(), compatibility["max"].toString()); } diff --git a/launcher/modManager/cmodlistview_moc.cpp b/launcher/modManager/cmodlistview_moc.cpp index 8a3aee237..5fe477894 100644 --- a/launcher/modManager/cmodlistview_moc.cpp +++ b/launcher/modManager/cmodlistview_moc.cpp @@ -207,11 +207,15 @@ QString CModListView::genChangelogText(CModEntry & mod) QString CModListView::genModInfoText(CModEntry & mod) { QString prefix = "

%1: "; // shared prefix + QString redPrefix = "

%1: "; // shared prefix QString lineTemplate = prefix + "%2

"; QString urlTemplate = prefix + "%3

"; QString textTemplate = prefix + "

%2

"; QString listTemplate = "

%1: %2

"; QString noteTemplate = "

%1

"; + QString compatibleString = prefix + "Mod is compatible

"; + QString incompatibleString = redPrefix + "Mod is incompatible

"; + QString supportedVersions = redPrefix + "%2 %3 %4

"; QString result; @@ -229,6 +233,32 @@ QString CModListView::genModInfoText(CModEntry & mod) if(mod.getValue("contact").isValid()) result += urlTemplate.arg(tr("Home")).arg(mod.getValue("contact").toString()).arg(mod.getValue("contact").toString()); + //compatibility info + if(mod.isCompatible()) + result += compatibleString.arg(tr("Compatibility")); + else + { + auto compatibilityInfo = mod.getValue("compatibility").toMap(); + auto minStr = compatibilityInfo.value("min").toString(); + auto maxStr = compatibilityInfo.value("max").toString(); + + result += incompatibleString.arg(tr("Compatibility")); + if(minStr == maxStr) + result += supportedVersions.arg(tr("Required VCMI version"), minStr, "", ""); + else + { + if(minStr.isEmpty() || maxStr.isEmpty()) + { + if(minStr.isEmpty()) + result += supportedVersions.arg(tr("Supported VCMI version"), maxStr, ", ", "please upgrade mod"); + else + result += supportedVersions.arg(tr("Required VCMI version"), minStr, " ", "or above"); + } + else + result += supportedVersions.arg(tr("Supported VCMI versions"), minStr, " - ", maxStr); + } + } + 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")));