diff --git a/PlayerAreaModel.cpp b/PlayerAreaModel.cpp index 6af42dc..bd96ae7 100644 --- a/PlayerAreaModel.cpp +++ b/PlayerAreaModel.cpp @@ -8,6 +8,7 @@ PlayerAreaModel::PlayerAreaModel(QObject *parent) for(int i = 0; i < 8; i++){ players.append(defaultValues); } + focusedPlayer_ = 1; } uint PlayerAreaModel::focusedPlayer() @@ -85,7 +86,7 @@ void PlayerAreaModel::cancelBet(BetType b, int n) void PlayerAreaModel::payout() { if (players.at(0).bet1.betType == NONE) { - printf("Select where the ball landed\n"); + fprintf(stderr, "Select where the ball landed\n"); } else { int rollSpot = 36 - players.at(0).bet1.betSpot; diff --git a/Root.qml b/Root.qml index e24fcfc..9302ee1 100644 --- a/Root.qml +++ b/Root.qml @@ -35,10 +35,9 @@ Window { Button { id: payoutButton - text: "Payout" - font.pointSize: 15 highlighted: false onClicked: PlayerAreaModel.payout() + enabled: false anchors { left: roulette.left @@ -46,21 +45,62 @@ Window { bottomMargin: 20 } + contentItem: Text { + text: "Payout" + font.pointSize: 15 + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + + color: { + if (enabled == true) { + "#000000" + } else { + "#555555" + } + } + } + background: Rectangle { implicitWidth: 150 implicitHeight: 60 opacity: { - if (parent.pressed) { - 1 - } else if (parent.hovered) { - 0.2 + if (enabled == true) { + if (parent.pressed) { + 0.5 + } else if (parent.hovered) { + 0.2 + } else { + 0.3 + } } else { 0.3 } } - color: "#CCCCCC" + color: { + if (enabled == true) { + "#AAAAAA" + } else { + "#444444" + } + } border.width: 0 } + + Connections { + target: PlayerAreaModel + + function onBetChanged() { + if (PlayerAreaModel.focusedPlayer == 0) { + payoutButton.enabled = true; + } + } + + function onBetRemoved() { + if (PlayerAreaModel.focusedPlayer == 0) { + payoutButton.enabled = false; + } + } + } } Results {