solitare/qml/ThrowawayPile.qml

35 lines
1 KiB
QML
Raw Permalink Normal View History

2024-12-04 18:20:06 +00:00
import QtQuick
2024-12-05 00:22:18 +00:00
import Solitare
2024-12-04 18:20:06 +00:00
// The throwaway pile (shows last 3 cards)
Row {
id: throwawayRow
required property real cardWidth
required property real cardHeight
2024-12-04 18:20:06 +00:00
// This allows makes the cards overlap
spacing: -cardWidth * 0.75
2024-12-04 18:20:06 +00:00
Repeater {
model: Math.min(GameState.throwawayPile.length, 3)
2024-12-05 02:24:09 +00:00
2024-12-05 00:22:18 +00:00
delegate: CardModel {
2024-12-04 18:20:06 +00:00
required property int index // passed from repeater
2024-12-05 00:22:18 +00:00
property int reversedIndex: Math.min(GameState.throwawayPile.length, 3) - 1 - index
2024-12-05 02:24:09 +00:00
width: throwawayRow.cardWidth
height: throwawayRow.cardHeight
2024-12-04 18:20:06 +00:00
card: GameState.throwawayPile[GameState.throwawayPile.length - 1 - reversedIndex]
isFaceDown: false
onClicked: {
// Only auto-move the last card in the throwaway pile
// cards below it are shown, but shouldn't have a click effect
2024-12-06 03:55:48 +00:00
if (reversedIndex == 0) {
2024-12-08 16:06:08 +00:00
GameState.autoMoveThrownCard();
2024-12-06 03:55:48 +00:00
}
2024-12-04 18:20:06 +00:00
}
}
}
}