summaryrefslogtreecommitdiff
path: root/src/gui/windows/skilldialog.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-09-20 17:55:42 +0300
committerAndrei Karas <akaras@inbox.ru>2014-09-20 17:55:42 +0300
commit5f7a8dd28733fd460578e43c6b2ea4990afa0670 (patch)
tree0263f50e8a566af4b8d081889316a05e1f048dab /src/gui/windows/skilldialog.cpp
parentc958cb619f667851b188b8c169d0fcb14500f6de (diff)
downloadmv-5f7a8dd28733fd460578e43c6b2ea4990afa0670.tar.gz
mv-5f7a8dd28733fd460578e43c6b2ea4990afa0670.tar.bz2
mv-5f7a8dd28733fd460578e43c6b2ea4990afa0670.tar.xz
mv-5f7a8dd28733fd460578e43c6b2ea4990afa0670.zip
Use skill owner field in most functions.
Diffstat (limited to 'src/gui/windows/skilldialog.cpp')
-rw-r--r--src/gui/windows/skilldialog.cpp27
1 files changed, 22 insertions, 5 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())