Package: kbreakout Version: 4:4.13.1-1 Severity: normal Tags: patch upstream
Dear Maintainer, The following debugging/cheat codes were available when running kbreakout with the KDE_DEBUG environment variable under Debian Wheezy (KBreakout 4.8.4), but are not available anymore after upgrading to Debian Jessie (KBreakout 4.13.1): * S = Skip level * L = Add life To fix this, I created attached fix specifically for kbreakout-4.13.1, the version included in Debian Jessie. I tested that it builds successfully and works as expected. I already submitted a port of this patch for the development version at KDE upstream, which was recently accepted. [1] [2] Thanks, Peter [1] https://git.reviewboard.kde.org/r/123950/ [2] http://quickgit.kde.org/?p=kbreakout.git&a=commit&h=37588239823a58f9e58446fb8ae3ce7db898abdd -- System Information: Debian Release: 8.1 APT prefers stable APT policy: (700, 'stable'), (500, 'stable-updates'), (500, 'proposed-updates'), (90, 'unstable') Architecture: i386 (i686) Kernel: Linux 3.16.0-4-686-pae (SMP w/1 CPU core) Locale: LANG=en_US.UTF8, LC_CTYPE=en_US.UTF8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages kbreakout depends on: ii kde-games-core-declarative 4:4.14.2-1 ii kde-runtime 4:4.14.2-2 ii libc6 2.19-18 ii libkdecore5 4:4.14.2-5 ii libkdegames6abi1 4:4.14.2-1 ii libkdeui5 4:4.14.2-5 ii libqt4-declarative 4:4.8.6+git64-g5dc8b2b+dfsg-3+deb8u1 ii libqt4-xml 4:4.8.6+git64-g5dc8b2b+dfsg-3+deb8u1 ii libqtcore4 4:4.8.6+git64-g5dc8b2b+dfsg-3+deb8u1 ii libqtgui4 4:4.8.6+git64-g5dc8b2b+dfsg-3+deb8u1 ii libstdc++6 4.9.2-10 Versions of packages kbreakout recommends: ii khelpcenter4 4:4.14.2-2 kbreakout suggests no packages. -- no debconf information
Author: Peter Nowee <peter.no...@gmail.com> Date: Wed Jul 05 16:47:47 2015 +0200 [kbreakout] Restore debugging/cheat codes This changeset restores the debugging/cheat codes that were left out of the QtQuick port (version 4.9.90, KDE commits 5043da7 and f8f3491): * S = Skip level * L = Add life These cheat codes are invaluable when designing and testing levels, as my son likes to do. Like before, all this will only be available when the KDE_DEBUG environment variable is true, for example: KDE_DEBUG=1 kbreakout The key shortcuts (default: "S", "L") can now also be configured through the menu (provided KDE_DEBUG is true). Note that this patch was specifically created for KBreakout 4.13.1. An updated patch for the current development version was commited upstream with KDE commit 3758823. diff --git a/src/canvaswidget.cpp b/src/canvaswidget.cpp index 42bada1..23bd872 100644 --- a/src/canvaswidget.cpp +++ b/src/canvaswidget.cpp @@ -96,6 +96,16 @@ void CanvasWidget::fire() QMetaObject::invokeMethod(rootObject(), "fire"); } +void CanvasWidget::cheatSkipLevel() +{ + QMetaObject::invokeMethod(rootObject(), "cheatSkipLevel"); +} + +void CanvasWidget::cheatAddLife() +{ + QMetaObject::invokeMethod(rootObject(), "cheatAddLife"); +} + void CanvasWidget::setGamePaused(bool paused) { QMetaObject::invokeMethod(rootObject(), "setGamePaused", diff --git a/src/canvaswidget.h b/src/canvaswidget.h index 8145124..7453d95 100644 --- a/src/canvaswidget.h +++ b/src/canvaswidget.h @@ -38,6 +38,8 @@ public slots: void fire(); void setGamePaused(bool paused); void updateFireShortcut(); + void cheatSkipLevel(); + void cheatAddLife(); private slots: void newGame(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 1263477..c2de58f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -59,6 +59,8 @@ MainWindow::MainWindow(QWidget *parent) { gameEngine = new GameEngine(this); + m_cheatsEnabled = !qgetenv("KDE_DEBUG").isEmpty(); + connect(canvasWidget, SIGNAL(focusLost()), this, SLOT(pauseGame())); @@ -134,6 +136,22 @@ void MainWindow::setupActions() connect(fireAction, SIGNAL(changed()), canvasWidget, SLOT(updateFireShortcut())); actionCollection()->addAction( QLatin1String( "fire" ), fireAction); + if (m_cheatsEnabled) { + KAction *cheatSkipLevelAction = new KAction(this); + cheatSkipLevelAction->setText(i18n("Skip level")); + cheatSkipLevelAction->setShortcut(Qt::Key_S); + cheatSkipLevelAction->setIcon(KIcon( QLatin1String( "kbreakout" ))); + connect(cheatSkipLevelAction, SIGNAL(triggered()), this, SLOT(cheatSkipLevel())); + actionCollection()->addAction( QLatin1String( "cheatSkipLevel" ), cheatSkipLevelAction); + + KAction *cheatAddLifeAction = new KAction(this); + cheatAddLifeAction->setText(i18n("Add life")); + cheatAddLifeAction->setShortcut(Qt::Key_L); + cheatAddLifeAction->setIcon(KIcon( QLatin1String( "kbreakout" ))); + connect(cheatAddLifeAction, SIGNAL(triggered()), this, SLOT(cheatAddLife())); + actionCollection()->addAction( QLatin1String( "cheatAddLife" ), cheatAddLifeAction); + } + pauseAction = KStandardGameAction::pause(this, SLOT(setGamePaused(bool)), actionCollection()); // set custom keys @@ -242,6 +260,25 @@ void MainWindow::fire() } } + +void MainWindow::cheatSkipLevel() +{ + if (pauseAction->isChecked()) { + pauseAction->activate(QAction::Trigger); + } else { + canvasWidget->cheatSkipLevel(); + } +} + +void MainWindow::cheatAddLife() +{ + if (pauseAction->isChecked()) { + pauseAction->activate(QAction::Trigger); + } else { + canvasWidget->cheatAddLife(); + } +} + void MainWindow::viewFullScreen(bool fullScreen) { KToggleFullScreenAction::setFullScreen(this, fullScreen); diff --git a/src/mainwindow.h b/src/mainwindow.h index 1bcd796..c4a5a79 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -39,6 +39,8 @@ private slots: void showHighscores(); void startNewGame(); void fire(); + void cheatSkipLevel(); + void cheatAddLife(); // calls the action void pauseGame(); // called by the action @@ -47,6 +49,8 @@ private slots: void handleMousePressed(); private: + bool m_cheatsEnabled; + void setupActions(); KToggleAction *pauseAction; diff --git a/src/qml/logic.js b/src/qml/logic.js index c43d0d4..5ca51e1 100644 --- a/src/qml/logic.js +++ b/src/qml/logic.js @@ -326,6 +326,12 @@ function fireBall() { randomCounter = 0; } +function addLife() { + if (lives < Globals.MAXIMUM_LIVES) { + lives++; + } +} + function setGamePaused(paused) { if (gameOver || gameWon || canvas.paused==paused) return; canvas.paused = paused; diff --git a/src/qml/main.qml b/src/qml/main.qml index c8a8dc6..48d0415 100644 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -230,6 +230,14 @@ Item { Logic.fireBall(); } + function cheatAddLife() { + Logic.addLife(); + } + + function cheatSkipLevel() { + Logic.loadNextLevel(); + } + Timer { id: burnBricksTimer property variant target