1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-13 21:40:11 +00:00

Remove sAttributeIds and sSkillIds

This commit is contained in:
unknown 2023-05-27 21:54:13 +02:00
parent 36aea64eb8
commit 14600de185
9 changed files with 33 additions and 45 deletions

View File

@ -94,11 +94,12 @@ namespace MWGui
mGenerateClassSpecializations[2] = 0; mGenerateClassSpecializations[2] = 0;
// Setup player stats // Setup player stats
for (int i = 0; i < ESM::Attribute::Length; ++i) const auto& store = MWBase::Environment::get().getWorld()->getStore();
mPlayerAttributes.emplace(ESM::Attribute::sAttributeIds[i], MWMechanics::AttributeValue()); for (const ESM::Attribute& attribute : store.get<ESM::Attribute>())
mPlayerAttributes.emplace(attribute.mId, MWMechanics::AttributeValue());
for (int i = 0; i < ESM::Skill::Length; ++i) for (const auto& skill : store.get<ESM::Skill>())
mPlayerSkillValues.emplace(ESM::Skill::sSkillIds[i], MWMechanics::SkillValue()); mPlayerSkillValues.emplace(skill.second.mIndex, MWMechanics::SkillValue());
} }
void CharacterCreation::setValue(std::string_view id, const MWMechanics::AttributeValue& value) void CharacterCreation::setValue(std::string_view id, const MWMechanics::AttributeValue& value)

View File

@ -745,15 +745,16 @@ namespace MWGui
// Centre dialog // Centre dialog
center(); center();
for (int i = 0; i < 8; ++i) const auto& store = MWBase::Environment::get().getWorld()->getStore().get<ESM::Attribute>();
for (const ESM::Attribute& attribute : store)
{ {
Widgets::MWAttributePtr attribute; Widgets::MWAttributePtr widget;
char theIndex = '0' + i; char theIndex = '0' + attribute.mId;
getWidget(attribute, std::string("Attribute").append(1, theIndex)); getWidget(widget, std::string("Attribute").append(1, theIndex));
attribute->setAttributeId(ESM::Attribute::sAttributeIds[i]); widget->setAttributeId(attribute.mId);
attribute->eventClicked += MyGUI::newDelegate(this, &SelectAttributeDialog::onAttributeClicked); widget->eventClicked += MyGUI::newDelegate(this, &SelectAttributeDialog::onAttributeClicked);
ToolTips::createAttributeToolTip(attribute, attribute->getAttributeId()); ToolTips::createAttributeToolTip(widget, widget->getAttributeId());
} }
MyGUI::Button* cancelButton; MyGUI::Button* cancelButton;

View File

@ -76,13 +76,14 @@ namespace MWGui
// Setup attributes // Setup attributes
Widgets::MWAttributePtr attribute; Widgets::MWAttributePtr widget;
for (int idx = 0; idx < ESM::Attribute::Length; ++idx) const auto& store = MWBase::Environment::get().getWorld()->getStore().get<ESM::Attribute>();
for (const ESM::Attribute& attribute : store)
{ {
getWidget(attribute, std::string("Attribute") + MyGUI::utility::toString(idx)); getWidget(widget, std::string("Attribute").append(1, '0' + attribute.mId));
mAttributeWidgets.insert(std::make_pair(static_cast<int>(ESM::Attribute::sAttributeIds[idx]), attribute)); mAttributeWidgets.emplace(attribute.mId, widget);
attribute->setAttributeId(ESM::Attribute::sAttributeIds[idx]); widget->setAttributeId(attribute.mId);
attribute->setAttributeValue(Widgets::MWAttribute::AttributeValue()); widget->setAttributeValue(Widgets::MWAttribute::AttributeValue());
} }
// Setup skills // Setup skills
@ -234,10 +235,11 @@ namespace MWGui
std::copy(major.begin(), major.end(), std::inserter(skillSet, skillSet.begin())); std::copy(major.begin(), major.end(), std::inserter(skillSet, skillSet.begin()));
std::copy(minor.begin(), minor.end(), std::inserter(skillSet, skillSet.begin())); std::copy(minor.begin(), minor.end(), std::inserter(skillSet, skillSet.begin()));
mMiscSkills.clear(); mMiscSkills.clear();
for (const int skill : ESM::Skill::sSkillIds) const auto& store = MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>();
for (const auto& skill : store)
{ {
if (skillSet.find(skill) == skillSet.end()) if (!skillSet.contains(skill.second.mIndex))
mMiscSkills.push_back(skill); mMiscSkills.push_back(skill.second.mIndex);
} }
mUpdateSkillArea = true; mUpdateSkillArea = true;

View File

