[prev in list] [next in list] [prev in thread] [next in thread]
List: atlantik-devel
Subject: [atlantik-cvs]
From: kde () office ! kde ! org
Date: 2003-11-15 22:09:09
[Download RAW message or body]
Update of /home/kde/kdegames/atlantik/client
In directory office:/tmp/cvs-serv27006/client
Modified Files:
Tag: atlantik_3_3_branch
atlantik.cpp main.h selectgame_widget.cpp selectgame_widget.h
Log Message:
deprecate updategamelist for gameupdate
Index: atlantik.cpp
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/atlantik.cpp,v
retrieving revision 1.157.2.2
retrieving revision 1.157.2.3
diff -u -d -r1.157.2.2 -r1.157.2.3
--- atlantik.cpp 15 Nov 2003 13:36:02 -0000 1.157.2.2
+++ atlantik.cpp 15 Nov 2003 22:09:06 -0000 1.157.2.3
@@ -33,6 +33,8 @@
#include <kstdaction.h>
#include <ktoolbar.h>
+#include <kdebug.h>
+
#include <atlantic_core.h>
#include <auction.h>
#include <estate.h>
@@ -76,12 +78,14 @@
// Game and network core
m_atlanticCore = new AtlanticCore(this, "atlanticCore");
- initEventLog();
- initNetworkObject();
-
+ connect(m_atlanticCore, SIGNAL(createGUI(Player *)), this, SLOT(newPlayer(Player \
*))); connect(m_atlanticCore, SIGNAL(removeGUI(Player *)), this, \
SLOT(removeGUI(Player *))); + connect(m_atlanticCore, SIGNAL(createGUI(Trade *)), \
this, SLOT(newTrade(Trade *))); connect(m_atlanticCore, SIGNAL(removeGUI(Trade *)), \
this, SLOT(removeGUI(Trade *)));
+ initEventLog();
+ initNetworkObject();
+
// Menu,toolbar: Move
m_roll = KStdGameAction::roll(this, SIGNAL(rollDice()), actionCollection());
m_roll->setEnabled(false);
@@ -189,9 +193,6 @@
void Atlantik::newPlayer(Player *player)
{
- if (player->isSelf())
- m_atlanticCore->setPlayerSelf(player);
-
initBoard();
m_board->addToken(player);
addPortfolioView(player);
@@ -245,14 +246,15 @@
void Atlantik::showSelectServer()
{
+ if (m_selectServer)
+ return;
+
m_selectServer = new SelectServer(m_config.connectOnStart, \
m_config.hideDevelopmentServers, m_mainWidget, "selectServer"); \
m_mainLayout->addMultiCellWidget(m_selectServer, 0, 2, 1, 1); \
m_selectServer->show();
if (m_selectGame)
{
- disconnect(m_atlantikNetwork, SIGNAL(gameListClear()), m_selectGame, \
SLOT(slotGameListClear()));
-
delete m_selectGame;
m_selectGame = 0;
}
@@ -260,14 +262,18 @@
m_atlanticCore->reset(true);
initNetworkObject();
- connect(m_atlantikNetwork, SIGNAL(gameListClear()), this, SLOT(showSelectGame()));
connect(m_selectServer, SIGNAL(serverConnect(const QString, int)), \
m_atlantikNetwork, SLOT(serverConnect(const QString, int))); connect(m_selectServer, \
SIGNAL(msgStatus(const QString &)), this, SLOT(slotMsgStatus(const QString &))); }
void Atlantik::showSelectGame()
{
- m_selectGame = new SelectGame(m_mainWidget, "selectGame");
+ if (m_selectGame)
+ return;
+
+ m_selectGame = new SelectGame(m_atlanticCore, m_mainWidget, "selectGame");
+ m_atlanticCore->emitGames();
+
m_mainLayout->addMultiCellWidget(m_selectGame, 0, 2, 1, 1);
m_selectGame->show();
@@ -294,15 +300,6 @@
m_selectConfiguration = 0;
}
- // Game list clear has a different meaning now
- 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, bool)), m_selectGame, SLOT(slotGameListAdd(QString, QString, QString, \
QString, QString, bool)));
- connect(m_atlantikNetwork, SIGNAL(gameListEdit(QString, QString, QString, QString, \
QString, bool)), m_selectGame, SLOT(slotGameListEdit(QString, QString, QString, \
QString, QString, bool)));
- connect(m_atlantikNetwork, SIGNAL(gameListDel(QString)), m_selectGame, \
SLOT(slotGameListDel(QString)));
- connect(m_atlantikNetwork, SIGNAL(gameListEndUpdate()), m_selectGame, \
SLOT(slotGameListEndUpdate()));
-
connect(m_selectGame, SIGNAL(joinGame(int)), m_atlantikNetwork, \
SLOT(joinGame(int))); connect(m_selectGame, SIGNAL(newGame(const QString &)), \
m_atlantikNetwork, SLOT(newGame(const QString &))); connect(m_selectGame, \
SIGNAL(leaveServer()), this, SLOT(showSelectServer())); @@ -311,26 +308,22 @@
void Atlantik::showSelectConfiguration()
{
+ if (m_selectConfiguration)
+ return;
+
if (m_selectGame)
{
- disconnect(m_atlantikNetwork, SIGNAL(gameListClear()), m_selectGame, \
SLOT(slotGameListClear()));
-
delete m_selectGame;
m_selectGame = 0;
}
- if (m_selectConfiguration)
- return;
-
Player *playerSelf = m_atlanticCore->playerSelf();
m_selectConfiguration = new SelectConfiguration(m_mainWidget, \
"selectConfiguration"); m_selectConfiguration->setCanStart(playerSelf ? \
playerSelf->master() : false); \
m_mainLayout->addMultiCellWidget(m_selectConfiguration, 0, 2, 1, 1); \
m_selectConfiguration->show();
- connect(m_atlantikNetwork, SIGNAL(gameListClear()), this, SLOT(showSelectGame()));
connect(m_atlantikNetwork, SIGNAL(gameOption(QString, QString, QString, QString, \
QString)), m_selectConfiguration, SLOT(gameOption(QString, QString, QString, QString, \
QString)));
- connect(m_atlantikNetwork, SIGNAL(endConfigUpdate()), m_selectConfiguration, \
SLOT(slotEndUpdate())); connect(m_atlantikNetwork, SIGNAL(gameInit()), \
m_selectConfiguration, SLOT(initGame())); connect(m_selectConfiguration, \
SIGNAL(startGame()), m_atlantikNetwork, SLOT(startGame())); \
connect(m_selectConfiguration, SIGNAL(leaveGame()), m_atlantikNetwork, \
SLOT(leaveGame())); @@ -358,8 +351,6 @@
{
if (m_selectGame)
{
- disconnect(m_atlantikNetwork, SIGNAL(gameListClear()), m_selectGame, \
SLOT(slotGameListClear()));
-
delete m_selectGame;
m_selectGame = 0;
}
@@ -381,8 +372,6 @@
for (QPtrListIterator<PortfolioView> it(m_portfolioViews); *it; ++it)
if ((portfolioView = dynamic_cast<PortfolioView*>(*it)))
portfolioView->buildPortfolio();
-
- connect(m_atlantikNetwork, SIGNAL(gameListClear()), this, SLOT(showSelectGame()));
}
void Atlantik::freezeBoard()
@@ -401,8 +390,6 @@
QCString game = args->getOption("game");
if (!game.isNull())
m_atlantikNetwork->joinGame(game.toInt());
- else
- showSelectGame();
}
void Atlantik::slotNetworkError(int errnum)
@@ -615,6 +602,13 @@
else
portfolioView->hide();
}
+ if (player->gameId() == -1)
+ showSelectGame();
+ else
+ {
+ if ( !m_board || m_board->isHidden() )
+ showSelectConfiguration();
+ }
if (m_selectConfiguration)
m_selectConfiguration->setCanStart(player->master());
@@ -673,16 +667,15 @@
connect(m_atlantikNetwork, SIGNAL(connectionSuccess()), this, \
SLOT(slotNetworkConnected())); connect(m_atlantikNetwork, \
SIGNAL(connectionFailed(int)), this, SLOT(slotNetworkError(int))); +
connect(m_atlantikNetwork, SIGNAL(receivedHandshake()), this, \
SLOT(sendHandshake()));
- connect(m_atlantikNetwork, SIGNAL(gameListClear()), this, SLOT(showSelectGame()));
+
connect(m_atlantikNetwork, SIGNAL(gameConfig()), this, \
SLOT(showSelectConfiguration())); connect(m_atlantikNetwork, SIGNAL(gameInit()), \
this, SLOT(initBoard())); connect(m_atlantikNetwork, SIGNAL(gameRun()), this, \
SLOT(showBoard())); connect(m_atlantikNetwork, SIGNAL(gameEnd()), this, \
SLOT(freezeBoard()));
- connect(m_atlantikNetwork, SIGNAL(newPlayer(Player *)), this, SLOT(newPlayer(Player \
*))); connect(m_atlantikNetwork, SIGNAL(newEstate(Estate *)), this, \
SLOT(newEstate(Estate *)));
- connect(m_atlantikNetwork, SIGNAL(newTrade(Trade *)), this, SLOT(newTrade(Trade \
*))); connect(m_atlantikNetwork, SIGNAL(newAuction(Auction *)), this, \
SLOT(newAuction(Auction *)));
connect(m_atlantikNetwork, SIGNAL(clientCookie(QString)), this, \
SLOT(clientCookie(QString)));
Index: main.h
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/main.h,v
retrieving revision 1.40.2.2
retrieving revision 1.40.2.3
diff -u -d -r1.40.2.2 -r1.40.2.3
--- main.h 15 Nov 2003 13:36:02 -0000 1.40.2.2
+++ main.h 15 Nov 2003 22:09:06 -0000 1.40.2.3
@@ -19,6 +19,7 @@
#define ATLANTIK_VERSION 070
#define ATLANTIK_VERSION_STRING "0.7.0 (CVS >= 20031115)"
+
#define ATLANTIK_VERSION_MAJOR 0
#define ATLANTIK_VERSION_MINOR 7
#define ATLANTIK_VERSION_RELEASE 0
Index: selectgame_widget.cpp
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/selectgame_widget.cpp,v
retrieving revision 1.28.2.1
retrieving revision 1.28.2.2
diff -u -d -r1.28.2.1 -r1.28.2.2
--- selectgame_widget.cpp 15 Nov 2003 13:31:04 -0000 1.28.2.1
+++ selectgame_widget.cpp 15 Nov 2003 22:09:06 -0000 1.28.2.2
@@ -1,4 +1,4 @@
-
+// Copyright (c) 2002-2003 Rob Kaper <cap@capsi.com>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -23,10 +23,18 @@
#include <kiconloader.h>
#include <knotifyclient.h>
-#include "selectgame_widget.moc"
+#include <atlantic_core.h>
+#include <game.h>
-SelectGame::SelectGame(QWidget *parent, const char *name) : QWidget(parent, name)
+#include "selectgame_widget.h"
+
+SelectGame::SelectGame(AtlanticCore *atlanticCore, QWidget *parent, const char \
*name) : QWidget(parent, name) {
+ m_atlanticCore = atlanticCore;
+
+ connect(m_atlanticCore, SIGNAL(createGUI(Game *)), this, SLOT(addGame(Game *)));
+ connect(m_atlanticCore, SIGNAL(removeGUI(Game *)), this, SLOT(delGame(Game *)));
+
m_mainLayout = new QVBoxLayout(this, KDialog::marginHint());
Q_CHECK_PTR(m_mainLayout);
@@ -65,73 +73,70 @@
}
-void SelectGame::slotGameListClear()
-{
- m_gameList->clear();
- validateConnectButton();
-}
-
-void SelectGame::slotGameListEndUpdate()
+void SelectGame::addGame(Game *game)
{
- emit msgStatus(i18n("Retrieved game list."));
-}
+ connect(game, SIGNAL(changed(Game *)), this, SLOT(updateGame(Game *)));
-void SelectGame::slotGameListAdd(QString gameId, QString name, QString description, \
QString players, QString gameType, bool canBeJoined)
-{
- if (gameId == "-1")
+ if (game->id() == -1)
{
- QListViewItem *item = new QListViewItem(m_gameList, i18n("Create new %1 \
Game").arg(name), description, QString::null, QString::null, gameType); \
+ QListViewItem *item = new QListViewItem( m_gameList, i18n("Create a new %1 \
Game").arg(game->name()), game->description(), QString::null, QString::null, \
game->type() ); 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);
- item->setPixmap(0, QPixmap(SmallIcon("atlantik")));
- item->setEnabled(canBeJoined);
+ QListViewItem *item = new QListViewItem( m_gameList, i18n("Join %1 Game \
#%2").arg(game->name()).arg(QString::number(game->id())), game->description(), \
QString::number(game->id()), QString::number(game->players()), game->type() ); \
+ item->setPixmap( 0, QPixmap(SmallIcon("atlantik")) ); \
+ item->setEnabled(game->canBeJoined()); +
KNotifyClient::event(this->winId(), "newgame");
}
+// validateConnectButton();
+}
+
+void SelectGame::delGame(Game *game)
+{
+ QListViewItem *item = findItem(game);
+ if (!item)
+ return;
+
+ delete item;
+
validateConnectButton();
}
-void SelectGame::slotGameListEdit(QString gameId, QString name, QString description, \
QString players, QString gameType, bool canBeJoined) +void \
SelectGame::updateGame(Game *game) {
- QListViewItem *item = m_gameList->firstChild();
- while (item)
+ QListViewItem *item = findItem(game);
+ if (!item)
+ return;
+
+ item->setText( 1, game->description() );
+
+ if (game->id() == -1)
+ item->setText(0, i18n("Create a new %1 Game").arg(game->name()));
+ else
{
- if (item->text(2) == gameId)
- {
- if (!name.isEmpty())
- item->setText(0, i18n("Join %1 Game #%2").arg(name).arg(gameId));
- if (!description.isEmpty())
- item->setText(1, description);
- item->setText(3, players);
- if (!gameType.isEmpty())
- item->setText(4, gameType);
- item->setEnabled(canBeJoined);
- m_gameList->triggerUpdate();
- return;
- }
- item = item->nextSibling();
+ item->setText(0, i18n("Join %1 Game \
#%2").arg(game->name()).arg(QString::number(game->id()))); + item->setText( 3, \
QString::number( game->players() ) ); + item->setEnabled( game->canBeJoined() );
}
+ m_gameList->triggerUpdate();
+
validateConnectButton();
-// emit statusChanged();
}
-void SelectGame::slotGameListDel(QString gameId)
+QListViewItem *SelectGame::findItem(Game *game)
{
QListViewItem *item = m_gameList->firstChild();
while (item)
{
- if (item->text(2) == gameId)
- {
- delete item;
- return;
- }
+ if ( (game->id() == -1 || item->text(2) == QString::number(game->id())) && \
item->text(4) == game->type() ) + return item;
+
item = item->nextSibling();
}
- validateConnectButton();
-// emit statusChanged();
+ return 0;
}
void SelectGame::validateConnectButton()
@@ -159,3 +164,5 @@
emit newGame(item->text(4));
}
}
+
+#include "selectgame_widget.moc"
Index: selectgame_widget.h
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/selectgame_widget.h,v
retrieving revision 1.16.2.1
retrieving revision 1.16.2.2
diff -u -d -r1.16.2.1 -r1.16.2.2
--- selectgame_widget.h 15 Nov 2003 13:31:04 -0000 1.16.2.1
+++ selectgame_widget.h 15 Nov 2003 22:09:06 -0000 1.16.2.2
@@ -1,4 +1,4 @@
-// Copyright (c) 2002 Rob Kaper <cap@capsi.com>
+
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -23,38 +23,37 @@
#include <klistview.h>
#include <kpushbutton.h>
+class AtlanticCore;
+
class SelectGame : public QWidget
{
Q_OBJECT
public:
- SelectGame(QWidget *parent, const char *name=0);
+ SelectGame(AtlanticCore *atlanticCore, QWidget *parent, const char *name=0);
void initPage();
- bool validateNext();
- QString hostToConnect() const;
- int portToConnect();
-
- public slots:
- void validateConnectButton();
-
- void slotGameListClear();
- void slotGameListAdd(QString gameId, QString name, QString description, QString \
players, QString gameType, bool canBeJoined);
- void slotGameListEdit(QString gameId, QString name, QString description, QString \
players, QString gameType, bool canBeJoined);
- void slotGameListDel(QString gameId);
+ bool validateNext();
+ QString hostToConnect() const;
+ int portToConnect();
private slots:
void connectClicked();
- void slotGameListEndUpdate();
+ void addGame(Game *game);
+ void delGame(Game *game);
+ void updateGame(Game *game);
+ void validateConnectButton();
signals:
void joinGame(int gameId);
void newGame(const QString &gameType);
void leaveServer();
void msgStatus(const QString &status);
-// void statusChanged();
private:
+ QListViewItem *findItem(Game *game);
+
+ AtlanticCore *m_atlanticCore;
QVBoxLayout *m_mainLayout;
KListView *m_gameList;
KPushButton *m_connectButton;
_______________________________________________
atlantik-cvs mailing list
atlantik-cvs@kde.org
https://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