Update of /home/kde/kdegames/atlantik/client
In directory office:/tmp/cvs-serv12968/client
Modified Files:
atlantik.cpp atlantik.h
Log Message:
better porfolio handling: show when we're in the same game, also when that's no game
Index: atlantik.cpp
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/atlantik.cpp,v
retrieving revision 1.152
retrieving revision 1.153
diff -u -d -r1.152 -r1.153
--- atlantik.cpp 12 Jul 2003 17:45:21 -0000 1.152
+++ atlantik.cpp 13 Jul 2003 04:41:40 -0000 1.153
@@ -177,9 +177,12 @@
{
initBoard();
m_board->addToken(player);
-
addPortfolioView(player);
+ // Player::changed() is not connected until later this method, so
+ // we'd better force an update.
+ playerChanged(player);
+
if (player->isSelf())
m_playerSelf = player;
@@ -262,7 +265,7 @@
// delete m_board;
// m_board = 0;
- m_portfolioViews.clear();
+ // m_portfolioViews.clear();
m_atlanticCore->reset();
}
@@ -547,13 +550,25 @@
void Atlantik::playerChanged(Player *player)
{
PortfolioView *portfolioView = findPortfolioView(player);
- if (portfolioView && player->gameId() == -1)
- m_portfolioViews.remove(portfolioView);
- else if (!portfolioView && player->gameId() != -1)
- addPortfolioView(player);
+ if (!portfolioView)
+ portfolioView = addPortfolioView(player);
if (player == m_playerSelf)
{
+ // We changed ourselves, see if other players (that we know
+ // about) have the same gameId..
+
+ PortfolioView *portfolioView = 0;
+ for (QPtrListIterator<PortfolioView> it(m_portfolioViews); *it; ++it)
+ if ((portfolioView = dynamic_cast<PortfolioView*>(*it)))
+ {
+ Player *pTmp = portfolioView->player();
+ if (pTmp->gameId() == m_playerSelf->gameId())
+ portfolioView->show();
+ else
+ portfolioView->hide();
+ }
+
if (m_selectConfiguration)
m_selectConfiguration->setCanStart(player->master());
@@ -567,6 +582,20 @@
m_jailPay->setEnabled(player->hasTurn() && player->inJail());
m_jailRoll->setEnabled(player->hasTurn() && player->inJail());
}
+ else
+ {
+ // Another player changed, check if we need to show or hide
+ // his/her portfolioView.
+ if (m_playerSelf)
+ {
+ if (player->gameId() == m_playerSelf->gameId())
+ portfolioView->show();
+ else
+ portfolioView->hide();
+ }
+ else if (player->gameId() == -1)
+ portfolioView->hide();
+ }
}
void Atlantik::initNetworkObject()
@@ -629,7 +658,7 @@
config->sync();
}
-void Atlantik::addPortfolioView(Player *player)
+PortfolioView *Atlantik::addPortfolioView(Player *player)
{
PortfolioView *portfolioView = new PortfolioView(m_atlanticCore, player, m_config.activeColor, m_config.inactiveColor, m_portfolioWidget);
m_portfolioViews.append(portfolioView);
@@ -640,6 +669,8 @@
m_portfolioLayout->addWidget(portfolioView);
portfolioView->show();
+
+ return portfolioView;
}
PortfolioView *Atlantik::findPortfolioView(Player *player)
Index: atlantik.h
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/atlantik.h,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- atlantik.h 1 Jul 2003 00:31:36 -0000 1.58
+++ atlantik.h 13 Jul 2003 04:41:40 -0000 1.59
@@ -194,7 +194,7 @@
private:
void initNetworkObject();
- void addPortfolioView(Player *player);
+ PortfolioView *addPortfolioView(Player *player);
PortfolioView *findPortfolioView(Player *player);
QWidget *m_mainWidget, *m_portfolioWidget;
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.