2024-05-31 12:10:00 +01:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
|
|
|
import roulette
|
|
|
|
|
|
|
|
Item {
|
2024-06-02 21:13:43 +01:00
|
|
|
anchors {
|
|
|
|
left: parent.left
|
|
|
|
leftMargin: 10
|
|
|
|
}
|
|
|
|
|
2024-06-01 14:46:10 +01:00
|
|
|
Text {
|
|
|
|
id: croupier
|
2024-06-07 10:06:28 +01:00
|
|
|
font.pointSize: 18
|
2024-06-01 14:46:10 +01:00
|
|
|
text: "Croupier"
|
2024-06-07 10:06:28 +01:00
|
|
|
color: {
|
|
|
|
if (tapHandler.pressed) {
|
|
|
|
"#99000000"
|
|
|
|
} else {
|
|
|
|
"#000000"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TapHandler {
|
|
|
|
id: tapHandler
|
|
|
|
|
|
|
|
onSingleTapped: {
|
|
|
|
PlayerAreaModel.focusedPlayer = 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: indicator
|
|
|
|
color: "red"
|
|
|
|
height: 10
|
|
|
|
width: 10
|
|
|
|
opacity: 0.5
|
|
|
|
visible: PlayerAreaModel.focusedPlayer == 0
|
|
|
|
|
|
|
|
anchors {
|
|
|
|
verticalCenter: parent.verticalCenter
|
|
|
|
right: parent.left
|
|
|
|
rightMargin: 5
|
|
|
|
}
|
|
|
|
}
|
2024-06-07 16:30:49 +01:00
|
|
|
|
|
|
|
Text {
|
|
|
|
id: roll
|
|
|
|
|
|
|
|
anchors {
|
|
|
|
top: parent.top
|
|
|
|
topMargin: 8
|
|
|
|
left: parent.right
|
|
|
|
leftMargin: 5
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: PlayerAreaModel
|
|
|
|
|
|
|
|
function onBetChanged(b, n, bet) {
|
|
|
|
if (PlayerAreaModel.focusedPlayer == 0) {
|
|
|
|
const betTypes = ["NONE", "Red", "Black", "Odd", "Even", "Low", "High",
|
|
|
|
"Dozen", "Street", "Single", "Column", "Split"]
|
|
|
|
if (b < 7) {
|
|
|
|
roll.text = betTypes[b]
|
|
|
|
} else {
|
|
|
|
roll.text = betTypes[b] + " " + (n + 1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onBetRemoved(b, n) {
|
|
|
|
if (PlayerAreaModel.focusedPlayer == 0) {
|
|
|
|
roll.text = ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-06-01 14:46:10 +01:00
|
|
|
}
|
|
|
|
|
2024-05-31 12:10:00 +01:00
|
|
|
ColumnLayout {
|
2024-06-01 14:46:10 +01:00
|
|
|
anchors {
|
|
|
|
top: croupier.bottom
|
|
|
|
topMargin: 20
|
2024-05-31 12:10:00 +01:00
|
|
|
}
|
2024-06-01 14:46:10 +01:00
|
|
|
|
|
|
|
spacing: 60
|
|
|
|
|
2024-06-04 21:10:39 +01:00
|
|
|
/*
|
|
|
|
* A repeater can only have one delegate model
|
|
|
|
* i.e. it can only have one object template defined in it.
|
|
|
|
* To repeat both a Text, and Rectangle AND a TextField, we put them inside an Item
|
|
|
|
* and use anchors to sort them inside the Item
|
|
|
|
*/
|
2024-06-01 14:46:10 +01:00
|
|
|
Repeater {
|
|
|
|
model: 7
|
|
|
|
|
|
|
|
Item {
|
|
|
|
Text {
|
|
|
|
id: label
|
|
|
|
text: "Player " + (index + 1)
|
|
|
|
}
|
|
|
|
|
2024-06-02 21:13:43 +01:00
|
|
|
Rectangle {
|
|
|
|
id: indicator
|
|
|
|
color: "red"
|
|
|
|
height: 10
|
|
|
|
width: 10
|
2024-06-04 21:10:39 +01:00
|
|
|
/*
|
|
|
|
* This check will run once when the object is created, but then only refresh
|
|
|
|
* when the NOTIFY signal for .focusedPlayer is sent
|
|
|
|
*/
|
2024-06-07 10:06:28 +01:00
|
|
|
visible: PlayerAreaModel.focusedPlayer - 1 == index
|
2024-06-02 21:13:43 +01:00
|
|
|
opacity: 0.5
|
|
|
|
|
|
|
|
anchors {
|
|
|
|
verticalCenter: inputField.verticalCenter
|
|
|
|
right: inputField.left
|
|
|
|
rightMargin: 5
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-01 14:46:10 +01:00
|
|
|
TextField {
|
2024-06-02 21:13:43 +01:00
|
|
|
id: inputField
|
2024-06-06 21:54:59 +01:00
|
|
|
|
|
|
|
anchors {
|
|
|
|
top: label.bottom
|
|
|
|
topMargin: 6
|
|
|
|
}
|
2024-06-01 14:46:10 +01:00
|
|
|
|
2024-06-08 00:41:25 +01:00
|
|
|
onTextEdited: PlayerAreaModel.setPlayerName(text, index + 1)
|
2024-06-02 21:13:43 +01:00
|
|
|
onActiveFocusChanged: {
|
2024-06-04 21:10:39 +01:00
|
|
|
/* focusReason 0, 1 and 2 are mouse, tab forward, and tab backward, respectively */
|
2024-06-02 21:13:43 +01:00
|
|
|
if (activeFocus && (focusReason == 0 || focusReason == 1 || focusReason == 2)) {
|
2024-06-07 10:06:28 +01:00
|
|
|
PlayerAreaModel.focusedPlayer = index + 1
|
2024-06-02 21:13:43 +01:00
|
|
|
}
|
|
|
|
}
|
2024-06-01 14:46:10 +01:00
|
|
|
}
|
2024-06-06 21:54:59 +01:00
|
|
|
|
|
|
|
Text {
|
2024-06-07 08:31:38 +01:00
|
|
|
property int betType
|
|
|
|
property int n
|
|
|
|
|
|
|
|
id: currentBet1
|
2024-06-06 21:54:59 +01:00
|
|
|
|
|
|
|
anchors {
|
|
|
|
verticalCenter: inputField.verticalCenter
|
|
|
|
left: inputField.right
|
|
|
|
leftMargin: 5
|
|
|
|
}
|
|
|
|
|
|
|
|
text: ""
|
|
|
|
}
|
|
|
|
|
2024-06-07 08:31:38 +01:00
|
|
|
Text {
|
|
|
|
property int betType
|
|
|
|
property int n
|
|
|
|
|
|
|
|
id: currentBet2
|
|
|
|
|
|
|
|
anchors {
|
|
|
|
verticalCenter: inputField.verticalCenter
|
|
|
|
left: currentBet1.right
|
|
|
|
leftMargin: 5
|
|
|
|
}
|
|
|
|
|
|
|
|
text: ""
|
|
|
|
}
|
|
|
|
|
2024-06-06 21:54:59 +01:00
|
|
|
Connections {
|
|
|
|
target: PlayerAreaModel
|
|
|
|
|
|
|
|
function onBetChanged(b, n, bet) {
|
2024-06-07 10:06:28 +01:00
|
|
|
if (PlayerAreaModel.focusedPlayer - 1 == index) {
|
2024-06-07 16:30:49 +01:00
|
|
|
const betTypes = ["NONE", "Red", "Black", "Odd", "Even", "Low", "High",
|
|
|
|
"Dozen", "Street", "Single", "Column", "Split"]
|
2024-06-07 08:31:38 +01:00
|
|
|
if (currentBet1.text == "") {
|
|
|
|
currentBet1.betType = b
|
|
|
|
currentBet1.n = n
|
2024-06-07 16:30:49 +01:00
|
|
|
if (b < 7) {
|
|
|
|
currentBet1.text = betTypes[b] + ": " + bet + "g"
|
|
|
|
} else {
|
|
|
|
currentBet1.text = betTypes[b] + " " + (n + 1) + ": " + bet + "g"
|
2024-06-07 08:31:38 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
currentBet2.betType = b
|
|
|
|
currentBet2.n = n
|
2024-06-07 16:30:49 +01:00
|
|
|
if (b < 7) {
|
|
|
|
currentBet2.text = betTypes[b] + ": " + bet + "g"
|
|
|
|
} else {
|
|
|
|
currentBet2.text = betTypes[b] + " " + (n + 1) + ": " + bet + "g"
|
2024-06-07 08:31:38 +01:00
|
|
|
}
|
2024-06-06 21:54:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-07 08:31:38 +01:00
|
|
|
function onBetRemoved(b, n) {
|
2024-06-07 10:06:28 +01:00
|
|
|
if (PlayerAreaModel.focusedPlayer - 1 == index) {
|
2024-06-07 08:31:38 +01:00
|
|
|
if (currentBet1.betType == b && currentBet1.n == n) {
|
|
|
|
currentBet1.text = ""
|
|
|
|
} else if (currentBet2.betType == b && currentBet2.n == n) {
|
|
|
|
currentBet2.text = ""
|
|
|
|
}
|
2024-06-06 21:54:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-06-01 14:46:10 +01:00
|
|
|
}
|
2024-05-31 12:10:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|