From 048054be139c70be96705e0a48e02f365e41e2e3 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Wed, 4 Dec 2024 19:08:02 +0100 Subject: [PATCH] Render a blank slot for empty column --- Main.qml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Main.qml b/Main.qml index 7a009d9..7f9e60b 100644 --- a/Main.qml +++ b/Main.qml @@ -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) } }