summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-07-05 23:34:33 +0300
committerAndrei Karas <akaras@inbox.ru>2016-07-06 00:07:18 +0300
commitbcdbc39b6efe7391866c81ef82a2e9358b6c3ff4 (patch)
treec296c08021c602687e3632b1f4c3f87033c99d34 /src
parent8b392d9c4a1c177c1207d297c75c1a4a06142245 (diff)
downloadManaVerse-bcdbc39b6efe7391866c81ef82a2e9358b6c3ff4.tar.gz
ManaVerse-bcdbc39b6efe7391866c81ef82a2e9358b6c3ff4.tar.bz2
ManaVerse-bcdbc39b6efe7391866c81ef82a2e9358b6c3ff4.tar.xz
ManaVerse-bcdbc39b6efe7391866c81ef82a2e9358b6c3ff4.zip
Add menu for selected skill for now with item only "set skill level".s20160706
Also add chat command /showskilllevels SKILL
Diffstat (limited to 'src')
-rw-r--r--src/actions/commands.cpp16
-rw-r--r--src/actions/commands.h1
-rw-r--r--src/dyetool/actions/commands.cpp1
-rw-r--r--src/enums/input/inputaction.h1
-rw-r--r--src/gui/popups/popupmenu.cpp44
-rw-r--r--src/gui/popups/popupmenu.h5
-rw-r--r--src/gui/widgets/skilllistbox.h24
-rw-r--r--src/input/inputactionmap.h6
8 files changed, 87 insertions, 11 deletions
diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp
index b25600835..98db8d57f 100644
--- a/src/actions/commands.cpp
+++ b/src/actions/commands.cpp
@@ -37,6 +37,8 @@
#include "gui/viewport.h"
+#include "gui/popups/popupmenu.h"
+
#ifdef EATHENA_SUPPORT
#include "gui/shortcut/emoteshortcut.h"
@@ -1174,7 +1176,6 @@ impHandler(skill)
}
else
{
- logger->log("text: " + text);
skillDialog->useSkill(skillId,
AutoTarget_true,
level,
@@ -1621,4 +1622,17 @@ impHandlerE(adoptChild)
#endif
}
+impHandler(showSkillLevels)
+{
+ 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->showSkillLevelPopup(skill);
+ return true;
+}
+
} // namespace Actions
diff --git a/src/actions/commands.h b/src/actions/commands.h
index ea7e7d278..4f701de37 100644
--- a/src/actions/commands.h
+++ b/src/actions/commands.h
@@ -141,6 +141,7 @@ namespace Actions
decHandler(commandGuildRecall);
decHandler(mailTo);
decHandler(adoptChild);
+ decHandler(showSkillLevels);
} // namespace Actions
#undef decHandler
diff --git a/src/dyetool/actions/commands.cpp b/src/dyetool/actions/commands.cpp
index 369d25009..6659f4ebd 100644
--- a/src/dyetool/actions/commands.cpp
+++ b/src/dyetool/actions/commands.cpp
@@ -141,5 +141,6 @@ impHandlerVoid(commandBreakGuild)
impHandlerVoid(commandGuildRecall)
impHandlerVoid(mailTo)
impHandlerVoid(adoptChild)
+impHandlerVoid(showSkillLevels)
} // namespace Actions
diff --git a/src/enums/input/inputaction.h b/src/enums/input/inputaction.h
index 263613cbc..babd4c23f 100644
--- a/src/enums/input/inputaction.h
+++ b/src/enums/input/inputaction.h
@@ -672,6 +672,7 @@ enumStart(InputAction)
DUMP_MEMORY_USAGE,
SET_EMOTE_TYPE,
CAMERA_RESTORE,
+ SHOW_SKILL_LEVELS,
TOTAL
}
enumEnd(InputAction);
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index fe636bf61..7bed7446f 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -126,7 +126,8 @@ PopupMenu::PopupMenu() :
mType(ActorType::Unknown),
mSubType(BeingTypeId_zero),
mX(0),
- mY(0)
+ mY(0),
+ mAllowCleanMenu(true)
{
mBrowserBox->setOpaque(false);
mBrowserBox->setLinkHandler(this);
@@ -1148,6 +1149,8 @@ void PopupMenu::handleLink(const std::string &link,
if (actorManager)
being = actorManager->findBeing(mBeingId);
+ mAllowCleanMenu = true;
+
if (link == "chat close" && mTab)
{
inputManager.executeChatCommand(InputAction::CLOSE_CHAT_TAB,
@@ -1684,6 +1687,9 @@ void PopupMenu::handleLink(const std::string &link,
logger->log("PopupMenu: Warning, unknown action '%s'", link.c_str());
}
+ if (!mAllowCleanMenu)
+ return;
+
setVisible(Visible_false);
mBeingId = BeingId_zero;
@@ -2375,10 +2381,43 @@ void PopupMenu::showSkillPopup(const SkillInfo *const info)
// using mItemId as skill id
mItemId = info->id;
+ // using mItemIndex as skill level
+ mItemIndex = info->level;
+ mBrowserBox->clearRows();
+
+ // TRANSLATORS: popup menu header
+ mBrowserBox->addRow(_("Skill"));
+ mBrowserBox->addRow("/showskilllevels 'ITEMID'",
+ // TRANSLATORS: popup menu item
+ // TRANSLATORS: set skill level
+ _("Set skill level"));
+ // TRANSLATORS: popup menu item
+ // TRANSLATORS: close menu
+ mBrowserBox->addRow("cancel", _("Cancel"));
+
+ showPopup(mX, mY);
+}
+
+void PopupMenu::showSkillLevelPopup(const SkillInfo *const info)
+{
+ if (!info || info->level <= 1)
+ return;
+ setMousePos();
+
+ // using mItemId as skill id
+ mItemId = info->id;
+ // using mItemIndex as skill level
+ mItemIndex = info->level;
+ showSkillLevelMenu();
+}
+
+void PopupMenu::showSkillLevelMenu()
+{
for (int f = 0; f < maxCards; f ++)
mItemCards[f] = 0;
mBrowserBox->clearRows();
- for (int f = 1; f <= info->level; f ++)
+ // mItemIndex as skill level
+ for (int f = 1; f <= mItemIndex; f ++)
{
mBrowserBox->addRow(strprintf("/selectskilllevel %d %d", mItemId, f),
// TRANSLATORS: popup menu item
@@ -2428,6 +2467,7 @@ void PopupMenu::showPopup(int x, int y)
setPosition(x, y);
setVisible(Visible_true);
requestMoveToTop();
+ mAllowCleanMenu = false;
}
void PopupMenu::addNormalRelations()
diff --git a/src/gui/popups/popupmenu.h b/src/gui/popups/popupmenu.h
index dc53312f4..cc1ad285f 100644
--- a/src/gui/popups/popupmenu.h
+++ b/src/gui/popups/popupmenu.h
@@ -163,6 +163,8 @@ class PopupMenu final : public Popup, public LinkHandler
void showSkillPopup(const SkillInfo *const info);
+ void showSkillLevelPopup(const SkillInfo *const info);
+
#ifdef EATHENA_SUPPORT
void showCraftPopup();
#endif
@@ -247,6 +249,8 @@ class PopupMenu final : public Popup, public LinkHandler
bool addBeingMenu();
+ void showSkillLevelMenu();
+
BrowserBox *mBrowserBox A_NONNULLPOINTER;
ScrollArea *mScrollArea A_NONNULLPOINTER;
@@ -271,6 +275,7 @@ class PopupMenu final : public Popup, public LinkHandler
BeingTypeId mSubType;
int mX;
int mY;
+ bool mAllowCleanMenu;
/**
* Shared code for the various showPopup functions.
diff --git a/src/gui/widgets/skilllistbox.h b/src/gui/widgets/skilllistbox.h
index 8415e0cab..b6feb194f 100644
--- a/src/gui/widgets/skilllistbox.h
+++ b/src/gui/widgets/skilllistbox.h
@@ -232,21 +232,29 @@ class SkillListBox final : public ListBox
void mousePressed(MouseEvent &event) override final
{
ListBox::mousePressed(event);
- if (event.getButton() == MouseButton::LEFT)
+ const MouseButtonT button = event.getButton();
+ if (button == MouseButton::LEFT ||
+ button == MouseButton::RIGHT)
{
const SkillInfo *const skill = getSkillByEvent(event);
if (!skill)
return;
event.consume();
mSkillClicked = true;
- if (event.getX() >
- getWidth() - mPadding - skill->skillLevelWidth)
+ SkillModel *const model = static_cast<SkillModel*>(
+ mListModel);
+ if (model &&
+ mSelected >= 0 &&
+ model->getSkillAt(mSelected) == skill)
{
- SkillModel *const model = static_cast<SkillModel*>(
- mListModel);
- if (model &&
- mSelected >= 0 &&
- model->getSkillAt(mSelected) == skill)
+ skillPopup->hide();
+ if (button == MouseButton::LEFT &&
+ event.getX() >
+ getWidth() - mPadding - skill->skillLevelWidth)
+ {
+ popupMenu->showSkillLevelPopup(skill);
+ }
+ else if (button == MouseButton::RIGHT)
{
popupMenu->showSkillPopup(skill);
}
diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h
index 4f677efda..7798bbe95 100644
--- a/src/input/inputactionmap.h
+++ b/src/input/inputactionmap.h
@@ -5521,6 +5521,12 @@ static const InputActionData inputActionData
"restorecamera|returncamera|camerarestore",
UseArgs_false,
Protected_false},
+ {"keyShowSkillLevels",
+ defaultAction(&Actions::showSkillLevels),
+ InputCondition::INGAME,
+ "showskilllevels",
+ UseArgs_true,
+ Protected_true},
};
#undef defaultAction