Resolve attribute GMST members

macos_ci
Evil Eye 2 years ago
parent eea730768b
commit 7b0680de5f

@ -89,10 +89,7 @@ namespace MWGui
if (effect->mData.mFlags & ESM::MagicEffect::TargetAttribute)
{
const ESM::Attribute* attribute = store->get<ESM::Attribute>().find(effectInfo.mKey.mArg);
sourcesDescription += " (";
sourcesDescription
+= MWBase::Environment::get().getWindowManager()->getGameSettingString(attribute->mName, {});
sourcesDescription += ')';
sourcesDescription += " (" + attribute->mName + ')';
}
ESM::MagicEffect::MagnitudeDisplayType displayType = effect->getMagnitudeDisplayType();
if (displayType == ESM::MagicEffect::MDT_TimesInt)

@ -342,7 +342,6 @@ namespace MWGui
const MWMechanics::NpcStats& PCstats = player.getClass().getNpcStats(player);
const auto& store = MWBase::Environment::get().getESMStore();
std::string detailText;
std::stringstream detail;
bool first = true;
for (const auto& attribute : store->get<ESM::Attribute>())
@ -353,12 +352,11 @@ namespace MWGui
{
if (!first)
detail << '\n';
detail << "#{" << MyGUI::TextIterator::toTagsString(attribute.mName) << "} x"
<< MyGUI::utility::toString(mult);
detail << attribute.mName << " x" << MyGUI::utility::toString(mult);
first = false;
}
}
detailText = MyGUI::LanguageManager::getInstance().replaceTags(detail.str());
std::string detailText = detail.str();
// level progress
MyGUI::Widget* levelWidget;
@ -528,8 +526,8 @@ namespace MWGui
"Caption_SkillName", MyGUI::TextIterator::toTagsString(skill->mName));
mSkillWidgets[mSkillWidgets.size() - 1 - i]->setUserString(
"Caption_SkillDescription", skill->mDescription);
mSkillWidgets[mSkillWidgets.size() - 1 - i]->setUserString(
"Caption_SkillAttribute", "#{sGoverningAttribute}: #{" + attr->mName + "}");
mSkillWidgets[mSkillWidgets.size() - 1 - i]->setUserString("Caption_SkillAttribute",
"#{sGoverningAttribute}: " + MyGUI::TextIterator::toTagsString(attr->mName));
mSkillWidgets[mSkillWidgets.size() - 1 - i]->setUserString("ImageTexture_SkillImage", skill->mIcon);
mSkillWidgets[mSkillWidgets.size() - 1 - i]->setUserString("Range_SkillProgress", "100");
}
@ -632,9 +630,10 @@ namespace MWGui
const ESM::Attribute* attr1 = store.get<ESM::Attribute>().find(faction->mData.mAttribute[0]);
const ESM::Attribute* attr2 = store.get<ESM::Attribute>().find(faction->mData.mAttribute[1]);
text += "\n#{fontcolourhtml=normal}#{" + attr1->mName
+ "}: " + MyGUI::utility::toString(rankData.mAttribute1) + ", #{" + attr2->mName
+ "}: " + MyGUI::utility::toString(rankData.mAttribute2);
text += "\n#{fontcolourhtml=normal}" + MyGUI::TextIterator::toTagsString(attr1->mName) + ": "
+ MyGUI::utility::toString(rankData.mAttribute1) + ", "
+ MyGUI::TextIterator::toTagsString(attr2->mName) + ": "
+ MyGUI::utility::toString(rankData.mAttribute2);
text += "\n\n#{fontcolourhtml=header}#{sFavoriteSkills}";
text += "\n#{fontcolourhtml=normal}";

@ -818,7 +818,8 @@ namespace MWGui
widget->setUserString("ToolTipLayout", "SkillNoProgressToolTip");
widget->setUserString("Caption_SkillNoProgressName", MyGUI::TextIterator::toTagsString(skill->mName));
widget->setUserString("Caption_SkillNoProgressDescription", skill->mDescription);
widget->setUserString("Caption_SkillNoProgressAttribute", "#{sGoverningAttribute}: #{" + attr->mName + "}");
widget->setUserString("Caption_SkillNoProgressAttribute",
"#{sGoverningAttribute}: " + MyGUI::TextIterator::toTagsString(attr->mName));
widget->setUserString("ImageTexture_SkillNoProgressImage", skill->mIcon);
}
@ -829,15 +830,12 @@ namespace MWGui
if (!attribute)
return;
const std::string& icon = attribute->mIcon;
const std::string& name = attribute->mName;
const std::string& desc = attribute->mDescription;
widget->setUserString("ToolTipType", "Layout");
widget->setUserString("ToolTipLayout", "AttributeToolTip");
widget->setUserString("Caption_AttributeName", "#{" + name + "}");
widget->setUserString("Caption_AttributeDescription", "#{" + desc + "}");
widget->setUserString("ImageTexture_AttributeImage", icon);
widget->setUserString("Caption_AttributeName", MyGUI::TextIterator::toTagsString(attribute->mName));
widget->setUserString(
"Caption_AttributeDescription", MyGUI::TextIterator::toTagsString(attribute->mDescription));
widget->setUserString("ImageTexture_AttributeImage", attribute->mIcon);
}
void ToolTips::createSpecializationToolTip(MyGUI::Widget* widget, const std::string& name, int specId)

@ -279,7 +279,7 @@ namespace MWMechanics
else if (targetsAttribute)
{
spellLine += ' ';
spellLine += windowManager->getGameSettingString(attribute->mName, {});
spellLine += attribute->mName;
}
return spellLine;
}

@ -447,7 +447,7 @@ namespace MWWorld
getWritable<ESM::Skill>().setUp(get<ESM::GameSetting>());
getWritable<ESM::MagicEffect>().setUp();
getWritable<ESM::Attribute>().setUp();
getWritable<ESM::Attribute>().setUp(get<ESM::GameSetting>());
getWritable<ESM4::Land>().updateLandPositions(get<ESM4::Cell>());
getWritable<ESM4::Reference>().preprocessReferences(get<ESM4::Cell>());
}

@ -99,7 +99,7 @@ namespace MWWorld
for (const auto& attribute : store->get<ESM::Attribute>())
{
MWMechanics::AttributeValue value = npcStats.getAttribute(attribute.mId);
value.setModifier(gmst.find(attribute.mWerewolfGMST)->mValue.getFloat() - value.getModified());
value.setModifier(attribute.mWerewolfValue - value.getModified());
npcStats.setAttribute(attribute.mId, value);
}

@ -31,6 +31,22 @@ namespace
}
return false;
}
std::string_view getGMSTString(const MWWorld::Store<ESM::GameSetting>& settings, std::string_view id)
{
const ESM::GameSetting* setting = settings.search(id);
if (setting && setting->mValue.getType() == ESM::VT_String)
return setting->mValue.getString();
return id;
}
float getGMSTFloat(const MWWorld::Store<ESM::GameSetting>& settings, std::string_view id)
{
const ESM::GameSetting* setting = settings.search(id);
if (setting && (setting->mValue.getType() == ESM::VT_Float || setting->mValue.getType() == ESM::VT_Int))
return setting->mValue.getFloat();
return {};
}
}
namespace MWWorld
@ -901,7 +917,7 @@ namespace MWWorld
Store<ESM::Skill>::Store() {}
void Store<ESM::Skill>::setUp(const MWWorld::Store<ESM::GameSetting> settings)
void Store<ESM::Skill>::setUp(const MWWorld::Store<ESM::GameSetting>& settings)
{
constexpr std::string_view skillNameIdsAndIcons[ESM::Skill::Length][2] = {
{ "sSkillBlock", "icons\\k\\combat_block.dds" },
@ -938,13 +954,8 @@ namespace MWWorld
if (found != mStatic.end())
{
ESM::Skill& skill = found->second;
std::string_view id = skillNameIdsAndIcons[i][0];
skill.mName = getGMSTString(settings, skillNameIdsAndIcons[i][0]);
skill.mIcon = skillNameIdsAndIcons[i][1];
const ESM::GameSetting* setting = settings.search(id);
if (setting && setting->mValue.getType() == ESM::VT_String)
skill.mName = setting->mValue.getString();
else
skill.mName = id;
}
}
}
@ -997,49 +1008,49 @@ namespace MWWorld
}
return ptr;
}
void Store<ESM::Attribute>::setUp()
void Store<ESM::Attribute>::setUp(const MWWorld::Store<ESM::GameSetting>& settings)
{
mStatic.push_back({ .mId = ESM::Attribute::Strength,
.mName = "sAttributeStrength",
.mDescription = "sStrDesc",
.mName = std::string{ getGMSTString(settings, "sAttributeStrength") },
.mDescription = std::string{ getGMSTString(settings, "sStrDesc") },
.mIcon = "icons\\k\\attribute_strength.dds",
.mWerewolfGMST = "fWerewolfStrength" });
.mWerewolfValue = getGMSTFloat(settings, "fWerewolfStrength") });
mStatic.push_back({ .mId = ESM::Attribute::Intelligence,
.mName = "sAttributeIntelligence",
.mDescription = "sIntDesc",
.mName = std::string{ getGMSTString(settings, "sAttributeIntelligence") },
.mDescription = std::string{ getGMSTString(settings, "sIntDesc") },
.mIcon = "icons\\k\\attribute_int.dds",
// Oh, Bethesda. It's "Intelligence".
.mWerewolfGMST = "fWerewolfIntellegence" });
.mWerewolfValue = getGMSTFloat(settings, "fWerewolfIntellegence") });
mStatic.push_back({ .mId = ESM::Attribute::Willpower,
.mName = "sAttributeWillpower",
.mDescription = "sWilDesc",
.mName = std::string{ getGMSTString(settings, "sAttributeWillpower") },
.mDescription = std::string{ getGMSTString(settings, "sWilDesc") },
.mIcon = "icons\\k\\attribute_wilpower.dds",
.mWerewolfGMST = "fWerewolfWillpower" });
.mWerewolfValue = getGMSTFloat(settings, "fWerewolfWillpower") });
mStatic.push_back({ .mId = ESM::Attribute::Agility,
.mName = "sAttributeAgility",
.mDescription = "sAgiDesc",
.mName = std::string{ getGMSTString(settings, "sAttributeAgility") },
.mDescription = std::string{ getGMSTString(settings, "sAgiDesc") },
.mIcon = "icons\\k\\attribute_agility.dds",
.mWerewolfGMST = "fWerewolfAgility" });
.mWerewolfValue = getGMSTFloat(settings, "fWerewolfAgility") });
mStatic.push_back({ .mId = ESM::Attribute::Speed,
.mName = "sAttributeSpeed",
.mDescription = "sSpdDesc",
.mName = std::string{ getGMSTString(settings, "sAttributeSpeed") },
.mDescription = std::string{ getGMSTString(settings, "sSpdDesc") },
.mIcon = "icons\\k\\attribute_speed.dds",
.mWerewolfGMST = "fWerewolfSpeed" });
.mWerewolfValue = getGMSTFloat(settings, "fWerewolfSpeed") });
mStatic.push_back({ .mId = ESM::Attribute::Endurance,
.mName = "sAttributeEndurance",
.mDescription = "sEndDesc",
.mName = std::string{ getGMSTString(settings, "sAttributeEndurance") },
.mDescription = std::string{ getGMSTString(settings, "sEndDesc") },
.mIcon = "icons\\k\\attribute_endurance.dds",
.mWerewolfGMST = "fWerewolfEndurance" });
.mWerewolfValue = getGMSTFloat(settings, "fWerewolfEndurance") });
mStatic.push_back({ .mId = ESM::Attribute::Personality,
.mName = "sAttributePersonality",
.mDescription = "sPerDesc",
.mName = std::string{ getGMSTString(settings, "sAttributePersonality") },
.mDescription = std::string{ getGMSTString(settings, "sPerDesc") },
.mIcon = "icons\\k\\attribute_personality.dds",
.mWerewolfGMST = "fWerewolfPersonality" });
.mWerewolfValue = getGMSTFloat(settings, "fWerewolfPersonality") });
mStatic.push_back({ .mId = ESM::Attribute::Luck,
.mName = "sAttributeLuck",
.mDescription = "sLucDesc",
.mName = std::string{ getGMSTString(settings, "sAttributeLuck") },
.mDescription = std::string{ getGMSTString(settings, "sLucDesc") },
.mIcon = "icons\\k\\attribute_luck.dds",
.mWerewolfGMST = "fWerewolfLuck" });
.mWerewolfValue = getGMSTFloat(settings, "fWerewolfLuck") });
}
size_t Store<ESM::Attribute>::getSize() const
{

@ -475,7 +475,7 @@ namespace MWWorld
public:
Store();
void setUp(const MWWorld::Store<ESM::GameSetting> settings);
void setUp(const MWWorld::Store<ESM::GameSetting>& settings);
};
template <>
@ -500,7 +500,7 @@ namespace MWWorld
// calls `search` and throws an exception if not found
const ESM::Attribute* find(size_t index) const;
void setUp();
void setUp(const MWWorld::Store<ESM::GameSetting>& settings);
size_t getSize() const;
iterator begin() const;

@ -26,7 +26,8 @@ namespace ESM
};
AttributeID mId;
std::string mName, mDescription, mIcon, mWerewolfGMST;
std::string mName, mDescription, mIcon;
float mWerewolfValue{};
static const std::string sAttributeNames[Length];

Loading…
Cancel
Save