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

Heroes switched to text id

This commit is contained in:
nordsoft 2023-09-28 00:00:32 +02:00
parent 0c94a4d891
commit 486091a915
5 changed files with 18 additions and 18 deletions

View File

@ -1035,8 +1035,8 @@ std::string CGHeroInstance::getNameTranslated() const
std::string CGHeroInstance::getNameTextID() const
{
if (!nameCustom.empty())
return nameCustom;
if (!nameCustomTextId.empty())
return nameCustomTextId;
if (type)
return type->getNameTextID();
@ -1052,8 +1052,8 @@ std::string CGHeroInstance::getBiographyTranslated() const
std::string CGHeroInstance::getBiographyTextID() const
{
if (!biographyCustom.empty())
return biographyCustom;
if (!biographyCustomTextId.empty())
return biographyCustomTextId;
if (type)
return type->getBiographyTextID();
@ -1515,7 +1515,7 @@ void CGHeroInstance::updateFrom(const JsonNode & data)
void CGHeroInstance::serializeCommonOptions(JsonSerializeFormat & handler)
{
handler.serializeString("biography", biographyCustom);
handler.serializeString("biography", biographyCustomTextId);
handler.serializeInt("experience", exp, 0);
if(!handler.saving && exp != UNINITIALIZED_EXPERIENCE) //do not gain levels if experience is not initialized
@ -1526,7 +1526,7 @@ void CGHeroInstance::serializeCommonOptions(JsonSerializeFormat & handler)
}
}
handler.serializeString("name", nameCustom);
handler.serializeString("name", nameCustomTextId);
handler.serializeInt("gender", gender, 0);
{

View File

@ -74,8 +74,8 @@ public:
std::vector<std::pair<SecondarySkill,ui8> > secSkills; //first - ID of skill, second - level of skill (1 - basic, 2 - adv., 3 - expert); if hero has ability (-1, -1) it meansthat it should have default secondary abilities
EHeroGender gender;
std::string nameCustom;
std::string biographyCustom;
std::string nameCustomTextId;
std::string biographyCustomTextId;
bool inTownGarrison; // if hero is in town garrison
ConstTransitivePtr<CGTownInstance> visitedTown; //set if hero is visiting town or in the town garrison
@ -319,8 +319,8 @@ public:
h & static_cast<CArtifactSet&>(*this);
h & exp;
h & level;
h & nameCustom;
h & biographyCustom;
h & nameCustomTextId;
h & biographyCustomTextId;
h & portrait;
h & mana;
h & secSkills;

View File

@ -860,7 +860,7 @@ void CMapLoaderH3M::readPredefinedHeroes()
bool hasCustomBio = reader->readBool();
if(hasCustomBio)
hero->biographyCustom = readLocalizedString(TextIdentifier("heroes", heroID, "biography"));
hero->biographyCustomTextId = readLocalizedString(TextIdentifier("heroes", heroID, "biography"));
// 0xFF is default, 00 male, 01 female
hero->gender = static_cast<EHeroGender>(reader->readUInt8());
@ -1685,7 +1685,7 @@ CGObjectInstance * CMapLoaderH3M::readHero(const int3 & mapPosition, const Objec
{
if(elem.heroId.getNum() == object->subID)
{
object->nameCustom = elem.name;
object->nameCustomTextId = elem.name;
object->portrait = elem.portrait;
break;
}
@ -1693,7 +1693,7 @@ CGObjectInstance * CMapLoaderH3M::readHero(const int3 & mapPosition, const Objec
bool hasName = reader->readBool();
if(hasName)
object->nameCustom = readLocalizedString(TextIdentifier("heroes", object->subID, "name"));
object->nameCustomTextId = readLocalizedString(TextIdentifier("heroes", object->subID, "name"));
if(features.levelSOD)
{
@ -1748,7 +1748,7 @@ CGObjectInstance * CMapLoaderH3M::readHero(const int3 & mapPosition, const Objec
{
bool hasCustomBiography = reader->readBool();
if(hasCustomBiography)
object->biographyCustom = readLocalizedString(TextIdentifier("heroes", object->subID, "biography"));
object->biographyCustomTextId = readLocalizedString(TextIdentifier("heroes", object->subID, "biography"));
object->gender = static_cast<EHeroGender>(reader->readUInt8());
assert(object->gender == EHeroGender::MALE || object->gender == EHeroGender::FEMALE || object->gender == EHeroGender::DEFAULT);

View File

@ -529,7 +529,7 @@ void CMapFormatJson::serializePlayerInfo(JsonSerializeFormat & handler)
if(hero)
{
auto heroData = handler.enterStruct(hero->instanceName);
heroData->serializeString("name", hero->nameCustom);
heroData->serializeString("name", hero->nameCustomTextId);
if(hero->ID == Obj::HERO)
{

View File

@ -277,8 +277,8 @@ void Inspector::updateProperties(CGHeroInstance * o)
delegate->options = {{"MALE", QVariant::fromValue(int(EHeroGender::MALE))}, {"FEMALE", QVariant::fromValue(int(EHeroGender::FEMALE))}};
addProperty<std::string>("Gender", (o->gender == EHeroGender::FEMALE ? "FEMALE" : "MALE"), delegate , false);
}
addProperty("Name", o->nameCustom, false);
addProperty("Biography", o->biographyCustom, new MessageDelegate, false);
addProperty("Name", o->nameCustomTextId, false);
addProperty("Biography", o->biographyCustomTextId, new MessageDelegate, false);
addProperty("Portrait", o->portrait, false);
auto * delegate = new HeroSkillsDelegate(*o);
@ -606,7 +606,7 @@ void Inspector::setProperty(CGHeroInstance * o, const QString & key, const QVari
o->gender = EHeroGender(value.toInt());
if(key == "Name")
o->nameCustom = value.toString().toStdString();
o->nameCustomTextId = value.toString().toStdString();
if(key == "Experience")
o->exp = value.toString().toInt();