1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-09-16 09:26:28 +02:00

Rename hero strings to text id

This commit is contained in:
nordsoft
2023-09-28 00:04:05 +02:00
parent 486091a915
commit 5b97c323d3
9 changed files with 14 additions and 14 deletions

View File

@@ -405,8 +405,8 @@ std::string OptionsTab::CPlayerSettingsHelper::getName()
return CGI->generaltexth->allTexts[522];
default:
{
if(!playerSettings.heroName.empty())
return playerSettings.heroName;
if(!playerSettings.heroNameTextId.empty())
return playerSettings.heroNameTextId;
auto index = playerSettings.hero.getNum() >= CGI->heroh->size() ? 0 : playerSettings.hero.getNum();
return (*CGI->heroh)[index]->getNameTranslated();
}
@@ -927,7 +927,7 @@ void OptionsTab::SelectionWindow::setElement(int elem, bool doApply)
if(!doApply)
{
CPlayerSettingsHelper helper = CPlayerSettingsHelper(set, SelType::HERO);
if(settings["general"]["enableUiEnhancements"].Bool() && helper.playerSettings.hero.getNum() > PlayerSettings::RANDOM && helper.playerSettings.heroName.empty())
if(settings["general"]["enableUiEnhancements"].Bool() && helper.playerSettings.hero.getNum() > PlayerSettings::RANDOM && helper.playerSettings.heroNameTextId.empty())
GH.windows().createAndPushWindow<CHeroOverview>(helper.playerSettings.hero);
else
GH.windows().createAndPushWindow<CPlayerOptionTooltipBox>(helper);
@@ -1013,7 +1013,7 @@ void OptionsTab::SelectedBox::showPopupWindow(const Point & cursorPosition)
if(playerSettings.hero.getNum() == PlayerSettings::NONE && !SEL->getPlayerInfo(playerSettings.color.getNum()).hasCustomMainHero() && CPlayerSettingsHelper::type == HERO)
return;
if(settings["general"]["enableUiEnhancements"].Bool() && CPlayerSettingsHelper::type == HERO && playerSettings.hero.getNum() > PlayerSettings::RANDOM && playerSettings.heroName.empty())
if(settings["general"]["enableUiEnhancements"].Bool() && CPlayerSettingsHelper::type == HERO && playerSettings.hero.getNum() > PlayerSettings::RANDOM && playerSettings.heroNameTextId.empty())
GH.windows().createAndPushWindow<CHeroOverview>(playerSettings.hero);
else
GH.windows().createAndPushWindow<CPlayerOptionTooltipBox>(*this);

View File

@@ -59,7 +59,7 @@ struct DLL_LINKAGE PlayerSettings
HeroTypeID hero;
HeroTypeID heroPortrait; //-1 if default, else ID
std::string heroName;
std::string heroNameTextId;
PlayerColor color; //from 0 -
enum EHandicap {NO_HANDICAP, MILD, SEVERE};
EHandicap handicap;//0-no, 1-mild, 2-severe
@@ -73,7 +73,7 @@ struct DLL_LINKAGE PlayerSettings
h & castle;
h & hero;
h & heroPortrait;
h & heroName;
h & heroNameTextId;
h & bonus;
h & color;
h & handicap;

View File

@@ -62,7 +62,7 @@ bool PlayerInfo::canAnyonePlay() const
bool PlayerInfo::hasCustomMainHero() const
{
return !mainCustomHeroName.empty() && mainCustomHeroPortrait != -1;
return !mainCustomHeroNameTextId.empty() && mainCustomHeroPortrait != -1;
}
EventCondition::EventCondition(EWinLoseType condition):

View File

@@ -63,7 +63,7 @@ struct DLL_LINKAGE PlayerInfo
bool hasRandomHero;
/// The default value is -1.
si32 mainCustomHeroPortrait;
std::string mainCustomHeroName;
std::string mainCustomHeroNameTextId;
/// ID of custom hero (only if portrait and hero name are set, otherwise unpredicted value), -1 if none (not always -1)
si32 mainCustomHeroId;
@@ -84,7 +84,7 @@ struct DLL_LINKAGE PlayerInfo
h & allowedFactions;
h & isFactionRandom;
h & mainCustomHeroPortrait;
h & mainCustomHeroName;
h & mainCustomHeroNameTextId;
h & heroesNames;
h & hasMainTown;
h & generateHeroAtMainTown;

View File

@@ -253,7 +253,7 @@ void CMapLoaderH3M::readPlayerInfo()
if(playerInfo.mainCustomHeroId != -1)
{
playerInfo.mainCustomHeroPortrait = reader->readHeroPortrait();
playerInfo.mainCustomHeroName = readLocalizedString(TextIdentifier("header", "player", i, "mainHeroName"));
playerInfo.mainCustomHeroNameTextId = readLocalizedString(TextIdentifier("header", "player", i, "mainHeroName"));
}
if(features.levelAB)

View File

@@ -571,7 +571,7 @@ void CMapFormatJson::serializePlayerInfo(JsonSerializeFormat & handler)
if(instanceName == info.mainHeroInstance)
{
//this is main hero
info.mainCustomHeroName = hname.heroName;
info.mainCustomHeroNameTextId = hname.heroName;
info.hasRandomHero = (hname.heroId == -1);
info.mainCustomHeroId = hname.heroId;
info.mainCustomHeroPortrait = -1;

View File

@@ -730,7 +730,7 @@ void CVCMIServer::updateStartInfoOnMapChange(std::shared_ptr<CMapInfo> mapInfo,
if(pset.hero.getNum() != PlayerSettings::RANDOM && pinfo.hasCustomMainHero())
{
pset.hero = pinfo.mainCustomHeroId;
pset.heroName = pinfo.mainCustomHeroName;
pset.heroNameTextId = pinfo.mainCustomHeroNameTextId;
pset.heroPortrait = pinfo.mainCustomHeroPortrait;
}

View File

@@ -170,7 +170,7 @@ public:
if(pset.hero.getNum() != PlayerSettings::RANDOM && pinfo.hasCustomMainHero())
{
pset.hero = pinfo.mainCustomHeroId;
pset.heroName = pinfo.mainCustomHeroName;
pset.heroNameTextId = pinfo.mainCustomHeroNameTextId;
pset.heroPortrait = pinfo.mainCustomHeroPortrait;
}

View File

@@ -76,7 +76,7 @@ void checkEqual(const PlayerInfo & actual, const PlayerInfo & expected)
VCMI_CHECK_FIELD_EQUAL(isFactionRandom);
VCMI_CHECK_FIELD_EQUAL(mainCustomHeroPortrait);
VCMI_CHECK_FIELD_EQUAL(mainCustomHeroName);
VCMI_CHECK_FIELD_EQUAL(mainCustomHeroNameTextId);
VCMI_CHECK_FIELD_EQUAL(mainCustomHeroId);