summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/widgets/tabs/setup_other.cpp4
-rw-r--r--src/gui/windows/skilldialog.cpp27
-rw-r--r--src/gui/windows/skilldialog.h7
3 files changed, 31 insertions, 7 deletions
diff --git a/src/gui/widgets/tabs/setup_other.cpp b/src/gui/widgets/tabs/setup_other.cpp
index cdb22490a..d80452e4f 100644
--- a/src/gui/widgets/tabs/setup_other.cpp
+++ b/src/gui/widgets/tabs/setup_other.cpp
@@ -116,6 +116,10 @@ Setup_Other::Setup_Other(const Widget2 *const widget) :
"targetOnlyReachable", this, "targetOnlyReachableEvent");
// TRANSLATORS: settings option
+ new SetupItemCheckBox(_("Seleck auto target for attack skills"), "",
+ "skillAutotarget", this, "skillAutotargetEvent");
+
+ // TRANSLATORS: settings option
new SetupItemCheckBox(_("Highlight monster attack range"), "",
"highlightMonsterAttackRange", this,
"highlightMonsterAttackRangeEvent");
diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp
index 9c1cbc618..58a9292ae 100644
--- a/src/gui/windows/skilldialog.cpp
+++ b/src/gui/windows/skilldialog.cpp
@@ -159,7 +159,8 @@ void SkillDialog::action(const ActionEvent &event)
if (tab)
{
const SkillInfo *const info = tab->getSelectedInfo();
- useSkill(info);
+ useSkill(info,
+ fromBool(config.getBoolValue("skillAutotarget"), AutoTarget));
}
}
else if (eventId == "close")
@@ -538,7 +539,8 @@ void SkillDialog::widgetResized(const Event &event)
mTabs->adjustSize();
}
-void SkillDialog::useItem(const int itemId) const
+void SkillDialog::useItem(const int itemId,
+ const AutoTarget autoTarget) const
{
const std::map<int, SkillInfo*>::const_iterator
it = mSkills.find(itemId - SKILL_MIN_ID);
@@ -546,7 +548,7 @@ void SkillDialog::useItem(const int itemId) const
return;
const SkillInfo *const info = (*it).second;
- useSkill(info);
+ useSkill(info, autoTarget);
}
void SkillDialog::updateTabSelection()
@@ -659,9 +661,10 @@ void SkillDialog::playCastingDstEffect(const int id, Being *const being) const
paths.getIntValue("skillCastingDstEffectId"));
}
-void SkillDialog::useSkill(const SkillInfo *const info)
+void SkillDialog::useSkill(const SkillInfo *const info,
+ const AutoTarget autoTarget)
{
- if (!info)
+ if (!info || !localPlayer)
return;
const SkillData *const data = info->data;
if (data)
@@ -675,6 +678,20 @@ void SkillDialog::useSkill(const SkillInfo *const info)
switch (info->type)
{
case SkillType::Attack:
+ {
+ const Being *being = localPlayer->getTarget();
+ if (!being && autoTarget == AutoTarget_true)
+ {
+ being = localPlayer->setNewTarget(ActorType::Monster,
+ AllowSort_true);
+ }
+ if (being)
+ {
+ skillHandler->useBeing(info->id,
+ info->level, being->getId());
+ }
+ break;
+ }
case SkillType::Support:
{
const Being *const being = localPlayer->getTarget();
diff --git a/src/gui/windows/skilldialog.h b/src/gui/windows/skilldialog.h
index 29cc69165..8f085ee22 100644
--- a/src/gui/windows/skilldialog.h
+++ b/src/gui/windows/skilldialog.h
@@ -25,6 +25,7 @@
#include "gui/widgets/window.h"
+#include "enums/simpletypes/autotarget.h"
#include "enums/simpletypes/modifiable.h"
#include "listeners/actionlistener.h"
@@ -112,7 +113,8 @@ class SkillDialog final : public Window,
void widgetResized(const Event &event) override final;
- void useItem(const int itemId) const;
+ void useItem(const int itemId,
+ const AutoTarget autoTarget) const;
void updateTabSelection();
@@ -132,7 +134,8 @@ class SkillDialog final : public Window,
void removeSkill(const int id);
- static void useSkill(const SkillInfo *const info);
+ static void useSkill(const SkillInfo *const info,
+ const AutoTarget autoTarget);
SkillData *getSkillData(const int id) const;