diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-09-20 17:55:42 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-09-20 17:55:42 +0300 |
commit | 5f7a8dd28733fd460578e43c6b2ea4990afa0670 (patch) | |
tree | 0263f50e8a566af4b8d081889316a05e1f048dab /src/gui | |
parent | c958cb619f667851b188b8c169d0fcb14500f6de (diff) | |
download | manaplus-5f7a8dd28733fd460578e43c6b2ea4990afa0670.tar.gz manaplus-5f7a8dd28733fd460578e43c6b2ea4990afa0670.tar.bz2 manaplus-5f7a8dd28733fd460578e43c6b2ea4990afa0670.tar.xz manaplus-5f7a8dd28733fd460578e43c6b2ea4990afa0670.zip |
Use skill owner field in most functions.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/windows/skilldialog.cpp | 27 | ||||
-rw-r--r-- | src/gui/windows/skilldialog.h | 10 |
2 files changed, 29 insertions, 8 deletions
diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index 08ceea30f..feef1dba6 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -57,6 +57,17 @@ SkillDialog *skillDialog = nullptr; +static SkillOwner::Type parseOwner(const std::string &str) +{ + if (str == "player") + return SkillOwner::Player; + else if (str == "mercenary") + return SkillOwner::Mercenary; + else if (str == "homunculus") + return SkillOwner::Homunculus; + return SkillOwner::Player; +} + SkillDialog::SkillDialog() : // TRANSLATORS: skills dialog name Window(_("Skills"), false, nullptr, "skills.xml"), @@ -201,12 +212,12 @@ void SkillDialog::clearSkills() mDurations.clear(); } -void SkillDialog::hideSkills() +void SkillDialog::hideSkills(const SkillOwner::Type owner) { FOR_EACH (SkillMap::iterator, it, mSkills) { SkillInfo *const info = (*it).second; - if (info) + if (info && info->owner == owner) info->visible = false; } } @@ -280,6 +291,8 @@ void SkillDialog::loadXmlFile(const std::string &fileName) skill->update(); skill->useButton = XML::getProperty( node, "useButton", _("Use")); + skill->owner = parseOwner(XML::getProperty( + node, "owner", "player")); model->addSkill(skill); mSkills[id] = skill; } @@ -367,7 +380,8 @@ bool SkillDialog::updateSkill(const int id, return false; } -void SkillDialog::addSkill(const int id, +void SkillDialog::addSkill(const SkillOwner::Type owner, + const int id, const std::string &name, const int level, const int range, @@ -380,6 +394,7 @@ void SkillDialog::addSkill(const int id, SkillInfo *const skill = new SkillInfo; skill->id = static_cast<unsigned int>(id); skill->type = type; + skill->owner = owner; SkillData *const data = skill->data; if (name.empty()) { @@ -427,13 +442,15 @@ SkillInfo* SkillDialog::getSkillByItem(const int itemId) const return nullptr; } -void SkillDialog::setSkillDuration(const int id, const int duration) +void SkillDialog::setSkillDuration(const SkillOwner::Type owner, + const int id, + const int duration) { SkillMap::const_iterator it = mSkills.find(id); SkillInfo *info = nullptr; if (it == mSkills.end()) { - addSkill(id, "", 0, 0, false, SkillType::Unknown, 0); + addSkill(owner, id, "", 0, 0, false, SkillType::Unknown, 0); it = mSkills.find(id); } if (it != mSkills.end()) diff --git a/src/gui/windows/skilldialog.h b/src/gui/windows/skilldialog.h index fd9bca7c2..ddeea2cc7 100644 --- a/src/gui/windows/skilldialog.h +++ b/src/gui/windows/skilldialog.h @@ -27,6 +27,7 @@ #include "listeners/actionlistener.h" +#include "resources/skillowner.h" #include "resources/skilltype.h" class Button; @@ -73,7 +74,7 @@ class SkillDialog final : public Window, void clearSkills(); - void hideSkills(); + void hideSkills(const SkillOwner::Type owner); void loadSkills(); @@ -83,7 +84,8 @@ class SkillDialog final : public Window, const SkillType::SkillType type, const int sp); - void addSkill(const int id, + void addSkill(const SkillOwner::Type owner, + const int id, const std::string &name, const int level, const int range, @@ -95,7 +97,9 @@ class SkillDialog final : public Window, SkillInfo* getSkillByItem(const int itemId) const A_WARN_UNUSED; - void setSkillDuration(const int id, const int duration); + void setSkillDuration(const SkillOwner::Type owner, + const int id, + const int duration); bool hasSkills() const A_WARN_UNUSED { return !mSkills.empty(); } |