KBreakout: Restore debugging/cheat codes on Jessie
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
For all those who found the debugging/cheat codes of KBreakout
missing after upgrading from Debian Wheezy (KBreakout 4.8.4) to
Jessie (KBreakout 4.13.1), here is a patch to restore them.
With this patch, it is not necessary to use the KDE_DEBUG environment
variable anymore either, and the keyboard shortcuts can be configured
through the menu.
* S = Skip level
* L = Add life
See the Debian Wiki BuildingTutorial [1] on how to download, build
and install a package from source. Before building, apply the patch
from within the kbreakout-4.13.1 directory:
$ patch -p1 < ~/kbreakout-4.13.1-cheat-codes.patch
I also created an updated patch for the current upstream master
(KBreakout 15.04.1), which will however require the KDE_DEBUG
environment variable again. It is currently under review as KDE
ReviewBoard Review Request #123950 [2].
Enjoy,
Peter
[1]: https://wiki.debian.org/BuildingTutorial
[2]: https://git.reviewboard.kde.org/r/123950/diff/1/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQIcBAEBCgAGBQJVdLgiAAoJENtOitaaBBTNe2cQAIQvqjx04OQmeDLES+gOr4GL
FraI9vjP8DrZCkI5djFeD7LOppsBY53CvQkuYLSa+v0LLdnztzzSSAdJWqnbwLlg
gXsJM2y0a9qbflK034krrZADY6KzAC2IY55HkRrdNJWWkByfl6Xdj+cqJ2C8UUE9
1/Q7R9mQlhLJdRAXlfmiQeejwFo1DRItXeVhi/ci531hvPtflmVhqATsyQMgnak3
LwMiVpOV0jHhJOLOPxAa0JP2DE2qNohA7AHOu09rHtDBiPPWATVfTBZ15W1ClxEz
FHDwnFqZo+ZDcYy9LsOZ7rEri1UJepLb51Jh8DyR/hXE49UXF1ECQMkjw3DjTd3c
jbPqsdvubq/42UguJtM7LIDvYrx5pok2PUsgJjRSTcBzUgkF52Sa+8alsgv7Upvs
M+kiYVWgZgiWVH3iZiNhYGswyb3wRPWx8NYUVHrHc46ezTw7wvwknsLmQZ540oNb
nSSg7Lh90XOrp0dc18tIAlPxnY41lfiVJd5wEig7/THGOX/WCtcQ6XK9N+eyBV35
YCpGrzvp7fWo2Ah/mSiILgeasHure6s1eBLmt+lVU84mRNeP9ctmEAf22lFpqhjF
9/eLJyVY28MZdBxKXH0h0ZSwjZlUZcdfbCokVcp/niapHzCMUWQ92SsLmLlO75dE
dyUjqpgLFB4O1pbsId08
=E2jb
-----END PGP SIGNATURE-----
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQIcBAABCgAGBQJVdLlAAAoJENtOitaaBBTNKuQP/0lH0bWUx/vEqdpjPfYKQlrX
Ldppprk563ELn7A7iAJKIah+DyCd6gTzjKcsmkY+qxMgfELGOPp+m5N+3etgwmGM
bz/xoQArynzoxjy1yOuWkIuyGRC2HqhntBzGt+yM2eY6qEC3bmi9YWG10xN3S6hs
cQbxxtJ0QDA5hDO/JYuG3/xdBe0+nSCRX//lt8D71eIapRBzPG92XDm5ODdZX7Rc
GPSZaZriRBrb3Z+jGakyj1UFb41oW52YNcyBd636av8mCHir/phD9RN5+BEfLYde
LEGR6gs7FDYgEEYpSW0HkkvGhttoNzDMQbwLVooAd2tpMym/c0pbTIJgB+jmMnKb
H2mtQkgRB05evd0gr4EIRbQoJnthC52axDgQX5bKFZhqEGVqkx8zuLKpAXkbQyzy
YtBLilqYPStkOVhT/ypoLU8vCIMnRAcCC1UotUSZ+SUfMZ8bIvYPkygALOdZiNKi
hezWsHYNFM1CI/7vTieGF6vpmT0cHZJNKkDGhyxJUfvVgxzTnhtJdpbQRMW8mkFN
KDWhcATO1AZZFvUboFUzh79XMJ+4YGliagHaq0KPehELZN7Zla29PoD49L2y+TD0
wbpT+yXqpv/aC57X604fd4xJyR7ZofKGJAr80hJE0TUeXCXUIwEMOxfIpMUIkERv
YVmY829a/TpmC09K/Tgj
=QIK1
-----END PGP SIGNATURE-----
commit 25743f826d3ef1ca09404476d3a5524b148ac56a
Author: Peter Nowee <peter.nowee@gmail.com>
Date: Wed May 20 19:16:44 2015 +0200
Bring back cheat codes
Bring back the following debug/cheat codes that were removed since
KBreakout 4.9.90 (commits 5043da7, f8f3491):
L = Add life
S = Skip level
The cheat codes will be enabled by default, so no need to set the
KDE_DEBUG environment variable anymore either.
This patch is against KBreakout 4.13.1.
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..9a546e2 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -134,6 +134,20 @@ void MainWindow::setupActions()
connect(fireAction, SIGNAL(changed()), canvasWidget, SLOT(updateFireShortcut()));
actionCollection()->addAction( QLatin1String( "fire" ), fireAction);
+ 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 +256,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..aed67b9 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
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
Reply to: