From 23311af88da21e9f704069edca9081c49e10c872 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 19 Sep 2014 14:07:35 +0300 Subject: In being context menu allow join being chat. --- src/gui/popups/popupmenu.cpp | 25 +++++++++++++++++++++++++ src/gui/popups/popupmenu.h | 2 ++ 2 files changed, 27 insertions(+) diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index d9690a11f..0af61c219 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -68,6 +68,7 @@ #include "net/adminhandler.h" #include "net/beinghandler.h" #include "net/buysellhandler.h" +#include "net/chathandler.h" #include "net/guildhandler.h" #include "net/inventoryhandler.h" #include "net/net.h" @@ -76,6 +77,7 @@ #include "net/serverfeatures.h" #include "net/tradehandler.h" +#include "resources/chatobject.h" #include "resources/iteminfo.h" #include "resources/mapitemtype.h" #include "resources/skillconsts.h" @@ -235,6 +237,7 @@ void PopupMenu::showPopup(const int x, const int y, const Being *const being) mBrowserBox->addRow("move", _("Move")); addPlayerMisc(); addBuySell(being); + addChat(being); break; } @@ -257,6 +260,7 @@ void PopupMenu::showPopup(const int x, const int y, const Being *const being) // TRANSLATORS: popup menu item // TRANSLATORS: add comment to npc mBrowserBox->addRow("addcomment", _("Add comment")); + addChat(being); break; case ActorType::Monster: @@ -1818,6 +1822,12 @@ void PopupMenu::handleLink(const std::string &link, if (Widget::widgetExists(mWindow)) mWindow->setSticky(true); } + else if (link == "join chat" && being) + { + const ChatObject *const chat = being->getChat(); + if (chat) + chatHandler->joinChat(chat, ""); + } else if (!link.compare(0, 10, "guild-pos-")) { if (localPlayer) @@ -2731,6 +2741,21 @@ void PopupMenu::addParty(const std::string &nick) } } +void PopupMenu::addChat(const Being *const being) +{ + if (!being) + return; + const ChatObject *const chat = being->getChat(); + if (chat) + { + // TRANSLATORS: popup menu item + // TRANSLATORS: invite player to party + mBrowserBox->addRow("join chat", + strprintf(_("Join chat %s"), chat->title.c_str()).c_str()); + mBrowserBox->addRow("##3---"); + } +} + void PopupMenu::addPlayerMisc() { // TRANSLATORS: popup menu item diff --git a/src/gui/popups/popupmenu.h b/src/gui/popups/popupmenu.h index 6e229072a..c98e6a26e 100644 --- a/src/gui/popups/popupmenu.h +++ b/src/gui/popups/popupmenu.h @@ -177,6 +177,8 @@ class PopupMenu final : public Popup, public LinkHandler void addWindowMenu(Window *const window); + void addChat(const Being *const being); + void showGMPopup(); BrowserBox *mBrowserBox; -- cgit v1.2.3-60-g2f50