[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdegames/kpat
From: Bram Schoenmakers <bram_s () hccnet ! nl>
Date: 2004-05-15 22:12:18
Message-ID: 20040515221218.C71AD7AFF () office ! kde ! org
[Download RAW message or body]
CVS commit by bram:
Mom's wish is my command :)
My mother asked me whether it was possible to show the number of moves
during a cardgame, "just like in Windows". It's possible now.
The statusbar will show how many moves are made during a game. It's
currently tracked for each gametype for now, I'll try to fix this if
there are gametypes where move-count doesn't make sense.
M +9 -1 dealer.cpp 1.75
M +5 -0 dealer.h 1.42
M +14 -0 pwidget.cpp 1.109
M +1 -0 pwidget.h 1.37
--- kdegames/kpat/pwidget.cpp #1.108:1.109
@@ -151,4 +151,6 @@ pWidget::pWidget()
games->setCurrentItem(game);
+ statusBar()->insertItem( "", 1, 0, true );
+
createGUI(QString::null, false);
KAcceleratorManager::manage(menuBar());
@@ -282,4 +284,6 @@ void pWidget::newGame() {
void pWidget::restart() {
statusBar()->clear();
+ dill->resetMoves();
+ slotSetMoves( 0 );
dill->startNew();
}
@@ -302,4 +306,5 @@ void pWidget::newGameType()
delete dill;
dill = 0;
+ slotSetMoves( 0 );
uint id = games->currentItem();
@@ -314,4 +319,6 @@ void pWidget::newGameType()
connect(dill, SIGNAL(gameInfo(const QString&)),
SLOT(slotGameInfo(const QString &)));
+ connect(dill, SIGNAL(setMoves(int)),
+ SLOT(slotSetMoves(int)));
dill->setGameId(id);
dill->setupActions();
@@ -337,4 +344,6 @@ void pWidget::newGameType()
}
+ dill->resetMoves();
+
setGameCaption();
@@ -364,4 +373,9 @@ void pWidget::slotGameInfo(const QString
}
+void pWidget::slotSetMoves( int moves )
+{
+ statusBar()->changeItem( i18n("Moves: %1").arg( moves ), 1 );
+}
+
void pWidget::setBackSide(const QString &deck, const QString &cards)
{
--- kdegames/kpat/pwidget.h #1.36:1.37
@@ -59,4 +59,5 @@ public slots:
void changeWallpaper();
void slotGameInfo(const QString &);
+ void slotSetMoves( int moves );
void helpGame();
void enableAutoDrop();
--- kdegames/kpat/dealer.cpp #1.74:1.75
@@ -35,5 +35,5 @@ Dealer::Dealer( KMainWindow* _parent , c
: QCanvasView( 0, _parent, _name ), towait(0), myActions(0),
ademo(0), ahint(0), aredeal(0),
- takeTargets(false), _won(false), _waiting(0), stop_demo_next(false), _autodrop(true)
+ takeTargets(false), _won(false), _waiting(0), stop_demo_next(false), _autodrop(true), moves(0)
{
setResizePolicy(QScrollView::Manual);
@@ -446,4 +446,6 @@ void Dealer::contentsMouseReleaseEvent(
}
c->source()->moveCards(movingCards, (*best).source);
+ ++moves;
+ emit setMoves( moves );
takeState();
}
@@ -800,4 +802,5 @@ void Dealer::saveGame(QDomDocument &doc)
if (!data.isEmpty())
dealer.setAttribute("data", data);
+ dealer.setAttribute("moves", QString::number(moves));
bool taken[1000];
@@ -932,4 +935,7 @@ void Dealer::openGame(QDomDocument &doc)
emit undoPossible(undoList.count() > 1);
}
+
+ emit setMoves( dealer.attribute("moves").toInt() );
+
takeState();
}
@@ -942,4 +948,6 @@ void Dealer::undo()
undoList.removeLast(); // the current state
setState(undoList.take(undoList.count() - 1));
+ --moves;
+ emit setMoves( moves );
takeState(); // copying it again
emit undoPossible(undoList.count() > 1);
--- kdegames/kpat/dealer.h #1.41:1.42
@@ -114,4 +114,7 @@ public:
bool autoDrop() const { return _autodrop; }
+ int getMoves() const { return moves; }
+ void resetMoves() { moves = 0; }
+
public slots:
@@ -130,4 +133,5 @@ signals:
void saveGame(); // emergency
void gameInfo(const QString &info);
+ void setMoves( int moves );
public slots:
@@ -215,4 +219,5 @@ protected:
static Dealer *s_instance;
bool _autodrop;
+ int moves;
private:
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic