Restart the timer on game restar

This commit is contained in:
ItsDrike 2024-12-12 20:02:12 +01:00
parent 6ecfc64a79
commit 1ecfd36598
Signed by: ItsDrike
GPG key ID: FA2745890B7048C0
3 changed files with 20 additions and 4 deletions

View file

@ -53,7 +53,7 @@ ApplicationWindow {
Timer {
id: gameTimer
interval: 1000
running: true
running: GameState.gameWon === false
repeat: true
onTriggered: scoreBar.time += 1
}
@ -68,6 +68,8 @@ ApplicationWindow {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
onRestart: time = 0
}
// Show the foundation piles, throwaway pile & the draw stack on the first row
@ -123,5 +125,9 @@ ApplicationWindow {
cardHeight: app.cardHeight
}
WinOverlay {}
WinOverlay {
onRestart: {
scoreBar.time = 0
}
}
}

View file

@ -10,10 +10,15 @@ Rectangle {
property int time: 0
property int moves: 0
signal restart
color: "lightgray"
RoundButton {
onClicked: GameState.dealCards()
onClicked: {
GameState.dealCards()
scoreBarRoot.restart()
}
anchors.left: parent.left
anchors.leftMargin: parent.width * 0.02

View file

@ -10,6 +10,8 @@ Rectangle {
visible: GameState.gameWon === true
anchors.fill: parent
signal restart
Text {
id: winText
@ -23,7 +25,10 @@ Rectangle {
Button {
text: "Restart"
onClicked: GameState.dealCards()
onClicked: {
GameState.dealCards();
winOverlay.restart();
}
anchors.top: winText.bottom
anchors.horizontalCenter: parent.horizontalCenter
}