simple net cha added
authordisplacer
Sun, 18 Feb 2007 16:57:43 +0000
changeset 453 4b1236759402
parent 452 45fbb9df0c99
child 454 19b0164f4284
simple net cha added
QTfrontend/hwform.cpp
QTfrontend/hwform.h
QTfrontend/newnetclient.cpp
QTfrontend/newnetclient.h
QTfrontend/pages.cpp
--- a/QTfrontend/hwform.cpp	Sun Feb 18 15:28:47 2007 +0000
+++ b/QTfrontend/hwform.cpp	Sun Feb 18 16:57:43 2007 +0000
@@ -265,7 +265,11 @@
 	connect(hwnet, SIGNAL(AddGame(const QString &)), this, SLOT(AddGame(const QString &)));
 	connect(hwnet, SIGNAL(EnteredGame()), this, SLOT(NetGameEnter()));
 	connect(hwnet, SIGNAL(AddNetTeam(const HWTeam&)), this, SLOT(AddNetTeam(const HWTeam&)));
+	connect(hwnet, SIGNAL(chatStringFromNet(const QStringList&)), 
+		this, SLOT(onChatStringFromNet(const QStringList&)));
 
+	connect(ui.pageNetGame->chatEditLine, SIGNAL(returnPressed()),
+		this, SLOT(chatLineToNet()));
 	connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(hhogsNumChanged(const HWTeam&)),
 		hwnet, SLOT(onHedgehogsNumChanged(const HWTeam&)));
 	connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamColorChanged(const HWTeam&)),
@@ -440,3 +444,17 @@
 			"Hedgewars",
 			msg);
 }
+
+void HWForm::chatLineToNet()
+{
+  hwnet->chatLineToNet(ui.pageNetGame->chatEditLine->text());
+  ui.pageNetGame->chatEditLine->clear();
+}
+
+void HWForm::onChatStringFromNet(const QStringList& str)
+{
+  QListWidget* w=ui.pageNetGame->chatText;
+  w->addItem(str[0]+": "+str[1]);
+  w->scrollToBottom();
+  w->setSelectionMode(QAbstractItemView::NoSelection);
+}
--- a/QTfrontend/hwform.h	Sun Feb 18 15:28:47 2007 +0000
+++ b/QTfrontend/hwform.h	Sun Feb 18 16:57:43 2007 +0000
@@ -75,6 +75,8 @@
 	void GameStats(char type, const QString & info);
 	void ForcedDisconnect();
 	void ShowErrorMessage(const QString &);
+	void chatLineToNet();
+	void onChatStringFromNet(const QStringList&);
 
 private:
 	void _NetConnect(const QString & hostName, quint16 port, const QString & nick);
--- a/QTfrontend/newnetclient.cpp	Sun Feb 18 15:28:47 2007 +0000
+++ b/QTfrontend/newnetclient.cpp	Sun Feb 18 16:57:43 2007 +0000
@@ -159,6 +159,13 @@
     return;
   }
 
+  if (lst[0] == "CHAT_STRING") {
+    lst.pop_front();
+    if(lst.size() < 2) return;
+    emit chatStringFromNet(lst);
+    return;
+  }
+
   if (lst[0] == "ADDTEAM:") {
     lst.pop_front();
     emit AddNetTeam(lst);
@@ -344,3 +351,11 @@
 {
   RawSendNet(QString("CONFIG_PARAM%1FORTSMODE%1%2").arg(delimeter).arg(value));
 }
+
+void HWNewNet::chatLineToNet(const QString& str)
+{
+  if(str!="") {
+    RawSendNet(QString("CHAT_STRING")+delimeter+mynick+delimeter+str);
+    emit(chatStringFromNet(QStringList(mynick) << str));
+  }
+}
--- a/QTfrontend/newnetclient.h	Sun Feb 18 15:28:47 2007 +0000
+++ b/QTfrontend/newnetclient.h	Sun Feb 18 16:57:43 2007 +0000
@@ -100,8 +100,10 @@
   void fortsModeChanged(bool value);
   void hhnumChanged(const HWTeam&);
   void teamColorChanged(const HWTeam&);
+  void chatStringFromNet(const QStringList&);
 
  public slots:
+  void chatLineToNet(const QString& str);
   void SendNet(const QByteArray & buf);
   void AddTeam(const HWTeam & team);
   void RemoveTeam(const HWTeam& team);
--- a/QTfrontend/pages.cpp	Sun Feb 18 15:28:47 2007 +0000
+++ b/QTfrontend/pages.cpp	Sun Feb 18 16:57:43 2007 +0000
@@ -512,13 +512,13 @@
 	QGridLayout * pageLayout = new QGridLayout(this);
 	pageLayout->setSizeConstraint(QLayout::SetMinimumSize);
 
-	chatText = new QListWidget(this);
-	//chatText->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
-	pageLayout->addWidget(chatText, 1, 0);
-
 	chatEditLine = new QLineEdit(this);
 	pageLayout->addWidget(chatEditLine, 2, 0);
 
+	chatText = new QListWidget(this);
+	chatText->setMinimumHeight(10);
+	pageLayout->addWidget(chatText, 1, 0);
+
 	pGameCFG = new GameCFGWidget(this);
 	pageLayout->addWidget(pGameCFG, 0, 0);