: pieceUi(pieceUi), fieldUi(fieldUi),
timeLabel(timeLabel), doneButton(doneButton),
currentPiece(ppieces), rows(0), cols(0), timeLeft(0), levelRunning(false), neededFlow(0),
- startRow(0), startCol(0), startDir(DirNone), flowRow(0), flowCol(0), flowDir(DirNone), flowPreplaced(0), flowScore(0)
+ startRow(0), startCol(0), startDir(DirNone), flowRow(0), flowCol(0), flowDir(DirNone), flowPreplaced(0), flowScore(0), animate(true)
{
connect(fieldUi, SIGNAL(cellClicked(int, int)), this, SLOT(onCellClicked(int, int)));
connect(pieceUi, SIGNAL(invalidPieceSelected()),
connect(this, SIGNAL(pieceUsed(const Piece*)), pieceUi, SLOT(onPieceUsed(const Piece*)));
- connect(doneButton, SIGNAL(clicked()), this, SLOT(levelEnds()));
+ connect(doneButton, SIGNAL(clicked()), this, SLOT(onDoneClicked()));
// Setup the timer, but don't start it yet
timer.setInterval(1000);
// Clear piece selection
onInvalidPieceSelected();
- doneButton->setEnabled(true);
+ doneButton->setText("Done");
timer.start();
levelRunning = true;
file.close();
currentPiece = ppieces;
}
+void GameController::onDoneClicked()
+{
+ // If the level was running, start flowing the liquid
+ if (levelRunning)
+ levelEnds();
+ // Else, skip the flowing animation
+ else {
+ animate = false;
+ flowTimer.setInterval(0);
+ }
+}
+
void GameController::levelEnds()
{
if (!levelRunning) return;
- doneButton->setEnabled(false);
+ doneButton->setText("Next");
levelRunning = false;
+ animate = true;
timer.stop();
// Initiate computing the flow
// some more time, so that the user sees the failure before we
// emit levelFailed.
flowDir = DirFailed;
- flowTimer.setInterval(1000);
+ if (animate) flowTimer.setInterval(1000);
return;
}
flowScore += 10;
else
flowDir = DirPassed;
- flowTimer.setInterval(1000);
+ if (animate) flowTimer.setInterval(1000);
return;
}
if (flowRow < 0 || flowCol < 0 || flowRow >= rows || flowCol >= cols) {
// Out of bounds
flowDir = DirFailed;
- flowTimer.setInterval(1000);
+ if (animate) flowTimer.setInterval(1000);
return;
}