diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-09-21 01:44:50 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-09-21 01:44:50 +0300 |
commit | 52e799ac652c6edd48d250f814e259af44f92329 (patch) | |
tree | 655a6cc9adc5a1f7179857d9d31c979ed39a1596 /src | |
parent | c4a9748e841fd8620e7e9d230aad8964f424bb08 (diff) | |
download | manaverse-52e799ac652c6edd48d250f814e259af44f92329.tar.gz manaverse-52e799ac652c6edd48d250f814e259af44f92329.tar.bz2 manaverse-52e799ac652c6edd48d250f814e259af44f92329.tar.xz manaverse-52e799ac652c6edd48d250f814e259af44f92329.zip |
Add option for auto target skill to closest target.
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/actions/actions.cpp | 3 | ||||
-rw-r--r-- | src/defaults.cpp | 1 | ||||
-rw-r--r-- | src/enums/simpletypes/autotarget.h | 28 | ||||
-rw-r--r-- | src/gui/widgets/tabs/setup_other.cpp | 4 | ||||
-rw-r--r-- | src/gui/windows/skilldialog.cpp | 27 | ||||
-rw-r--r-- | src/gui/windows/skilldialog.h | 7 | ||||
-rw-r--r-- | src/itemshortcut.cpp | 3 |
9 files changed, 66 insertions, 9 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b722e9c8d..697d00766 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1086,6 +1086,7 @@ SET(SRCS enums/state.h enums/simpletypes/allowsort.h enums/simpletypes/allplayers.h + enums/simpletypes/autotarget.h enums/simpletypes/beingid.h enums/simpletypes/beingtypeid.h enums/simpletypes/booldefines.h diff --git a/src/Makefile.am b/src/Makefile.am index 067ecc39b..efc6b41f1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -553,6 +553,7 @@ SRC += events/actionevent.h \ enums/state.h \ enums/simpletypes/allowsort.h \ enums/simpletypes/allplayers.h \ + enums/simpletypes/autotarget.h \ enums/simpletypes/beingid.h \ enums/simpletypes/beingtypeid.h \ enums/simpletypes/booldefines.h \ diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp index 5dd1cbb6c..f77b22ddf 100644 --- a/src/actions/actions.cpp +++ b/src/actions/actions.cpp @@ -1493,7 +1493,8 @@ impHandler(useItem) } else if (skillDialog) { - skillDialog->useItem(itemId); + skillDialog->useItem(itemId, + fromBool(config.getBoolValue("skillAutotarget"), AutoTarget)); } return true; } diff --git a/src/defaults.cpp b/src/defaults.cpp index 9e178014d..3bf640f78 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -382,6 +382,7 @@ DefaultsData* getConfigDefaults() AddDEF("sellShopName", "unnamed"); AddDEF("showBadges", 1); AddDEF("tradescreenshot", false); + AddDEF("skillAutotarget", true); return configData; } diff --git a/src/enums/simpletypes/autotarget.h b/src/enums/simpletypes/autotarget.h new file mode 100644 index 000000000..20b5ea5d6 --- /dev/null +++ b/src/enums/simpletypes/autotarget.h @@ -0,0 +1,28 @@ +/* + * The ManaPlus Client + * Copyright (C) 2015 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef ENUMS_SIMPLETYPES_AUTOTARGET_H +#define ENUMS_SIMPLETYPES_AUTOTARGET_H + +#include "enums/simpletypes/booldefines.h" + +defBoolEnum(AutoTarget); + +#endif // ENUMS_SIMPLETYPES_AUTOTARGET_H 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; diff --git a/src/itemshortcut.cpp b/src/itemshortcut.cpp index b9696a2a2..681c4c0f5 100644 --- a/src/itemshortcut.cpp +++ b/src/itemshortcut.cpp @@ -141,7 +141,8 @@ void ItemShortcut::useItem(const int index) const } else if (skillDialog) { - skillDialog->useItem(itemId); + skillDialog->useItem(itemId, + fromBool(config.getBoolValue("skillAutotarget"), AutoTarget)); } } } |