Long time wish to be able to continue a failed KMines game, as it is not always possible to complete by guessing alone.
Description
So....
Not really sure how to use all your tooling (way, way too complicated, doesn't work/breaks).
But I saw it mention on your contributing guidelines that I could just submit a git patch somewhere? I have one created, I don't see any way to submit it here.
diff --git a/cellitem.cpp b/cellitem.cpp index b4e3060..443b743 100644 --- a/cellitem.cpp +++ b/cellitem.cpp @@ -33,6 +33,17 @@ CellItem::CellItem(KGameRenderer* renderer, QGraphicsItem* parent) reset(); } +void CellItem::unflag() +{ + m_state = KMinesState::Released; + updatePixmap(); +} + +void CellItem::unexplode() +{ + m_exploded = false; +} + void CellItem::reset() { m_state = KMinesState::Released; diff --git a/cellitem.h b/cellitem.h index 8c45a2d..b07e17d 100644 --- a/cellitem.h +++ b/cellitem.h @@ -72,6 +72,9 @@ public: * I.e. resets revealed state */ void unreveal() { m_state = KMinesState::Released; updatePixmap(); } + + void unflag(); + void unexplode(); /** * @return whether this cell is revealed */ diff --git a/mainwindow.cpp b/mainwindow.cpp index 2ab6e5b..836ec64 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -202,6 +202,13 @@ void KMinesMainWindow::onGameOver(bool won) scoreDialog->exec(); delete scoreDialog; + } else { + //ask to reset + if (QMessageBox::question(this, tr("Reset?"), tr("Reset the Game?")) == QMessageBox::Yes){ + m_scene->reset(); + m_gameClock->restart(); + m_actionPause->setEnabled(true); + } } } diff --git a/minefielditem.cpp b/minefielditem.cpp index 7030d66..0246d9b 100644 --- a/minefielditem.cpp +++ b/minefielditem.cpp @@ -32,6 +32,22 @@ MineFieldItem::MineFieldItem(KGameRenderer* renderer) setFlag(QGraphicsItem::ItemHasNoContents); } +void MineFieldItem::resetMines() +{ + m_gameOver = false; + m_numUnrevealed = m_numRows*m_numCols; + + for(CellItem* item : m_cells) { + item->unreveal(); + item->unflag(); + item->unexplode(); + } + + m_flaggedMinesCount = 0; + emit flaggedMinesCountChanged(m_flaggedMinesCount); +} + + void MineFieldItem::initField( int numRows, int numCols, int numMines ) { numMines = qMin(numMines, numRows*numCols - MINIMAL_FREE ); diff --git a/minefielditem.h b/minefielditem.h index 50eac77..dac4f8b 100644 --- a/minefielditem.h +++ b/minefielditem.h @@ -54,6 +54,8 @@ public: * @param numMines number of mines */ void initField( int numRows, int numCols, int numMines ); + + void resetMines(); /** * Resizes this graphics item so it fits in given rect */ diff --git a/scene.cpp b/scene.cpp index 469be58..3979b50 100644 --- a/scene.cpp +++ b/scene.cpp @@ -75,6 +75,11 @@ KMinesScene::KMinesScene( QObject* parent ) setBackgroundBrush(m_renderer.spritePixmap(QStringLiteral( "mainWidget" ), sceneRect().size().toSize())); } +void KMinesScene::reset() { + m_fieldItem->resetMines(); + m_messageItem->forceHide(); +} + void KMinesScene::resizeScene(int width, int height) { setSceneRect(0, 0, width, height); diff --git a/scene.h b/scene.h index c2189b3..62673bf 100644 --- a/scene.h +++ b/scene.h @@ -53,6 +53,8 @@ public: * Toggles paused state for all cells in the field item */ void setGamePaused(bool paused); + + void reset(); KGameRenderer& renderer() {return m_renderer;} Q_SIGNALS:
SRPM:
https://mega.nz/#!HKAxHIra!3nqFSDIZ74fPn7H-fhu4jy3tpVl43GqxmIOzD14p5Eg
RPM:
https://mega.nz/#!rDBXlKYI!3gXR8uPyhJTBP2wh4ePw2uirJIzjMwwfxif5VAwBLQk
Additionally I have these, the source code for actually getting it working on my platform was a bit different than the official source, these are RPMs for source and binary build...as well as one more for my raw build directory:
https://mega.nz/#!DaZ3naoR!6i5x-DaShlT16_1l4-4sRH_Prm2xmQRNu3GOlimkEWo
I'd really suggest to use arcanist and send a patch. Commit to the local repository, arc diff, and that's it, the kdegames mailing list will be notified.
https://community.kde.org/Get_Involved/development#Submit_a_patch
Also, it is extremely unpractical to get a review through a task - they are not meant for this. Please close this and send a review.
https://phabricator.kde.org/D17860
Updated. I'm not using arcanist... I suppose I should bug the mailing list every so often?
No, the mailing list is one of the subscribers of that review, so a notification is sent on the list for any update or comment on the review.