summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-11-22 19:26:02 +0300
committerAndrei Karas <akaras@inbox.ru>2015-11-22 19:26:02 +0300
commitaf026c1d1e1d574cfc403064a3c9f6b10288d55e (patch)
tree23e95f7ff3609b5cc4792043aba90f76b1f3835e
parent09e8d7ba7a5e29e4991b21056e358a7dcf0dd2df (diff)
downloadplus-af026c1d1e1d574cfc403064a3c9f6b10288d55e.tar.gz
plus-af026c1d1e1d574cfc403064a3c9f6b10288d55e.tar.bz2
plus-af026c1d1e1d574cfc403064a3c9f6b10288d55e.tar.xz
plus-af026c1d1e1d574cfc403064a3c9f6b10288d55e.zip
Add popup menu for left click on skill level.
-rw-r--r--src/gui/popups/popupmenu.cpp29
-rw-r--r--src/gui/popups/popupmenu.h4
-rw-r--r--src/gui/widgets/skilllistbox.h13
3 files changed, 46 insertions, 0 deletions
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index 5f0676741..a5228e672 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -59,6 +59,7 @@
#include "gui/widgets/createwidget.h"
#include "gui/widgets/progressbar.h"
#include "gui/widgets/scrollarea.h"
+#include "gui/widgets/skillinfo.h"
#include "gui/widgets/textfield.h"
#include "gui/widgets/tabs/chat/whispertab.h"
@@ -2231,6 +2232,34 @@ void PopupMenu::showNpcDialogPopup(const BeingId npcId,
showPopup(x, y);
}
+void PopupMenu::showSkillPopup(const SkillInfo *const info)
+{
+ if (!info || info->level <= 1)
+ return;
+ setMousePos();
+
+ // using mItemId as skill id
+ mItemId = info->id;
+ mBrowserBox->clearRows();
+ for(int f = 1; f <= info->level; f ++)
+ {
+ mBrowserBox->addRow(strprintf("/selectskilllevel %d %d", mItemId, f),
+ // TRANSLATORS: popup menu item
+ // TRANSLATORS: skill level
+ strprintf(_("Level: %d"), f).c_str());
+ }
+ mBrowserBox->addRow(strprintf("/selectskilllevel %d 0", mItemId),
+ // TRANSLATORS: popup menu item
+ // TRANSLATORS: skill level
+ _("Max level"));
+ 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 0a83c5dd7..9cca08f16 100644
--- a/src/gui/popups/popupmenu.h
+++ b/src/gui/popups/popupmenu.h
@@ -54,6 +54,8 @@ class TextField;
class ProgressBar;
class Window;
+struct SkillInfo;
+
/**
* Window showing popup menu.
*/
@@ -152,6 +154,8 @@ class PopupMenu final : public Popup, public LinkHandler
void showWindowPopup(Window *const window);
+ void showSkillPopup(const SkillInfo *const info);
+
/**
* Handles link action.
*/
diff --git a/src/gui/widgets/skilllistbox.h b/src/gui/widgets/skilllistbox.h
index 35d2998a9..fcfeebe62 100644
--- a/src/gui/widgets/skilllistbox.h
+++ b/src/gui/widgets/skilllistbox.h
@@ -34,6 +34,7 @@
#include "gui/models/skillmodel.h"
+#include "gui/popups/popupmenu.h"
#include "gui/popups/skillpopup.h"
#include "utils/delete2.h"
@@ -234,6 +235,18 @@ class SkillListBox final : public ListBox
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)
+ {
+ popupMenu->showSkillPopup(skill);
+ }
+ }
}
}