FreeKill/Fk/RoomElement/AG.qml
YoumuKon 1556da2f13
QML修改+bugfix (#181)
*因为一些原因,带动了之前的内容*

- 将QML的大多数let改成了const
- 修复一些bug
2023-06-09 17:23:02 +08:00

67 lines
1.4 KiB
QML

// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick
GraphicsBox {
property int spacing: 5
property string currentPlayerName: ""
property bool interactive: false
id: root
title.text: Backend.translate("Please choose cards")
width: cards.count * 100 + spacing * (cards.count - 1) + 25
height: 180
ListModel {
id: cards
}
Row {
x: 20
y: 35
spacing: root.spacing
Repeater {
model: cards
CardItem {
cid: model.cid
name: model.name
suit: model.suit
number: model.number
autoBack: false
selectable: model.selectable
footnote: model.footnote
footnoteVisible: true
onClicked: {
if (root.interactive && selectable) {
root.interactive = false;
roomScene.state = "notactive";
ClientInstance.replyToServer("", cid.toString());
}
}
}
}
}
function addIds(ids) {
ids.forEach((id) => {
let data = Backend.callLuaFunction("GetCardData", [id]);
data = JSON.parse(data);
data.selectable = true;
data.footnote = "";
cards.append(data);
});
}
function takeAG(g, cid) {
for (let i = 0; i < cards.count; i++) {
const item = cards.get(i);
if (item.cid !== cid) continue;
item.footnote = g;
item.selectable = false;
break;
}
}
}