2023-10-03 00:19:12 +08:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Layouts
|
|
|
|
import QtQuick.Controls
|
|
|
|
import Qt5Compat.GraphicalEffects
|
|
|
|
|
2023-12-06 21:07:35 +08:00
|
|
|
ColumnLayout {
|
2023-10-03 00:19:12 +08:00
|
|
|
id: root
|
|
|
|
anchors.fill: parent
|
|
|
|
property var extra_data: ({}) // unused
|
|
|
|
signal finish()
|
|
|
|
property var cards: []
|
|
|
|
|
|
|
|
Text {
|
2024-01-25 03:23:29 +08:00
|
|
|
text: luatr("Handcard selector")
|
2023-12-06 21:07:35 +08:00
|
|
|
Layout.fillWidth: true
|
2023-10-03 00:19:12 +08:00
|
|
|
horizontalAlignment: Text.AlignHCenter
|
2023-12-06 21:07:35 +08:00
|
|
|
font.pixelSize: 18
|
|
|
|
color: "#E4D5A0"
|
2023-10-03 00:19:12 +08:00
|
|
|
}
|
|
|
|
|
2023-12-06 21:07:35 +08:00
|
|
|
GridView {
|
|
|
|
id: cardsList
|
|
|
|
cellWidth: 93 * 0.9 + 4
|
|
|
|
cellHeight: 130 * 0.9 + 4
|
|
|
|
Layout.preferredWidth: root.width - root.width % 88
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
2023-10-03 00:19:12 +08:00
|
|
|
clip: true
|
|
|
|
|
2023-12-06 21:07:35 +08:00
|
|
|
model: cards
|
|
|
|
|
|
|
|
delegate: CardItem {
|
|
|
|
width: 93 * 0.9
|
|
|
|
height: 130 * 0.9
|
|
|
|
chosenInBox: modelData.chosen
|
|
|
|
onClicked: {
|
|
|
|
const clist = roomScene.dashboard.handcardArea.cards;
|
|
|
|
for (let cd of clist) {
|
|
|
|
if (cd.cid == cid) {
|
|
|
|
cd.selected = !cd.selected;
|
|
|
|
cd.clicked();
|
|
|
|
finish();
|
2023-10-03 00:19:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-12-06 21:07:35 +08:00
|
|
|
Component.onCompleted: {
|
2024-01-25 03:23:29 +08:00
|
|
|
setData(lcall("GetCardData", modelData.cid));
|
2023-12-06 21:07:35 +08:00
|
|
|
}
|
2023-10-03 00:19:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
cards = roomScene.dashboard.handcardArea.cards
|
|
|
|
.filter(c => c.selectable)
|
|
|
|
.map(c => { return { cid: c.cid, chosen: c.selected }; });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|