diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-08-14 19:25:00 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-08-14 19:25:00 +0300 |
commit | 8ea20d3e1f61bcfeccf6885e11cacddeb014fe0f (patch) | |
tree | bda5dc8f66925aed8a1671a9d806a407af7bef3f | |
parent | f3781554bf946a22ac307d1c8fe6154db05bbf2e (diff) | |
download | mv-8ea20d3e1f61bcfeccf6885e11cacddeb014fe0f.tar.gz mv-8ea20d3e1f61bcfeccf6885e11cacddeb014fe0f.tar.bz2 mv-8ea20d3e1f61bcfeccf6885e11cacddeb014fe0f.tar.xz mv-8ea20d3e1f61bcfeccf6885e11cacddeb014fe0f.zip |
Add skill cast type option in skills window.
Can be changed, but for now unused.
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/actions/commands.cpp | 29 | ||||
-rw-r--r-- | src/actions/commands.h | 2 | ||||
-rw-r--r-- | src/dragdrop.h | 2 | ||||
-rw-r--r-- | src/dyetool/actions/commands.cpp | 2 | ||||
-rw-r--r-- | src/enums/input/inputaction.h | 2 | ||||
-rw-r--r-- | src/enums/resources/skill/casttype.h | 35 | ||||
-rw-r--r-- | src/gui/popups/popupmenu.cpp | 57 | ||||
-rw-r--r-- | src/gui/popups/popupmenu.h | 2 | ||||
-rw-r--r-- | src/gui/popups/skillpopup.cpp | 39 | ||||
-rw-r--r-- | src/gui/popups/skillpopup.h | 1 | ||||
-rw-r--r-- | src/gui/widgets/skilllistbox.h | 2 | ||||
-rw-r--r-- | src/gui/windows/skilldialog.cpp | 16 | ||||
-rw-r--r-- | src/gui/windows/skilldialog.h | 5 | ||||
-rw-r--r-- | src/input/inputactionmap.h | 12 | ||||
-rw-r--r-- | src/resources/skill/skillinfo.cpp | 11 | ||||
-rw-r--r-- | src/resources/skill/skillinfo.h | 5 |
18 files changed, 207 insertions, 17 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 60a856bc0..2f3e2ce39 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1088,6 +1088,7 @@ SET(SRCS maingui.h enums/resources/map/blockmask.h enums/resources/map/blocktype.h + enums/resources/skill/casttype.h resources/map/location.h resources/map/map.cpp resources/map/map.h diff --git a/src/Makefile.am b/src/Makefile.am index 03454a1d7..20644b120 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1319,6 +1319,7 @@ manaplus_SOURCES += main.cpp \ resources/updatefile.h \ enums/resources/map/blockmask.h \ enums/resources/map/blocktype.h \ + enums/resources/skill/casttype.h \ resources/map/location.h \ resources/map/map.cpp \ resources/map/map.h \ diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp index 0d3111b59..98a66df0e 100644 --- a/src/actions/commands.cpp +++ b/src/actions/commands.cpp @@ -33,6 +33,8 @@ #include "being/homunculusinfo.h" #include "being/playerinfo.h" +#include "enums/resources/skill/casttype.h" + #include "gui/viewport.h" #include "gui/popups/popupmenu.h" @@ -1592,4 +1594,31 @@ impHandler(showSkillLevels) return true; } +impHandler(showSkillType) +{ + const std::string args = event.args; + if (args.empty()) + return false; + const SkillInfo *restrict const skill = skillDialog->getSkill( + atoi(args.c_str())); + if (!skill) + return false; + popupMenu->showSkillTypePopup(skill); + return true; +} + +impHandler(selectSkillType) +{ + int skill = 0; + int type = 0; + + if (skillDialog && parse2Int(event.args, skill, type)) + { + skillDialog->selectSkillCastType(skill, + static_cast<CastTypeT>(type)); + return true; + } + return false; +} + } // namespace Actions diff --git a/src/actions/commands.h b/src/actions/commands.h index 4f701de37..ce07d3b03 100644 --- a/src/actions/commands.h +++ b/src/actions/commands.h @@ -142,6 +142,8 @@ namespace Actions decHandler(mailTo); decHandler(adoptChild); decHandler(showSkillLevels); + decHandler(showSkillType); + decHandler(selectSkillType); } // namespace Actions #undef decHandler diff --git a/src/dragdrop.h b/src/dragdrop.h index 65e87c5e1..d684110ee 100644 --- a/src/dragdrop.h +++ b/src/dragdrop.h @@ -164,7 +164,7 @@ class DragDrop final mTag = tag; } mItem = info->id; - mItemColor = fromInt(info->selectedLevel, + mItemColor = fromInt(info->customSelectedLevel, ItemColor); } } diff --git a/src/dyetool/actions/commands.cpp b/src/dyetool/actions/commands.cpp index 6659f4ebd..4356d3267 100644 --- a/src/dyetool/actions/commands.cpp +++ b/src/dyetool/actions/commands.cpp @@ -142,5 +142,7 @@ impHandlerVoid(commandGuildRecall) impHandlerVoid(mailTo) impHandlerVoid(adoptChild) impHandlerVoid(showSkillLevels) +impHandlerVoid(showSkillType) +impHandlerVoid(selectSkillType) } // namespace Actions diff --git a/src/enums/input/inputaction.h b/src/enums/input/inputaction.h index babd4c23f..60eb5bf82 100644 --- a/src/enums/input/inputaction.h +++ b/src/enums/input/inputaction.h @@ -673,6 +673,8 @@ enumStart(InputAction) SET_EMOTE_TYPE, CAMERA_RESTORE, SHOW_SKILL_LEVELS, + SHOW_SKILL_TYPE, + SELECT_SKILL_TYPE, TOTAL } enumEnd(InputAction); diff --git a/src/enums/resources/skill/casttype.h b/src/enums/resources/skill/casttype.h new file mode 100644 index 000000000..b9be6d30b --- /dev/null +++ b/src/enums/resources/skill/casttype.h @@ -0,0 +1,35 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2016 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_RESOURCES_CASTTYPE_H +#define ENUMS_RESOURCES_CASTTYPE_H + +#include "enums/simpletypes/enumdefines.h" + +enumStart(CastType) +{ + Default = 0, + Target = 1, + Position = 2, + Self = 3 +} +enumEnd(CastType); + +#endif // ENUMS_RESOURCES_CASTTYPE_H diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index d0896efaa..e7e866491 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -2361,7 +2361,7 @@ void PopupMenu::showNpcDialogPopup(const BeingId npcId, void PopupMenu::showSkillPopup(const SkillInfo *const info) { - if (!info || info->level <= 1) + if (!info) return; setMousePos(); @@ -2373,10 +2373,17 @@ void PopupMenu::showSkillPopup(const SkillInfo *const info) // TRANSLATORS: popup menu header mBrowserBox->addRow(_("Skill")); - mBrowserBox->addRow("/showskilllevels 'ITEMID'", + if (info->level > 1) + { + mBrowserBox->addRow("/showskilllevels 'ITEMID'", + // TRANSLATORS: popup menu item + // TRANSLATORS: set skill level + _("Skill level...")); + } + mBrowserBox->addRow("/showskilltypes 'ITEMID'", // TRANSLATORS: popup menu item - // TRANSLATORS: set skill level - _("Set skill level")); + // TRANSLATORS: set skill cast type + _("Skill cast type...")); // TRANSLATORS: popup menu item // TRANSLATORS: close menu mBrowserBox->addRow("cancel", _("Cancel")); @@ -2422,6 +2429,48 @@ void PopupMenu::showSkillLevelMenu() showPopup(mX, mY); } +void PopupMenu::showSkillTypePopup(const SkillInfo *const info) +{ + if (!info) + return; + setMousePos(); + + // using mItemId as skill id + mItemId = info->id; + // using mItemIndex as skill level + mItemIndex = info->level; + + for (int f = 0; f < maxCards; f ++) + mItemCards[f] = 0; + mBrowserBox->clearRows(); + + // TRANSLATORS: popup menu item + // TRANSLATORS: skill cast type header + mBrowserBox->addRow(_("Select skill cast type")); + mBrowserBox->addRow(strprintf("/selectskilltype %d 0", mItemId), + // TRANSLATORS: popup menu item + // TRANSLATORS: skill cast type + _("Default")); + mBrowserBox->addRow(strprintf("/selectskilltype %d 1", mItemId), + // TRANSLATORS: popup menu item + // TRANSLATORS: skill cast type + _("Target")); + mBrowserBox->addRow(strprintf("/selectskilltype %d 2", mItemId), + // TRANSLATORS: popup menu item + // TRANSLATORS: skill cast type + _("Mouse position")); + mBrowserBox->addRow(strprintf("/selectskilltype %d 3", mItemId), + // TRANSLATORS: popup menu item + // TRANSLATORS: skill cast type + _("Self")); + mBrowserBox->addRow("##3---"); + // TRANSLATORS: popup menu item + // TRANSLATORS: close menu + mBrowserBox->addRow("cancel", _("Cancel")); + + showPopup(mX, mY); +} + void PopupMenu::showPopup(int x, int y) { const int pad2 = 2 * mPadding; diff --git a/src/gui/popups/popupmenu.h b/src/gui/popups/popupmenu.h index a7a745873..ba88e93f1 100644 --- a/src/gui/popups/popupmenu.h +++ b/src/gui/popups/popupmenu.h @@ -165,6 +165,8 @@ class PopupMenu final : public Popup, public LinkHandler void showSkillLevelPopup(const SkillInfo *const info); + void showSkillTypePopup(const SkillInfo *const info); + void showCraftPopup(); void showEmoteType(); diff --git a/src/gui/popups/skillpopup.cpp b/src/gui/popups/skillpopup.cpp index f6e1f19a7..4c9af3d0f 100644 --- a/src/gui/popups/skillpopup.cpp +++ b/src/gui/popups/skillpopup.cpp @@ -46,6 +46,7 @@ SkillPopup::SkillPopup() : mSkillDesc(new TextBox(this)), mSkillEffect(new TextBox(this)), mSkillLevel(new TextBox(this)), + mSkillCastType(new TextBox(this)), mLastId(0U), mLastLevel(-1) { @@ -68,6 +69,11 @@ SkillPopup::SkillPopup() : mSkillLevel->setPosition(0, 3 * fontHeight); mSkillLevel->setForegroundColorAll(getThemeColor(ThemeColorId::POPUP), getThemeColor(ThemeColorId::POPUP_OUTLINE)); + + mSkillCastType->setEditable(false); + mSkillCastType->setPosition(0, 4 * fontHeight); + mSkillCastType->setForegroundColorAll(getThemeColor(ThemeColorId::POPUP), + getThemeColor(ThemeColorId::POPUP_OUTLINE)); } void SkillPopup::postInit() @@ -77,6 +83,7 @@ void SkillPopup::postInit() add(mSkillDesc); add(mSkillEffect); add(mSkillLevel); + add(mSkillCastType); addMouseListener(this); } @@ -136,6 +143,27 @@ void SkillPopup::show(const SkillInfo *const skill, 196); } } + std::string castStr; + switch (skill->customCastType) + { + case CastType::Default: + default: + castStr = _("Default"); + break; + case CastType::Target: + castStr = _("Target"); + break; + case CastType::Position: + castStr = _("Mouse position"); + break; + case CastType::Self: + castStr = _("Self position"); + break; + } + mSkillCastType->setTextWrapped(strprintf( + // TRANSLATORS: skill cast type + _("Cast type: %s"), + castStr.c_str()), 196); int minWidth = mSkillName->getWidth(); @@ -147,25 +175,32 @@ void SkillPopup::show(const SkillInfo *const skill, minWidth = mSkillEffect->getMinWidth(); if (mSkillLevel->getMinWidth() > minWidth) minWidth = mSkillLevel->getMinWidth(); + if (mSkillCastType->getMinWidth() > minWidth) + minWidth = mSkillCastType->getMinWidth(); const int numRowsDesc = mSkillDesc->getNumberOfRows(); const int numRowsEffect = mSkillEffect->getNumberOfRows(); const int numRowsLevel = mSkillLevel->getNumberOfRows(); + const int numRowsCast = mSkillCastType->getNumberOfRows(); const int height = getFont()->getHeight(); if (skill->skillEffect.empty()) { setContentSize(minWidth, - (numRowsDesc + numRowsLevel + 1) * height); + (numRowsDesc + numRowsLevel + numRowsCast + 1) * height); mSkillLevel->setPosition(0, (numRowsDesc + 1) * height); + mSkillCastType->setPosition(0, (numRowsDesc + 2) * height); } else { setContentSize(minWidth, - (numRowsDesc + numRowsLevel + numRowsEffect + 1) * height); + (numRowsDesc + numRowsLevel + numRowsEffect + numRowsCast + 1) * + height); mSkillEffect->setPosition(0, (numRowsDesc + 1) * height); mSkillLevel->setPosition(0, (numRowsDesc + numRowsEffect + 1) * height); + mSkillCastType->setPosition(0, + (numRowsDesc + numRowsEffect + 2) * height); } mSkillDesc->setPosition(0, 1 * height); diff --git a/src/gui/popups/skillpopup.h b/src/gui/popups/skillpopup.h index 33d6d50cc..be416330a 100644 --- a/src/gui/popups/skillpopup.h +++ b/src/gui/popups/skillpopup.h @@ -66,6 +66,7 @@ class SkillPopup final : public Popup TextBox *mSkillDesc A_NONNULLPOINTER; TextBox *mSkillEffect A_NONNULLPOINTER; TextBox *mSkillLevel A_NONNULLPOINTER; + TextBox *mSkillCastType A_NONNULLPOINTER; unsigned int mLastId; int mLastLevel; }; diff --git a/src/gui/widgets/skilllistbox.h b/src/gui/widgets/skilllistbox.h index b6feb194f..818dbf8cb 100644 --- a/src/gui/widgets/skilllistbox.h +++ b/src/gui/widgets/skilllistbox.h @@ -200,7 +200,7 @@ class SkillListBox final : public ListBox if (!skill) return; skillPopup->show(skill, - skill->selectedLevel); + skill->customSelectedLevel); skillPopup->position(viewport->mMouseX, viewport->mMouseY); } diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index 66ffb6378..5df9428ce 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -176,7 +176,7 @@ void SkillDialog::action(const ActionEvent &event) const SkillInfo *const info = tab->getSelectedInfo(); useSkill(info, fromBool(config.getBoolValue("skillAutotarget"), AutoTarget), - info->selectedLevel); + info->customSelectedLevel); } } else if (eventId == "close") @@ -908,8 +908,18 @@ void SkillDialog::selectSkillLevel(const int skillId, if (!info) return; if (level > info->level) - info->selectedLevel = info->level; + info->customSelectedLevel = info->level; else - info->selectedLevel = level; + info->customSelectedLevel = level; + info->update(); +} + +void SkillDialog::selectSkillCastType(const int skillId, + const CastTypeT type) +{ + SkillInfo *const info = getSkill(skillId); + if (!info) + return; + info->customCastType = type; info->update(); } diff --git a/src/gui/windows/skilldialog.h b/src/gui/windows/skilldialog.h index f12f9621b..b93fda1b9 100644 --- a/src/gui/windows/skilldialog.h +++ b/src/gui/windows/skilldialog.h @@ -31,6 +31,8 @@ #include "enums/resources/skillowner.h" #include "enums/resources/skilltype.h" +#include "enums/resources/skill/casttype.h" + #include "listeners/actionlistener.h" #include "utils/xml.h" @@ -158,6 +160,9 @@ class SkillDialog final : public Window, void selectSkillLevel(const int skillId, const int level); + void selectSkillCastType(const int skillId, + const CastTypeT type); + private: void addSkillDuration(SkillInfo *const skill); diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h index 7e098af65..58f25afbb 100644 --- a/src/input/inputactionmap.h +++ b/src/input/inputactionmap.h @@ -5527,6 +5527,18 @@ static const InputActionData inputActionData "showskilllevels", UseArgs_true, Protected_true}, + {"keyShowskilltype", + defaultAction(&Actions::showSkillType), + InputCondition::INGAME, + "showskilltypes", + UseArgs_true, + Protected_true}, + {"keySelectSkillType", + defaultAction(&Actions::selectSkillType), + InputCondition::INGAME, + "selectskilltype", + UseArgs_true, + Protected_true}, }; #undef defaultAction diff --git a/src/resources/skill/skillinfo.cpp b/src/resources/skill/skillinfo.cpp index 9c81219d5..45106ab95 100644 --- a/src/resources/skill/skillinfo.cpp +++ b/src/resources/skill/skillinfo.cpp @@ -46,7 +46,7 @@ SkillInfo::SkillInfo() : model(nullptr), data(nullptr), level(0), - selectedLevel(0), + customSelectedLevel(0), skillLevelWidth(0), id(0), range(0), @@ -56,6 +56,7 @@ SkillInfo::SkillInfo() : cooldown(0), type(SkillType::Unknown), owner(SkillOwner::Player), + customCastType(CastType::Default), modifiable(Modifiable_false), visible(Visible_false), alwaysVisible(Visible_false), @@ -95,7 +96,7 @@ void SkillInfo::update() } else { - if (!selectedLevel) + if (!customSelectedLevel) { // TRANSLATORS: skill level skillLevel = strprintf(_("Lvl: %d"), baseLevel); @@ -104,7 +105,7 @@ void SkillInfo::update() { // TRANSLATORS: skill level skillLevel = strprintf(_("Lvl: %d / %d"), - selectedLevel, + customSelectedLevel, baseLevel); } } @@ -153,8 +154,8 @@ void SkillInfo::update() } level = baseLevel; - if (selectedLevel > level) - selectedLevel = level; + if (customSelectedLevel > level) + customSelectedLevel = level; skillLevelWidth = -1; diff --git a/src/resources/skill/skillinfo.h b/src/resources/skill/skillinfo.h index a9554b1b9..b49d79e2c 100644 --- a/src/resources/skill/skillinfo.h +++ b/src/resources/skill/skillinfo.h @@ -29,6 +29,8 @@ #include "enums/resources/skillowner.h" #include "enums/resources/skilltype.h" +#include "enums/resources/skill/casttype.h" + #include <string> #include <vector> #include <map> @@ -57,7 +59,7 @@ struct SkillInfo final SkillModel *model; SkillData *data; int level; - int selectedLevel; + int customSelectedLevel; int skillLevelWidth; unsigned int id; int range; @@ -67,6 +69,7 @@ struct SkillInfo final int cooldown; SkillType::SkillType type; SkillOwner::Type owner; + CastTypeT customCastType; Modifiable modifiable; Visible visible; Visible alwaysVisible; |