Render a blank slot for empty column

This commit is contained in:
ItsDrike 2024-12-04 19:08:02 +01:00
parent a381288413
commit 048054be13
Signed by: ItsDrike
GPG key ID: FA2745890B7048C0

View file

@ -100,21 +100,25 @@ ApplicationWindow {
Repeater {
model: GameState.columns.length
// Make a column for each slot
delegate: Column {
required property int index // passed from repeater
spacing: -80 // Overlap
Repeater {
model: GameState.columns[parent.index].length
model: GameState.columns[parent.index].length > 0
? GameState.columns[parent.index].length
: 1 // Render an empty slot for an empty column
delegate: CardModel {
required property int index
property ColumnSlot col: GameState.columns[parent.index][index]
property ColumnSlot col: GameState.columns[parent.index].length > 0
? GameState.columns[parent.index][index]
: null // empty column (single empty slot)
card: col.card
isFaceDown: !col.revealed
card: col ? col.card : null
isFaceDown: col ? !col.revealed : false
onClicked: {
if (col.revealed) {
if (col && col.revealed) {
GameState.autoMoveColumnCard(parent.index, index)
}
}