@ -324,10 +324,11 @@ namespace MWGui
std::copy(major.begin(), major.end(), std::inserter(skillSet, skillSet.begin())); std::copy(major.begin(), major.end(), std::inserter(skillSet, skillSet.begin()));
std::copy(minor.begin(), minor.end(), std::inserter(skillSet, skillSet.begin())); std::copy(minor.begin(), minor.end(), std::inserter(skillSet, skillSet.begin()));
mMiscSkills.clear(); mMiscSkills.clear();
for (const int skill : ESM::Skill::sSkillIds) const auto& store = MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>();
for (const auto& skill : store)
{ {
if (skillSet.find(skill) == skillSet.end()) if (!skillSet.contains(skill.second.mIndex))
mMiscSkills.push_back(skill); mMiscSkills.push_back(skill.second.mIndex);
} }
updateSkillArea(); updateSkillArea();

View File

@ -951,7 +951,7 @@ namespace MWWorld
for (int i = 0; i < ESM::Attribute::Length; ++i) for (int i = 0; i < ESM::Attribute::Length; ++i)
{ {
ESM::Attribute newAttribute; ESM::Attribute newAttribute;
newAttribute.mId = ESM::Attribute::sAttributeIds[i]; newAttribute.mId = ESM::Attribute::AttributeID(i);
newAttribute.mName = ESM::Attribute::sGmstAttributeIds[i]; newAttribute.mName = ESM::Attribute::sGmstAttributeIds[i];
newAttribute.mDescription = ESM::Attribute::sGmstAttributeDescIds[i]; newAttribute.mDescription = ESM::Attribute::sGmstAttributeDescIds[i];
mStatic.push_back(newAttribute); mStatic.push_back(newAttribute);

View File

@ -4,17 +4,6 @@
using namespace ESM; using namespace ESM;
const Attribute::AttributeID Attribute::sAttributeIds[Attribute::Length] = {
Attribute::Strength,
Attribute::Intelligence,
Attribute::Willpower,
Attribute::Agility,
Attribute::Speed,
Attribute::Endurance,
Attribute::Personality,
Attribute::Luck,
};
const std::string Attribute::sAttributeNames[Attribute::Length] = { const std::string Attribute::sAttributeNames[Attribute::Length] = {
"Strength", "Strength",
"Intelligence", "Intelligence",
@ -61,9 +50,9 @@ const std::string Attribute::sAttributeIcons[Attribute::Length] = {
Attribute::AttributeID Attribute::stringToAttributeId(std::string_view attribute) Attribute::AttributeID Attribute::stringToAttributeId(std::string_view attribute)
{ {
for (auto id : sAttributeIds) for (int id = 0; id < Attribute::Length; ++id)
if (Misc::StringUtils::ciEqual(sAttributeNames[id], attribute)) if (Misc::StringUtils::ciEqual(sAttributeNames[id], attribute))
return id; return Attribute::AttributeID(id);
throw std::logic_error("No such attribute: " + std::string(attribute)); throw std::logic_error("No such attribute: " + std::string(attribute));
} }

View File

@ -28,7 +28,6 @@ namespace ESM
AttributeID mId; AttributeID mId;
std::string mName, mDescription; std::string mName, mDescription;
static const AttributeID sAttributeIds[Length];
static const std::string sAttributeNames[Length]; static const std::string sAttributeNames[Length];
static const std::string sGmstAttributeIds[Length]; static const std::string sGmstAttributeIds[Length];
static const std::string sGmstAttributeDescIds[Length]; static const std::string sGmstAttributeDescIds[Length];

View File

@ -94,16 +94,12 @@ namespace ESM
"stealth_speechcraft.dds", "stealth_speechcraft.dds",
"stealth_handtohand.dds", "stealth_handtohand.dds",
}; };
const std::array<Skill::SkillEnum, Skill::Length> Skill::sSkillIds
= { { Block, Armorer, MediumArmor, HeavyArmor, BluntWeapon, LongBlade, Axe, Spear, Athletics, Enchant,
Destruction, Alteration, Illusion, Conjuration, Mysticism, Restoration, Alchemy, Unarmored, Security, Sneak,
Acrobatics, LightArmor, ShortBlade, Marksman, Mercantile, Speechcraft, HandToHand } };
Skill::SkillEnum Skill::stringToSkillId(std::string_view skill) Skill::SkillEnum Skill::stringToSkillId(std::string_view skill)
{ {
for (auto id : sSkillIds) for (int id = 0; id < Skill::Length; ++id)
if (Misc::StringUtils::ciEqual(sSkillNames[id], skill)) if (Misc::StringUtils::ciEqual(sSkillNames[id], skill))
return id; return Skill::SkillEnum(id);
throw std::logic_error("No such skill: " + std::string(skill)); throw std::logic_error("No such skill: " + std::string(skill));
} }

View File

@ -79,7 +79,6 @@ namespace ESM
static const std::string sSkillNames[Length]; static const std::string sSkillNames[Length];
static const std::string sSkillNameIds[Length]; static const std::string sSkillNameIds[Length];
static const std::string sIconNames[Length]; static const std::string sIconNames[Length];
static const std::array<SkillEnum, Length> sSkillIds;
static SkillEnum stringToSkillId(std::string_view skill); static SkillEnum stringToSkillId(std::string_view skill);