summaryrefslogtreecommitdiff
path: root/src/actions
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-08-08 00:38:31 +0300
committerAndrei Karas <akaras@inbox.ru>2017-08-08 00:38:31 +0300
commit344efb2009b8c6d329a6d19dd45ed49076252710 (patch)
tree2e5c1a7d9484e1cc3bfedac7b03c7146be442896 /src/actions
parentfa4c5d79b04a319550996c48448cd799fe7fde56 (diff)
downloadmanaplus-344efb2009b8c6d329a6d19dd45ed49076252710.tar.gz
manaplus-344efb2009b8c6d329a6d19dd45ed49076252710.tar.bz2
manaplus-344efb2009b8c6d329a6d19dd45ed49076252710.tar.xz
manaplus-344efb2009b8c6d329a6d19dd45ed49076252710.zip
Add into skill context menu for add shortcut.
Also add chat command for add skill shortcut by skill id into free slot.
Diffstat (limited to 'src/actions')
-rw-r--r--src/actions/commands.cpp42
-rw-r--r--src/actions/commands.h1
2 files changed, 43 insertions, 0 deletions
diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp
index 6b51d2270..235afecb5 100644
--- a/src/actions/commands.cpp
+++ b/src/actions/commands.cpp
@@ -33,11 +33,14 @@
#include "being/homunculusinfo.h"
#include "being/playerinfo.h"
+#include "const/resources/skill.h"
+
#include "gui/viewport.h"
#include "gui/popups/popupmenu.h"
#include "gui/shortcut/emoteshortcut.h"
+#include "gui/shortcut/itemshortcut.h"
#include "gui/windows/mailwindow.h"
@@ -45,6 +48,7 @@
#include "gui/windows/inventorywindow.h"
#include "gui/windows/npcdialog.h"
#include "gui/windows/outfitwindow.h"
+#include "gui/windows/shortcutwindow.h"
#include "gui/windows/skilldialog.h"
#include "gui/windows/socialwindow.h"
@@ -71,6 +75,8 @@
#include "resources/map/map.h"
+#include "resources/skill/skillinfo.h"
+
#include "utils/booleanoptions.h"
#include "utils/chatutils.h"
#include "utils/copynpaste.h"
@@ -2091,4 +2097,40 @@ impHandler(movePriorityAttackDown)
return false;
}
+impHandler(addSkillShortcut)
+{
+ const std::string args = event.args;
+ if (args.empty() ||
+ itemShortcutWindow == nullptr)
+ {
+ return false;
+ }
+ const SkillInfo *restrict const skill = skillDialog->getSkill(
+ atoi(args.c_str()));
+ if (skill == nullptr)
+ return false;
+
+ const int num = itemShortcutWindow->getTabIndex();
+ if (num < 0 ||
+ num >= CAST_S32(SHORTCUT_TABS) ||
+ num == SHORTCUT_AUTO_TAB)
+ {
+ return false;
+ }
+
+ ItemShortcut *const selShortcut = itemShortcut[num];
+ const int index = selShortcut->getFreeIndex();
+ if (index < 0)
+ return true;
+
+ selShortcut->setItem(index,
+ skill->id + SKILL_MIN_ID,
+ fromInt(skill->customSelectedLevel, ItemColor));
+ selShortcut->setItemData(index,
+ skill->toDataStr());
+
+// popupMenu->showSkillLevelPopup(skill);
+ return true;
+}
+
} // namespace Actions
diff --git a/src/actions/commands.h b/src/actions/commands.h
index 5d6e7ce58..414e20658 100644
--- a/src/actions/commands.h
+++ b/src/actions/commands.h
@@ -162,6 +162,7 @@ namespace Actions
decHandler(moveAttackDown);
decHandler(movePriorityAttackUp);
decHandler(movePriorityAttackDown);
+ decHandler(addSkillShortcut);
} // namespace Actions
#undef decHandler