- Add stub page for rooms list
authorunc0rr
Tue, 07 Oct 2008 12:37:06 +0000
changeset 1311 49beb1221c0b
parent 1310 4616e15d566f
child 1312 0078e4f72d40
- Add stub page for rooms list - Clear chat box on disconnect (not only nicks list)
QTfrontend/chatwidget.cpp
QTfrontend/hwform.cpp
QTfrontend/hwform.h
QTfrontend/newnetclient.cpp
QTfrontend/newnetclient.h
QTfrontend/pages.cpp
QTfrontend/pages.h
QTfrontend/ui_hwform.cpp
QTfrontend/ui_hwform.h
--- a/QTfrontend/chatwidget.cpp	Mon Oct 06 19:01:59 2008 +0000
+++ b/QTfrontend/chatwidget.cpp	Tue Oct 07 12:37:06 2008 +0000
@@ -80,5 +80,6 @@
 
 void HWChatWidget::clear()
 {
-  chatNicks->clear();
+	chatText->clear();
+	chatNicks->clear();
 }
--- a/QTfrontend/hwform.cpp	Mon Oct 06 19:01:59 2008 +0000
+++ b/QTfrontend/hwform.cpp	Tue Oct 07 12:37:06 2008 +0000
@@ -400,10 +400,13 @@
 		delete hwnet;
 		hwnet=0;
 	}
+	
 	ui.pageNetGame->pChatWidget->clear();
+	
 	hwnet = new HWNewNet(config, ui.pageNetGame->pGameCFG, ui.pageNetGame->pNetTeamsWidget);
 
 	connect(hwnet, SIGNAL(AskForRunGame()), this, SLOT(CreateNetGame()));
+	connect(hwnet, SIGNAL(Connected()), this, SLOT(NetConnected()));
 	connect(hwnet, SIGNAL(EnteredGame()), this, SLOT(NetGameEnter()));
 	connect(hwnet, SIGNAL(AddNetTeam(const HWTeam&)), this, SLOT(AddNetTeam(const HWTeam&)));
 
@@ -514,6 +517,11 @@
   GoBack();
 }
 
+void HWForm::NetConnected()
+{
+	GoToPage(ID_PAGE_ROOMSLIST);
+}
+
 void HWForm::NetGameEnter()
 {
 	GoToPage(ID_PAGE_NETCFG);
@@ -521,9 +529,9 @@
 
 void HWForm::NetStartGame()
 {
-  ui.pageNetGame->BtnGo->setText(QPushButton::tr("Waiting"));
-  ui.pageNetGame->BtnGo->setEnabled(false);
-  hwnet->StartGame();
+	ui.pageNetGame->BtnGo->setText(QPushButton::tr("Waiting"));
+	ui.pageNetGame->BtnGo->setEnabled(false);
+	hwnet->Ready();
 }
 
 void HWForm::AddNetTeam(const HWTeam& team)
--- a/QTfrontend/hwform.h	Mon Oct 06 19:01:59 2008 +0000
+++ b/QTfrontend/hwform.h	Tue Oct 07 12:37:06 2008 +0000
@@ -72,6 +72,7 @@
 	void NetConnectServer(const QString & host, quint16 port);
 	void NetStartServer();
 	void NetDisconnect();
+	void NetConnected();
 	void NetGameEnter();
 	void NetStartGame();
 	void AddNetTeam(const HWTeam& team);
@@ -106,7 +107,8 @@
 		ID_PAGE_TRAINING        = 10,
 		ID_PAGE_SELECTWEAPON    = 11,
 		ID_PAGE_NETSERVER       = 12,
-		ID_PAGE_INGAME          = 13
+		ID_PAGE_INGAME          = 13,
+		ID_PAGE_ROOMSLIST       = 14
 		};
 	HWGame * game;
 	HWTeam * editedTeam;
--- a/QTfrontend/newnetclient.cpp	Mon Oct 06 19:01:59 2008 +0000
+++ b/QTfrontend/newnetclient.cpp	Tue Oct 07 12:37:06 2008 +0000
@@ -51,7 +51,7 @@
 
 void HWNewNet::Disconnect()
 {
-  m_game_connected=false;
+  m_game_connected = false;
   NetSocket.disconnectFromHost();
 }
 
