1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-17 00:07:41 +02:00

Restored mod uninstall functionality, restored translatable mod fields,

added more fields to translatable list
This commit is contained in:
Ivan Savenko
2024-11-15 11:54:43 +00:00
parent 2fcda48c65
commit 30ed066cea
8 changed files with 56 additions and 15 deletions

View File

@ -14,6 +14,7 @@
#include "ModVerificationInfo.h"
#include "../json/JsonNode.h"
#include "../texts/CGeneralTextHandler.h"
VCMI_LIB_NAMESPACE_BEGIN
@ -57,6 +58,16 @@ TModID ModDescription::getParentID() const
return identifier.substr(0, dotPos);
}
TModID ModDescription::getTopParentID() const
{
size_t dotPos = identifier.find('.');
if(dotPos == std::string::npos)
return {};
return identifier.substr(0, dotPos);
}
const TModSet & ModDescription::getDependencies() const
{
return dependencies;
@ -81,7 +92,7 @@ const std::string & ModDescription::getBaseLanguage() const
const std::string & ModDescription::getName() const
{
return getValue("name").String();
return getLocalizedValue("name").String();
}
const JsonNode & ModDescription::getFilesystemConfig() const
@ -94,6 +105,19 @@ const JsonNode & ModDescription::getLocalConfig() const
return *localConfig;
}
const JsonNode & ModDescription::getLocalizedValue(const std::string & keyName) const
{
const std::string language = CGeneralTextHandler::getPreferredLanguage();
const JsonNode & languageNode = getValue(language);
const JsonNode & baseValue = getValue(keyName);
const JsonNode & localizedValue = languageNode[keyName];
if (localizedValue.isNull())
return baseValue;
else
return localizedValue;
}
const JsonNode & ModDescription::getValue(const std::string & keyName) const
{
const JsonNode & localValue = getLocalValue(keyName);