diff options
author | David Athay <ko2fan@gmail.com> | 2009-01-13 12:48:36 +0000 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2009-01-20 10:54:07 -0700 |
commit | 088ccc74d9b8695c906eaabae8e4019ebf55c83c (patch) | |
tree | 8054c8531d721a7555b2c2b46c7b43adbad9b9d2 /src/gui/chat.cpp | |
parent | 114559b98b7e8c94b1d84d4d450309fd16ed2a38 (diff) | |
download | mana-088ccc74d9b8695c906eaabae8e4019ebf55c83c.tar.gz mana-088ccc74d9b8695c906eaabae8e4019ebf55c83c.tar.bz2 mana-088ccc74d9b8695c906eaabae8e4019ebf55c83c.tar.xz mana-088ccc74d9b8695c906eaabae8e4019ebf55c83c.zip |
Added WoW style item adding to chat window. Right click, then left
clicking on add to chat 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 | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index fa969d17..3e9b292e 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -27,6 +27,7 @@ #include "browserbox.h" #include "chat.h" #include "chatinput.h" +#include "itemlinkhandler.h" #include "scrollarea.h" #include "sdlinput.h" #include "windowcontainer.h" @@ -54,19 +55,23 @@ Window(""), mNetwork(network), mTmpVisible(false) setResizable(true); setDefaultSize(0, windowContainer->getHeight() - 123, 600, 123); + mItemLinkHandler = new ItemLinkHandler(); + mChatInput = new ChatInput; mChatInput->setActionEventId("chatinput"); mChatInput->addActionListener(this); mTextOutput = new BrowserBox(BrowserBox::AUTO_WRAP); mTextOutput->setOpaque(false); - mTextOutput->disableLinksAndUserColors(); mTextOutput->setMaxRow((int) config.getValue("ChatLogLength", 0)); + mTextOutput->setLinkHandler(mItemLinkHandler); + mScrollArea = new ScrollArea(mTextOutput); - mScrollArea->setPosition(mScrollArea->getFrameSize(), + mScrollArea->setPosition(mScrollArea->getFrameSize(), mScrollArea->getFrameSize()); mScrollArea->setScrollPolicy(gcn::ScrollArea::SHOW_NEVER, gcn::ScrollArea::SHOW_ALWAYS); + mScrollArea->setScrollAmount(0, 1); mScrollArea->setOpaque(false); add(mScrollArea); @@ -257,9 +262,8 @@ void ChatWindow::action(const gcn::ActionEvent & event) // If the chatWindow is shown up because you want to send a message // It should hide now - if (mTmpVisible) { + if (mTmpVisible) setVisible(false); - } } } } @@ -697,7 +701,15 @@ 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(); } |