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 {
|
Repeater {
|
||||||
model: GameState.columns.length
|
model: GameState.columns.length
|
||||||
// Make a column for each slot
|
|
||||||
delegate: Column {
|
delegate: Column {
|
||||||
required property int index // passed from repeater
|
required property int index // passed from repeater
|
||||||
spacing: -80 // Overlap
|
spacing: -80 // Overlap
|
||||||
|
|
||||||
Repeater {
|
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 {
|
delegate: CardModel {
|
||||||
required property int index
|
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
|
card: col ? col.card : null
|
||||||
isFaceDown: !col.revealed
|
isFaceDown: col ? !col.revealed : false
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (col.revealed) {
|
if (col && col.revealed) {
|
||||||
GameState.autoMoveColumnCard(parent.index, index)
|
GameState.autoMoveColumnCard(parent.index, index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue