Add redeal button
This commit is contained in:
parent
48d1bd0a89
commit
a4a91e09f9
105
qml/ScoreBar.qml
105
qml/ScoreBar.qml
|
@ -1,4 +1,6 @@
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import QtQuick.Controls
|
||||||
import Solitare
|
import Solitare
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
@ -7,24 +9,39 @@ Rectangle {
|
||||||
property int score: 0
|
property int score: 0
|
||||||
property int time: 0
|
property int time: 0
|
||||||
property int moves: 0
|
property int moves: 0
|
||||||
property int dynamicFontSize: Math.round(height * 0.35)
|
|
||||||
|
|
||||||
color: "lightgray"
|
color: "lightgray"
|
||||||
|
|
||||||
Column {
|
Item {
|
||||||
|
id: firstRow
|
||||||
|
|
||||||
|
anchors.top: parent.top
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
anchors.topMargin: parent.height * 0.1
|
||||||
|
anchors.leftMargin: parent.width * 0.02
|
||||||
|
anchors.rightMargin: parent.width * 0.02
|
||||||
|
height: parent.height * 0.5
|
||||||
|
|
||||||
|
Button {
|
||||||
|
text: "Redeal"
|
||||||
|
onClicked: GameState.dealCards()
|
||||||
|
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
height: parent.height
|
||||||
|
}
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
id: scoreContainer
|
anchors.top: parent.top
|
||||||
|
height: parent.height
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
spacing: 40
|
spacing: parent.width * 0.05
|
||||||
|
|
||||||
ScoreItem {
|
ScoreItem {
|
||||||
title: "SCORE"
|
title: "SCORE"
|
||||||
value: scoreBarRoot.score
|
value: scoreBarRoot.score
|
||||||
fontPixelSize: scoreBarRoot.dynamicFontSize
|
height: parent.height
|
||||||
}
|
}
|
||||||
|
|
||||||
ScoreItem {
|
ScoreItem {
|
||||||
|
@ -50,74 +67,82 @@ Rectangle {
|
||||||
|
|
||||||
title: "TIME"
|
title: "TIME"
|
||||||
value: formatTime(scoreBarRoot.time)
|
value: formatTime(scoreBarRoot.time)
|
||||||
fontPixelSize: scoreBarRoot.dynamicFontSize
|
height: parent.height
|
||||||
}
|
}
|
||||||
|
|
||||||
ScoreItem {
|
ScoreItem {
|
||||||
title: "MOVES"
|
title: "MOVES"
|
||||||
value: scoreBarRoot.moves
|
value: scoreBarRoot.moves
|
||||||
fontPixelSize: scoreBarRoot.dynamicFontSize
|
height: parent.height
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Row {
|
Item {
|
||||||
id: statusContainer
|
id: statusRow
|
||||||
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.top: firstRow.bottom
|
||||||
spacing: 40
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
anchors.topMargin: parent.height * 0.1
|
||||||
|
anchors.bottomMargin: parent.height * 0.1
|
||||||
|
anchors.leftMargin: parent.width * 0.02
|
||||||
|
anchors.rightMargin: parent.height * 0.02
|
||||||
|
height: parent.height * 0.2
|
||||||
|
|
||||||
ScoreItem {
|
ScoreItem {
|
||||||
visible: GameState.isWinnable.winnable === false
|
visible: GameState.isWinnable.winnable === false
|
||||||
title: "GAME LOST"
|
title: "GAME LOST"
|
||||||
titleColor: "red"
|
titleColor: "red"
|
||||||
fontPixelSize: scoreBarRoot.dynamicFontSize * 1.5
|
anchors.fill: parent
|
||||||
}
|
}
|
||||||
|
|
||||||
ScoreItem {
|
ScoreItem {
|
||||||
visible: GameState.preliminaryWin === true && GameState.gameWon === false
|
visible: GameState.preliminaryWin === true && GameState.gameWon === false
|
||||||
title: "PRE-WON"
|
title: "PRE-WON"
|
||||||
titleColor: "green"
|
titleColor: "green"
|
||||||
fontPixelSize: scoreBarRoot.dynamicFontSize * 1.5
|
anchors.fill: parent
|
||||||
}
|
}
|
||||||
|
|
||||||
ScoreItem {
|
ScoreItem {
|
||||||
visible: GameState.gameWon === true
|
visible: GameState.gameWon === true
|
||||||
title: "GAME WON"
|
title: "GAME WON"
|
||||||
titleColor: "green"
|
titleColor: "green"
|
||||||
fontPixelSize: scoreBarRoot.dynamicFontSize * 1.5
|
anchors.fill: parent
|
||||||
}
|
}
|
||||||
|
|
||||||
ScoreItem {
|
ScoreItem {
|
||||||
visible: GameState.gameWon === false && GameState.preliminaryWin === false && GameState.isWinnable.winnable !== false
|
visible: GameState.gameWon === false && GameState.preliminaryWin === false && GameState.isWinnable.winnable !== false
|
||||||
title: "PLAYING"
|
title: "PLAYING"
|
||||||
fontPixelSize: scoreBarRoot.dynamicFontSize * 1.5
|
anchors.fill: parent
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
component ScoreItem: Column {
|
component ScoreItem: Column {
|
||||||
required property string title
|
required property string title
|
||||||
property string value
|
property string value
|
||||||
required property int fontPixelSize
|
|
||||||
property color titleColor
|
property color titleColor
|
||||||
property color valueColor
|
property color valueColor
|
||||||
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
property real fontHeight: height * 0.95 // Use 95% of the height for the font pixel size
|
||||||
spacing: 4
|
property int titleFontSize: Math.round(value ? fontHeight * 0.3 : fontHeight) // 30% of the height, or full height if no value
|
||||||
|
property int valueFontSize: Math.round(fontHeight - titleFontSize) // Remaining height
|
||||||
|
|
||||||
|
spacing: height * 0.05 // Remaining 5% of the height for spacing between the title & value
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
text: parent.title
|
text: parent.title
|
||||||
color: parent.titleColor
|
color: parent.titleColor
|
||||||
font.pixelSize: Math.round(parent.fontPixelSize * 0.4) // 40% of the dynamic font size
|
font.pixelSize: parent.titleFontSize
|
||||||
font.bold: true
|
font.bold: true
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
|
visible: parent.value
|
||||||
text: parent.value
|
text: parent.value
|
||||||
color: parent.valueColor
|
color: parent.valueColor
|
||||||
font.pixelSize: parent.fontPixelSize // 100% of the dynamic font size
|
font.pixelSize: parent.valueFontSize
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue