[prev in list] [next in list] [prev in thread] [next in thread] 

List:       atlantik-devel
Subject:    [atlantik-cvs] CVS: kdegames/atlantik/client atlantik.cpp,1.103,1.104 atlantik.h,1.44,1.45 main.h,1.
From:       kde () office ! kde ! org
Date:       2002-07-16 0:35:19
[Download RAW message or body]

Update of /home/kde/kdegames/atlantik/client
In directory office:/tmp/cvs-serv13794/client

Modified Files:
	atlantik.cpp atlantik.h main.h selectconfiguration_widget.cpp 
	selectconfiguration_widget.h selectgame_widget.cpp 
Log Message:
support for leaving game

Index: atlantik.cpp
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/atlantik.cpp,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -d -r1.103 -r1.104
--- atlantik.cpp	2002/07/10 11:01:55	1.103
+++ atlantik.cpp	2002/07/16 00:35:16	1.104
@@ -14,8 +14,6 @@
 // the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 // Boston, MA 02111-1307, USA.
 
-#include <iostream>
-
 #include <errno.h>
 
 #include <qcolor.h>
@@ -25,7 +23,6 @@
 #include <kapplication.h>
 #include <kcmdlineargs.h>
 #include <kconfig.h>
-#include <kdebug.h>
 #include <klocale.h>
 #include <kstdgameaction.h>
 #include <kstdaction.h>
@@ -82,7 +79,7 @@
 	connect(m_atlantikNetwork, SIGNAL(connectionSuccess()), this, \
SLOT(slotNetworkConnected()));  connect(m_atlantikNetwork, \
SIGNAL(connectionFailed(int)), this, SLOT(slotNetworkError(int)));  
-	connect(m_atlantikNetwork, SIGNAL(joinedGame()), this, SLOT(slotJoinedGame()));
+	connect(m_atlantikNetwork, SIGNAL(joinedGame()), this, \
SLOT(showSelectConfiguration()));  connect(m_atlantikNetwork, SIGNAL(initGame()), \
this, SLOT(initGame()));  connect(m_atlantikNetwork, SIGNAL(gameStarted()), this, \
SLOT(gameStarted()));  
@@ -154,12 +151,7 @@
 	if (!host.isNull() && !port.isNull())
 		m_atlantikNetwork->serverConnect(host, port.toInt());
 	else
-	{
-		m_selectServer = new SelectServer(m_mainWidget, "selectServer");
-		m_mainLayout->addMultiCellWidget(m_selectServer, 0, 2, 1, 1);
-		m_selectServer->show();
-		connect(m_selectServer, SIGNAL(serverConnect(const QString, int)), \
                m_atlantikNetwork, SLOT(serverConnect(const QString, int)));
-	}
+		showSelectServer();
 }
 
 void Atlantik::readConfig()
@@ -238,10 +230,73 @@
 		delete tradeDisplay;
 }
 
