Render a blank slot for empty column
This commit is contained in:
parent
a381288413
commit
048054be13
16
Main.qml
16
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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue