mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-30 16:20:21 +00:00
Dehardcode the list of skills in the stats window
This commit is contained in:
parent
15a5fa84f6
commit
9a93dcc39e
@ -145,7 +145,7 @@ namespace MWGui
|
|||||||
mReviewDialog->setSkillValue(id, value);
|
mReviewDialog->setSkillValue(id, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharacterCreation::configureSkills(const SkillList& major, const SkillList& minor)
|
void CharacterCreation::configureSkills(const std::vector<ESM::RefId>& major, const std::vector<ESM::RefId>& minor)
|
||||||
{
|
{
|
||||||
if (mReviewDialog)
|
if (mReviewDialog)
|
||||||
mReviewDialog->configureSkills(major, minor);
|
mReviewDialog->configureSkills(major, minor);
|
||||||
|
@ -38,8 +38,6 @@ namespace MWGui
|
|||||||
class CharacterCreation : public StatsListener
|
class CharacterCreation : public StatsListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::vector<int> SkillList;
|
|
||||||
|
|
||||||
CharacterCreation(osg::Group* parent, Resource::ResourceSystem* resourceSystem);
|
CharacterCreation(osg::Group* parent, Resource::ResourceSystem* resourceSystem);
|
||||||
virtual ~CharacterCreation();
|
virtual ~CharacterCreation();
|
||||||
|
|
||||||
@ -49,7 +47,7 @@ namespace MWGui
|
|||||||
void setValue(std::string_view id, const MWMechanics::AttributeValue& value) override;
|
void setValue(std::string_view id, const MWMechanics::AttributeValue& value) override;
|
||||||
void setValue(std::string_view id, const MWMechanics::DynamicStat<float>& value) override;
|
void setValue(std::string_view id, const MWMechanics::DynamicStat<float>& value) override;
|
||||||
void setValue(ESM::RefId id, const MWMechanics::SkillValue& value) override;
|
void setValue(ESM::RefId id, const MWMechanics::SkillValue& value) override;
|
||||||
void configureSkills(const SkillList& major, const SkillList& minor) override;
|
void configureSkills(const std::vector<ESM::RefId>& major, const std::vector<ESM::RefId>& minor) override;
|
||||||
|
|
||||||
void onFrame(float duration);
|
void onFrame(float duration);
|
||||||
|
|
||||||
@ -57,7 +55,7 @@ namespace MWGui
|
|||||||
osg::Group* mParent;
|
osg::Group* mParent;
|
||||||
Resource::ResourceSystem* mResourceSystem;
|
Resource::ResourceSystem* mResourceSystem;
|
||||||
|
|
||||||
SkillList mPlayerMajorSkills, mPlayerMinorSkills;
|
std::vector<ESM::RefId> mPlayerMajorSkills, mPlayerMinorSkills;
|
||||||
std::map<int, MWMechanics::AttributeValue> mPlayerAttributes;
|
std::map<int, MWMechanics::AttributeValue> mPlayerAttributes;
|
||||||
std::map<ESM::RefId, MWMechanics::SkillValue> mPlayerSkillValues;
|
std::map<ESM::RefId, MWMechanics::SkillValue> mPlayerSkillValues;
|
||||||
|
|
||||||
|
@ -226,21 +226,21 @@ namespace MWGui
|
|||||||
mUpdateSkillArea = true;
|
mUpdateSkillArea = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReviewDialog::configureSkills(const std::vector<int>& major, const std::vector<int>& minor)
|
void ReviewDialog::configureSkills(const std::vector<ESM::RefId>& major, const std::vector<ESM::RefId>& minor)
|
||||||
{
|
{
|
||||||
mMajorSkills = major;
|
mMajorSkills = major;
|
||||||
mMinorSkills = minor;
|
mMinorSkills = minor;
|
||||||
|
|
||||||
// Update misc skills with the remaining skills not in major or minor
|
// Update misc skills with the remaining skills not in major or minor
|
||||||
std::set<int> skillSet;
|
std::set<ESM::RefId> skillSet;
|
||||||
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();
|
||||||
const auto& store = MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>();
|
const auto& store = MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>();
|
||||||
for (const ESM::Skill& skill : store)
|
for (const ESM::Skill& skill : store)
|
||||||
{
|
{
|
||||||
if (!skillSet.contains(skill.mIndex))
|
if (!skillSet.contains(skill.mId))
|
||||||
mMiscSkills.push_back(skill.mIndex);
|
mMiscSkills.push_back(skill.mId);
|
||||||
}
|
}
|
||||||
|
|
||||||
mUpdateSkillArea = true;
|
mUpdateSkillArea = true;
|
||||||
@ -328,8 +328,8 @@ namespace MWGui
|
|||||||
coord2.top += lineHeight;
|
coord2.top += lineHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReviewDialog::addSkills(const SkillList& skills, const std::string& titleId, const std::string& titleDefault,
|
void ReviewDialog::addSkills(const std::vector<ESM::RefId>& skills, const std::string& titleId,
|
||||||
MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2)
|
const std::string& titleDefault, MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2)
|
||||||
{
|
{
|
||||||
// Add a line separator if there are items above
|
// Add a line separator if there are items above
|
||||||
if (!mSkillWidgets.empty())
|
if (!mSkillWidgets.empty())
|
||||||
@ -340,10 +340,9 @@ namespace MWGui
|
|||||||
addGroup(
|
addGroup(
|
||||||
MWBase::Environment::get().getWindowManager()->getGameSettingString(titleId, titleDefault), coord1, coord2);
|
MWBase::Environment::get().getWindowManager()->getGameSettingString(titleId, titleDefault), coord1, coord2);
|
||||||
|
|
||||||
for (const int& skillIndex : skills)
|
for (const ESM::RefId& skillId : skills)
|
||||||
{
|
{
|
||||||
const ESM::Skill* skill = MWBase::Environment::get().getESMStore()->get<ESM::Skill>().search(
|
const ESM::Skill* skill = MWBase::Environment::get().getESMStore()->get<ESM::Skill>().search(skillId);
|
||||||
ESM::Skill::indexToRefId(skillIndex));
|
|
||||||
if (!skill) // Skip unknown skills
|
if (!skill) // Skip unknown skills
|
||||||
continue;
|
continue;
|
||||||
const MWMechanics::SkillValue& stat = mSkillValues.find(skill->mId)->second;
|
const MWMechanics::SkillValue& stat = mSkillValues.find(skill->mId)->second;
|
||||||
|
@ -24,7 +24,6 @@ namespace MWGui
|
|||||||
CLASS_DIALOG,
|
CLASS_DIALOG,
|
||||||
BIRTHSIGN_DIALOG
|
BIRTHSIGN_DIALOG
|
||||||
};
|
};
|
||||||
typedef std::vector<int> SkillList;
|
|
||||||
|
|
||||||
ReviewDialog();
|
ReviewDialog();
|
||||||
|
|
||||||
@ -41,7 +40,7 @@ namespace MWGui
|
|||||||
|
|
||||||
void setAttribute(ESM::Attribute::AttributeID attributeId, const MWMechanics::AttributeValue& value);
|
void setAttribute(ESM::Attribute::AttributeID attributeId, const MWMechanics::AttributeValue& value);
|
||||||
|
|
||||||
void configureSkills(const SkillList& major, const SkillList& minor);
|
void configureSkills(const std::vector<ESM::RefId>& major, const std::vector<ESM::RefId>& minor);
|
||||||
void setSkillValue(ESM::RefId id, const MWMechanics::SkillValue& value);
|
void setSkillValue(ESM::RefId id, const MWMechanics::SkillValue& value);
|
||||||
|
|
||||||
void onOpen() override;
|
void onOpen() override;
|
||||||
@ -76,8 +75,8 @@ namespace MWGui
|
|||||||
void onMouseWheel(MyGUI::Widget* _sender, int _rel);
|
void onMouseWheel(MyGUI::Widget* _sender, int _rel);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addSkills(const SkillList& skills, const std::string& titleId, const std::string& titleDefault,
|
void addSkills(const std::vector<ESM::RefId>& skills, const std::string& titleId,
|
||||||
MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2);
|
const std::string& titleDefault, MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2);
|
||||||
void addSeparator(MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2);
|
void addSeparator(MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2);
|
||||||
void addGroup(std::string_view label, MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2);
|
void addGroup(std::string_view label, MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2);
|
||||||
MyGUI::TextBox* addValueItem(std::string_view text, const std::string& value, const std::string& state,
|
MyGUI::TextBox* addValueItem(std::string_view text, const std::string& value, const std::string& state,
|
||||||
@ -93,7 +92,7 @@ namespace MWGui
|
|||||||
|
|
||||||
std::map<int, Widgets::MWAttributePtr> mAttributeWidgets;
|
std::map<int, Widgets::MWAttributePtr> mAttributeWidgets;
|
||||||
|
|
||||||
SkillList mMajorSkills, mMinorSkills, mMiscSkills;
|
std::vector<ESM::RefId> mMajorSkills, mMinorSkills, mMiscSkills;
|
||||||
std::map<ESM::RefId, MWMechanics::SkillValue> mSkillValues;
|
std::map<ESM::RefId, MWMechanics::SkillValue> mSkillValues;
|
||||||
std::map<ESM::RefId, MyGUI::TextBox*> mSkillWidgetMap;
|
std::map<ESM::RefId, MyGUI::TextBox*> mSkillWidgetMap;
|
||||||
ESM::RefId mRaceId, mBirthSignId;
|
ESM::RefId mRaceId, mBirthSignId;
|
||||||
|
@ -125,13 +125,13 @@ namespace MWGui
|
|||||||
setValue("class", cls->mName);
|
setValue("class", cls->mName);
|
||||||
|
|
||||||
size_t size = cls->mData.mSkills.size();
|
size_t size = cls->mData.mSkills.size();
|
||||||
MWBase::WindowManager::SkillList majorSkills(size);
|
std::vector<ESM::RefId> majorSkills(size);
|
||||||
MWBase::WindowManager::SkillList minorSkills(size);
|
std::vector<ESM::RefId> minorSkills(size);
|
||||||
|
|
||||||
for (size_t i = 0; i < size; ++i)
|
for (size_t i = 0; i < size; ++i)
|
||||||
{
|
{
|
||||||
minorSkills[i] = cls->mData.mSkills[i][0];
|
minorSkills[i] = ESM::Skill::indexToRefId(cls->mData.mSkills[i][0]);
|
||||||
majorSkills[i] = cls->mData.mSkills[i][1];
|
majorSkills[i] = ESM::Skill::indexToRefId(cls->mData.mSkills[i][1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
configureSkills(majorSkills, minorSkills);
|
configureSkills(majorSkills, minorSkills);
|
||||||
@ -181,7 +181,7 @@ namespace MWGui
|
|||||||
listener->setValue(id, value);
|
listener->setValue(id, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatsWatcher::configureSkills(const std::vector<int>& major, const std::vector<int>& minor)
|
void StatsWatcher::configureSkills(const std::vector<ESM::RefId>& major, const std::vector<ESM::RefId>& minor)
|
||||||
{
|
{
|
||||||
for (StatsListener* listener : mListeners)
|
for (StatsListener* listener : mListeners)
|
||||||
listener->configureSkills(major, minor);
|
listener->configureSkills(major, minor);
|
||||||
|
@ -24,7 +24,7 @@ namespace MWGui
|
|||||||
virtual void setValue(std::string_view, const std::string& value) {}
|
virtual void setValue(std::string_view, const std::string& value) {}
|
||||||
virtual void setValue(std::string_view, int value) {}
|
virtual void setValue(std::string_view, int value) {}
|
||||||
virtual void setValue(ESM::RefId id, const MWMechanics::SkillValue& value) {}
|
virtual void setValue(ESM::RefId id, const MWMechanics::SkillValue& value) {}
|
||||||
virtual void configureSkills(const std::vector<int>& major, const std::vector<int>& minor) {}
|
virtual void configureSkills(const std::vector<ESM::RefId>& major, const std::vector<ESM::RefId>& minor) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class StatsWatcher
|
class StatsWatcher
|
||||||
@ -55,7 +55,7 @@ namespace MWGui
|
|||||||
void setValue(std::string_view id, const std::string& value);
|
void setValue(std::string_view id, const std::string& value);
|
||||||
void setValue(std::string_view id, int value);
|
void setValue(std::string_view id, int value);
|
||||||
void setValue(ESM::RefId id, const MWMechanics::SkillValue& value);
|
void setValue(ESM::RefId id, const MWMechanics::SkillValue& value);
|
||||||
void configureSkills(const std::vector<int>& major, const std::vector<int>& minor);
|
void configureSkills(const std::vector<ESM::RefId>& major, const std::vector<ESM::RefId>& minor);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StatsWatcher();
|
StatsWatcher();
|
||||||
|
@ -304,21 +304,21 @@ namespace MWGui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatsWindow::configureSkills(const std::vector<int>& major, const std::vector<int>& minor)
|
void StatsWindow::configureSkills(const std::vector<ESM::RefId>& major, const std::vector<ESM::RefId>& minor)
|
||||||
{
|
{
|
||||||
mMajorSkills = major;
|
mMajorSkills = major;
|
||||||
mMinorSkills = minor;
|
mMinorSkills = minor;
|
||||||
|
|
||||||
// Update misc skills with the remaining skills not in major or minor
|
// Update misc skills with the remaining skills not in major or minor
|
||||||
std::set<int> skillSet;
|
std::set<ESM::RefId> skillSet;
|
||||||
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();
|
||||||
const auto& store = MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>();
|
const auto& store = MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>();
|
||||||
for (const auto& skill : store)
|
for (const auto& skill : store)
|
||||||
{
|
{
|
||||||
if (!skillSet.contains(skill.mIndex))
|
if (!skillSet.contains(skill.mId))
|
||||||
mMiscSkills.push_back(skill.mIndex);
|
mMiscSkills.push_back(skill.mId);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSkillArea();
|
updateSkillArea();
|
||||||
@ -482,7 +482,7 @@ namespace MWGui
|
|||||||
return skillNameWidget;
|
return skillNameWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatsWindow::addSkills(const SkillList& skills, const std::string& titleId, const std::string& titleDefault,
|
void StatsWindow::addSkills(const std::vector<ESM::RefId>& skills, const std::string& titleId, const std::string& titleDefault,
|
||||||
MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2)
|
MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2)
|
||||||
{
|
{
|
||||||
// Add a line separator if there are items above
|
// Add a line separator if there are items above
|
||||||
@ -495,9 +495,9 @@ namespace MWGui
|
|||||||
MWBase::Environment::get().getWindowManager()->getGameSettingString(titleId, titleDefault), coord1, coord2);
|
MWBase::Environment::get().getWindowManager()->getGameSettingString(titleId, titleDefault), coord1, coord2);
|
||||||
|
|
||||||
const MWWorld::ESMStore& esmStore = *MWBase::Environment::get().getESMStore();
|
const MWWorld::ESMStore& esmStore = *MWBase::Environment::get().getESMStore();
|
||||||
for (const int skillId : skills)
|
for (const ESM::RefId& skillId : skills)
|
||||||
{
|
{
|
||||||
const ESM::Skill* skill = esmStore.get<ESM::Skill>().search(ESM::Skill::indexToRefId(skillId));
|
const ESM::Skill* skill = esmStore.get<ESM::Skill>().search(skillId);
|
||||||
if (!skill) // Skip unknown skills
|
if (!skill) // Skip unknown skills
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -12,8 +12,6 @@ namespace MWGui
|
|||||||
public:
|
public:
|
||||||
typedef std::map<ESM::RefId, int> FactionList;
|
typedef std::map<ESM::RefId, int> FactionList;
|
||||||
|
|
||||||
typedef std::vector<int> SkillList;
|
|
||||||
|
|
||||||
StatsWindow(DragAndDrop* drag);
|
StatsWindow(DragAndDrop* drag);
|
||||||
|
|
||||||
/// automatically updates all the data in the stats window, but only if it has changed.
|
/// automatically updates all the data in the stats window, but only if it has changed.
|
||||||
@ -28,7 +26,7 @@ namespace MWGui
|
|||||||
void setValue(std::string_view id, const std::string& value) override;
|
void setValue(std::string_view id, const std::string& value) override;
|
||||||
void setValue(std::string_view id, int value) override;
|
void setValue(std::string_view id, int value) override;
|
||||||
void setValue(ESM::RefId id, const MWMechanics::SkillValue& value) override;
|
void setValue(ESM::RefId id, const MWMechanics::SkillValue& value) override;
|
||||||
void configureSkills(const SkillList& major, const SkillList& minor) override;
|
void configureSkills(const std::vector<ESM::RefId>& major, const std::vector<ESM::RefId>& minor) override;
|
||||||
|
|
||||||
void setReputation(int reputation)
|
void setReputation(int reputation)
|
||||||
{
|
{
|
||||||
@ -47,8 +45,8 @@ namespace MWGui
|
|||||||
void onOpen() override { onWindowResize(mMainWidget->castType<MyGUI::Window>()); }
|
void onOpen() override { onWindowResize(mMainWidget->castType<MyGUI::Window>()); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addSkills(const SkillList& skills, const std::string& titleId, const std::string& titleDefault,
|
void addSkills(const std::vector<ESM::RefId>& skills, const std::string& titleId,
|
||||||
MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2);
|
const std::string& titleDefault, MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2);
|
||||||
void addSeparator(MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2);
|
void addSeparator(MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2);
|
||||||
void addGroup(std::string_view label, MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2);
|
void addGroup(std::string_view label, MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2);
|
||||||
std::pair<MyGUI::TextBox*, MyGUI::TextBox*> addValueItem(std::string_view text, const std::string& value,
|
std::pair<MyGUI::TextBox*, MyGUI::TextBox*> addValueItem(std::string_view text, const std::string& value,
|
||||||
@ -67,7 +65,7 @@ namespace MWGui
|
|||||||
|
|
||||||
MyGUI::ScrollView* mSkillView;
|
MyGUI::ScrollView* mSkillView;
|
||||||
|
|
||||||
SkillList mMajorSkills, mMinorSkills, mMiscSkills;
|
std::vector<ESM::RefId> mMajorSkills, mMinorSkills, mMiscSkills;
|
||||||
std::map<ESM::RefId, MWMechanics::SkillValue> mSkillValues;
|
std::map<ESM::RefId, MWMechanics::SkillValue> mSkillValues;
|
||||||
std::map<ESM::RefId, std::pair<MyGUI::TextBox*, MyGUI::TextBox*>> mSkillWidgetMap;
|
std::map<ESM::RefId, std::pair<MyGUI::TextBox*, MyGUI::TextBox*>> mSkillWidgetMap;
|
||||||
std::map<std::string, MyGUI::Widget*> mFactionWidgetMap;
|
std::map<std::string, MyGUI::Widget*> mFactionWidgetMap;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user