-void Atlantik::slotNetworkConnected()
+void Atlantik::showSelectServer()
 {
-	kdDebug() << "Atlantik::slotNetworkConnected()" << std::endl;
+	m_selectServer = new SelectServer(m_mainWidget, "selectServer");
+	m_mainLayout->addMultiCellWidget(m_selectServer, 0, 2, 1, 1);
+	m_selectServer->show();
+	if (m_selectGame)
+	{
+		delete m_selectGame;
+		m_selectGame = 0;
+	}
+	connect(m_selectServer, SIGNAL(serverConnect(const QString, int)), \
m_atlantikNetwork, SLOT(serverConnect(const QString, int))); \
+	connect(m_atlantikNetwork, SIGNAL(gameListClear()), this, SLOT(showSelectGame())); \
+} +
+void Atlantik::showSelectGame()
+{
+	m_selectGame = new SelectGame(m_mainWidget, "selectGame");
+	m_mainLayout->addMultiCellWidget(m_selectGame, 0, 2, 1, 1);
+	m_selectGame->show();
+	if (m_selectServer)
+	{
+		delete m_selectServer;
+		m_selectServer = 0;
+
+		disconnect(m_atlantikNetwork, SIGNAL(gameListClear()), this, \
SLOT(showSelectGame())); +	}
+	if (m_selectConfiguration)
+	{
+		delete m_selectConfiguration;
+		m_selectConfiguration = 0;
+
+		disconnect(m_atlantikNetwork, SIGNAL(gameListClear()), this, \
SLOT(showSelectGame())); +	}
+
+	connect(m_atlantikNetwork, SIGNAL(gameListClear()), m_selectGame, \
SLOT(slotGameListClear())); +
+	connect(m_atlantikNetwork, SIGNAL(gameListAdd(QString, QString, QString, QString, \
QString)), m_selectGame, SLOT(slotGameListAdd(QString, QString, QString, QString, \
QString))); +	connect(m_atlantikNetwork, SIGNAL(gameListEdit(QString, QString, \
QString, QString, QString)), m_selectGame, SLOT(slotGameListEdit(QString, QString, \
QString, QString, QString))); +	connect(m_atlantikNetwork, \
SIGNAL(gameListDel(QString)), m_selectGame, SLOT(slotGameListDel(QString)));  
+	connect(m_selectGame, SIGNAL(joinGame(int)), m_atlantikNetwork, \
SLOT(joinGame(int))); +	connect(m_selectGame, SIGNAL(newGame(const QString &)), \
m_atlantikNetwork, SLOT(newGame(const QString &))); +}
+
+void Atlantik::showSelectConfiguration()
+{
+	m_selectConfiguration = new SelectConfiguration(m_mainWidget, \
"selectConfiguration"); +	m_mainLayout->addMultiCellWidget(m_selectConfiguration, 0, \
2, 1, 1); +	m_selectConfiguration->show();
+	if (m_selectGame)
+	{
+		delete m_selectGame;
+		m_selectGame = 0;
+	}
+
+	connect(m_atlantikNetwork, SIGNAL(playerListClear()), m_selectConfiguration, \
SLOT(slotPlayerListClear())); +	connect(m_atlantikNetwork, \
SIGNAL(playerListAdd(QString, QString, QString)), m_selectConfiguration, \
SLOT(slotPlayerListAdd(QString, QString, QString))); +	connect(m_atlantikNetwork, \
SIGNAL(playerListEdit(QString, QString, QString)), m_selectConfiguration, \
SLOT(slotPlayerListEdit(QString, QString, QString))); +	connect(m_atlantikNetwork, \
SIGNAL(playerListDel(QString)), m_selectConfiguration, \
SLOT(slotPlayerListDel(QString))); +	connect(m_atlantikNetwork, \
SIGNAL(gameListClear()), this, SLOT(showSelectGame())); +
+	connect(m_selectConfiguration, SIGNAL(startGame()), m_atlantikNetwork, \
SLOT(startGame())); +	connect(m_selectConfiguration, SIGNAL(leaveGame()), \
m_atlantikNetwork, SLOT(leaveGame())); +}
+
+void Atlantik::slotNetworkConnected()
+{
 	// We're connected, so let's make ourselves known.
 	m_atlantikNetwork->setName(m_config.playerName);
 
@@ -252,25 +307,7 @@
 	if (!game.isNull())
 		m_atlantikNetwork->joinGame(game.toInt());
 	else
-	{
-		// Create select game widget and replace the select server widget.
-		m_selectGame = new SelectGame(m_mainWidget, "selectGame");
-		m_mainLayout->addMultiCellWidget(m_selectGame, 0, 2, 1, 1);
-		m_selectGame->show();
-		if (m_selectServer)
-		{
-			delete m_selectServer;
-			m_selectServer = 0;
-		}
-
-		connect(m_atlantikNetwork, SIGNAL(gameListClear()), m_selectGame, \
                SLOT(slotGameListClear()));
-		connect(m_atlantikNetwork, SIGNAL(gameListAdd(QString, QString, QString, QString, \
QString)), m_selectGame, SLOT(slotGameListAdd(QString, QString, QString, QString, \
                QString)));
-		connect(m_atlantikNetwork, SIGNAL(gameListEdit(QString, QString, QString, QString, \
QString)), m_selectGame, SLOT(slotGameListEdit(QString, QString, QString, QString, \
                QString)));
-		connect(m_atlantikNetwork, SIGNAL(gameListDel(QString)), m_selectGame, \
                SLOT(slotGameListDel(QString)));
-
-		connect(m_selectGame, SIGNAL(joinGame(int)), m_atlantikNetwork, \
                SLOT(joinGame(int)));
-		connect(m_selectGame, SIGNAL(newGame(const QString &)), m_atlantikNetwork, \
                SLOT(newGame(const QString &)));
-	}
+		showSelectGame();
 }
 
 void Atlantik::slotNetworkError(int errnum)
