diff --git a/apps/openmw/mwgui/layouts.cpp b/apps/openmw/mwgui/layouts.cpp index 2268cf1fc..884c3578d 100644 --- a/apps/openmw/mwgui/layouts.cpp +++ b/apps/openmw/mwgui/layouts.cpp @@ -4,6 +4,8 @@ #include "../mwmechanics/mechanicsmanager.hpp" #include "../mwgui/window_manager.hpp" +#include +#include #include using namespace MWGui; @@ -77,11 +79,23 @@ void StatsWindow::setValue (const std::string& id, const MWMechanics::Stat& major, const std::set& minor, const std::set& misc) +void StatsWindow::configureSkills (const std::vector& major, const std::vector& minor) { majorSkills = major; minorSkills = minor; - miscSkills = misc; + + // Update misc skills with the remaining skills not in major or minor + std::set skillSet; + std::copy(major.begin(), major.end(), std::inserter(skillSet, skillSet.begin())); + std::copy(minor.begin(), minor.end(), std::inserter(skillSet, skillSet.begin())); + boost::array::const_iterator end = ESM::Skill::skillIds.end(); + miscSkills.clear(); + for (boost::array::const_iterator it = ESM::Skill::skillIds.begin(); it != end; ++it) + { + int skill = *it; + if (skillSet.find(skill) == skillSet.end()) + miscSkills.push_back(skill); + } } void StatsWindow::setFactions (const std::vector& factions) @@ -145,7 +159,7 @@ void StatsWindow::addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI coord2.top += lineHeight; } -void StatsWindow::addSkills(const std::set &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) +void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) { WindowManager *wm = environment.mWindowManager; MWMechanics::MechanicsManager *mm = environment.mMechanicsManager; @@ -159,8 +173,8 @@ void StatsWindow::addSkills(const std::set &skills, const std::string &titl addGroup(wm->getGameSettingString(titleId, titleDefault), coord1, coord2); - std::set::const_iterator end = skills.end(); - for (std::set::const_iterator it = skills.begin(); it != end; ++it) + SkillList::const_iterator end = skills.end(); + for (SkillList::const_iterator it = skills.begin(); it != end; ++it) { int skillId = *it; if (skillId < 0 || skillId > ESM::Skill::Length) // Skip unknown skill indexes diff --git a/apps/openmw/mwgui/layouts.hpp b/apps/openmw/mwgui/layouts.hpp index b6f7e5dd1..bc45536d4 100644 --- a/apps/openmw/mwgui/layouts.hpp +++ b/apps/openmw/mwgui/layouts.hpp @@ -183,6 +183,8 @@ namespace MWGui typedef std::pair Faction; typedef std::vector FactionList; + typedef std::vector SkillList; + void setBar(const std::string& name, const std::string& tname, int val, int max) { MyGUI::ProgressPtr pt; @@ -306,7 +308,7 @@ namespace MWGui void setValue (const std::string& id, const MWMechanics::Stat& value); - void configureSkills (const std::set& major, const std::set& minor, const std::set& misc); + void configureSkills (const SkillList& major, const SkillList& minor); void setFactions (const std::vector& factions); void setBirthSign (const std::string &signId); void setReputation (int reputation) { this->reputation = reputation; } @@ -321,7 +323,7 @@ namespace MWGui CS_Super }; void setStyledText(MyGUI::WidgetPtr widget, ColorStyle style, const std::string &value); - void addSkills(const std::set &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); + void addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); MyGUI::WidgetPtr addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); @@ -331,7 +333,7 @@ namespace MWGui MWWorld::Environment& environment; MyGUI::WidgetPtr skillAreaWidget; - std::set majorSkills, minorSkills, miscSkills; + SkillList majorSkills, minorSkills, miscSkills; std::map > skillValues; std::map skillWidgetMap; std::map factionWidgetMap; diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 50fa9eabd..2dae461c6 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -171,9 +171,9 @@ void WindowManager::setValue (const std::string& id, int value) stats->setValue (id, value); } -void WindowManager::configureSkills (const std::set& major, const std::set& minor, const std::set& misc) +void WindowManager::configureSkills (const SkillList& major, const SkillList& minor) { - stats->configureSkills (major, minor, misc); + stats->configureSkills (major, minor); } void WindowManager::setFactions (const FactionList& factions) diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index 06305834d..3d8bcf6f1 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -128,6 +128,7 @@ namespace MWGui typedef std::pair Faction; typedef std::vector FactionList; + typedef std::vector SkillList; void setValue (const std::string& id, const MWMechanics::Stat& value); ///< Set value for the given ID. @@ -144,7 +145,7 @@ namespace MWGui void setValue (const std::string& id, int value); ///< set value for the given ID. - void configureSkills (const std::set& major, const std::set& minor, const std::set& misc); + void configureSkills (const SkillList& major, const SkillList& minor); ///< configure skill groups, each set contains the skill ID for that group. void setFactions (const FactionList& factions); diff --git a/components/esm/loadskil.hpp b/components/esm/loadskil.hpp index 27959c4ef..24535c6c3 100644 --- a/components/esm/loadskil.hpp +++ b/components/esm/loadskil.hpp @@ -1,6 +1,8 @@ #ifndef _ESM_SKIL_H #define _ESM_SKIL_H +#include + #include "esm_reader.hpp" #include "defs.hpp" @@ -62,6 +64,7 @@ struct Skill Length }; static const std::string sSkillNameIds[Length]; + static const boost::array skillIds; void load(ESMReader &esm) { diff --git a/components/esm/skill.cpp b/components/esm/skill.cpp index 021248ab9..05c8c103a 100644 --- a/components/esm/skill.cpp +++ b/components/esm/skill.cpp @@ -31,4 +31,33 @@ namespace ESM "sSkillSpeechcraft", "sSkillHandtohand", }; + const boost::array Skill::skillIds = {{ + 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 + }}; }