Allow /me in chat
authorunc0rr
Sat, 18 Oct 2008 17:01:34 +0000
changeset 1378 1a391883261d
parent 1377 a9e768739345
child 1379 39cfee7a5be5
Allow /me in chat
QTfrontend/newnetclient.cpp
QTfrontend/newnetclient.h
hedgewars/CCHandlers.inc
hedgewars/uChat.pas
--- a/QTfrontend/newnetclient.cpp	Sat Oct 18 13:53:58 2008 +0000
+++ b/QTfrontend/newnetclient.cpp	Sat Oct 18 17:01:34 2008 +0000
@@ -249,7 +249,7 @@
 			qWarning("Net: Empty CHAT_STRING message");
 			return;
 		}
-		emit chatStringFromNet(QString("%1: %2").arg(lst[1]).arg(lst[2]));
+		emit chatStringFromNet(formatChatMsg(lst[1], lst[2]));
 		return;
 	}
 
@@ -298,7 +298,7 @@
 					ConfigAsked();
 			}
 			emit nickAdded(lst[i]);
-			emit chatStringFromNet(QString(tr("* %1 joined")).arg(lst[i]));
+			emit chatStringFromNet(QString(tr("*** %1 joined")).arg(lst[i]));
 		}
 		return;
 	}
@@ -310,7 +310,7 @@
 			return;
 		}
 		emit nickRemoved(lst[1]);
-		emit chatStringFromNet(QString(tr("* %1 left")).arg(lst[1]));
+		emit chatStringFromNet(QString(tr("*** %1 left")).arg(lst[1]));
 		return;
 	}
 
@@ -492,7 +492,7 @@
 {
   if(str!="") {
     RawSendNet(QString("CHAT_STRING")+delimeter+str);
-    emit(chatStringFromMe(QString("%1: %2").arg(mynick).arg(str)));
+    emit(chatStringFromMe(formatChatMsg(mynick, str)));
   }
 }
 
@@ -516,3 +516,11 @@
 	netClientState = 3;
 	RawSendNet(QString("ROUNDFINISHED"));
 }
+
+QString HWNewNet::formatChatMsg(const QString & nick, const QString & msg)
+{
+	if(msg.left(4) == "/me ")
+		return QString("* %1 %2").arg(nick).arg(msg.mid(4));
+	else
+		return QString("%1: %2").arg(nick).arg(msg);
+}
--- a/QTfrontend/newnetclient.h	Sat Oct 18 13:53:58 2008 +0000
+++ b/QTfrontend/newnetclient.h	Sat Oct 18 17:01:34 2008 +0000
@@ -82,6 +82,7 @@
   void RawSendNet(const QString & buf);
   void RawSendNet(const QByteArray & buf);
   void ParseCmd(const QStringList & lst);
+  QString formatChatMsg(const QString & nick, const QString & msg);
 
   int loginStep;
   int netClientState;
--- a/hedgewars/CCHandlers.inc	Sat Oct 18 13:53:58 2008 +0000
+++ b/hedgewars/CCHandlers.inc	Sat Oct 18 17:01:34 2008 +0000
@@ -297,7 +297,12 @@
 procedure chSay(var s: shortstring);
 begin
 SendIPC('s' + s);
-s:= UserNick + ': ' + s;
+
+if copy(s, 1, 4) = '/me ' then
+	s:= '* ' + UserNick + ' ' + s
+else
+	s:= UserNick + ': ' + s;
+
 AddChatString(s)
 end;
 
--- a/hedgewars/uChat.pas	Sat Oct 18 13:53:58 2008 +0000
+++ b/hedgewars/uChat.pas	Sat Oct 18 17:01:34 2008 +0000
@@ -120,7 +120,7 @@
 procedure AcceptChatString(s: shortstring);
 var i: TWave;
 begin
-if s[1] = '/' then
+if (s[1] = '/') and (copy(s, 1, 4) <> '/me ') then
 	begin
 	if CurrentTeam^.ExtDriven then exit;