summaryrefslogtreecommitdiff
path: root/src/gui/skilldialog.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-03-10 20:20:36 +0300
committerAndrei Karas <akaras@inbox.ru>2012-03-10 20:20:36 +0300
commit501f9934731114562c3659918d9d7b39625eb7b5 (patch)
treeafefc8debeff97d40141a342135da8e7ab5cb9bb /src/gui/skilldialog.cpp
parent307818fecbd1f258c668a1667e76e950e9d22622 (diff)
downloadmv-501f9934731114562c3659918d9d7b39625eb7b5.tar.gz
mv-501f9934731114562c3659918d9d7b39625eb7b5.tar.bz2
mv-501f9934731114562c3659918d9d7b39625eb7b5.tar.xz
mv-501f9934731114562c3659918d9d7b39625eb7b5.zip
Allow add skills to shortcuts bar (same as for magic and script commands).
Diffstat (limited to 'src/gui/skilldialog.cpp')
-rw-r--r--src/gui/skilldialog.cpp36
1 files changed, 33 insertions, 3 deletions
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index 023c5a4f0..a930d3929 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -22,12 +22,14 @@
#include "gui/skilldialog.h"
+#include "itemshortcut.h"
#include "localplayer.h"
#include "logger.h"
#include "playerinfo.h"
#include "configuration.h"
#include "gui/setup.h"
+#include "gui/shortcutwindow.h"
#include "gui/textpopup.h"
#include "gui/theme.h"
#include "gui/viewport.h"
@@ -268,9 +270,20 @@ void SkillDialog::action(const gcn::ActionEvent &event)
if (tab)
{
if (SkillInfo *info = tab->getSelectedInfo())
+ {
mUseButton->setEnabled(info->range > 0);
+
+ int num = itemShortcutWindow->getTabIndex();
+ if (num >= 0 && num < SHORTCUT_TABS && itemShortcut[num])
+ {
+ itemShortcut[num]->setItemSelected(
+ info->id + SKILL_MIN_ID);
+ }
+ }
else
+ {
mUseButton->setEnabled(false);
+ }
}
}
else if (event.getId() == "use")
@@ -361,6 +374,7 @@ void SkillDialog::loadSkills(const std::string &file)
skill->id = 1;
skill->name = _("basic");
skill->dispName = _("Skill: basic, Id: 1");
+ skill->shortName = "bas";
skill->setIcon("");
skill->modifiable = true;
skill->visible = true;
@@ -416,6 +430,8 @@ void SkillDialog::loadSkills(const std::string &file)
skill->name = name;
skill->dispName = strprintf(_("Skill: %s, Id: %d"),
name.c_str(), skill->id);
+ skill->shortName = XML::langProperty(node,
+ "shortName", name.substr(0, 3));
skill->setIcon(icon);
skill->modifiable = false;
skill->visible = false;
@@ -507,9 +523,9 @@ void SkillModel::updateVisibilities()
}
SkillInfo::SkillInfo() :
- id(0), name(""), dispName(""), icon(nullptr), modifiable(false),
- visible(false), model(nullptr), level(0), skillLevel(""),
- skillLevelWidth(0), skillExp(""), progress(0.0f), range(0),
+ id(0), name(""), shortName(""), dispName(""), icon(nullptr),
+ modifiable(false), visible(false), model(nullptr), level(0),
+ skillLevel(""), skillLevelWidth(0), skillExp(""), progress(0.0f), range(0),
particle(""), soundHit(""), soundMiss("")
{
}
@@ -626,3 +642,17 @@ void SkillDialog::widgetResized(const gcn::Event &event)
if (mTabs)
mTabs->fixSize();
}
+
+void SkillDialog::useItem(int itemId)
+{
+ const SkillInfo *info = mSkills[itemId - SKILL_MIN_ID];
+ if (info && player_node && player_node->getTarget())
+ {
+ const Being *being = player_node->getTarget();
+ if (being)
+ {
+ Net::getSpecialHandler()->useBeing(info->level,
+ info->id, being->getId());
+ }
+ }
+}