Show players ready status in chat nick list
authorunc0rr
Fri, 24 Oct 2008 13:00:53 +0000
changeset 1405 ee4b28a1861d
parent 1404 2b6b6809c2e4
child 1406 08b9c28419f1
Show players ready status in chat nick list
QTfrontend/chatwidget.cpp
QTfrontend/chatwidget.h
QTfrontend/hwform.cpp
QTfrontend/newnetclient.cpp
QTfrontend/newnetclient.h
--- a/QTfrontend/chatwidget.cpp	Fri Oct 24 12:57:06 2008 +0000
+++ b/QTfrontend/chatwidget.cpp	Fri Oct 24 13:00:53 2008 +0000
@@ -96,3 +96,18 @@
 	if (curritem)
 		emit kick(curritem->text());
 }
+
+void HWChatWidget::setReadyStatus(const QString & nick, bool isReady)
+{
+	QList<QListWidgetItem *> items = chatNicks->findItems(nick, Qt::MatchExactly);
+	if (items.size() != 1)
+	{
+		qWarning("Bug: cannot find user in chat");
+		return;
+	}
+
+	if(isReady)
+		items[0]->setIcon(QIcon(":/res/checked.png"));
+	else
+		items[0]->setIcon(QIcon(":/res/unchecked.png"));
+}
--- a/QTfrontend/chatwidget.h	Fri Oct 24 12:57:06 2008 +0000
+++ b/QTfrontend/chatwidget.h	Fri Oct 24 13:00:53 2008 +0000
@@ -38,6 +38,7 @@
   void nickAdded(const QString& nick);
   void nickRemoved(const QString& nick);
   void clear();
+  void setReadyStatus(const QString & nick, bool isReady);
 
  signals:
   void chatLine(const QString& str);
--- a/QTfrontend/hwform.cpp	Fri Oct 24 12:57:06 2008 +0000
+++ b/QTfrontend/hwform.cpp	Fri Oct 24 13:00:53 2008 +0000
@@ -440,6 +440,8 @@
 
 	connect(hwnet, SIGNAL(chatStringFromNet(const QString&)),
 		ui.pageNetGame->pChatWidget, SLOT(onChatString(const QString&)));
+	connect(hwnet, SIGNAL(setReadyStatus(const QString &, bool)),
+		ui.pageNetGame->pChatWidget, SLOT(setReadyStatus(const QString &, bool)));
 	connect(hwnet, SIGNAL(chatStringFromMe(const QString&)),
 		ui.pageNetGame->pChatWidget, SLOT(onChatString(const QString&)));
 	connect(ui.pageNetGame->pChatWidget, SIGNAL(chatLine(const QString&)),
--- a/QTfrontend/newnetclient.cpp	Fri Oct 24 12:57:06 2008 +0000
+++ b/QTfrontend/newnetclient.cpp	Fri Oct 24 13:00:53 2008 +0000
@@ -253,6 +253,25 @@
 		return;
 	}
 
+	if (lst[0] == "READY") {
+		if(lst.size() != 2)
+		{
+			qWarning("Net: Malformed READY message");
+			return;
+		}
+		emit setReadyStatus(lst[1], true);
+		return;
+	}
+	if (lst[0] == "NOT_READY") {
+		if(lst.size() != 2)
+		{
+			qWarning("Net: Malformed NOT_READY message");
+			return;
+		}
+		emit setReadyStatus(lst[1], false);
+		return;
+	}
+
 	if (lst[0] == "ADD_TEAM") {
 		if(lst.size() != 21)
 		{
--- a/QTfrontend/newnetclient.h	Fri Oct 24 12:57:06 2008 +0000
+++ b/QTfrontend/newnetclient.h	Fri Oct 24 13:00:53 2008 +0000
@@ -111,6 +111,8 @@
   void roomsList(const QStringList&);
   void serverMessage(const QString &);
 
+  void setReadyStatus(const QString & nick, bool isReady);
+
  public slots:
   void ToggleReady();
   void chatLineToNet(const QString& str);