roulette-payout/StreetBetsView.qml

114 lines
3.7 KiB
QML
Raw Normal View History

2024-06-01 01:14:46 +01:00
import QtQuick
2024-06-01 14:46:10 +01:00
import QtQuick.Layouts
2024-06-01 01:14:46 +01:00
import roulette
/*
* The very important id 'rouletteTable'
* comes from Roulette.qml
*/
2024-06-01 01:14:46 +01:00
Item {
2024-06-01 14:46:10 +01:00
RowLayout {
id: layout
property int indexForDialog
2024-06-01 14:46:10 +01:00
anchors {
left: parent.left
leftMargin: 90
top: parent.top
topMargin: 22
}
2024-06-01 01:14:46 +01:00
2024-06-01 14:46:10 +01:00
spacing: 1.8
2024-06-01 01:14:46 +01:00
2024-06-01 14:46:10 +01:00
Repeater {
id: repeater
2024-06-01 14:46:10 +01:00
model: 12
2024-06-01 01:14:46 +01:00
Item {
property alias selected: selected
id: betButton
2024-06-01 14:46:10 +01:00
height: 45
width: 35
Rectangle {
id: selected
visible: true
height: parent.height
width: parent.width
border.color: "blue"
border.width: 0
color: {
if (rouletteTable.numberOfBets < 2 || border.width == 2) {
if (tapHandler1.pressed) {
"#AA999999"
} else if (hoverHandler.hovered) {
"#AAEEEEEE"
} else {
"#00000000"
}
} else {
"#00000000"
}
}
HoverHandler {
id: hoverHandler
}
TapHandler {
id: tapHandler1
2024-06-01 01:14:46 +01:00
onTapped: {
if (rouletteTable.numberOfBets < 2 && parent.border.width == 0) {
parent.border.width = 2
layout.indexForDialog = index
roulette.showBetInputDialog(PlayerAreaModel.STREET, index, betButton.x, betButton.y)
} else if (parent.border.width == 2) {
parent.border.width = 0
PlayerAreaModel.removeBet(PlayerAreaModel.STREET, index)
rouletteTable.numberOfBets -= 1
}
2024-06-01 14:46:10 +01:00
}
2024-06-01 01:14:46 +01:00
}
Connections {
target: PlayerAreaModel
function onFocusedPlayerChanged(b1, n1, b2, n2) {
if (b1 == PlayerAreaModel.STREET && n1 == index) {
if (selected.border.width != 0) {
rouletteTable.numberOfBets -=1
}
selected.border.width = 2;
rouletteTable.numberOfBets += 1
} else if (b2 == PlayerAreaModel.STREET && n2 == index) {
if (selected.border.width != 0) {
rouletteTable.numberOfBets -=1
}
selected.border.width = 2;
rouletteTable.numberOfBets += 1
} else {
if (selected.border.width != 0) {
rouletteTable.numberOfBets -=1
}
selected.border.width = 0;
}
}
function onBetCanceled(n) {
if (index == n) {
selected.border.width = 0
}
}
}
}
}
}
}
2024-06-01 01:14:46 +01:00
}