Browse Source

GenerateMagicItemName make translation configurable

pull/5745/head^2
obligaron 3 years ago committed by Anders Jenbo
parent
commit
8c49524aa3
  1. 18
      Source/items.cpp

18
Source/items.cpp

@ -1154,17 +1154,17 @@ void GetStaffPower(const Player &player, Item &item, int lvl, SpellID bs, bool o
CalcItemValue(item);
}
std::string GenerateMagicItemName(const string_view &baseNamel, const PLStruct *pPrefix, const PLStruct *pSufix)
std::string GenerateMagicItemName(const string_view &baseNamel, const PLStruct *pPrefix, const PLStruct *pSufix, bool translate)
{
if (pPrefix != nullptr && pSufix != nullptr) {
string_view fmt = _(/* TRANSLATORS: Constructs item names. Format: {Prefix} {Item} of {Suffix}. Example: King's Long Sword of the Whale */ "{0} {1} of {2}");
return fmt::format(fmt::runtime(fmt), _(pPrefix->PLName), baseNamel, _(pSufix->PLName));
string_view fmt = translate ? _(/* TRANSLATORS: Constructs item names. Format: {Prefix} {Item} of {Suffix}. Example: King's Long Sword of the Whale */ "{0} {1} of {2}") : "{0} {1} of {2}";
return fmt::format(fmt::runtime(fmt), translate ? _(pPrefix->PLName) : pPrefix->PLName, baseNamel, translate ? _(pSufix->PLName) : pSufix->PLName);
} else if (pPrefix != nullptr) {
string_view fmt = _(/* TRANSLATORS: Constructs item names. Format: {Prefix} {Item}. Example: King's Long Sword */ "{0} {1}");
return fmt::format(fmt::runtime(fmt), _(pPrefix->PLName), baseNamel);
string_view fmt = translate ? _(/* TRANSLATORS: Constructs item names. Format: {Prefix} {Item}. Example: King's Long Sword */ "{0} {1}") : "{0} {1}";
return fmt::format(fmt::runtime(fmt), translate ? _(pPrefix->PLName) : pPrefix->PLName, baseNamel);
} else if (pSufix != nullptr) {
string_view fmt = _(/* TRANSLATORS: Constructs item names. Format: {Item} of {Suffix}. Example: Long Sword of the Whale */ "{0} of {1}");
return fmt::format(fmt::runtime(fmt), baseNamel, _(pSufix->PLName));
string_view fmt = translate ? _(/* TRANSLATORS: Constructs item names. Format: {Item} of {Suffix}. Example: Long Sword of the Whale */ "{0} of {1}") : "{0} of {1}";
return fmt::format(fmt::runtime(fmt), baseNamel, translate ? _(pSufix->PLName) : pSufix->PLName);
}
return std::string(baseNamel);
@ -1251,9 +1251,9 @@ void GetItemPower(const Player &player, Item &item, int minlvl, int maxlvl, Affi
pSufix = &suffix;
});
CopyUtf8(item._iIName, GenerateMagicItemName(item._iName, pPrefix, pSufix), sizeof(item._iIName));
CopyUtf8(item._iIName, GenerateMagicItemName(item._iName, pPrefix, pSufix, true), sizeof(item._iIName));
if (!StringInPanel(item._iIName)) {
CopyUtf8(item._iIName, GenerateMagicItemName(_(AllItemsList[item.IDidx].iSName), pPrefix, pSufix), sizeof(item._iIName));
CopyUtf8(item._iIName, GenerateMagicItemName(_(AllItemsList[item.IDidx].iSName), pPrefix, pSufix, true), sizeof(item._iIName));
}
if (pPrefix != nullptr || pSufix != nullptr)
CalcItemValue(item);

Loading…
Cancel
Save