mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-03 14:52:11 +02:00
Implemented missing mod description fields
This commit is contained in:
parent
75a1a0938f
commit
f72fb53117
@ -314,8 +314,13 @@ QString CModListView::genModInfoText(const ModState & mod)
|
|||||||
QString result;
|
QString result;
|
||||||
|
|
||||||
result += replaceIfNotEmpty(mod.getName(), lineTemplate.arg(tr("Mod name")));
|
result += replaceIfNotEmpty(mod.getName(), lineTemplate.arg(tr("Mod name")));
|
||||||
result += replaceIfNotEmpty(mod.getInstalledVersion(), lineTemplate.arg(tr("Installed version")));
|
if (mod.isUpdateAvailable())
|
||||||
result += replaceIfNotEmpty(mod.getRepositoryVersion(), lineTemplate.arg(tr("Latest version")));
|
{
|
||||||
|
result += replaceIfNotEmpty(mod.getInstalledVersion(), lineTemplate.arg(tr("Installed version")));
|
||||||
|
result += replaceIfNotEmpty(mod.getRepositoryVersion(), lineTemplate.arg(tr("Latest version")));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
result += replaceIfNotEmpty(mod.getVersion(), lineTemplate.arg(tr("Version")));
|
||||||
|
|
||||||
if(!mod.getLocalSizeFormatted().isEmpty())
|
if(!mod.getLocalSizeFormatted().isEmpty())
|
||||||
result += replaceIfNotEmpty(mod.getLocalSizeFormatted(), lineTemplate.arg(tr("Size")));
|
result += replaceIfNotEmpty(mod.getLocalSizeFormatted(), lineTemplate.arg(tr("Size")));
|
||||||
@ -416,6 +421,8 @@ void CModListView::dataChanged(const QModelIndex & topleft, const QModelIndex &
|
|||||||
|
|
||||||
void CModListView::selectMod(const QModelIndex & index)
|
void CModListView::selectMod(const QModelIndex & index)
|
||||||
{
|
{
|
||||||
|
ui->tabWidget->setCurrentIndex(0);
|
||||||
|
|
||||||
if(!index.isValid())
|
if(!index.isValid())
|
||||||
{
|
{
|
||||||
disableModInfo();
|
disableModInfo();
|
||||||
@ -425,6 +432,9 @@ void CModListView::selectMod(const QModelIndex & index)
|
|||||||
const auto modName = index.data(ModRoles::ModNameRole).toString();
|
const auto modName = index.data(ModRoles::ModNameRole).toString();
|
||||||
auto mod = modStateModel->getMod(modName);
|
auto mod = modStateModel->getMod(modName);
|
||||||
|
|
||||||
|
ui->tabWidget->setTabEnabled(1, !mod.getChangelog().isEmpty());
|
||||||
|
ui->tabWidget->setTabEnabled(2, !mod.getScreenshots().isEmpty());
|
||||||
|
|
||||||
ui->modInfoBrowser->setHtml(genModInfoText(mod));
|
ui->modInfoBrowser->setHtml(genModInfoText(mod));
|
||||||
ui->changelogBrowser->setHtml(genChangelogText(mod));
|
ui->changelogBrowser->setHtml(genChangelogText(mod));
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "../../lib/modding/ModDescription.h"
|
#include "../../lib/modding/ModDescription.h"
|
||||||
#include "../../lib/json/JsonNode.h"
|
#include "../../lib/json/JsonNode.h"
|
||||||
#include "../../lib/texts/CGeneralTextHandler.h"
|
#include "../../lib/texts/CGeneralTextHandler.h"
|
||||||
|
#include "../../lib/texts/Languages.h"
|
||||||
|
|
||||||
ModState::ModState(const ModDescription & impl)
|
ModState::ModState(const ModDescription & impl)
|
||||||
: impl(impl)
|
: impl(impl)
|
||||||
@ -70,7 +71,7 @@ QStringList ModState::getConflicts() const
|
|||||||
|
|
||||||
QStringList ModState::getScreenshots() const
|
QStringList ModState::getScreenshots() const
|
||||||
{
|
{
|
||||||
return {}; // TODO
|
return stringListStdToQt(impl.getValue("screenshots").convertTo<std::vector<std::string>>());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ModState::getBaseLanguage() const
|
QString ModState::getBaseLanguage() const
|
||||||
@ -80,12 +81,33 @@ QString ModState::getBaseLanguage() const
|
|||||||
|
|
||||||
QStringList ModState::getSupportedLanguages() const
|
QStringList ModState::getSupportedLanguages() const
|
||||||
{
|
{
|
||||||
return {}; //TODO
|
QStringList result;
|
||||||
|
result.push_back(getBaseLanguage());
|
||||||
|
|
||||||
|
for (const auto & language : Languages::getLanguageList())
|
||||||
|
{
|
||||||
|
QString languageID = QString::fromStdString(language.identifier);
|
||||||
|
|
||||||
|
if (languageID != getBaseLanguage() && !impl.getValue(language.identifier).isNull())
|
||||||
|
result.push_back(languageID);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QString, QStringList> ModState::getChangelog() const
|
QMap<QString, QStringList> ModState::getChangelog() const
|
||||||
{
|
{
|
||||||
return {}; //TODO
|
QMap<QString, QStringList> result;
|
||||||
|
const JsonNode & changelog = impl.getValue("changelog");
|
||||||
|
|
||||||
|
for (const auto & entry : changelog.Struct())
|
||||||
|
{
|
||||||
|
QString version = QString::fromStdString(entry.first);
|
||||||
|
QStringList changes = stringListStdToQt(entry.second.convertTo<std::vector<std::string>>());
|
||||||
|
|
||||||
|
result[version] = changes;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ModState::getInstalledVersion() const
|
QString ModState::getInstalledVersion() const
|
||||||
@ -98,6 +120,11 @@ QString ModState::getRepositoryVersion() const
|
|||||||
return QString::fromStdString(impl.getRepositoryValue("version").String());
|
return QString::fromStdString(impl.getRepositoryValue("version").String());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ModState::getVersion() const
|
||||||
|
{
|
||||||
|
return QString::fromStdString(impl.getValue("version").String());
|
||||||
|
}
|
||||||
|
|
||||||
double ModState::getDownloadSizeMegabytes() const
|
double ModState::getDownloadSizeMegabytes() const
|
||||||
{
|
{
|
||||||
return impl.getRepositoryValue("downloadSize").Float();
|
return impl.getRepositoryValue("downloadSize").Float();
|
||||||
@ -110,7 +137,7 @@ size_t ModState::getDownloadSizeBytes() const
|
|||||||
|
|
||||||
QString ModState::getDownloadSizeFormatted() const
|
QString ModState::getDownloadSizeFormatted() const
|
||||||
{
|
{
|
||||||
return {}; // TODO
|
return QCoreApplication::translate("File size", "%1 MiB").arg(QString::number(getDownloadSizeMegabytes(), 'f', 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ModState::getLocalSizeFormatted() const
|
QString ModState::getLocalSizeFormatted() const
|
||||||
@ -145,7 +172,14 @@ QString ModState::getDownloadUrl() const
|
|||||||
|
|
||||||
QPair<QString, QString> ModState::getCompatibleVersionRange() const
|
QPair<QString, QString> ModState::getCompatibleVersionRange() const
|
||||||
{
|
{
|
||||||
return {}; // TODO
|
const JsonNode & compatibility = impl.getValue("compatibility");
|
||||||
|
|
||||||
|
if (compatibility.isNull())
|
||||||
|
return {};
|
||||||
|
|
||||||
|
auto min = QString::fromStdString(compatibility["min"].String());
|
||||||
|
auto max = QString::fromStdString(compatibility["max"].String());
|
||||||
|
return { min, max};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModState::isSubmod() const
|
bool ModState::isSubmod() const
|
||||||
@ -203,7 +237,7 @@ bool ModState::isUpdateAvailable() const
|
|||||||
|
|
||||||
bool ModState::isCompatible() const
|
bool ModState::isCompatible() const
|
||||||
{
|
{
|
||||||
return true; //TODO
|
return impl.isCompatible();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModState::isKeptDisabled() const
|
bool ModState::isKeptDisabled() const
|
||||||
|
@ -41,6 +41,7 @@ public:
|
|||||||
|
|
||||||
QString getInstalledVersion() const;
|
QString getInstalledVersion() const;
|
||||||
QString getRepositoryVersion() const;
|
QString getRepositoryVersion() const;
|
||||||
|
QString getVersion() const;
|
||||||
|
|
||||||
double getDownloadSizeMegabytes() const;
|
double getDownloadSizeMegabytes() const;
|
||||||
size_t getDownloadSizeBytes() const;
|
size_t getDownloadSizeBytes() const;
|
||||||
|
@ -126,6 +126,23 @@ ModVerificationInfo ModDescription::getVerificationInfo() const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ModDescription::isCompatible() const
|
||||||
|
{
|
||||||
|
const JsonNode & compatibility = getValue("compatibility");
|
||||||
|
|
||||||
|
if (compatibility.isNull())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
auto vcmiCompatibleMin = CModVersion::fromString(compatibility["min"].String());
|
||||||
|
auto vcmiCompatibleMax = CModVersion::fromString(compatibility["max"].String());
|
||||||
|
|
||||||
|
bool compatible = true;
|
||||||
|
compatible &= (vcmiCompatibleMin.isNull() || CModVersion::GameVersion().compatible(vcmiCompatibleMin, true, true));
|
||||||
|
compatible &= (vcmiCompatibleMax.isNull() || vcmiCompatibleMax.compatible(CModVersion::GameVersion(), true, true));
|
||||||
|
|
||||||
|
return compatible;
|
||||||
|
}
|
||||||
|
|
||||||
bool ModDescription::isCompatibility() const
|
bool ModDescription::isCompatibility() const
|
||||||
{
|
{
|
||||||
return getValue("modType").String() == "Compatibility";
|
return getValue("modType").String() == "Compatibility";
|
||||||
|
@ -55,6 +55,8 @@ public:
|
|||||||
CModVersion getVersion() const;
|
CModVersion getVersion() const;
|
||||||
ModVerificationInfo getVerificationInfo() const;
|
ModVerificationInfo getVerificationInfo() const;
|
||||||
|
|
||||||
|
bool isCompatible() const;
|
||||||
|
|
||||||
bool affectsGameplay() const;
|
bool affectsGameplay() const;
|
||||||
bool isCompatibility() const;
|
bool isCompatibility() const;
|
||||||
bool isTranslation() const;
|
bool isTranslation() const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user