@@ -295,26 +332,6 @@
 	}
 
 	serverMsgsAppend(errMsg);
-}
-
-void Atlantik::slotJoinedGame()
-{
-	// Create configuration widget and replace the select game widget.
-	m_selectConfiguration = new SelectConfiguration(m_mainWidget, \
                "selectConfiguration");
-	m_mainLayout->addMultiCellWidget(m_selectConfiguration, 0, 2, 1, 1);
-	m_selectConfiguration->show();
-	if (m_selectGame)
-	{
-		delete m_selectGame;
-		m_selectGame = 0;
-	}
-
-	connect(m_atlantikNetwork, SIGNAL(playerListClear()), m_selectConfiguration, \
                SLOT(slotPlayerListClear()));
-	connect(m_atlantikNetwork, SIGNAL(playerListAdd(QString, QString, QString)), \
                m_selectConfiguration, SLOT(slotPlayerListAdd(QString, QString, \
                QString)));
-	connect(m_atlantikNetwork, SIGNAL(playerListEdit(QString, QString, QString)), \
                m_selectConfiguration, SLOT(slotPlayerListEdit(QString, QString, \
                QString)));
-	connect(m_atlantikNetwork, SIGNAL(playerListDel(QString)), m_selectConfiguration, \
                SLOT(slotPlayerListDel(QString)));
-
-	connect(m_selectConfiguration, SIGNAL(startGame()), m_atlantikNetwork, \
SLOT(startGame()));  }
 
 void Atlantik::initGame()

Index: atlantik.h
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/atlantik.h,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- atlantik.h	2002/04/30 17:58:08	1.44
+++ atlantik.h	2002/07/16 00:35:16	1.45
@@ -90,7 +90,13 @@
 
 	AtlantikConfig config() { return m_config; }
 
+private slots:
+	void showSelectServer();
+	void showSelectGame();
+	void showSelectConfiguration();
+
 public slots:
+
 	/**
 	 * A network connection has been established, so we can show the game
 	 * list instead of the server list.
@@ -109,13 +115,6 @@
 	/**
 	 * A game was succesfully created or joined, so we can show the
 	 * configuration dialog instead of the game list.
-	 *
-	 */
-	 void slotJoinedGame();
-
-	/**
- 	 * The game is starting, so we can show the game board instead of the
-	 * pre-game configuration.
 	 *
 	 */
 	 void initGame();

Index: main.h
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/main.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- main.h	2002/07/07 02:35:58	1.17
+++ main.h	2002/07/16 00:35:16	1.18
@@ -17,11 +17,11 @@
 #ifndef ATLANTIK_MAIN_H
 #define ATLANTIK_MAIN_H
 
-#define	ATLANTIK_VERSION 031
-#define	ATLANTIK_VERSION_STRING "0.3.1 (CVS >= 20020707)"
+#define	ATLANTIK_VERSION 032
+#define	ATLANTIK_VERSION_STRING "0.3.2 (CVS >= 20020716)"
 #define ATLANTIK_VERSION_MAJOR 0
 #define ATLANTIK_VERSION_MINOR 3
-#define ATLANTIK_VERSION_RELEASE 1
+#define ATLANTIK_VERSION_RELEASE 2
 
 int main(int, char *[]);
 

Index: selectconfiguration_widget.cpp
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/selectconfiguration_widget.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- selectconfiguration_widget.cpp	2002/07/10 11:01:55	1.16
+++ selectconfiguration_widget.cpp	2002/07/16 00:35:16	1.17
@@ -36,7 +36,6 @@
 	m_playerGroupBox = new QVGroupBox(i18n("Player List"), this, "groupBox");
 	m_mainLayout->addWidget(m_playerGroupBox); 
 
-
 	// List of  players
 	m_playerList = new KListView(m_playerGroupBox, "m_playerList");
 	m_playerList->addColumn(QString(i18n("Id")));
