summaryrefslogtreecommitdiff
path: root/src/gui/popups
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/gui/popups
parent8b392d9c4a1c177c1207d297c75c1a4a06142245 (diff)
downloadplus-bcdbc39b6efe7391866c81ef82a2e9358b6c3ff4.tar.gz
plus-bcdbc39b6efe7391866c81ef82a2e9358b6c3ff4.tar.bz2
plus-bcdbc39b6efe7391866c81ef82a2e9358b6c3ff4.tar.xz
plus-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/gui/popups')
-rw-r--r--src/gui/popups/popupmenu.cpp44
-rw-r--r--src/gui/popups/popupmenu.h5
2 files changed, 47 insertions, 2 deletions
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.