Awful code for showing players' bets next to name.
This commit is contained in:
parent
e482529d67
commit
14009e8a5d
3 changed files with 107 additions and 44 deletions
|
@ -52,16 +52,6 @@ Dialog {
|
|||
}
|
||||
|
||||
onAccepted: {
|
||||
/*
|
||||
* Qt has no good way of making bottom to top grid layouts, so I had to use
|
||||
* a workaround where the indexes do not work as expected.
|
||||
*
|
||||
* A solution for the indexes is to rotate the layout 180º, but that will mess up
|
||||
* the x and y coordinates which is even more annoying to fix.
|
||||
*/
|
||||
if (betType == 9 && n <= 35) {
|
||||
n = 35 - n
|
||||
}
|
||||
PlayerAreaModel.bet(betType, n, input.text)
|
||||
rouletteTable.numberOfBets += 1
|
||||
}
|
||||
|
|
|
@ -43,11 +43,17 @@ void PlayerAreaModel::bet(BetType b, int n, int bet)
|
|||
player->bet1.betType = b;
|
||||
player->bet1.betValue = bet;
|
||||
player->bet1.betSpot = n;
|
||||
if (b == 9 && n <= 35) {
|
||||
n = 35 - n;
|
||||
}
|
||||
emit betChanged(b, n, bet);
|
||||
} else if (player->bet2.betType == NONE) {
|
||||
player->bet2.betType = b;
|
||||
player->bet2.betValue = bet;
|
||||
player->bet2.betSpot = n;
|
||||
if (b == 9 && n <= 35) {
|
||||
n = 35 - n;
|
||||
}
|
||||
emit betChanged(b, n, bet);
|
||||
}
|
||||
}
|
||||
|
@ -57,9 +63,15 @@ void PlayerAreaModel::removeBet(BetType b, int n)
|
|||
Player *player = &players[focusedPlayer_];
|
||||
if (player->bet1.betType != NONE) {
|
||||
player->bet1.betType = NONE;
|
||||
if (b == 9 && n <= 35) {
|
||||
n = 35 - n;
|
||||
}
|
||||
emit betRemoved(b, n);
|
||||
} else {
|
||||
player->bet2.betType = NONE;
|
||||
if (b == 9 && n <= 35) {
|
||||
n = 35 - n;
|
||||
}
|
||||
emit betRemoved(b, n);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,7 +75,10 @@ Item {
|
|||
}
|
||||
|
||||
Text {
|
||||
id: currentBet
|
||||
property int betType
|
||||
property int n
|
||||
|
||||
id: currentBet1
|
||||
|
||||
anchors {
|
||||
verticalCenter: inputField.verticalCenter
|
||||
|
@ -86,49 +89,107 @@ Item {
|
|||
text: ""
|
||||
}
|
||||
|
||||
Text {
|
||||
property int betType
|
||||
property int n
|
||||
|
||||
id: currentBet2
|
||||
|
||||
anchors {
|
||||
verticalCenter: inputField.verticalCenter
|
||||
left: currentBet1.right
|
||||
leftMargin: 5
|
||||
}
|
||||
|
||||
text: ""
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: PlayerAreaModel
|
||||
|
||||
function onBetChanged(b, n, bet) {
|
||||
if (PlayerAreaModel.focusedPlayer == index) {
|
||||
if (currentBet1.text == "") {
|
||||
currentBet1.betType = b
|
||||
currentBet1.n = n
|
||||
switch(b) {
|
||||
case 1:
|
||||
currentBet.text = "Red: " + bet + "g"
|
||||
currentBet1.text = "Red: " + bet + "g"
|
||||
break;
|
||||
case 2:
|
||||
currentBet.text = "Black: " + bet + "g"
|
||||
currentBet1.text = "Black: " + bet + "g"
|
||||
break;
|
||||
case 3:
|
||||
currentBet.text = "Odd: " + bet + "g"
|
||||
currentBet1.text = "Odd: " + bet + "g"
|
||||
break;
|
||||
case 4:
|
||||
currentBet.text = "Even: " + bet + "g"
|
||||
currentBet1.text = "Even: " + bet + "g"
|
||||
break;
|
||||
case 5:
|
||||
currentBet.text = "Low: " + bet + "g"
|
||||
currentBet1.text = "Low: " + bet + "g"
|
||||
break;
|
||||
case 6:
|
||||
currentBet.text = "High: " + bet + "g"
|
||||
currentBet1.text = "High: " + bet + "g"
|
||||
break;
|
||||
case 7:
|
||||
currentBet.text = "Dozen " + (n + 1) + ": " + bet + "g"
|
||||
currentBet1.text = "Dozen " + (n + 1) + ": " + bet + "g"
|
||||
break;
|
||||
case 8:
|
||||
currentBet.text = "Street " + (n + 1) + ": " + bet + "g"
|
||||
currentBet1.text = "Street " + (n + 1) + ": " + bet + "g"
|
||||
break;
|
||||
case 9:
|
||||
currentBet.text = "Single " + (n + 1) + ": " + bet + "g"
|
||||
currentBet1.text = "Single " + (n + 1) + ": " + bet + "g"
|
||||
break;
|
||||
case 10:
|
||||
currentBet.text = "Column " + (n + 1) + ": " + bet + "g"
|
||||
currentBet1.text = "Column " + (n + 1) + ": " + bet + "g"
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
currentBet2.betType = b
|
||||
currentBet2.n = n
|
||||
switch(b) {
|
||||
case 1:
|
||||
currentBet2.text = "Red: " + bet + "g"
|
||||
break;
|
||||
case 2:
|
||||
currentBet2.text = "Black: " + bet + "g"
|
||||
break;
|
||||
case 3:
|
||||
currentBet2.text = "Odd: " + bet + "g"
|
||||
break;
|
||||
case 4:
|
||||
currentBet2.text = "Even: " + bet + "g"
|
||||
break;
|
||||
case 5:
|
||||
currentBet2.text = "Low: " + bet + "g"
|
||||
break;
|
||||
case 6:
|
||||
currentBet2.text = "High: " + bet + "g"
|
||||
break;
|
||||
case 7:
|
||||
currentBet2.text = "Dozen " + (n + 1) + ": " + bet + "g"
|
||||
break;
|
||||
case 8:
|
||||
currentBet2.text = "Street " + (n + 1) + ": " + bet + "g"
|
||||
break;
|
||||
case 9:
|
||||
currentBet2.text = "Single " + (n + 1) + ": " + bet + "g"
|
||||
break;
|
||||
case 10:
|
||||
currentBet2.text = "Column " + (n + 1) + ": " + bet + "g"
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onBetRemoved(b, n, bet) {
|
||||
function onBetRemoved(b, n) {
|
||||
if (PlayerAreaModel.focusedPlayer == index) {
|
||||
currentBet.text = ""
|
||||
if (currentBet1.betType == b && currentBet1.n == n) {
|
||||
currentBet1.text = ""
|
||||
} else if (currentBet2.betType == b && currentBet2.n == n) {
|
||||
currentBet2.text = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue