--- a/QTfrontend/chatwidget.cpp Tue Feb 20 19:00:46 2007 +0000
+++ b/QTfrontend/chatwidget.cpp Tue Feb 20 19:50:38 2007 +0000
@@ -44,3 +44,22 @@
w->scrollToBottom();
w->setSelectionMode(QAbstractItemView::NoSelection);
}
+
+void HWChatWidget::nickAdded(const QString& nick)
+{
+ chatNicks->addItem(nick);
+}
+
+void HWChatWidget::nickRemoved(const QString& nick)
+{
+ QList<QListWidgetItem *> items=chatNicks->findItems(nick, Qt::MatchExactly);
+ for(QList<QListWidgetItem *>::iterator it=items.begin(); it!=items.end();) {
+ chatNicks->takeItem(chatNicks->row(*it));
+ ++it;
+ }
+}
+
+void HWChatWidget::clear()
+{
+ chatNicks->clear();
+}
--- a/QTfrontend/chatwidget.h Tue Feb 20 19:00:46 2007 +0000
+++ b/QTfrontend/chatwidget.h Tue Feb 20 19:50:38 2007 +0000
@@ -17,6 +17,9 @@
public slots:
void onChatStringFromNet(const QStringList& str);
+ void nickAdded(const QString& nick);
+ void nickRemoved(const QString& nick);
+ void clear();
signals:
void chatLine(const QString& str);
--- a/QTfrontend/hwform.cpp Tue Feb 20 19:00:46 2007 +0000
+++ b/QTfrontend/hwform.cpp Tue Feb 20 19:50:38 2007 +0000
@@ -261,6 +261,7 @@
void HWForm::_NetConnect(const QString & hostName, quint16 port, const QString & nick)
{
+ ui.pageNetGame->pChatWidget->clear();
hwnet = new HWNewNet(config, ui.pageNetGame->pGameCFG, ui.pageNetGame->pNetTeamsWidget);
connect(hwnet, SIGNAL(GameStateChanged(GameState)), this, SLOT(NetGameStateChanged(GameState)));
connect(hwnet, SIGNAL(AddGame(const QString &)), this, SLOT(AddGame(const QString &)));
@@ -271,6 +272,10 @@
ui.pageNetGame->pChatWidget, SLOT(onChatStringFromNet(const QStringList&)));
connect(ui.pageNetGame->pChatWidget, SIGNAL(chatLine(const QString&)),
hwnet, SLOT(chatLineToNet(const QString&)));
+ connect(hwnet, SIGNAL(nickAdded(const QString&)),
+ ui.pageNetGame->pChatWidget, SLOT(nickAdded(const QString&)));
+ connect(hwnet, SIGNAL(nickRemoved(const QString&)),
+ ui.pageNetGame->pChatWidget, SLOT(nickRemoved(const QString&)));
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(hhogsNumChanged(const HWTeam&)),
hwnet, SLOT(onHedgehogsNumChanged(const HWTeam&)));
--- a/QTfrontend/netconnectedclient.cpp Tue Feb 20 19:00:46 2007 +0000
+++ b/QTfrontend/netconnectedclient.cpp Tue Feb 20 19:50:38 2007 +0000
@@ -72,7 +72,9 @@
client_nick=lst[1];
qDebug() << "send connected";
RawSendNet(QString("CONNECTED"));
- if(m_hwserver->isChiefClient(this)) RawSendNet(QString("CONFIGASKED"));
+ if(m_hwserver->isChiefClient(this)) {
+ RawSendNet(QString("CONFIGASKED"));
+ }
else {
RawSendNet(QString("SLAVE"));
// send teams
@@ -88,6 +90,7 @@
qDebug() << QString("CONFIG_PARAM")+delimeter+it.key()+delimeter+it.value().join(QString(delimeter));
}
}
+ m_hwserver->sendNicks(this);
m_hwserver->sendOthers(this, QString("JOINED")+delimeter+client_nick);
return;
}
--- a/QTfrontend/netserver.cpp Tue Feb 20 19:00:46 2007 +0000
+++ b/QTfrontend/netserver.cpp Tue Feb 20 19:50:38 2007 +0000
@@ -113,6 +113,14 @@
return false;
}
+void HWNetServer::sendNicks(HWConnectedClient* cl) const
+{
+ for(QList<HWConnectedClient*>::const_iterator it=connclients.begin(); it!=connclients.end(); ++it) {
+ qDebug() << "sendNicks: " << (*it)->client_nick;
+ cl->RawSendNet(QString("JOINED")+delimeter+(*it)->client_nick);
+ }
+}
+
QList<QStringList> HWNetServer::getTeamsConfig() const
{
QList<QStringList> lst;
--- a/QTfrontend/netserver.h Tue Feb 20 19:00:46 2007 +0000
+++ b/QTfrontend/netserver.h Tue Feb 20 19:50:38 2007 +0000
@@ -41,6 +41,7 @@
QMap<QString, QStringList> getGameCfg() const;
void sendAll(QString gameCfg);
void sendOthers(HWConnectedClient* this_cl, QString gameCfg);
+ void sendNicks(HWConnectedClient* cl) const;
bool haveNick(const QString& nick) const;
QString getRunningHostName() const;
quint16 getRunningPort() const;
--- a/QTfrontend/newnetclient.cpp Tue Feb 20 19:00:46 2007 +0000
+++ b/QTfrontend/newnetclient.cpp Tue Feb 20 19:50:38 2007 +0000
@@ -187,12 +187,14 @@
if(lst[0]=="JOINED") {
if(lst.size()<2) return;
qDebug() << "JOINED" << lst[1];
+ emit nickAdded(lst[1]);
return;
}
if(lst[0]=="LEFT") {
if(lst.size()<2) return;
qDebug() << "LEFT" << lst[1];
+ emit nickRemoved(lst[1]);
return;
}
--- a/QTfrontend/newnetclient.h Tue Feb 20 19:00:46 2007 +0000
+++ b/QTfrontend/newnetclient.h Tue Feb 20 19:50:38 2007 +0000
@@ -88,6 +88,8 @@
void Disconnected();
void AddGame(const QString & chan);
void EnteredGame();
+ void nickAdded(const QString& nick);
+ void nickRemoved(const QString& nick);
void FromNet(const QByteArray & buf);
void AddNetTeam(const HWTeam&);
void GameStateChanged(GameState gameState);