@@ -54,6 +53,11 @@
 
 	QHBoxLayout *buttonBox = new QHBoxLayout(this, 0, KDialog::spacingHint());
 	m_mainLayout->addItem(buttonBox);
+
+	m_backButton = new KPushButton(SmallIcon("back"), i18n("Leave game"), this);
+	buttonBox->addWidget(m_backButton);
+
+	connect(m_backButton, SIGNAL(pressed()), this, SIGNAL(leaveGame()));
 
 	buttonBox->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, \
QSizePolicy::Minimum));  

Index: selectconfiguration_widget.h
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/selectconfiguration_widget.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- selectconfiguration_widget.h	2002/04/23 16:56:30	1.8
+++ selectconfiguration_widget.h	2002/07/16 00:35:16	1.9
@@ -47,18 +47,19 @@
 		void connectPressed();
 		void slotClicked();
 
-	signals:
-		void startGame();
-		void joinConfiguration(int configurationId);
-		void newConfiguration();
-//		void statusChanged();
+signals:
+	void startGame();
+	void leaveGame();
+	void joinConfiguration(int configurationId);
+	void newConfiguration();
+//	void statusChanged();
 
 	private:
 		QVBoxLayout *m_mainLayout;
 		QLabel *status_label;
 		QVGroupBox *m_playerGroupBox, *m_groupBox, *m_messageBox;
 		KListView *m_playerList;
-		KPushButton *m_connectButton;
+		KPushButton *m_backButton, *m_connectButton;
 };
 
 #endif

Index: selectgame_widget.cpp
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/selectgame_widget.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- selectgame_widget.cpp	2002/07/10 03:17:50	1.17
+++ selectgame_widget.cpp	2002/07/16 00:35:16	1.18
@@ -30,7 +30,7 @@
 	Q_CHECK_PTR(m_mainLayout);
 
 	QVGroupBox *groupBox;
-	groupBox = new QVGroupBox(i18n("Start or Select a monopd Game"), this, "groupBox");
+	groupBox = new QVGroupBox(i18n("Create or Select a monopd Game"), this, \
"groupBox");  m_mainLayout->addWidget(groupBox);
 
 	// List of games
@@ -51,7 +51,7 @@
 
 	buttonBox->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, \
QSizePolicy::Minimum));  
-	m_connectButton = new KPushButton(SmallIcon("forward"), i18n("Connect"), this);
+	m_connectButton = new KPushButton(SmallIcon("forward"), i18n("Create Game"), this);
 	m_connectButton->setEnabled(false);
 	buttonBox->addWidget(m_connectButton);
 
@@ -74,12 +74,12 @@
 {
 	if (gameId == "-1")
 	{
-		QListViewItem *item = new QListViewItem(m_gameList, i18n("Start a new %1 \
game").arg(name), description, "", "", gameType); +		QListViewItem *item = new \
QListViewItem(m_gameList, i18n("Create a new %1 Game").arg(name), description, "", \
"", gameType);  item->setPixmap(0, QPixmap(SmallIcon("filenew")));
 	}
 	else
 	{
-		QListViewItem *item = new QListViewItem(m_gameList, i18n("Join %1 game \
#%2").arg(name).arg(gameId), description, gameId, players, gameType); \
+		QListViewItem *item = new QListViewItem(m_gameList, i18n("Join %1 Game \
#%2").arg(name).arg(gameId), description, gameId, players, gameType);  \
item->setPixmap(0, QPixmap(SmallIcon("atlantik")));  }
 
@@ -125,8 +125,15 @@
 
 void SelectGame::validateConnectButton()
 {
-	if (m_gameList->selectedItem())
+	if (QListViewItem *item = m_gameList->selectedItem())
+	{
+		if (int gameId = item->text(2).toInt())
+			m_connectButton->setText(i18n("Join Game"));
+		else
+			m_connectButton->setText(i18n("Create Game"));
+
 		m_connectButton->setEnabled(true);
+	}
 	else
 		m_connectButton->setEnabled(false);
 }

_______________________________________________
atlantik-cvs mailing list
atlantik-cvs@mail.kde.org
http://mail.kde.org/mailman/listinfo/atlantik-cvs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic