Move ThrowawayPile to it's own file

This commit is contained in:
ItsDrike 2024-12-04 19:20:06 +01:00
parent 5dd95b1a65
commit 981d724ee4
Signed by: ItsDrike
GPG key ID: FA2745890B7048C0
3 changed files with 27 additions and 22 deletions

View file

@ -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

View file

@ -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
View 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()
}
}
}
}
}