summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorKess Vargavind <vargavind@gmail.com>2009-02-16 17:22:38 +0100
committerJared Adams <jaxad0127@gmail.com>2009-03-10 05:16:03 -0600
commit881f3c693e2ac4d17f2e7109a809d1bd4c2f62c6 (patch)
treefd66ed57cf63ecffb76e0c0f6e88ea289fbe5424 /src/gui
parent2d94d3d381c2cfdd0e66cbfcc0759c25df6b59be (diff)
downloadmana-client-881f3c693e2ac4d17f2e7109a809d1bd4c2f62c6.tar.gz
mana-client-881f3c693e2ac4d17f2e7109a809d1bd4c2f62c6.tar.bz2
mana-client-881f3c693e2ac4d17f2e7109a809d1bd4c2f62c6.tar.xz
mana-client-881f3c693e2ac4d17f2e7109a809d1bd4c2f62c6.zip
Expand the scope where item links work
This patch makes item links work in any chatLog() message, not only chatSend() as before. I enabled it for the "You picked <nr> <item>" message by explicitly adding [] around the item name in the string.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/chat.cpp62
1 files changed, 31 insertions, 31 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 20d0213b..26eaf488 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -223,6 +223,37 @@ void ChatWindow::chatLog(std::string line, int own, bool ignoreRecord)
<< (int) ((t / 60) % 60)
<< "] ";
+ // Check for item link
+ std::string::size_type start = msg.find('[');
+ while (start != std::string::npos && msg[start+1] != '@')
+ {
+ std::string::size_type end = msg.find(']', start);
+ if (start+1 != end && end != std::string::npos)
+ {
+ // Catch multiple embeds and ignore them
+ // so it doesn't crash the client.
+ while ((msg.find('[', start + 1) != std::string::npos) &&
+ (msg.find('[', start + 1) < end))
+ {
+ start = msg.find('[', start + 1);
+ }
+
+ std::string temp = msg.substr(start + 1, end - start - 1);
+
+ toLower(trim(temp));
+
+ const ItemInfo itemInfo = ItemDB::get(temp);
+ if (itemInfo.getName() != _("Unknown item"))
+ {
+ msg.insert(end, "@@");
+ msg.insert(start+1, "|");
+ msg.insert(start+1, toString(itemInfo.getId()));
+ msg.insert(start+1, "@@");
+ }
+ }
+ start = msg.find('[', start + 1);
+ }
+
line = lineColor + timeStr.str() + tmp.nick + tmp.text;
// We look if the Vertical Scroll Bar is set at the max before
@@ -389,37 +420,6 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg)
return;
}
- // Check for item link
- std::string::size_type start = msg.find('[');
- while (start != std::string::npos && msg[start+1] != '@')
- {
- std::string::size_type end = msg.find(']', start);
- if (start+1 != end && end != std::string::npos)
- {
- // Catch multiple embeds and ignore them
- // so it doesn't crash the client.
- while ((msg.find('[', start + 1) != std::string::npos) &&
- (msg.find('[', start + 1) < end))
- {
- start = msg.find('[', start + 1);
- }
-
- std::string temp = msg.substr(start + 1, end - start - 1);
-
- toLower(trim(temp));
-
- const ItemInfo itemInfo = ItemDB::get(temp);
- if (itemInfo.getName() != _("Unknown item"))
- {
- msg.insert(end, "@@");
- msg.insert(start+1, "|");
- msg.insert(start+1, toString(itemInfo.getId()));
- msg.insert(start+1, "@@");
- }
- }
- start = msg.find('[', start + 1);
- }
-
// Prepare ordinary message
if (msg.substr(0, 1) != "/")
{