1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Fixed custom hero names text ID's

This commit is contained in:
Ivan Savenko 2023-02-24 13:40:06 +02:00
parent 190368e419
commit 8b3309b47d
5 changed files with 22 additions and 14 deletions

View File

@ -987,11 +987,13 @@ void CGHeroInstance::initExp(CRandomGenerator & rand)
std::string CGHeroInstance::nodeName() const
{
return "Hero " + getNameTextID();
return "Hero " + getNameTranslated();
}
std::string CGHeroInstance::getNameTranslated() const
{
if (!nameCustom.empty())
return nameCustom;
return VLC->generaltexth->translate(getNameTextID());
}
@ -1009,6 +1011,9 @@ std::string CGHeroInstance::getNameTextID() const
std::string CGHeroInstance::getBiographyTranslated() const
{
if (!biographyCustom.empty())
return biographyCustom;
return VLC->generaltexth->translate(getBiographyTextID());
}

View File

@ -151,11 +151,13 @@ public:
//////////////////////////////////////////////////////////////////////////
std::string getNameTranslated() const;
std::string getNameTextID() const;
std::string getBiographyTranslated() const;
std::string getNameTranslated() const;
private:
std::string getNameTextID() const;
std::string getBiographyTextID() const;
public:
bool hasSpellbook() const;
int maxSpellLevel() const;

View File

@ -234,7 +234,7 @@ void CQuest::getVisitText(MetaString &iwText, std::vector<Component> &components
//FIXME: portrait may not match hero, if custom portrait was set in map editor
components.emplace_back(Component::HERO_PORTRAIT, VLC->heroh->objects[m13489val]->imageIndex, 0, 0);
if(!isCustom)
iwText.addReplacement(VLC->heroh->objects[m13489val]->getNameTextID());
iwText.addReplacement(VLC->heroh->objects[m13489val]->getNameTranslated());
break;
case MISSION_KILL_CREATURE:
{
@ -373,7 +373,7 @@ void CQuest::getRolloverText(MetaString &ms, bool onHover) const
}
break;
case MISSION_HERO:
ms.addReplacement(VLC->heroh->objects[m13489val]->getNameTextID());
ms.addReplacement(VLC->heroh->objects[m13489val]->getNameTranslated());
break;
case MISSION_PLAYER:
ms.addReplacement(VLC->generaltexth->colors[m13489val]);
@ -456,7 +456,7 @@ void CQuest::getCompletionText(MetaString &iwText, std::vector<Component> &compo
break;
case MISSION_HERO:
if (!isCustomComplete)
iwText.addReplacement(VLC->heroh->objects[m13489val]->getNameTextID());
iwText.addReplacement(VLC->heroh->objects[m13489val]->getNameTranslated());
break;
case MISSION_PLAYER:
if (!isCustomComplete)

View File

@ -1615,7 +1615,7 @@ std::string CGShrine::getHoverText(PlayerColor player) const
if(wasVisited(player))
{
hoverName += "\n" + VLC->generaltexth->allTexts[355]; // + (learn %s)
boost::algorithm::replace_first(hoverName,"%s", spell.toSpell()->getNameTextID());
boost::algorithm::replace_first(hoverName,"%s", spell.toSpell()->getNameTranslated());
}
return hoverName;
}

View File

@ -637,7 +637,7 @@ void CGameHandler::changePrimSkill(const CGHeroInstance * hero, PrimarySkill::Pr
InfoWindow iw;
iw.player = hero->tempOwner;
iw.text.addTxt(MetaString::GENERAL_TXT, 1); //can gain no more XP
iw.text.addReplacement(hero->getNameTextID());
iw.text.addReplacement(hero->getNameTranslated());
sendAndApply(&iw);
}
}
@ -860,7 +860,7 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance * heroAttacker, con
InfoWindow iw;
iw.player = finishingBattle->winnerHero->tempOwner;
iw.text.addTxt(MetaString::GENERAL_TXT, 221); //Through eagle-eyed observation, %s is able to learn %s
iw.text.addReplacement(finishingBattle->winnerHero->getNameTextID());
iw.text.addReplacement(finishingBattle->winnerHero->getNameTranslated());
std::ostringstream names;
for (int i = 0; i < cs.spells.size(); i++)
@ -2826,7 +2826,7 @@ void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID t
iw.components.push_back(Component(Component::SEC_SKILL, 18, ScholarSkillLevel, 0));
iw.text.addTxt(MetaString::GENERAL_TXT, 139);//"%s, who has studied magic extensively,
iw.text.addReplacement(h1->getNameTextID());
iw.text.addReplacement(h1->getNameTranslated());
if (!cs2.spells.empty())//if found new spell - apply
{
@ -2844,7 +2844,7 @@ void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID t
}
}
iw.text.addTxt(MetaString::GENERAL_TXT, 142);//from %s
iw.text.addReplacement(h2->getNameTextID());
iw.text.addReplacement(h2->getNameTranslated());
sendAndApply(&cs2);
}
@ -2866,9 +2866,10 @@ void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID t
case 2: iw.text.addTxt(MetaString::GENERAL_TXT, 141);
case 1: break;
default: iw.text << ", ";
} }
}
}
iw.text.addTxt(MetaString::GENERAL_TXT, 148);//from %s
iw.text.addReplacement(h2->getNameTextID());
iw.text.addReplacement(h2->getNameTranslated());
sendAndApply(&cs1);
}
sendAndApply(&iw);