solitare/qml/ThrowawayPile.qml
ItsDrike 57958ed853
Dynamically scale the cards & everything else
Currently, most things were scaled based on the card dimensions,
though some things were hard-coded. This commit moves away from all
hard-coded sizes in favor of everything relying on card heights.

Additionally, it makes the card height itself no longer hard-coded,
passing it as a property to most custom structures.

The card height itself is now calculated from Main.qml to make sure
everything fits within the screen and scales as the window is resized.
2024-12-08 13:09:15 +01:00

41 lines
1.3 KiB
QML

import QtQuick
import Solitare
// The throwaway pile (shows last 3 cards)
Row {
id: throwawayRow
required property real cardWidth
required property real cardHeight
// This allows makes the cards overlap
spacing: -cardWidth * 0.75
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
width: throwawayRow.cardWidth
height: throwawayRow.cardHeight
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) {
if (GameState.autoMoveThrownCard()) {
if (GameState.isWinnable()) {
console.log("Still winnable");
} else {
console.log("Game is lost");
}
}
}
}
}
}
}