FreeKill/Fk/RoomElement/ChooseHandcard.qml
notify be03b04ef0
小修复&Qml美化 (#308)
- 修复了虚拟牌点数相加的bug
- 修复cleaner出错直接爆炸
- QML的代码将宽度控制到80以内
2024-01-25 03:23:29 +08:00

61 lines
1.3 KiB
QML

// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import Qt5Compat.GraphicalEffects
ColumnLayout {
id: root
anchors.fill: parent
property var extra_data: ({}) // unused
signal finish()
property var cards: []
Text {
text: luatr("Handcard selector")
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
font.pixelSize: 18
color: "#E4D5A0"
}
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
clip: true
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();
}
}
}
Component.onCompleted: {
setData(lcall("GetCardData", modelData.cid));
}
}
}
Component.onCompleted: {
cards = roomScene.dashboard.handcardArea.cards
.filter(c => c.selectable)
.map(c => { return { cid: c.cid, chosen: c.selected }; });
}
}