diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-06-12 23:45:14 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-06-13 12:49:24 +0300 |
commit | 24f4c6de03a3a65df1ad9100e912e968fe9b8b18 (patch) | |
tree | d1a858ac91f493d97334499c4056abfb044501cd /src/gui | |
parent | 9233c3936657f6dc4ca9c73d84ea8c045b3fc09d (diff) | |
download | manaplus-24f4c6de03a3a65df1ad9100e912e968fe9b8b18.tar.gz manaplus-24f4c6de03a3a65df1ad9100e912e968fe9b8b18.tar.bz2 manaplus-24f4c6de03a3a65df1ad9100e912e968fe9b8b18.tar.xz manaplus-24f4c6de03a3a65df1ad9100e912e968fe9b8b18.zip |
add copy to clipboard in npc dialog.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/npcdialog.cpp | 26 | ||||
-rw-r--r-- | src/gui/npcdialog.h | 4 | ||||
-rw-r--r-- | src/gui/popupmenu.cpp | 20 | ||||
-rw-r--r-- | src/gui/popupmenu.h | 2 | ||||
-rw-r--r-- | src/gui/viewport.cpp | 5 | ||||
-rw-r--r-- | src/gui/viewport.h | 3 |
6 files changed, 60 insertions, 0 deletions
diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index 2271a0bc7..0d9a27bcc 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -50,6 +50,7 @@ #include "net/net.h" #include "net/npchandler.h" +#include "utils/copynpaste.h" #include "utils/gettext.h" #include <guichan/font.hpp> @@ -787,3 +788,28 @@ void NpcDialog::clearDialogs() } mNpcDialogs.clear(); } + +void NpcDialog::mousePressed(gcn::MouseEvent &event) +{ + Window::mousePressed(event); + if (event.getButton() == gcn::MouseEvent::RIGHT + && event.getSource() == mTextBox) + { + if (viewport) + viewport->showNpcDialogPopup(mNpcId); + } +} + +void NpcDialog::copyToClipboard(const int npcId, const int x, const int y) +{ + NpcDialogs::iterator it = mNpcDialogs.find(npcId); + if (it != mNpcDialogs.end()) + { + const BrowserBox *const text = (*it).second->mTextBox; + if (!text) + return; + + std::string str = text->getTextAtPos(x, y); + sendBuffer(str); + } +} diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h index 8a4e5b614..815bc7564 100644 --- a/src/gui/npcdialog.h +++ b/src/gui/npcdialog.h @@ -205,6 +205,10 @@ class NpcDialog final : public Window, void clearRows(); + void mousePressed(gcn::MouseEvent &event); + + static void copyToClipboard(const int npcId, const int x, const int y); + static NpcDialogs mNpcDialogs; static void clearDialogs(); diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 91bf514a3..b6272a4e4 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -44,6 +44,7 @@ #include "gui/inventorywindow.h" #include "gui/itemamountwindow.h" #include "gui/ministatuswindow.h" +#include "gui/npcdialog.h" #include "gui/outfitwindow.h" #include "gui/selldialog.h" #include "gui/skilldialog.h" @@ -1352,6 +1353,10 @@ void PopupMenu::handleLink(const std::string &link, if (chatWindow) chatWindow->copyToClipboard(mX, mY); } + else if (link == "npc clipboard" && mBeingId) + { + NpcDialog::copyToClipboard(mBeingId, mX, mY); + } else if (link == "remove attack" && being) { if (actorSpriteManager && being->getType() == Being::MONSTER) @@ -2366,6 +2371,21 @@ void PopupMenu::showWindowsPopup(const int x, const int y) showPopup(x, y); } +void PopupMenu::showNpcDialogPopup(const int npcId, const int x, const int y) +{ + mBeingId = npcId; + mX = x; + mY = y; + mBrowserBox->clearRows(); + // TRANSLATORS: popup menu item + mBrowserBox->addRow("npc clipboard", _("Copy to clipboard")); + mBrowserBox->addRow("##3---"); + // TRANSLATORS: popup menu item + mBrowserBox->addRow("cancel", _("Cancel")); + + showPopup(x, y); +} + void PopupMenu::showPopup(int x, int y) { const int pad2 = 2 * mPadding; diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h index ef2c10ff0..3eac9355a 100644 --- a/src/gui/popupmenu.h +++ b/src/gui/popupmenu.h @@ -178,6 +178,8 @@ class PopupMenu final : public Popup, public LinkHandler void showWindowsPopup(const int x, const int y); + void showNpcDialogPopup(const int npcId, const int x, const int y); + /** * Handles link action. */ diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 7ca330f95..867142c52 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -813,6 +813,11 @@ void Viewport::showWindowsPopup() mPopupMenu->showWindowsPopup(mMouseX, mMouseY); } +void Viewport::showNpcDialogPopup(const int npcId) +{ + mPopupMenu->showNpcDialogPopup(npcId, mMouseX, mMouseY); +} + void Viewport::closePopupMenu() { if (mPopupMenu) diff --git a/src/gui/viewport.h b/src/gui/viewport.h index cde09b7fd..128689186 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -35,6 +35,7 @@ class ActorSprite; class Button; class Being; class BeingPopup; +class BrowserBox; class ChatTab; class FloorItem; class Graphics; @@ -189,6 +190,8 @@ class Viewport final : public WindowContainer, void showWindowsPopup(); + void showNpcDialogPopup(const int npcId); + /** * Closes the popup menu. Needed for when the player dies or switching * maps. |