QTfrontend/newnetclient.cpp
changeset 1378 1a391883261d
parent 1377 a9e768739345
child 1384 329d3308e2e3
equal deleted inserted replaced
1377:a9e768739345 1378:1a391883261d
   247 		if(lst.size() < 3)
   247 		if(lst.size() < 3)
   248 		{
   248 		{
   249 			qWarning("Net: Empty CHAT_STRING message");
   249 			qWarning("Net: Empty CHAT_STRING message");
   250 			return;
   250 			return;
   251 		}
   251 		}
   252 		emit chatStringFromNet(QString("%1: %2").arg(lst[1]).arg(lst[2]));
   252 		emit chatStringFromNet(formatChatMsg(lst[1], lst[2]));
   253 		return;
   253 		return;
   254 	}
   254 	}
   255 
   255 
   256 	if (lst[0] == "ADD_TEAM") {
   256 	if (lst[0] == "ADD_TEAM") {
   257 		if(lst.size() != 21)
   257 		if(lst.size() != 21)
   296 				emit EnteredGame();
   296 				emit EnteredGame();
   297 				if (isChief)
   297 				if (isChief)
   298 					ConfigAsked();
   298 					ConfigAsked();
   299 			}
   299 			}
   300 			emit nickAdded(lst[i]);
   300 			emit nickAdded(lst[i]);
   301 			emit chatStringFromNet(QString(tr("* %1 joined")).arg(lst[i]));
   301 			emit chatStringFromNet(QString(tr("*** %1 joined")).arg(lst[i]));
   302 		}
   302 		}
   303 		return;
   303 		return;
   304 	}
   304 	}
   305 
   305 
   306 	if(lst[0] == "LEFT") {
   306 	if(lst[0] == "LEFT") {
   308 		{
   308 		{
   309 			qWarning("Net: Bad LEFT message");
   309 			qWarning("Net: Bad LEFT message");
   310 			return;
   310 			return;
   311 		}
   311 		}
   312 		emit nickRemoved(lst[1]);
   312 		emit nickRemoved(lst[1]);
   313 		emit chatStringFromNet(QString(tr("* %1 left")).arg(lst[1]));
   313 		emit chatStringFromNet(QString(tr("*** %1 left")).arg(lst[1]));
   314 		return;
   314 		return;
   315 	}
   315 	}
   316 
   316 
   317 	if (lst[0] == "RUN_GAME") {
   317 	if (lst[0] == "RUN_GAME") {
   318 		netClientState = 5;
   318 		netClientState = 5;
   490 
   490 
   491 void HWNewNet::chatLineToNet(const QString& str)
   491 void HWNewNet::chatLineToNet(const QString& str)
   492 {
   492 {
   493   if(str!="") {
   493   if(str!="") {
   494     RawSendNet(QString("CHAT_STRING")+delimeter+str);
   494     RawSendNet(QString("CHAT_STRING")+delimeter+str);
   495     emit(chatStringFromMe(QString("%1: %2").arg(mynick).arg(str)));
   495     emit(chatStringFromMe(formatChatMsg(mynick, str)));
   496   }
   496   }
   497 }
   497 }
   498 
   498 
   499 void HWNewNet::askRoomsList()
   499 void HWNewNet::askRoomsList()
   500 {
   500 {
   514 void HWNewNet::gameFinished()
   514 void HWNewNet::gameFinished()
   515 {
   515 {
   516 	netClientState = 3;
   516 	netClientState = 3;
   517 	RawSendNet(QString("ROUNDFINISHED"));
   517 	RawSendNet(QString("ROUNDFINISHED"));
   518 }
   518 }
       
   519 
       
   520 QString HWNewNet::formatChatMsg(const QString & nick, const QString & msg)
       
   521 {
       
   522 	if(msg.left(4) == "/me ")
       
   523 		return QString("* %1 %2").arg(nick).arg(msg.mid(4));
       
   524 	else
       
   525 		return QString("%1: %2").arg(nick).arg(msg);
       
   526 }