summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/popups/popupmenu.cpp44
-rw-r--r--src/gui/popups/popupmenu.h5
-rw-r--r--src/gui/widgets/skilllistbox.h24
3 files changed, 63 insertions, 10 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.
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);
}