Separate Tableau to it's own file
This commit is contained in:
parent
0364ae6b9e
commit
5dd95b1a65
|
@ -22,6 +22,7 @@ qt_add_qml_module(appSolitare
|
||||||
Main.qml
|
Main.qml
|
||||||
QML_FILES ScoreBar.qml
|
QML_FILES ScoreBar.qml
|
||||||
QML_FILES CardModel.qml
|
QML_FILES CardModel.qml
|
||||||
|
QML_FILES Tableau.qml
|
||||||
SOURCES playingcard.h playingcard.cpp
|
SOURCES playingcard.h playingcard.cpp
|
||||||
SOURCES gamestate.h gamestate.cpp
|
SOURCES gamestate.h gamestate.cpp
|
||||||
SOURCES columnslot.h columnslot.cpp
|
SOURCES columnslot.h columnslot.cpp
|
||||||
|
|
34
Main.qml
34
Main.qml
|
@ -89,41 +89,9 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Second row, with the individual columns
|
Tableau {
|
||||||
Row {
|
|
||||||
spacing: 10
|
|
||||||
|
|
||||||
anchors.top: firstRow.bottom
|
anchors.top: firstRow.bottom
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
anchors.topMargin: 50
|
anchors.topMargin: 50
|
||||||
|
|
||||||
Repeater {
|
|
||||||
model: GameState.columns.length
|
|
||||||
|
|
||||||
delegate: Column {
|
|
||||||
required property int index // passed from repeater
|
|
||||||
spacing: -80 // Overlap
|
|
||||||
|
|
||||||
Repeater {
|
|
||||||
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].length > 0
|
|
||||||
? GameState.columns[parent.index][index]
|
|
||||||
: null // empty column (single empty slot)
|
|
||||||
|
|
||||||
card: col ? col.card : null
|
|
||||||
isFaceDown: col ? !col.revealed : false
|
|
||||||
onClicked: {
|
|
||||||
if (col && col.revealed) {
|
|
||||||
GameState.autoMoveColumnCard(parent.index, index)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
36
Tableau.qml
Normal file
36
Tableau.qml
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
import QtQuick
|
||||||
|
|
||||||
|
// In solitare, Tableau refers to the part of the board where all of the columns are placed
|
||||||
|
|
||||||
|
Row {
|
||||||
|
spacing: 10
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: GameState.columns.length
|
||||||
|
|
||||||
|
delegate: Column {
|
||||||
|
required property int index // passed from repeater
|
||||||
|
spacing: -80 // Overlap
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
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].length > 0
|
||||||
|
? GameState.columns[parent.index][index]
|
||||||
|
: null // empty column (single empty slot)
|
||||||
|
|
||||||
|
card: col ? col.card : null
|
||||||
|
isFaceDown: col ? !col.revealed : false
|
||||||
|
onClicked: {
|
||||||
|
if (col && col.revealed) {
|
||||||
|
GameState.autoMoveColumnCard(parent.index, index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue