summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-12-10 13:25:38 +0300
committerAndrei Karas <akaras@inbox.ru>2014-12-10 13:25:38 +0300
commit926a702799f919bbe75f3e8adcac30129749a963 (patch)
tree387e4b0bf80904863e056bd71d36ff36f5a221b6 /src/gui
parentb4de7c68b240dd1b63ac1b78feb0721977cdb171 (diff)
downloadplus-926a702799f919bbe75f3e8adcac30129749a963.tar.gz
plus-926a702799f919bbe75f3e8adcac30129749a963.tar.bz2
plus-926a702799f919bbe75f3e8adcac30129749a963.tar.xz
plus-926a702799f919bbe75f3e8adcac30129749a963.zip
Show custom menu for npc.
Also fix loading menu.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/popups/popupmenu.cpp49
-rw-r--r--src/gui/popups/popupmenu.h2
2 files changed, 39 insertions, 12 deletions
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index eb2144de3..b636d1d7c 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -85,6 +85,8 @@
#include "resources/mapitemtype.h"
#include "resources/skillconsts.h"
+#include "resources/db/npcdb.h"
+
#include "resources/map/map.h"
#include "resources/map/mapitem.h"
#include "resources/map/speciallayer.h"
@@ -245,21 +247,25 @@ void PopupMenu::showPopup(const int x, const int y, const Being *const being)
}
case ActorType::Npc:
- // TRANSLATORS: popup menu item
- // TRANSLATORS: talk with npc
- mBrowserBox->addRow("talk", _("Talk"));
- if (serverFeatures->haveNpcWhispers())
+ if (!addBeingMenu())
{
// TRANSLATORS: popup menu item
- // TRANSLATORS: whisper to npc
- mBrowserBox->addRow("npc whisper", _("Whisper"));
+ // TRANSLATORS: talk with npc
+ mBrowserBox->addRow("talk", _("Talk"));
+ if (serverFeatures->haveNpcWhispers())
+ {
+ // TRANSLATORS: popup menu item
+ // TRANSLATORS: whisper to npc
+ mBrowserBox->addRow("npc whisper", _("Whisper"));
+ }
+ // TRANSLATORS: popup menu item
+ // TRANSLATORS: buy from npc
+ mBrowserBox->addRow("buy", _("Buy"));
+ // TRANSLATORS: popup menu item
+ // TRANSLATORS: sell to npc
+ mBrowserBox->addRow("sell", _("Sell"));
}
- // TRANSLATORS: popup menu item
- // TRANSLATORS: buy from npc
- mBrowserBox->addRow("buy", _("Buy"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: sell to npc
- mBrowserBox->addRow("sell", _("Sell"));
+
mBrowserBox->addRow("##3---");
// TRANSLATORS: popup menu item
// TRANSLATORS: move to npc location
@@ -370,6 +376,25 @@ void PopupMenu::showPopup(const int x, const int y, const Being *const being)
showPopup(x, y);
}
+bool PopupMenu::addBeingMenu()
+{
+ Being *being = actorManager->findBeing(mBeingId);
+ if (!being)
+ return false;
+
+ BeingInfo *const info = NPCDB::get(being->getSubType());
+ if (!info)
+ return false;
+
+ const std::vector<BeingMenuItem> &menu = info->getMenu();
+ FOR_EACH (std::vector<BeingMenuItem>::const_iterator, it, menu)
+ {
+ const BeingMenuItem &item = *it;
+ mBrowserBox->addRow("@" + item.command, item.name.c_str());
+ }
+ return true;
+}
+
void PopupMenu::setMousePos()
{
if (viewport)
diff --git a/src/gui/popups/popupmenu.h b/src/gui/popups/popupmenu.h
index da0f59847..e60d13d8d 100644
--- a/src/gui/popups/popupmenu.h
+++ b/src/gui/popups/popupmenu.h
@@ -187,6 +187,8 @@ class PopupMenu final : public Popup, public LinkHandler
void showGMPopup();
+ bool addBeingMenu();
+
BrowserBox *mBrowserBox;
ScrollArea *mScrollArea;