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

List:       kde-commits
Subject:    playground/games/magazynier
From:       Tadeusz Andrzej Kadłubowski <yess () hell ! org ! pl>
Date:       2009-03-14 20:35:01
Message-ID: 1237062901.257097.3761.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 939417 by tkadlubo:

Move counter in the status bar


 M  +2 -1      levelModel.cpp  
 M  +1 -0      levelModel.h  
 M  +12 -0     window.cpp  
 M  +1 -0      window.h  


--- trunk/playground/games/magazynier/levelModel.cpp #939416:939417
@@ -326,7 +326,7 @@
 void LevelModel::moveDone() //{{{
 {
 	++m_moveCount;
-	
+	emit moveCountChanged(m_moveCount);
 	if (m_goalsLeft == 0) {
 		kDebug() << "Level completed";
 		emit levelCompleted();
@@ -338,6 +338,7 @@
 void LevelModel::moveUndone() //{{{
 {
 	--m_moveCount;
+	emit moveCountChanged(m_moveCount);
 
 	return;
 } //}}}
--- trunk/playground/games/magazynier/levelModel.h #939416:939417
@@ -81,6 +81,7 @@
 signals:
 	void addNewUndoCommand(MagazynierCommand *command);
 	void levelCompleted(void);
+	void moveCountChanged(int i);
 };
 
 #endif
--- trunk/playground/games/magazynier/window.cpp #939416:939417
@@ -196,10 +196,22 @@
 			m_LevelPack->getCurrentLevelNumber(),
 			m_LevelPack->getLevelCount()
 		), 1);
+	statusBar()->changeItem(i18n("Moves: %1", 0), 2);
 
+	if (oldLevelModel != NULL) {
+		disconnect(oldLevelModel, SIGNAL(moveCountChanged(int)),
+			this, SLOT(updateMoveCounter(int)));
+	}
+	connect(newLevelModel, SIGNAL(moveCountChanged(int)),
+		this, SLOT(updateMoveCounter(int)));
 	return;
 } //}}}
 
+void MagazynierWindow::updateMoveCounter(int i) //{{{
+{
+	statusBar()->changeItem(i18n("Moves: %1", i), 2);
+} //}}}
+
 void MagazynierWindow::newUndoCommandCreated(MagazynierCommand *command) //{{{
 {
 	kDebug() << "New command pushed onto undo stack.";
--- trunk/playground/games/magazynier/window.h #939416:939417
@@ -60,6 +60,7 @@
 		void levelPackChanged(LevelPack *newLevelPack);
 		void redrawNeeded(void);
 		void newUndoCommandCreated(MagazynierCommand *command);
+		void updateMoveCounter(int i);
 };
 
 #endif
[prev in list] [next in list] [prev in thread] [next in thread] 

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