From eea730768b831a51718a9e94d75ea76e0337184d Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Tue, 30 May 2023 20:22:04 +0200 Subject: [PATCH 1/3] Replace sIconNames with ESM::Skill::mIcon --- apps/openmw/mwgui/statswindow.cpp | 4 +-- apps/openmw/mwgui/tooltips.cpp | 4 +-- apps/openmw/mwworld/store.cpp | 59 ++++++++++++++++--------------- components/esm3/loadskil.cpp | 29 --------------- components/esm3/loadskil.hpp | 2 +- 5 files changed, 33 insertions(+), 65 deletions(-) diff --git a/apps/openmw/mwgui/statswindow.cpp b/apps/openmw/mwgui/statswindow.cpp index 90e734d640..349a087611 100644 --- a/apps/openmw/mwgui/statswindow.cpp +++ b/apps/openmw/mwgui/statswindow.cpp @@ -514,8 +514,6 @@ namespace MWGui const ESM::Skill* skill = esmStore.get().find(skillId); - std::string icon = "icons\\k\\" + ESM::Skill::sIconNames[skillId]; - const ESM::Attribute* attr = esmStore.get().find(skill->mData.mAttribute); std::pair widgets @@ -532,7 +530,7 @@ namespace MWGui "Caption_SkillDescription", skill->mDescription); mSkillWidgets[mSkillWidgets.size() - 1 - i]->setUserString( "Caption_SkillAttribute", "#{sGoverningAttribute}: #{" + attr->mName + "}"); - mSkillWidgets[mSkillWidgets.size() - 1 - i]->setUserString("ImageTexture_SkillImage", icon); + mSkillWidgets[mSkillWidgets.size() - 1 - i]->setUserString("ImageTexture_SkillImage", skill->mIcon); mSkillWidgets[mSkillWidgets.size() - 1 - i]->setUserString("Range_SkillProgress", "100"); } diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index b97e29af7d..f871e67156 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -814,14 +814,12 @@ namespace MWGui const ESM::Skill* skill = store.get().find(skillId); const ESM::Attribute* attr = store.get().find(skill->mData.mAttribute); - std::string icon = "icons\\k\\" + ESM::Skill::sIconNames[skillId]; - widget->setUserString("ToolTipType", "Layout"); 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("ImageTexture_SkillNoProgressImage", icon); + widget->setUserString("ImageTexture_SkillNoProgressImage", skill->mIcon); } void ToolTips::createAttributeToolTip(MyGUI::Widget* widget, int attributeId) diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp index dd42476f64..7331e1b23e 100644 --- a/apps/openmw/mwworld/store.cpp +++ b/apps/openmw/mwworld/store.cpp @@ -903,34 +903,34 @@ namespace MWWorld void Store::setUp(const MWWorld::Store settings) { - constexpr std::string_view skillNameIds[ESM::Skill::Length] = { - "sSkillBlock", - "sSkillArmorer", - "sSkillMediumarmor", - "sSkillHeavyarmor", - "sSkillBluntweapon", - "sSkillLongblade", - "sSkillAxe", - "sSkillSpear", - "sSkillAthletics", - "sSkillEnchant", - "sSkillDestruction", - "sSkillAlteration", - "sSkillIllusion", - "sSkillConjuration", - "sSkillMysticism", - "sSkillRestoration", - "sSkillAlchemy", - "sSkillUnarmored", - "sSkillSecurity", - "sSkillSneak", - "sSkillAcrobatics", - "sSkillLightarmor", - "sSkillShortblade", - "sSkillMarksman", - "sSkillMercantile", - "sSkillSpeechcraft", - "sSkillHandtohand", + constexpr std::string_view skillNameIdsAndIcons[ESM::Skill::Length][2] = { + { "sSkillBlock", "icons\\k\\combat_block.dds" }, + { "sSkillArmorer", "icons\\k\\combat_armor.dds" }, + { "sSkillMediumarmor", "icons\\k\\combat_mediumarmor.dds" }, + { "sSkillHeavyarmor", "icons\\k\\combat_heavyarmor.dds" }, + { "sSkillBluntweapon", "icons\\k\\combat_blunt.dds" }, + { "sSkillLongblade", "icons\\k\\combat_longblade.dds" }, + { "sSkillAxe", "icons\\k\\combat_axe.dds" }, + { "sSkillSpear", "icons\\k\\combat_spear.dds" }, + { "sSkillAthletics", "icons\\k\\combat_athletics.dds" }, + { "sSkillEnchant", "icons\\k\\magic_enchant.dds" }, + { "sSkillDestruction", "icons\\k\\magic_destruction.dds" }, + { "sSkillAlteration", "icons\\k\\magic_alteration.dds" }, + { "sSkillIllusion", "icons\\k\\magic_illusion.dds" }, + { "sSkillConjuration", "icons\\k\\magic_conjuration.dds" }, + { "sSkillMysticism", "icons\\k\\magic_mysticism.dds" }, + { "sSkillRestoration", "icons\\k\\magic_restoration.dds" }, + { "sSkillAlchemy", "icons\\k\\magic_alchemy.dds" }, + { "sSkillUnarmored", "icons\\k\\magic_unarmored.dds" }, + { "sSkillSecurity", "icons\\k\\stealth_security.dds" }, + { "sSkillSneak", "icons\\k\\stealth_sneak.dds" }, + { "sSkillAcrobatics", "icons\\k\\stealth_acrobatics.dds" }, + { "sSkillLightarmor", "icons\\k\\stealth_lightarmor.dds" }, + { "sSkillShortblade", "icons\\k\\stealth_shortblade.dds" }, + { "sSkillMarksman", "icons\\k\\stealth_marksman.dds" }, + { "sSkillMercantile", "icons\\k\\stealth_mercantile.dds" }, + { "sSkillSpeechcraft", "icons\\k\\stealth_speechcraft.dds" }, + { "sSkillHandtohand", "icons\\k\\stealth_handtohand.dds" }, }; for (int i = 0; i < ESM::Skill::Length; ++i) { @@ -938,7 +938,8 @@ namespace MWWorld if (found != mStatic.end()) { ESM::Skill& skill = found->second; - std::string_view id = skillNameIds[i]; + std::string_view id = 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(); diff --git a/components/esm3/loadskil.cpp b/components/esm3/loadskil.cpp index 0115e84e34..9fbbbdae2b 100644 --- a/components/esm3/loadskil.cpp +++ b/components/esm3/loadskil.cpp @@ -36,35 +36,6 @@ namespace ESM "Speechcraft", "Handtohand", }; - const std::string Skill::sIconNames[Length] = { - "combat_block.dds", - "combat_armor.dds", - "combat_mediumarmor.dds", - "combat_heavyarmor.dds", - "combat_blunt.dds", - "combat_longblade.dds", - "combat_axe.dds", - "combat_spear.dds", - "combat_athletics.dds", - "magic_enchant.dds", - "magic_destruction.dds", - "magic_alteration.dds", - "magic_illusion.dds", - "magic_conjuration.dds", - "magic_mysticism.dds", - "magic_restoration.dds", - "magic_alchemy.dds", - "magic_unarmored.dds", - "stealth_security.dds", - "stealth_sneak.dds", - "stealth_acrobatics.dds", - "stealth_lightarmor.dds", - "stealth_shortblade.dds", - "stealth_marksman.dds", - "stealth_mercantile.dds", - "stealth_speechcraft.dds", - "stealth_handtohand.dds", - }; Skill::SkillEnum Skill::stringToSkillId(std::string_view skill) { diff --git a/components/esm3/loadskil.hpp b/components/esm3/loadskil.hpp index 5ceec6ffa7..827bfb2b2f 100644 --- a/components/esm3/loadskil.hpp +++ b/components/esm3/loadskil.hpp @@ -45,6 +45,7 @@ namespace ESM std::string mDescription; std::string mName; + std::string mIcon; enum SkillEnum { @@ -78,7 +79,6 @@ namespace ESM Length }; static const std::string sSkillNames[Length]; - static const std::string sIconNames[Length]; static SkillEnum stringToSkillId(std::string_view skill); From 7b0680de5fff36b2a4158289ec7cf4c27cb5db61 Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Wed, 31 May 2023 17:02:18 +0200 Subject: [PATCH 2/3] Resolve attribute GMST members --- apps/openmw/mwgui/spellicons.cpp | 5 +- apps/openmw/mwgui/statswindow.cpp | 17 +++--- apps/openmw/mwgui/tooltips.cpp | 14 ++--- apps/openmw/mwmechanics/magiceffects.cpp | 2 +- apps/openmw/mwworld/esmstore.cpp | 2 +- apps/openmw/mwworld/player.cpp | 2 +- apps/openmw/mwworld/store.cpp | 75 ++++++++++++++---------- apps/openmw/mwworld/store.hpp | 4 +- components/esm/attr.hpp | 3 +- 9 files changed, 65 insertions(+), 59 deletions(-) diff --git a/apps/openmw/mwgui/spellicons.cpp b/apps/openmw/mwgui/spellicons.cpp index 5f69f7f168..8e90166e51 100644 --- a/apps/openmw/mwgui/spellicons.cpp +++ b/apps/openmw/mwgui/spellicons.cpp @@ -89,10 +89,7 @@ namespace MWGui if (effect->mData.mFlags & ESM::MagicEffect::TargetAttribute) { const ESM::Attribute* attribute = store->get().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) diff --git a/apps/openmw/mwgui/statswindow.cpp b/apps/openmw/mwgui/statswindow.cpp index 349a087611..93062ef6ab 100644 --- a/apps/openmw/mwgui/statswindow.cpp +++ b/apps/openmw/mwgui/statswindow.cpp @@ -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()) @@ -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().find(faction->mData.mAttribute[0]); const ESM::Attribute* attr2 = store.get().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}"; diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index f871e67156..7ad3206055 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -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) diff --git a/apps/openmw/mwmechanics/magiceffects.cpp b/apps/openmw/mwmechanics/magiceffects.cpp index b3f7a89d00..b9918a398e 100644 --- a/apps/openmw/mwmechanics/magiceffects.cpp +++ b/apps/openmw/mwmechanics/magiceffects.cpp @@ -279,7 +279,7 @@ namespace MWMechanics else if (targetsAttribute) { spellLine += ' '; - spellLine += windowManager->getGameSettingString(attribute->mName, {}); + spellLine += attribute->mName; } return spellLine; } diff --git a/apps/openmw/mwworld/esmstore.cpp b/apps/openmw/mwworld/esmstore.cpp index 29576709cc..a7ae594f3c 100644 --- a/apps/openmw/mwworld/esmstore.cpp +++ b/apps/openmw/mwworld/esmstore.cpp @@ -447,7 +447,7 @@ namespace MWWorld getWritable().setUp(get()); getWritable().setUp(); - getWritable().setUp(); + getWritable().setUp(get()); getWritable().updateLandPositions(get()); getWritable().preprocessReferences(get()); } diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index 0b8c49cf4d..3a388883fd 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -99,7 +99,7 @@ namespace MWWorld for (const auto& attribute : store->get()) { 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); } diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp index 7331e1b23e..ee0d71f5ab 100644 --- a/apps/openmw/mwworld/store.cpp +++ b/apps/openmw/mwworld/store.cpp @@ -31,6 +31,22 @@ namespace } return false; } + + std::string_view getGMSTString(const MWWorld::Store& 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& 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::Store() {} - void Store::setUp(const MWWorld::Store settings) + void Store::setUp(const MWWorld::Store& 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::setUp() + void Store::setUp(const MWWorld::Store& 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::getSize() const { diff --git a/apps/openmw/mwworld/store.hpp b/apps/openmw/mwworld/store.hpp index 453f36db11..3cbe6347c5 100644 --- a/apps/openmw/mwworld/store.hpp +++ b/apps/openmw/mwworld/store.hpp @@ -475,7 +475,7 @@ namespace MWWorld public: Store(); - void setUp(const MWWorld::Store settings); + void setUp(const MWWorld::Store& 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& settings); size_t getSize() const; iterator begin() const; diff --git a/components/esm/attr.hpp b/components/esm/attr.hpp index 784042afc8..9029306376 100644 --- a/components/esm/attr.hpp +++ b/components/esm/attr.hpp @@ -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]; From 08f35fe8395f368f2c3e0147c908398baccc706d Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Wed, 31 May 2023 17:45:20 +0200 Subject: [PATCH 3/3] Add ESM::Skill::mWerewolfValue --- .../mwmechanics/mechanicsmanagerimp.cpp | 8 +-- apps/openmw/mwworld/player.cpp | 12 ++-- apps/openmw/mwworld/store.cpp | 64 ++++++++++--------- components/esm3/loadskil.hpp | 1 + 4 files changed, 43 insertions(+), 42 deletions(-) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 3268c01ecc..1a9262b8da 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -1924,11 +1924,11 @@ namespace MWMechanics void MechanicsManager::applyWerewolfAcrobatics(const MWWorld::Ptr& actor) { - const MWWorld::Store& gmst - = MWBase::Environment::get().getESMStore()->get(); + const ESM::Skill* acrobatics + = MWBase::Environment::get().getESMStore()->get().find(ESM::Skill::Acrobatics); MWMechanics::NpcStats& stats = actor.getClass().getNpcStats(actor); - auto& skill = stats.getSkill(ESM::Skill::Acrobatics); - skill.setModifier(gmst.find("fWerewolfAcrobatics")->mValue.getFloat() - skill.getModified()); + auto& skill = stats.getSkill(acrobatics->mIndex); + skill.setModifier(acrobatics->mWerewolfValue - skill.getModified()); } void MechanicsManager::cleanupSummonedCreature(const MWWorld::Ptr& caster, int creatureActorId) diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index 3a388883fd..72933d0970 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -103,18 +103,14 @@ namespace MWWorld npcStats.setAttribute(attribute.mId, value); } - for (size_t i = 0; i < ESM::Skill::Length; i++) + for (const auto& [_, skill] : store->get()) { // Acrobatics is set separately for some reason. - if (i == ESM::Skill::Acrobatics) + if (skill.mIndex == ESM::Skill::Acrobatics) continue; - // "Mercantile"! >_< - std::string name = "fWerewolf" - + ((i == ESM::Skill::Mercantile) ? std::string("Merchantile") : ESM::Skill::sSkillNames[i]); - - MWMechanics::SkillValue& value = npcStats.getSkill(i); - value.setModifier(gmst.find(name)->mValue.getFloat() - value.getModified()); + MWMechanics::SkillValue& value = npcStats.getSkill(skill.mIndex); + value.setModifier(skill.mWerewolfValue - value.getModified()); } } diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp index ee0d71f5ab..080a9eb3e8 100644 --- a/apps/openmw/mwworld/store.cpp +++ b/apps/openmw/mwworld/store.cpp @@ -919,34 +919,35 @@ namespace MWWorld void Store::setUp(const MWWorld::Store& settings) { - constexpr std::string_view skillNameIdsAndIcons[ESM::Skill::Length][2] = { - { "sSkillBlock", "icons\\k\\combat_block.dds" }, - { "sSkillArmorer", "icons\\k\\combat_armor.dds" }, - { "sSkillMediumarmor", "icons\\k\\combat_mediumarmor.dds" }, - { "sSkillHeavyarmor", "icons\\k\\combat_heavyarmor.dds" }, - { "sSkillBluntweapon", "icons\\k\\combat_blunt.dds" }, - { "sSkillLongblade", "icons\\k\\combat_longblade.dds" }, - { "sSkillAxe", "icons\\k\\combat_axe.dds" }, - { "sSkillSpear", "icons\\k\\combat_spear.dds" }, - { "sSkillAthletics", "icons\\k\\combat_athletics.dds" }, - { "sSkillEnchant", "icons\\k\\magic_enchant.dds" }, - { "sSkillDestruction", "icons\\k\\magic_destruction.dds" }, - { "sSkillAlteration", "icons\\k\\magic_alteration.dds" }, - { "sSkillIllusion", "icons\\k\\magic_illusion.dds" }, - { "sSkillConjuration", "icons\\k\\magic_conjuration.dds" }, - { "sSkillMysticism", "icons\\k\\magic_mysticism.dds" }, - { "sSkillRestoration", "icons\\k\\magic_restoration.dds" }, - { "sSkillAlchemy", "icons\\k\\magic_alchemy.dds" }, - { "sSkillUnarmored", "icons\\k\\magic_unarmored.dds" }, - { "sSkillSecurity", "icons\\k\\stealth_security.dds" }, - { "sSkillSneak", "icons\\k\\stealth_sneak.dds" }, - { "sSkillAcrobatics", "icons\\k\\stealth_acrobatics.dds" }, - { "sSkillLightarmor", "icons\\k\\stealth_lightarmor.dds" }, - { "sSkillShortblade", "icons\\k\\stealth_shortblade.dds" }, - { "sSkillMarksman", "icons\\k\\stealth_marksman.dds" }, - { "sSkillMercantile", "icons\\k\\stealth_mercantile.dds" }, - { "sSkillSpeechcraft", "icons\\k\\stealth_speechcraft.dds" }, - { "sSkillHandtohand", "icons\\k\\stealth_handtohand.dds" }, + constexpr std::string_view skillValues[ESM::Skill::Length][3] = { + { "sSkillBlock", "icons\\k\\combat_block.dds", "fWerewolfBlock" }, + { "sSkillArmorer", "icons\\k\\combat_armor.dds", "fWerewolfArmorer" }, + { "sSkillMediumarmor", "icons\\k\\combat_mediumarmor.dds", "fWerewolfMediumarmor" }, + { "sSkillHeavyarmor", "icons\\k\\combat_heavyarmor.dds", "fWerewolfHeavyarmor" }, + { "sSkillBluntweapon", "icons\\k\\combat_blunt.dds", "fWerewolfBluntweapon" }, + { "sSkillLongblade", "icons\\k\\combat_longblade.dds", "fWerewolfLongblade" }, + { "sSkillAxe", "icons\\k\\combat_axe.dds", "fWerewolfAxe" }, + { "sSkillSpear", "icons\\k\\combat_spear.dds", "fWerewolfSpear" }, + { "sSkillAthletics", "icons\\k\\combat_athletics.dds", "fWerewolfAthletics" }, + { "sSkillEnchant", "icons\\k\\magic_enchant.dds", "fWerewolfEnchant" }, + { "sSkillDestruction", "icons\\k\\magic_destruction.dds", "fWerewolfDestruction" }, + { "sSkillAlteration", "icons\\k\\magic_alteration.dds", "fWerewolfAlteration" }, + { "sSkillIllusion", "icons\\k\\magic_illusion.dds", "fWerewolfIllusion" }, + { "sSkillConjuration", "icons\\k\\magic_conjuration.dds", "fWerewolfConjuration" }, + { "sSkillMysticism", "icons\\k\\magic_mysticism.dds", "fWerewolfMysticism" }, + { "sSkillRestoration", "icons\\k\\magic_restoration.dds", "fWerewolfRestoration" }, + { "sSkillAlchemy", "icons\\k\\magic_alchemy.dds", "fWerewolfAlchemy" }, + { "sSkillUnarmored", "icons\\k\\magic_unarmored.dds", "fWerewolfUnarmored" }, + { "sSkillSecurity", "icons\\k\\stealth_security.dds", "fWerewolfSecurity" }, + { "sSkillSneak", "icons\\k\\stealth_sneak.dds", "fWerewolfSneak" }, + { "sSkillAcrobatics", "icons\\k\\stealth_acrobatics.dds", "fWerewolfAcrobatics" }, + { "sSkillLightarmor", "icons\\k\\stealth_lightarmor.dds", "fWerewolfLightarmor" }, + { "sSkillShortblade", "icons\\k\\stealth_shortblade.dds", "fWerewolfShortblade" }, + { "sSkillMarksman", "icons\\k\\stealth_marksman.dds", "fWerewolfMarksman" }, + // "Mercantile"! >_< + { "sSkillMercantile", "icons\\k\\stealth_mercantile.dds", "fWerewolfMerchantile" }, + { "sSkillSpeechcraft", "icons\\k\\stealth_speechcraft.dds", "fWerewolfSpeechcraft" }, + { "sSkillHandtohand", "icons\\k\\stealth_handtohand.dds", "fWerewolfHandtohand" }, }; for (int i = 0; i < ESM::Skill::Length; ++i) { @@ -954,8 +955,9 @@ namespace MWWorld if (found != mStatic.end()) { ESM::Skill& skill = found->second; - skill.mName = getGMSTString(settings, skillNameIdsAndIcons[i][0]); - skill.mIcon = skillNameIdsAndIcons[i][1]; + skill.mName = getGMSTString(settings, skillValues[i][0]); + skill.mIcon = skillValues[i][1]; + skill.mWerewolfValue = getGMSTFloat(settings, skillValues[i][2]); } } } @@ -1010,6 +1012,8 @@ namespace MWWorld } void Store::setUp(const MWWorld::Store& settings) { + // TODO remove after !3084 gets merged + mStatic.clear(); mStatic.push_back({ .mId = ESM::Attribute::Strength, .mName = std::string{ getGMSTString(settings, "sAttributeStrength") }, .mDescription = std::string{ getGMSTString(settings, "sStrDesc") }, diff --git a/components/esm3/loadskil.hpp b/components/esm3/loadskil.hpp index 827bfb2b2f..a0dc56f1d4 100644 --- a/components/esm3/loadskil.hpp +++ b/components/esm3/loadskil.hpp @@ -46,6 +46,7 @@ namespace ESM std::string mDescription; std::string mName; std::string mIcon; + float mWerewolfValue{}; enum SkillEnum {