summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui/windows/skilldialog.cpp27
-rw-r--r--src/gui/windows/skilldialog.h10
-rw-r--r--src/net/ea/skillhandler.cpp3
-rw-r--r--src/net/eathena/skillhandler.cpp14
-rw-r--r--src/net/tmwa/skillhandler.cpp5
-rw-r--r--src/resources/skillowner.h2
6 files changed, 46 insertions, 15 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(); }
diff --git a/src/net/ea/skillhandler.cpp b/src/net/ea/skillhandler.cpp
index 19f7d4d63..99fffac86 100644
--- a/src/net/ea/skillhandler.cpp
+++ b/src/net/ea/skillhandler.cpp
@@ -91,7 +91,8 @@ void SkillHandler::processPlayerSkillUp(Net::MessageIn &msg)
if (!skillDialog->updateSkill(skillId, range,
up, SkillType::Unknown, sp))
{
- skillDialog->addSkill(skillId, "", level,
+ skillDialog->addSkill(SkillOwner::Player,
+ skillId, "", level,
range, up, SkillType::Unknown, sp);
}
}
diff --git a/src/net/eathena/skillhandler.cpp b/src/net/eathena/skillhandler.cpp
index 77e87d64a..bcd90b6e0 100644
--- a/src/net/eathena/skillhandler.cpp
+++ b/src/net/eathena/skillhandler.cpp
@@ -127,7 +127,7 @@ void SkillHandler::processPlayerSkills(Net::MessageIn &msg)
int updateSkill = 0;
if (skillDialog)
- skillDialog->hideSkills();
+ skillDialog->hideSkills(SkillOwner::Player);
for (int k = 0; k < skillCount; k++)
{
const int skillId = msg.readInt16("skill id");
@@ -145,7 +145,10 @@ void SkillHandler::processPlayerSkills(Net::MessageIn &msg)
if (skillDialog)
{
if (!skillDialog->updateSkill(skillId, range, up, inf, sp))
- skillDialog->addSkill(skillId, name, level, range, up, inf, sp);
+ {
+ skillDialog->addSkill(SkillOwner::Player,
+ skillId, name, level, range, up, inf, sp);
+ }
}
}
if (updateSkill && skillDialog)
@@ -157,7 +160,7 @@ void SkillHandler::processSkillCoolDown(Net::MessageIn &msg)
const int skillId = msg.readInt16("skill id");
const int duration = msg.readInt32("duration");
if (skillDialog)
- skillDialog->setSkillDuration(skillId, duration);
+ skillDialog->setSkillDuration(SkillOwner::Player, skillId, duration);
}
void SkillHandler::processSkillCoolDownList(Net::MessageIn &msg)
@@ -169,7 +172,10 @@ void SkillHandler::processSkillCoolDownList(Net::MessageIn &msg)
msg.readInt32("total");
const int duration = msg.readInt32("duration");
if (skillDialog)
- skillDialog->setSkillDuration(skillId, duration);
+ {
+ skillDialog->setSkillDuration(SkillOwner::Player,
+ skillId, duration);
+ }
}
}
diff --git a/src/net/tmwa/skillhandler.cpp b/src/net/tmwa/skillhandler.cpp
index 05f7b0d90..bfedcf927 100644
--- a/src/net/tmwa/skillhandler.cpp
+++ b/src/net/tmwa/skillhandler.cpp
@@ -136,7 +136,10 @@ void SkillHandler::processPlayerSkills(Net::MessageIn &msg)
if (skillDialog)
{
if (!skillDialog->updateSkill(skillId, range, up, inf, sp))
- skillDialog->addSkill(skillId, "", level, range, up, inf, sp);
+ {
+ skillDialog->addSkill(SkillOwner::Player,
+ skillId, "", level, range, up, inf, sp);
+ }
}
}
if (updateSkill && skillDialog)
diff --git a/src/resources/skillowner.h b/src/resources/skillowner.h
index f80291fdd..7820bba64 100644
--- a/src/resources/skillowner.h
+++ b/src/resources/skillowner.h
@@ -30,6 +30,6 @@ namespace SkillOwner
Homunculus = 2
};
-};
+}
#endif // RESOURCES_SKILLOWNER_H