1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-10 12:39:53 +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;
// Setup player stats
for (int i = 0; i < ESM::Attribute::Length; ++i)
mPlayerAttributes.emplace(ESM::Attribute::sAttributeIds[i], MWMechanics::AttributeValue());
const auto& store = MWBase::Environment::get().getWorld()->getStore();
for (const ESM::Attribute& attribute : store.get<ESM::Attribute>())
mPlayerAttributes.emplace(attribute.mId, MWMechanics::AttributeValue());
for (int i = 0; i < ESM::Skill::Length; ++i)
mPlayerSkillValues.emplace(ESM::Skill::sSkillIds[i], MWMechanics::SkillValue());
for (const auto& skill : store.get<ESM::Skill>())
mPlayerSkillValues.emplace(skill.second.mIndex, MWMechanics::SkillValue());
}
void CharacterCreation::setValue(std::string_view id, const MWMechanics::AttributeValue& value)

View File

@ -745,15 +745,16 @@ namespace MWGui
// Centre dialog
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;
char theIndex = '0' + i;
Widgets::MWAttributePtr widget;
char theIndex = '0' + attribute.mId;
getWidget(attribute, std::string("Attribute").append(1, theIndex));
attribute->setAttributeId(ESM::Attribute::sAttributeIds[i]);
attribute->eventClicked += MyGUI::newDelegate(this, &SelectAttributeDialog::onAttributeClicked);
ToolTips::createAttributeToolTip(attribute, attribute->getAttributeId());
getWidget(widget, std::string("Attribute").append(1, theIndex));
widget->setAttributeId(attribute.mId);
widget->eventClicked += MyGUI::newDelegate(this, &SelectAttributeDialog::onAttributeClicked);
ToolTips::createAttributeToolTip(widget, widget->getAttributeId());
}
MyGUI::Button* cancelButton;

View File

@ -76,13 +76,14 @@ namespace MWGui
// Setup attributes
Widgets::MWAttributePtr attribute;
for (int idx = 0; idx < ESM::Attribute::Length; ++idx)
Widgets::MWAttributePtr widget;
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));
mAttributeWidgets.insert(std::make_pair(static_cast<int>(ESM::Attribute::sAttributeIds[idx]), attribute));
attribute->setAttributeId(ESM::Attribute::sAttributeIds[idx]);
attribute->setAttributeValue(Widgets::MWAttribute::AttributeValue());
getWidget(widget, std::string("Attribute").append(1, '0' + attribute.mId));
mAttributeWidgets.emplace(attribute.mId, widget);
widget->setAttributeId(attribute.mId);
widget->setAttributeValue(Widgets::MWAttribute::AttributeValue());
}
// Setup skills
@ -234,10 +235,11 @@ namespace MWGui
std::copy(major.begin(), major.end(), std::inserter(skillSet, skillSet.begin()));
std::copy(minor.begin(), minor.end(), std::inserter(skillSet, skillSet.begin()));
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())
mMiscSkills.push_back(skill);
if (!skillSet.contains(skill.second.mIndex))
mMiscSkills.push_back(skill.second.mIndex);
}
mUpdateSkillArea = true;

View File

@ -324,10 +324,11 @@ namespace MWGui
std::copy(major.begin(), major.end(), std::inserter(skillSet, skillSet.begin()));
std::copy(minor.begin(), minor.end(), std::inserter(skillSet, skillSet.begin()));
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())
mMiscSkills.push_back(skill);
if (!skillSet.contains(skill.second.mIndex))
mMiscSkills.push_back(skill.second.mIndex);
}
updateSkillArea();

View File

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

View File

@ -4,17 +4,6 @@
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] = {
"Strength",
"Intelligence",
@ -61,9 +50,9 @@ const std::string Attribute::sAttributeIcons[Attribute::Length] = {
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))
return id;
return Attribute::AttributeID(id);
throw std::logic_error("No such attribute: " + std::string(attribute));
}

View File

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

View File

@ -94,16 +94,12 @@ namespace ESM
"stealth_speechcraft.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)
{
for (auto id : sSkillIds)
for (int id = 0; id < Skill::Length; ++id)
if (Misc::StringUtils::ciEqual(sSkillNames[id], skill))
return id;
return Skill::SkillEnum(id);
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 sSkillNameIds[Length];
static const std::string sIconNames[Length];
static const std::array<SkillEnum, Length> sSkillIds;
static SkillEnum stringToSkillId(std::string_view skill);