summaryrefslogtreecommitdiff
path: root/src/gui/chat.cpp
diff options
context:
space:
mode:
authorDavid Athay <ko2fan@gmail.com>2009-01-14 14:11:35 +0000
committerIra Rice <irarice@gmail.com>2009-01-20 11:04:37 -0700
commitde068425200d5254181c6806ebeb4a72d68895ec (patch)
tree7ec17c0bbd7a2654dbad678cd129575ca74f8dcd /src/gui/chat.cpp
parent088ccc74d9b8695c906eaabae8e4019ebf55c83c (diff)
downloadmana-client-de068425200d5254181c6806ebeb4a72d68895ec.tar.gz
mana-client-de068425200d5254181c6806ebeb4a72d68895ec.tar.bz2
mana-client-de068425200d5254181c6806ebeb4a72d68895ec.tar.xz
mana-client-de068425200d5254181c6806ebeb4a72d68895ec.zip
Added linking to item's just using [Item Name] in chat
Diffstat (limited to 'src/gui/chat.cpp')
-rw-r--r--src/gui/chat.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 3e9b292e..84666df4 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -43,8 +43,12 @@
#include "../net/messageout.h"
#include "../net/protocol.h"
+#include "../resources/iteminfo.h"
+#include "../resources/itemdb.h"
+
#include "../utils/gettext.h"
#include "../utils/strprintf.h"
+#include "../utils/tostring.h"
#include "../utils/trim.h"
ChatWindow::ChatWindow(Network * network):
@@ -352,6 +356,23 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg)
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.substr(0, 1) != "/")
{