1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-21 17:17:06 +02:00

Merge pull request #4906 from MichalZr6/hill_fort_fixes

Omit unnecessary string registration for HillFort and fix popup window crash for miniHillFort
This commit is contained in:
Ivan Savenko 2024-11-19 13:02:35 +02:00 committed by GitHub
commit 55f437332b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 13 additions and 4 deletions

View File

@ -18,7 +18,9 @@ VCMI_LIB_NAMESPACE_BEGIN
void HillFortInstanceConstructor::initTypeData(const JsonNode & config)
{
parameters = config;
VLC->generaltexth->registerString(parameters.getModScope(), TextIdentifier(getBaseTextID(), "unavailableUpgradeMessage"), parameters["unavailableUpgradeMessage"].String());
if(!parameters["unavailableUpgradeMessage"].isNull())
VLC->generaltexth->registerString(parameters.getModScope(), TextIdentifier(getBaseTextID(), "unavailableUpgradeMessage"), parameters["unavailableUpgradeMessage"].String());
VLC->generaltexth->registerString(parameters.getModScope(), TextIdentifier(getBaseTextID(), "description"), parameters["description"].String());
}

View File

@ -1337,7 +1337,7 @@ std::string HillFort::getPopupText(PlayerColor player) const
{
MetaString message = MetaString::createFromRawString("{%s}\r\n\r\n%s");
message.replaceName(ID);
message.replaceName(ID, subID);
message.replaceTextID(getDescriptionToolTip());
return message.toString();
@ -1356,6 +1356,7 @@ std::string HillFort::getDescriptionToolTip() const
std::string HillFort::getUnavailableUpgradeMessage() const
{
assert(getObjectHandler()->getModScope() != "core");
return TextIdentifier(getObjectHandler()->getBaseTextID(), "unavailableUpgradeMessage").get();
}

View File

@ -393,11 +393,16 @@ void MetaString::replaceName(const FactionID & id)
replaceTextID(id.toEntity(VLC)->getNameTextID());
}
void MetaString::replaceName(const MapObjectID& id)
void MetaString::replaceName(const MapObjectID & id)
{
replaceTextID(VLC->objtypeh->getObjectName(id, 0));
}
void MetaString::replaceName(const MapObjectID & id, const MapObjectSubID & subId)
{
replaceTextID(VLC->objtypeh->getObjectName(id, subId));
}
void MetaString::replaceName(const PlayerColor & id)
{
replaceTextID(TextIdentifier("vcmi.capitalColors", id.getNum()).get());

View File

@ -99,7 +99,8 @@ public:
void replaceName(const ArtifactID & id);
void replaceName(const FactionID& id);
void replaceName(const MapObjectID& id);
void replaceName(const MapObjectID & id);
void replaceName(const MapObjectID & id, const MapObjectSubID & subId);
void replaceName(const PlayerColor& id);
void replaceName(const SecondarySkill& id);
void replaceName(const SpellID& id);