diff options
author | David Athay <ko2fan@gmail.com> | 2009-01-13 12:48:36 +0000 |
---|---|---|
committer | David Athay <ko2fan@gmail.com> | 2009-01-13 12:48:36 +0000 |
commit | db37dcd73f3116917584e81a474f70e0d0786bc4 (patch) | |
tree | e1b03485652de7a129f6c9277a973e1d468b7a16 /src/gui/chat.cpp | |
parent | 8d6cc0162fec250743e6491fb4b1e2f07c7657c2 (diff) | |
download | mana-client-db37dcd73f3116917584e81a474f70e0d0786bc4.tar.gz mana-client-db37dcd73f3116917584e81a474f70e0d0786bc4.tar.bz2 mana-client-db37dcd73f3116917584e81a474f70e0d0786bc4.tar.xz mana-client-db37dcd73f3116917584e81a474f70e0d0786bc4.zip |
Added WoW style item adding to chat window. Right Ctrl and Left click to put the item in the chat input. Left click the item link to show a popup description, and click the link again to remove the popup.
Diffstat (limited to 'src/gui/chat.cpp')
-rw-r--r-- | src/gui/chat.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 888dd27d..34daab38 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -28,6 +28,7 @@ #include "browserbox.h" #include "chatinput.h" +#include "itemlinkhandler.h" #include "scrollarea.h" #include "sdlinput.h" #include "windowcontainer.h" @@ -57,14 +58,16 @@ ChatWindow::ChatWindow(): setDefaultSize(0, windowContainer->getHeight() - 123, 600, 123); setOpaque(false); + mItemLinkHandler = new ItemLinkHandler(); + mChatInput = new ChatInput; mChatInput->setActionEventId("chatinput"); mChatInput->addActionListener(this); BrowserBox *textOutput = new BrowserBox(BrowserBox::AUTO_WRAP); textOutput->setOpaque(false); - textOutput->disableLinksAndUserColors(); textOutput->setMaxRow((int) config.getValue("ChatLogLength", 0)); + textOutput->setLinkHandler(mItemLinkHandler); ScrollArea *scrollArea = new ScrollArea(textOutput); scrollArea->setPosition( @@ -416,10 +419,18 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event) void ChatWindow::setInputText(std::string input_str) { - mChatInput->setText(input_str + " "); + mChatInput->setText(mChatInput->getText() + input_str + " "); requestChatFocus(); } +void ChatWindow::addItemText(int itemId, const std::string &item) +{ + std::ostringstream text; + text << "[@@" << itemId << "|" << item << "@@] "; + mChatInput->setText(mChatInput->getText() + text.str()); + requestChatFocus(); +} + void ChatWindow::setVisible(bool isVisible) { Window::setVisible(isVisible); |