Replace sSkillNameIds with ESM::Skill::mName

macos_ci
Evil Eye 2 years ago
parent df57f8004b
commit 9c60a6fa4d

@ -165,8 +165,8 @@ namespace MWClass
{
text += "\n#{sType} ";
int skill = MWMechanics::getWeaponType(ref->mBase->mData.mType)->mSkill;
const std::string& type = ESM::Skill::sSkillNameIds[skill];
const ESM::Skill* skill
= store.get<ESM::Skill>().find(MWMechanics::getWeaponType(ref->mBase->mData.mType)->mSkill);
std::string_view oneOrTwoHanded;
if (weaponType->mWeaponClass == ESM::WeaponType::Melee)
{
@ -176,7 +176,7 @@ namespace MWClass
oneOrTwoHanded = "sOneHanded";
}
text += store.get<ESM::GameSetting>().find(type)->mValue.getString();
text += skill->mName;
if (!oneOrTwoHanded.empty())
text += ", " + store.get<ESM::GameSetting>().find(oneOrTwoHanded)->mValue.getString();

@ -88,15 +88,16 @@ namespace MWGui
// We should not worsen corprus when in prison
player.getClass().getCreatureStats(player).getActiveSpells().skipWorsenings(mDays * 24);
std::set<int> skills;
const auto& skillStore = MWBase::Environment::get().getESMStore()->get<ESM::Skill>();
std::set<const ESM::Skill*> skills;
for (int day = 0; day < mDays; ++day)
{
auto& prng = MWBase::Environment::get().getWorld()->getPrng();
int skill = Misc::Rng::rollDice(ESM::Skill::Length, prng);
const ESM::Skill* skill = skillStore.find(Misc::Rng::rollDice(ESM::Skill::Length, prng));
skills.insert(skill);
MWMechanics::SkillValue& value = player.getClass().getNpcStats(player).getSkill(skill);
if (skill == ESM::Skill::Security || skill == ESM::Skill::Sneak)
MWMechanics::SkillValue& value = player.getClass().getNpcStats(player).getSkill(skill->mIndex);
if (skill->mIndex == ESM::Skill::Security || skill->mIndex == ESM::Skill::Sneak)
value.setBase(std::min(100.f, value.getBase() + 1));
else
value.setBase(std::max(0.f, value.getBase() - 1));
@ -113,15 +114,14 @@ namespace MWGui
message = Misc::StringUtils::format(message, mDays);
for (const int& skill : skills)
for (const ESM::Skill* skill : skills)
{
const std::string& skillName = gmst.find(ESM::Skill::sSkillNameIds[skill])->mValue.getString();
int skillValue = player.getClass().getNpcStats(player).getSkill(skill).getBase();
int skillValue = player.getClass().getNpcStats(player).getSkill(skill->mIndex).getBase();
std::string skillMsg = gmst.find("sNotifyMessage44")->mValue.getString();
if (skill == ESM::Skill::Sneak || skill == ESM::Skill::Security)
if (skill->mIndex == ESM::Skill::Sneak || skill->mIndex == ESM::Skill::Security)
skillMsg = gmst.find("sNotifyMessage39")->mValue.getString();
skillMsg = Misc::StringUtils::format(skillMsg, skillName, skillValue);
skillMsg = Misc::StringUtils::format(skillMsg, skill->mName, skillValue);
message += "\n" + skillMsg;
}

@ -341,10 +341,9 @@ namespace MWGui
for (const int& skillId : skills)
{
if (skillId < 0 || skillId >= ESM::Skill::Length) // Skip unknown skill indexes
const ESM::Skill* skill = MWBase::Environment::get().getESMStore()->get<ESM::Skill>().search(skillId);
if (!skill) // Skip unknown skill indexes
continue;
assert(skillId >= 0 && skillId < ESM::Skill::Length);
const std::string& skillNameId = ESM::Skill::sSkillNameIds[skillId];
const MWMechanics::SkillValue& stat = mSkillValues.find(skillId)->second;
int base = stat.getBase();
int modified = stat.getModified();
@ -355,8 +354,7 @@ namespace MWGui
else if (modified < base)
state = "decreased";
MyGUI::TextBox* widget = addValueItem(
MWBase::Environment::get().getWindowManager()->getGameSettingString(skillNameId, skillNameId),
MyGUI::utility::toString(static_cast<int>(modified)), state, coord1, coord2);
skill->mName, MyGUI::utility::toString(static_cast<int>(modified)), state, coord1, coord2);
for (int i = 0; i < 2; ++i)
{

@ -83,10 +83,8 @@ namespace MWGui
if (effect->mData.mFlags & ESM::MagicEffect::TargetSkill)
{
sourcesDescription += " (";
sourcesDescription += MWBase::Environment::get().getWindowManager()->getGameSettingString(
ESM::Skill::sSkillNameIds[effectInfo.mKey.mArg], {});
sourcesDescription += ')';
const ESM::Skill* skill = store->get<ESM::Skill>().find(effectInfo.mKey.mArg);
sourcesDescription += " (" + skill->mName + ')';
}
if (effect->mData.mFlags & ESM::MagicEffect::TargetAttribute)
{

@ -55,8 +55,9 @@ namespace MWGui
{
const ESM::MagicEffect* magicEffect = store.get<ESM::MagicEffect>().find(effectId);
const ESM::Attribute* attribute = store.get<ESM::Attribute>().search(effect.mAttribute);
const ESM::Skill* skill = store.get<ESM::Skill>().search(effect.mSkill);
std::string fullEffectName = MWMechanics::getMagicEffectString(*magicEffect, attribute, effect.mSkill);
std::string fullEffectName = MWMechanics::getMagicEffectString(*magicEffect, attribute, skill);
std::string convert = Utf8Stream::lowerCaseUtf8(fullEffectName);
if (convert.find(filter) != std::string::npos)
{

@ -510,8 +510,6 @@ namespace MWGui
{
if (skillId < 0 || skillId >= ESM::Skill::Length) // Skip unknown skill indexes
continue;
const std::string& skillNameId = ESM::Skill::sSkillNameIds[skillId];
const MWWorld::ESMStore& esmStore = *MWBase::Environment::get().getESMStore();
const ESM::Skill* skill = esmStore.get<ESM::Skill>().find(skillId);
@ -520,9 +518,8 @@ namespace MWGui
const ESM::Attribute* attr = esmStore.get<ESM::Attribute>().find(skill->mData.mAttribute);
std::pair<MyGUI::TextBox*, MyGUI::TextBox*> widgets = addValueItem(
MWBase::Environment::get().getWindowManager()->getGameSettingString(skillNameId, skillNameId), {},
"normal", coord1, coord2);
std::pair<MyGUI::TextBox*, MyGUI::TextBox*> widgets
= addValueItem(skill->mName, {}, "normal", coord1, coord2);
mSkillWidgetMap[skillId] = widgets;
for (int i = 0; i < 2; ++i)
@ -530,7 +527,7 @@ namespace MWGui
mSkillWidgets[mSkillWidgets.size() - 1 - i]->setUserString("ToolTipType", "Layout");
mSkillWidgets[mSkillWidgets.size() - 1 - i]->setUserString("ToolTipLayout", "SkillToolTip");
mSkillWidgets[mSkillWidgets.size() - 1 - i]->setUserString(
"Caption_SkillName", "#{" + skillNameId + "}");
"Caption_SkillName", MyGUI::TextIterator::toTagsString(skill->mName));
mSkillWidgets[mSkillWidgets.size() - 1 - i]->setUserString(
"Caption_SkillDescription", skill->mDescription);
mSkillWidgets[mSkillWidgets.size() - 1 - i]->setUserString(
@ -652,8 +649,8 @@ namespace MWGui
text += ", ";
firstSkill = false;
text += "#{" + ESM::Skill::sSkillNameIds[faction->mData.mSkills[i]] + "}";
const ESM::Skill* skill = store.get<ESM::Skill>().find(faction->mData.mSkills[i]);
text += MyGUI::TextIterator::toTagsString(skill->mName);
}
}

@ -6,6 +6,7 @@
#include <MyGUI_ImageBox.h>
#include <MyGUI_InputManager.h>
#include <MyGUI_RenderManager.h>
#include <MyGUI_TextIterator.h>
#include <components/esm/records.hpp>
#include <components/l10n/manager.hpp>
@ -810,18 +811,14 @@ namespace MWGui
return;
const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore();
const std::string& skillNameId = ESM::Skill::sSkillNameIds[skillId];
const ESM::Skill* skill = store.get<ESM::Skill>().find(skillId);
assert(skill);
const ESM::Attribute* attr = store.get<ESM::Attribute>().find(skill->mData.mAttribute);
assert(attr);
std::string icon = "icons\\k\\" + ESM::Skill::sIconNames[skillId];
widget->setUserString("ToolTipType", "Layout");
widget->setUserString("ToolTipLayout", "SkillNoProgressToolTip");
widget->setUserString("Caption_SkillNoProgressName", "#{" + skillNameId + "}");
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);
@ -853,16 +850,16 @@ namespace MWGui
const MWWorld::Store<ESM::Skill>& skills = MWBase::Environment::get().getESMStore()->get<ESM::Skill>();
bool isFirst = true;
for (auto& skillPair : skills)
for (const auto& [_, skill] : skills)
{
if (skillPair.second.mData.mSpecialization == specId)
if (skill.mData.mSpecialization == specId)
{
if (isFirst)
isFirst = false;
else
specText += "\n";
specText += std::string("#{") + ESM::Skill::sSkillNameIds[skillPair.first] + "}";
specText += MyGUI::TextIterator::toTagsString(skill.mName);
}
}
widget->setUserString("Caption_ColumnText", specText);

@ -2,6 +2,7 @@
#include <MyGUI_Button.h>
#include <MyGUI_Gui.h>
#include <MyGUI_TextIterator.h>
#include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp"
@ -97,8 +98,9 @@ namespace MWGui
MWMechanics::NpcStats& pcStats = player.getClass().getNpcStats(player);
const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
const auto& store = MWBase::Environment::get().getESMStore();
const MWWorld::Store<ESM::GameSetting>& gmst = store->get<ESM::GameSetting>();
const MWWorld::Store<ESM::Skill>& skillStore = store->get<ESM::Skill>();
const int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2;
@ -118,8 +120,9 @@ namespace MWGui
button->setUserData(skills[i].first);
button->eventMouseButtonClick += MyGUI::newDelegate(this, &TrainingWindow::onTrainingSelected);
const ESM::Skill* skill = skillStore.find(skills[i].first);
button->setCaptionWithReplacing(
"#{" + ESM::Skill::sSkillNameIds[skills[i].first] + "} - " + MyGUI::utility::toString(price));
MyGUI::TextIterator::toTagsString(skill->mName) + " - " + MyGUI::utility::toString(price));
button->setSize(button->getTextSize().width + 12, button->getSize().height);

@ -60,16 +60,11 @@ namespace MWGui::Widgets
{
if (mSkillNameWidget)
{
if (mSkillId == ESM::Skill::Length)
{
const ESM::Skill* skill = MWBase::Environment::get().getESMStore()->get<ESM::Skill>().search(mSkillId);
if (skill == nullptr)
mSkillNameWidget->setCaption({});
}
else
{
MyGUI::UString name = toUString(MWBase::Environment::get().getWindowManager()->getGameSettingString(
ESM::Skill::sSkillNameIds[mSkillId], {}));
mSkillNameWidget->setCaption(name);
}
mSkillNameWidget->setCaption(skill->mName);
}
if (mSkillValueWidget)
{
@ -379,6 +374,7 @@ namespace MWGui::Widgets
const ESM::MagicEffect* magicEffect = store.get<ESM::MagicEffect>().search(mEffectParams.mEffectID);
const ESM::Attribute* attribute = store.get<ESM::Attribute>().search(mEffectParams.mAttribute);
const ESM::Skill* skill = store.get<ESM::Skill>().search(mEffectParams.mSkill);
assert(magicEffect);
@ -394,7 +390,7 @@ namespace MWGui::Widgets
std::string sec = " " + std::string{ windowManager->getGameSettingString("ssecond", {}) };
std::string secs = " " + std::string{ windowManager->getGameSettingString("sseconds", {}) };
std::string spellLine = MWMechanics::getMagicEffectString(*magicEffect, attribute, mEffectParams.mSkill);
std::string spellLine = MWMechanics::getMagicEffectString(*magicEffect, attribute, skill);
if (mEffectParams.mMagnMin || mEffectParams.mMagnMax)
{

@ -569,7 +569,6 @@ std::vector<std::string> MWMechanics::Alchemy::effectsDescription(const MWWorld:
for (auto i = 0; i < 4; ++i)
{
const auto effectID = data.mEffectID[i];
const auto skillID = data.mSkills[i];
if (alchemySkill < fWortChanceValue * (i + 1))
break;
@ -577,7 +576,8 @@ std::vector<std::string> MWMechanics::Alchemy::effectsDescription(const MWWorld:
if (effectID != -1)
{
const ESM::Attribute* attribute = store->get<ESM::Attribute>().search(data.mAttributes[i]);
std::string effect = getMagicEffectString(*mgef.find(effectID), attribute, skillID);
const ESM::Skill* skill = store->get<ESM::Skill>().search(data.mAttributes[i]);
std::string effect = getMagicEffectString(*mgef.find(effectID), attribute, skill);
effects.push_back(effect);
}

@ -53,7 +53,8 @@ namespace MWMechanics
{
const auto& store = MWBase::Environment::get().getESMStore();
const ESM::MagicEffect* magicEffect = store->get<ESM::MagicEffect>().search(mId);
return getMagicEffectString(*magicEffect, store->get<ESM::Attribute>().find(mArg), mArg);
return getMagicEffectString(
*magicEffect, store->get<ESM::Attribute>().search(mArg), store->get<ESM::Skill>().search(mArg));
}
bool operator<(const EffectKey& left, const EffectKey& right)
@ -227,9 +228,10 @@ namespace MWMechanics
}
}
std::string getMagicEffectString(const ESM::MagicEffect& effect, const ESM::Attribute* attribute, int skillArg)
std::string getMagicEffectString(
const ESM::MagicEffect& effect, const ESM::Attribute* attribute, const ESM::Skill* skill)
{
const bool targetsSkill = effect.mData.mFlags & ESM::MagicEffect::TargetSkill && skillArg != -1;
const bool targetsSkill = effect.mData.mFlags & ESM::MagicEffect::TargetSkill && skill;
const bool targetsAttribute = effect.mData.mFlags & ESM::MagicEffect::TargetAttribute && attribute;
std::string spellLine;
@ -272,7 +274,7 @@ namespace MWMechanics
if (targetsSkill)
{
spellLine += ' ';
spellLine += windowManager->getGameSettingString(ESM::Skill::sSkillNameIds[skillArg], {});
spellLine += skill->mName;
}
else if (targetsAttribute)
{

@ -12,6 +12,7 @@ namespace ESM
struct EffectList;
struct MagicEffect;
struct MagicEffects;
struct Skill;
}
namespace MWMechanics
@ -114,7 +115,8 @@ namespace MWMechanics
///< Return changes from \a prev to \a now.
};
std::string getMagicEffectString(const ESM::MagicEffect& effect, const ESM::Attribute* attribute, int skillArg);
std::string getMagicEffectString(
const ESM::MagicEffect& effect, const ESM::Attribute* attribute, const ESM::Skill* skill);
}
#endif

@ -10,6 +10,8 @@
#include <components/misc/strings/format.hpp>
#include <MyGUI_TextIterator.h>
#include "../mwworld/esmstore.hpp"
#include "../mwbase/environment.hpp"
@ -259,8 +261,8 @@ void MWMechanics::NpcStats::increaseSkill(
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("skillraise"));
std::string message{ MWBase::Environment::get().getWindowManager()->getGameSettingString("sNotifyMessage39", {}) };
message = Misc::StringUtils::format(
message, ("#{" + ESM::Skill::sSkillNameIds[skillIndex] + "}"), static_cast<int>(base));
message
= Misc::StringUtils::format(message, MyGUI::TextIterator::toTagsString(skill->mName), static_cast<int>(base));
if (readBook)
message = "#{sBookSkillMessage}\n" + message;

@ -445,7 +445,7 @@ namespace MWWorld
for (const auto& [k, v] : mStoreImp->mIds)
mStoreImp->mStaticIds.emplace(k, v);
getWritable<ESM::Skill>().setUp();
getWritable<ESM::Skill>().setUp(get<ESM::GameSetting>());
getWritable<ESM::MagicEffect>().setUp();
getWritable<ESM::Attribute>().setUp();
getWritable<ESM4::Land>().updateLandPositions(get<ESM4::Cell>());

@ -901,6 +901,53 @@ namespace MWWorld
Store<ESM::Skill>::Store() {}
void Store<ESM::Skill>::setUp(const MWWorld::Store<ESM::GameSetting> 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",
};
for (int i = 0; i < ESM::Skill::Length; ++i)
{
auto found = mStatic.find(i);
if (found != mStatic.end())
{
ESM::Skill& skill = found->second;
std::string_view id = skillNameIds[i];
const ESM::GameSetting* setting = settings.search(id);
if (setting && setting->mValue.getType() == ESM::VT_String)
skill.mName = setting->mValue.getString();
else
skill.mName = id;
}
}
}
// Game Settings
//=========================================================================

@ -474,6 +474,8 @@ namespace MWWorld
{
public:
Store();
void setUp(const MWWorld::Store<ESM::GameSetting> settings);
};
template <>

@ -36,35 +36,6 @@ namespace ESM
"Speechcraft",
"Handtohand",
};
const std::string Skill::sSkillNameIds[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",
};
const std::string Skill::sIconNames[Length] = {
"combat_block.dds",
"combat_armor.dds",

@ -44,6 +44,7 @@ namespace ESM
int mIndex;
std::string mDescription;
std::string mName;
enum SkillEnum
{
@ -77,7 +78,6 @@ namespace ESM
Length
};
static const std::string sSkillNames[Length];
static const std::string sSkillNameIds[Length];
static const std::string sIconNames[Length];
static SkillEnum stringToSkillId(std::string_view skill);

Loading…
Cancel
Save