summaryrefslogtreecommitdiff
path: root/src/gui/windows
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/windows')
-rw-r--r--src/gui/windows/skilldialog.cpp58
-rw-r--r--src/gui/windows/skilldialog.h10
2 files changed, 52 insertions, 16 deletions
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;