@@ -67,7 +67,7 @@
 
 void HWNewNet::AddTeam(const HWTeam & team)
 {
-	QString cmd = QString("ADDTEAM:") + delimeter +
+	QString cmd = QString("ADDTEAM") + delimeter +
 	     team.TeamName + delimeter +
 	     team.teamColor.name() + delimeter +
 	     team.Grave + delimeter +
@@ -86,20 +86,20 @@
 
 void HWNewNet::RemoveTeam(const HWTeam & team)
 {
-  RawSendNet(QString("REMOVETEAM:") + delimeter + team.TeamName);
+  RawSendNet(QString("REMOVETEAM") + delimeter + team.TeamName);
   m_networkToLocalteams.remove(m_networkToLocalteams.key(team.TeamName));
 }
 
-void HWNewNet::StartGame()
+void HWNewNet::Ready()
 {
-  RawSendNet(QString("START:"));
+  RawSendNet(QString("READY"));
 }
 
 void HWNewNet::SendNet(const QByteArray & buf)
 {
   QString msg = QString(buf.toBase64());
 
-  RawSendNet(QString("GAMEMSG:%1%2").arg(delimeter).arg(msg));
+  RawSendNet(QString("GAMEMSG%1%2").arg(delimeter).arg(msg));
 }
 
 void HWNewNet::RawSendNet(const QString & str)
@@ -193,7 +193,6 @@
 	if (lst[0] == "CONNECTED") {
 		m_game_connected=true;
 		emit Connected();
-		emit EnteredGame();
 		return;
 	}
 
@@ -243,8 +242,12 @@
 			qWarning("Net: Bad JOINED message");
 			return;
 		}
+		
 		for(int i = 1; i < lst.size(); ++i)
+		{
+			if (lst[i] == mynick) emit EnteredGame();
 			emit nickAdded(lst[i]);
+		}
 		return;
 	}
 
--- a/QTfrontend/newnetclient.h	Mon Oct 06 19:01:59 2008 +0000
+++ b/QTfrontend/newnetclient.h	Tue Oct 07 12:37:06 2008 +0000
@@ -43,7 +43,7 @@
   void Disconnect();
   void JoinRoom(const QString & room);
   void CreateRoom(const QString & room);
-  void StartGame();
+  void Ready();
 
  private:
   GameUIConfig* config;
@@ -126,9 +126,7 @@
   void ClientRead();
   void OnConnect();
   void OnDisconnect();
-  //void Perform();
   void displayError(QAbstractSocket::SocketError socketError);
-  //void FlushNetBuf();
 };
 
 #endif // _NEW_NETCLIENT_INCLUDED
--- a/QTfrontend/pages.cpp	Mon Oct 06 19:01:59 2008 +0000
+++ b/QTfrontend/pages.cpp	Tue Oct 07 12:37:06 2008 +0000
@@ -618,3 +618,9 @@
 	QLabel * label = new QLabel(this);
 	label->setText("In game...");
 }
+
+PageRoomsList::PageRoomsList(QWidget* parent) :
+  AbstractPage(parent)
+{
+
+}
--- a/QTfrontend/pages.h	Mon Oct 06 19:01:59 2008 +0000
+++ b/QTfrontend/pages.h	Tue Oct 07 12:37:06 2008 +0000
@@ -336,4 +336,12 @@
 	PageInGame(QWidget* parent = 0);
 };
 
+class PageRoomsList : public AbstractPage
+{
+	Q_OBJECT
+
+public:
+	PageRoomsList(QWidget* parent = 0);
+};
+
 #endif // PAGES_H
--- a/QTfrontend/ui_hwform.cpp	Mon Oct 06 19:01:59 2008 +0000
+++ b/QTfrontend/ui_hwform.cpp	Tue Oct 07 12:37:06 2008 +0000
@@ -95,4 +95,7 @@
 
 	pageInGame = new PageInGame();
 	Pages->addWidget(pageInGame);
+
+	pageRoomsList = new PageRoomsList();
+	Pages->addWidget(pageRoomsList);
 }
--- a/QTfrontend/ui_hwform.h	Mon Oct 06 19:01:59 2008 +0000
+++ b/QTfrontend/ui_hwform.h	Tue Oct 07 12:37:06 2008 +0000
@@ -34,6 +34,7 @@
 class PageTraining;
 class PageSelectWeapon;
 class PageInGame;
+class PageRoomsList;
 class QStackedLayout;
 class QFont;
 class QWidget;
@@ -59,6 +60,7 @@
 	PageTraining *pageTraining;
 	PageSelectWeapon *pageSelectWeapon;
 	PageInGame *pageInGame;
+	PageRoomsList *pageRoomsList;
 
 	QStackedLayout *Pages;
 	QFont *font14;