summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-09-05 11:02:33 +0300
committerAndrei Karas <akaras@inbox.ru>2014-09-06 01:18:57 +0300
commitfeeddcb6fe41864d862b9e36e503d3ace07eb76d (patch)
treef32d3727ffbb566f9fcdc5ce3a6e08ba16b88a7e /src/gui
parent78edce93375df12e878b69af829f37a84c5c86d5 (diff)
downloadmv-feeddcb6fe41864d862b9e36e503d3ace07eb76d.tar.gz
mv-feeddcb6fe41864d862b9e36e503d3ace07eb76d.tar.bz2
mv-feeddcb6fe41864d862b9e36e503d3ace07eb76d.tar.xz
mv-feeddcb6fe41864d862b9e36e503d3ace07eb76d.zip
allow use unknown skills.
Move skill usage code into separate method.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/windows/skilldialog.cpp46
-rw-r--r--src/gui/windows/skilldialog.h2
2 files changed, 28 insertions, 20 deletions
diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp
index 5cd79c600..0babe5d38 100644
--- a/src/gui/windows/skilldialog.cpp
+++ b/src/gui/windows/skilldialog.cpp
@@ -125,8 +125,17 @@ void SkillDialog::action(const ActionEvent &event)
{
if (const SkillInfo *const info = tab->getSelectedInfo())
{
- mUseButton->setEnabled(info->range > 0);
- mUseButton->setCaption(info->useButton);
+ if (info && info->data && info->useButton.empty()
+ && info->data->description.empty())
+ {
+ mUseButton->setEnabled(true);
+ mUseButton->setCaption(_("Use"));
+ }
+ else
+ {
+ mUseButton->setEnabled(info->range > 0);
+ mUseButton->setCaption(info->useButton);
+ }
mIncreaseButton->setEnabled(info->id < SKILL_VAR_MIN_ID);
const int num = itemShortcutWindow->getTabIndex();
if (num >= 0 && num < static_cast<int>(SHORTCUT_TABS)
@@ -151,15 +160,7 @@ void SkillDialog::action(const ActionEvent &event)
if (tab)
{
const SkillInfo *const info = tab->getSelectedInfo();
- if (info && localPlayer && localPlayer->getTarget())
- {
- const Being *const being = localPlayer->getTarget();
- if (being)
- {
- Net::getSkillHandler()->useBeing(info->level,
- info->id, being->getId());
- }
- }
+ useSkill(info);
}
}
else if (eventId == "close")
@@ -420,15 +421,7 @@ void SkillDialog::useItem(const int itemId) const
return;
const SkillInfo *const info = (*it).second;
- if (info && localPlayer && localPlayer->getTarget())
- {
- const Being *const being = localPlayer->getTarget();
- if (being)
- {
- Net::getSkillHandler()->useBeing(info->level,
- info->id, being->getId());
- }
- }
+ useSkill(info);
}
void SkillDialog::updateTabSelection()
@@ -480,3 +473,16 @@ void SkillDialog::playUpdateEffect(const int id) const
effectManager->trigger(effectId, localPlayer);
}
}
+
+void SkillDialog::useSkill(const SkillInfo *const info)
+{
+ if (info && localPlayer && localPlayer->getTarget())
+ {
+ const Being *const being = localPlayer->getTarget();
+ if (being)
+ {
+ Net::getSkillHandler()->useBeing(info->level,
+ info->id, being->getId());
+ }
+ }
+}
diff --git a/src/gui/windows/skilldialog.h b/src/gui/windows/skilldialog.h
index e0ed1f1b2..394679d1b 100644
--- a/src/gui/windows/skilldialog.h
+++ b/src/gui/windows/skilldialog.h
@@ -95,6 +95,8 @@ class SkillDialog final : public Window,
void playUpdateEffect(const int id) const;
+ static void useSkill(const SkillInfo *const info);
+
private:
typedef std::map<int, SkillInfo*> SkillMap;
SkillMap mSkills;