summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorDavid Athay <ko2fan@gmail.com>2009-01-14 14:11:35 +0000
committerDavid Athay <ko2fan@gmail.com>2009-01-14 14:11:35 +0000
commit451b5887beae88c1f3c139a35d23e5521e896e7d (patch)
treee1d5f5058311a1121d1eb2c122eb3d1eb5cee372 /src/gui
parentac3d5127cb7f3e3a4f5fa7a3ceb6f7c8de6808be (diff)
downloadmana-client-451b5887beae88c1f3c139a35d23e5521e896e7d.tar.gz
mana-client-451b5887beae88c1f3c139a35d23e5521e896e7d.tar.bz2
mana-client-451b5887beae88c1f3c139a35d23e5521e896e7d.tar.xz
mana-client-451b5887beae88c1f3c139a35d23e5521e896e7d.zip
Added linking to item's just using [Item Name] in chat
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/chat.cpp24
-rw-r--r--src/gui/chat.h2
2 files changed, 24 insertions, 2 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 34daab38..f391ccb9 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -46,8 +46,12 @@
#include "../net/chatserver/chatserver.h"
#include "../net/gameserver/player.h"
+#include "../resources/iteminfo.h"
+#include "../resources/itemdb.h"
+
#include "../utils/dtor.h"
#include "../utils/trim.h"
+#include "../utils/tostring.h"
ChatWindow::ChatWindow():
Window("Chat"),
@@ -301,10 +305,28 @@ bool ChatWindow::isInputFocused()
return mChatInput->isFocused();
}
-void ChatWindow::chatSend(const std::string &msg)
+void ChatWindow::chatSend(std::string &msg)
{
if (msg.empty()) return;
+ // check for item link
+ std::string::size_type start = msg.find('[');
+ if (start != std::string::npos)
+ {
+ std::string::size_type end = msg.find(']', start);
+ if (end != std::string::npos)
+ {
+ std::string temp = msg.substr(start+1, end-1);
+ ItemInfo itemInfo = ItemDB::get(temp);
+ msg.insert(end, "@@");
+ msg.insert(start+1, "|");
+ msg.insert(start+1, toString(itemInfo.getId()));
+ msg.insert(start+1, "@@");
+
+ }
+ }
+
+
// Prepare ordinary message
if (msg[0] != '/')
{
diff --git a/src/gui/chat.h b/src/gui/chat.h
index bb742a77..114b389c 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -119,7 +119,7 @@ class ChatWindow : public Window,
* @param msg The message text which is to be sent.
*
*/
- void chatSend(const std::string &msg);
+ void chatSend(std::string &msg);
/** Called to remove the channel from the channel manager */
void removeChannel(short channelId);