diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-11-23 01:00:04 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-11-23 01:00:04 +0300 |
commit | 26c14e5269feafec782166f80c31fe1a7c2b3d53 (patch) | |
tree | 3e3af33e53421438332a8738f273d032d7165640 /src | |
parent | 9a50b90628eb61e1e48db35a36e9ad5c2a9a2bd5 (diff) | |
download | plus-26c14e5269feafec782166f80c31fe1a7c2b3d53.tar.gz plus-26c14e5269feafec782166f80c31fe1a7c2b3d53.tar.bz2 plus-26c14e5269feafec782166f80c31fe1a7c2b3d53.tar.xz plus-26c14e5269feafec782166f80c31fe1a7c2b3d53.zip |
Add chat command skill.
New chat command: /skill ID[ LEVEL[ TEXT]]
Diffstat (limited to 'src')
-rw-r--r-- | src/actions/commands.cpp | 39 | ||||
-rw-r--r-- | src/actions/commands.h | 1 | ||||
-rw-r--r-- | src/dyetool/actions/commands.cpp | 1 | ||||
-rw-r--r-- | src/enums/input/inputaction.h | 1 | ||||
-rw-r--r-- | src/gui/windows/skilldialog.cpp | 58 | ||||
-rw-r--r-- | src/gui/windows/skilldialog.h | 10 | ||||
-rw-r--r-- | src/input/inputactionmap.h | 6 |
7 files changed, 100 insertions, 16 deletions
diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp index 5dcbc3d93..cea0bdc67 100644 --- a/src/actions/commands.cpp +++ b/src/actions/commands.cpp @@ -1076,4 +1076,43 @@ impHandler(selectSkillLevel) return false; } +impHandler(skill) +{ + if (!skillDialog) + return false; + + StringVect vect; + splitToStringVector(vect, event.args, ' '); + const int sz = static_cast<int>(vect.size()); + if (sz < 1) + return true; + const int skillId = atoi(vect[0].c_str()); + int level = 0; + std::string text; + if (sz > 1) + { + level = atoi(vect[1].c_str()); + if (sz > 2) + text = vect[2]; + } + if (text.empty()) + { + skillDialog->useSkill(skillId, + AutoTarget_true, + level, + false, + ""); + } + else + { + logger->log("text: " + text); + skillDialog->useSkill(skillId, + AutoTarget_true, + level, + true, + text); + } + return true; +} + } // namespace Actions diff --git a/src/actions/commands.h b/src/actions/commands.h index 0e71f409c..67b53be0c 100644 --- a/src/actions/commands.h +++ b/src/actions/commands.h @@ -91,6 +91,7 @@ namespace Actions decHandler(serverConfGet); decHandler(slide); decHandler(selectSkillLevel); + decHandler(skill); } // namespace Actions #undef decHandler diff --git a/src/dyetool/actions/commands.cpp b/src/dyetool/actions/commands.cpp index 60206a5a7..01c7f56ea 100644 --- a/src/dyetool/actions/commands.cpp +++ b/src/dyetool/actions/commands.cpp @@ -91,4 +91,5 @@ impHandlerVoid(confGet) impHandlerVoid(serverConfGet) impHandlerVoid(slide) impHandlerVoid(selectSkillLevel) +impHandlerVoid(skill) } // namespace Actions diff --git a/src/enums/input/inputaction.h b/src/enums/input/inputaction.h index 936aa9403..8c437afaa 100644 --- a/src/enums/input/inputaction.h +++ b/src/enums/input/inputaction.h @@ -606,6 +606,7 @@ enumStart(InputAction) TEST_INFO, SLIDE, SELECT_SKILL_LEVEL, + SKILL, TOTAL } enumEnd(InputAction); diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index 44d02b573..e163923cc 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -704,9 +704,27 @@ void SkillDialog::playCastingDstTileEffect(const int id, paths.getIntValue("skillCastingGroundEffectId")); } +void SkillDialog::useSkill(const int skillId, + const AutoTarget autoTarget, + int level, + const bool withText, + const std::string &text) +{ + SkillInfo *const info = skillDialog->getSkill(skillId); + if (!info) + return; + useSkill(info, + autoTarget, + level, + withText, + text); +} + void SkillDialog::useSkill(const SkillInfo *const info, const AutoTarget autoTarget, - int level) + int level, + const bool withText, + const std::string &text) { if (!info || !localPlayer) return; @@ -766,20 +784,30 @@ void SkillDialog::useSkill(const SkillInfo *const info, viewport->getMouseTile(x, y); if (info->useTextParameter) { - textSkillListener.setSkill(info->id, - x, - y, - level); - TextDialog *const dialog = CREATEWIDGETR(TextDialog, - // TRANSLATORS: text skill dialog header - strprintf(_("Add text to skill %s"), - data->name.c_str()), - // TRANSLATORS: text skill dialog field - _("Text: ")); - dialog->setModal(Modal_true); - textSkillListener.setDialog(dialog); - dialog->setActionEventId("ok"); - dialog->addActionListener(&textSkillListener); + if (withText) + { + skillHandler->usePos(info->id, + level, + x, y, + text); + } + else + { + textSkillListener.setSkill(info->id, + x, + y, + level); + TextDialog *const dialog = CREATEWIDGETR(TextDialog, + // TRANSLATORS: text skill dialog header + strprintf(_("Add text to skill %s"), + data->name.c_str()), + // TRANSLATORS: text skill dialog field + _("Text: ")); + dialog->setModal(Modal_true); + textSkillListener.setDialog(dialog); + dialog->setActionEventId("ok"); + dialog->addActionListener(&textSkillListener); + } } else { diff --git a/src/gui/windows/skilldialog.h b/src/gui/windows/skilldialog.h index 2e0125e9c..6618e7f49 100644 --- a/src/gui/windows/skilldialog.h +++ b/src/gui/windows/skilldialog.h @@ -140,9 +140,17 @@ class SkillDialog final : public Window, void removeSkill(const int id); + static void useSkill(const int skillId, + const AutoTarget autoTarget, + int level, + const bool withText, + const std::string &text); + static void useSkill(const SkillInfo *const info, const AutoTarget autoTarget, - int level); + int level, + const bool withText = false, + const std::string &text = ""); SkillData *getSkillData(const int id) const; diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h index c814e5ee6..e08885edb 100644 --- a/src/input/inputactionmap.h +++ b/src/input/inputactionmap.h @@ -5078,6 +5078,12 @@ static const InputActionData inputActionData "selectskilllevel", UseArgs_true, Protected_false}, + {"keySkill", + defaultAction(&Actions::skill), + InputCondition::INGAME, + "skill|useskill", + UseArgs_true, + Protected_false}, }; #undef defaultAction |