Move ThrowawayPile to it's own file
This commit is contained in:
parent
5dd95b1a65
commit
981d724ee4
|
@ -23,6 +23,7 @@ qt_add_qml_module(appSolitare
|
|||
QML_FILES ScoreBar.qml
|
||||
QML_FILES CardModel.qml
|
||||
QML_FILES Tableau.qml
|
||||
QML_FILES ThrowawayPile.qml
|
||||
SOURCES playingcard.h playingcard.cpp
|
||||
SOURCES gamestate.h gamestate.cpp
|
||||
SOURCES columnslot.h columnslot.cpp
|
||||
|
|
23
Main.qml
23
Main.qml
|
@ -54,28 +54,7 @@ ApplicationWindow {
|
|||
spacing: 20
|
||||
anchors.right: parent.right
|
||||
|
||||
// Throwaway pile (last 3 cards visible with overlap)
|
||||
Row {
|
||||
// This allows makes the cards overlap
|
||||
spacing: -60
|
||||
|
||||
Repeater {
|
||||
model: Math.min(GameState.throwawayPile.length, 3)
|
||||
delegate: CardModel {
|
||||
required property int index // passed from repeater
|
||||
property int reversedIndex: Math.min(GameState.throwawayPile.length, 3) - 1 - index;
|
||||
card: GameState.throwawayPile[GameState.throwawayPile.length - 1 - reversedIndex]
|
||||
isFaceDown: false
|
||||
onClicked: {
|
||||
// Only auto-move the last card in the throwaway pile
|
||||
// cards below it are shown, but shouldn't have a click effect
|
||||
if (reversedIndex == 0) {
|
||||
GameState.autoMoveThrownCard()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ThrowawayPile {}
|
||||
|
||||
// Draw pile (only the top card is shown)
|
||||
CardModel {
|
||||
|
|
25
ThrowawayPile.qml
Normal file
25
ThrowawayPile.qml
Normal file
|
@ -0,0 +1,25 @@
|
|||
import QtQuick
|
||||
|
||||
// The throwaway pile (shows last 3 cards)
|
||||
|
||||
Row {
|
||||
// This allows makes the cards overlap
|
||||
spacing: -60
|
||||
|
||||
Repeater {
|
||||
model: Math.min(GameState.throwawayPile.length, 3)
|
||||
delegate: CardModel {
|
||||
required property int index // passed from repeater
|
||||
property int reversedIndex: Math.min(GameState.throwawayPile.length, 3) - 1 - index;
|
||||
card: GameState.throwawayPile[GameState.throwawayPile.length - 1 - reversedIndex]
|
||||
isFaceDown: false
|
||||
onClicked: {
|
||||
// Only auto-move the last card in the throwaway pile
|
||||
// cards below it are shown, but shouldn't have a click effect
|
||||
if (reversedIndex == 0) {
|
||||
GameState.autoMoveThrownCard()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue