From 2300cbef216ff22275854e7fe76752a31a947bdc Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 12 Nov 2015 21:34:36 +0300 Subject: Add support for invoke ground skill with text parameter. --- src/CMakeLists.txt | 2 ++ src/Makefile.am | 2 ++ src/gui/windows/skilldialog.cpp | 39 +++++++++++++++++++++++++++++++++++---- 3 files changed, 39 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 24ea0e3fa..c44faad51 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1224,6 +1224,8 @@ SET(SRCS listeners/statlistener.cpp listeners/statlistener.h listeners/tablemodellistener.h + listeners/textskilllistener.cpp + listeners/textskilllistener.h listeners/tooltiplistener.cpp listeners/tooltiplistener.h listeners/updatestatuslistener.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 9e7d0a6fe..86315260c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1039,6 +1039,8 @@ manaplus_SOURCES += main.cpp \ listeners/renamelistener.cpp \ listeners/renamelistener.h \ listeners/requesttradelistener.h \ + listeners/textskilllistener.cpp \ + listeners/textskilllistener.h \ particle/rotationalparticle.cpp \ particle/rotationalparticle.h \ navigationmanager.cpp \ diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index 3567a23bb..60eb32b64 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -40,6 +40,10 @@ #include "gui/widgets/tabs/skilltab.h" +#include "gui/windows/textdialog.h" + +#include "listeners/textskilllistener.h" + #include "net/playerhandler.h" #include "net/skillhandler.h" @@ -53,6 +57,11 @@ SkillDialog *skillDialog = nullptr; +namespace +{ + TextSkillListener textSkillListener; +} // namespace + static SkillOwner::Type parseOwner(const std::string &str) { if (str == "player") @@ -687,7 +696,9 @@ void SkillDialog::useSkill(const SkillInfo *const info, { if (!info || !localPlayer) return; - const SkillData *const data = info->data; + const SkillData *data = info->data; + if (!data) + data = info->getData1(info->level); if (data) { const std::string cmd = data->invokeCmd; @@ -733,9 +744,29 @@ void SkillDialog::useSkill(const SkillInfo *const info, int x = 0; int y = 0; viewport->getMouseTile(x, y); - skillHandler->usePos(info->id, - info->level, - x, y); + if (info->useTextParameter) + { + textSkillListener.setSkill(info->id, + x, + y, + info->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 + { + skillHandler->usePos(info->id, + info->level, + x, y); + } break; } -- cgit v1.2.3-70-g09d2