diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-10-26 19:17:04 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-10-26 19:18:17 +0300 |
commit | f8b39b10698870111df67af3645b17d8d15a7685 (patch) | |
tree | 05146e7a9f7a45321237e3be629dff7af7e733a7 /src | |
parent | ea6a5a78b7bed5fc47cfc4d81dac78c71d6289b3 (diff) | |
download | manaplus-f8b39b10698870111df67af3645b17d8d15a7685.tar.gz manaplus-f8b39b10698870111df67af3645b17d8d15a7685.tar.bz2 manaplus-f8b39b10698870111df67af3645b17d8d15a7685.tar.xz manaplus-f8b39b10698870111df67af3645b17d8d15a7685.zip |
Allow invoke chat command from invoking skill.
New skill attribute: invokeCmd.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/widgets/skilldata.cpp | 1 | ||||
-rw-r--r-- | src/gui/widgets/skilldata.h | 1 | ||||
-rw-r--r-- | src/gui/windows/skilldialog.cpp | 10 | ||||
-rw-r--r-- | src/spellmanager.cpp | 8 | ||||
-rw-r--r-- | src/spellmanager.h | 3 |
5 files changed, 23 insertions, 0 deletions
diff --git a/src/gui/widgets/skilldata.cpp b/src/gui/widgets/skilldata.cpp index 0d8b2b7a9..66c0da2fe 100644 --- a/src/gui/widgets/skilldata.cpp +++ b/src/gui/widgets/skilldata.cpp @@ -38,6 +38,7 @@ SkillData::SkillData() : description(), icon(nullptr), particle(), + invokeCmd(), soundHit(std::string(), 0), soundMiss(std::string(), 0) { diff --git a/src/gui/widgets/skilldata.h b/src/gui/widgets/skilldata.h index eb8de62f6..6839a427a 100644 --- a/src/gui/widgets/skilldata.h +++ b/src/gui/widgets/skilldata.h @@ -36,6 +36,7 @@ struct SkillData final Image *icon; std::string particle; + std::string invokeCmd; SoundInfo soundHit; SoundInfo soundMiss; diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index 5ae89301a..bceb8645c 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -25,6 +25,7 @@ #include "configuration.h" #include "effectmanager.h" #include "itemshortcut.h" +#include "spellmanager.h" #include "being/attributes.h" #include "being/localplayer.h" @@ -361,6 +362,8 @@ void SkillDialog::loadXmlFile(const std::string &fileName) node, "soundMiss", ""); data->soundMiss.delay = XML::getProperty( node, "soundMissDelay", 0); + data->invokeCmd = XML::getProperty( + node, "invokeCmd", ""); skill->addData(level, data); } @@ -565,6 +568,13 @@ void SkillDialog::playUpdateEffect(const int id) const void SkillDialog::useSkill(const SkillInfo *const info) { + const SkillData *const data = info->data; + if (data) + { + const std::string cmd = data->invokeCmd; + if (!cmd.empty()) + SpellManager::invokeCommand(cmd, localPlayer->getTarget()); + } if (info && localPlayer) { switch (info->type) diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp index fbf372de7..6dfdd483d 100644 --- a/src/spellmanager.cpp +++ b/src/spellmanager.cpp @@ -182,6 +182,14 @@ void SpellManager::invokeSpell(const TextCommand *const spell, chatWindow->localChatInput(parseCommand(spell->getCommand(), target)); } +void SpellManager::invokeCommand(const std::string &command, + const Being *const target) +{ + if (!chatWindow) + return; + chatWindow->localChatInput(parseCommand(command, target)); +} + std::string SpellManager::parseCommand(std::string command, const Being *const target) { diff --git a/src/spellmanager.h b/src/spellmanager.h index f2830edb6..976c324ed 100644 --- a/src/spellmanager.h +++ b/src/spellmanager.h @@ -67,6 +67,9 @@ class SpellManager final void swap(const int id1, const int id2); + static void invokeCommand(const std::string &command, + const Being *const target); + private: void fillSpells(); |