[kde-doc-english] KDE/kdegames/kblocks
Dirk Leifeld
dirkleifeld at yahoo.de
Tue Mar 24 17:31:57 CET 2009
SVN commit 943907 by leifeld:
can now drop blocks down with one key
FEATURE: 162529
GUI:
M +6 -0 kblocks.cpp
M +18 -0 kblocksscene.cpp
M +1 -0 kblocksscene.h
M +5 -0 kblocksview.cpp
M +1 -0 kblocksview.h
--- trunk/KDE/kdegames/kblocks/kblocks.cpp #943906:943907
@@ -95,6 +95,12 @@
movedown->setIcon(KIcon("arrow-down"));
movedown->setShortcuts( KShortcut( Qt::Key_Down ) );
connect(movedown, SIGNAL(triggered(bool)), view, SLOT(moveDown()));
+
+ KAction* pushdown = actionCollection()->addAction("push_down");
+ pushdown->setText(i18n("Drop the Piece"));
+ pushdown->setIcon(KIcon("arrow-down"));
+ pushdown->setShortcuts( KShortcut( Qt::Key_Space ) );
+ connect(pushdown, SIGNAL(triggered(bool)), view, SLOT(pushDown()));
//restore difficulty and sound from settings, need to read them first
Settings::self()->readConfig();
--- trunk/KDE/kdegames/kblocks/kblocksscene.cpp #943906:943907
@@ -300,6 +300,24 @@
}
}
+void KBlocksScene::attemptPushDown(const QPoint& delta)
+{
+ if (gameState!=Game_Active) {
+ return;
+ }
+ //check how deep we can move
+ bool moveable = true;
+ while(moveable) {
+ moveable=false;
+ foreach (Piece* piece, activePieces){
+ if (canMove(piece, delta)) {
+ movePiece(piece,delta);
+ moveable=true;
+ }
+ }
+ }
+}
+
void KBlocksScene::attemptRotation(KBlocksRotationDirection direction)
{
if (gameState!=Game_Active) {
--- trunk/KDE/kdegames/kblocks/kblocksscene.h #943906:943907
@@ -61,6 +61,7 @@
void setSoundsEnabled(bool enabled);
void viewScaled(const QSize& newsize);
void attemptMove(const QPoint& delta);
+ void attemptPushDown(const QPoint& delta);
void attemptRotation(KBlocksRotationDirection direction);
private:
--- trunk/KDE/kdegames/kblocks/kblocksview.cpp #943906:943907
@@ -82,6 +82,11 @@
m_scene->attemptMove(QPoint(0,1));
}
+void KBlocksView::pushDown()
+{
+ m_scene->attemptPushDown(QPoint(0,1));
+}
+
void KBlocksView::focusInEvent ( QFocusEvent * )
{
//Recover from suspended state, sinalize it was not initiated by UI
--- trunk/KDE/kdegames/kblocks/kblocksview.h #943906:943907
@@ -33,6 +33,7 @@
void moveLeft();
void moveRight();
void moveDown();
+ void pushDown();
protected:
void focusInEvent ( QFocusEvent * event );
More information about the kde-doc-english
mailing list