2023-04-09 13:35:35 +08:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-02-15 19:54:35 +08:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
width: 138
|
|
|
|
|
|
|
|
ListModel {
|
|
|
|
id: markList
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
width: parent.width
|
|
|
|
height: parent.height
|
|
|
|
color: "#3C3229"
|
|
|
|
opacity: 0.8
|
|
|
|
radius: 4
|
|
|
|
border.color: "white"
|
|
|
|
border.width: 1
|
2023-04-27 14:15:08 +08:00
|
|
|
|
|
|
|
Behavior on height {
|
|
|
|
NumberAnimation { duration: 300; easing.type: Easing.InOutQuad }
|
|
|
|
}
|
2023-02-15 19:54:35 +08:00
|
|
|
}
|
|
|
|
|
2023-04-20 00:19:48 +08:00
|
|
|
Repeater {
|
|
|
|
id: markRepeater
|
|
|
|
model: markList
|
|
|
|
Item {
|
|
|
|
width: childrenRect.width
|
|
|
|
height: 22
|
|
|
|
Text {
|
|
|
|
text: Backend.translate(mark_name) + ' ' + Backend.translate(mark_extra)
|
|
|
|
font.family: fontLibian.name
|
|
|
|
font.pixelSize: 22
|
|
|
|
font.letterSpacing: -0.6
|
|
|
|
color: "white"
|
|
|
|
style: Text.Outline
|
|
|
|
textFormat: Text.RichText
|
|
|
|
}
|
2023-02-15 19:54:35 +08:00
|
|
|
|
2023-04-27 14:15:08 +08:00
|
|
|
Behavior on x {
|
|
|
|
NumberAnimation { duration: 300; easing.type: Easing.InOutQuad }
|
|
|
|
}
|
|
|
|
|
|
|
|
Behavior on y {
|
|
|
|
NumberAnimation { duration: 300; easing.type: Easing.InOutQuad }
|
|
|
|
}
|
|
|
|
|
2023-04-20 00:19:48 +08:00
|
|
|
TapHandler {
|
|
|
|
enabled: root.parent.state != "candidate" || !root.parent.selectable
|
|
|
|
onTapped: {
|
|
|
|
let data = JSON.parse(Backend.callLuaFunction("GetPile", [root.parent.playerid, mark_name]));
|
|
|
|
data = data.filter((e) => e !== -1);
|
|
|
|
if (data.length === 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Just for using room's right drawer
|
|
|
|
roomScene.startCheat("RoomElement/ViewPile.qml", {
|
|
|
|
name: mark_name,
|
|
|
|
ids: data
|
|
|
|
});
|
2023-02-21 13:44:24 +08:00
|
|
|
}
|
2023-02-15 19:54:35 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-20 00:19:48 +08:00
|
|
|
ColumnLayout {
|
|
|
|
id: markTxtList
|
|
|
|
x: 2
|
|
|
|
spacing: 0
|
|
|
|
}
|
|
|
|
|
2023-02-15 19:54:35 +08:00
|
|
|
function setMark(mark, data) {
|
|
|
|
let i, modelItem;
|
|
|
|
for (i = 0; i < markList.count; i++) {
|
|
|
|
if (markList.get(i).mark_name === mark) {
|
|
|
|
modelItem = markList.get(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (modelItem)
|
|
|
|
modelItem.mark_extra = data;
|
|
|
|
else
|
|
|
|
markList.append({ mark_name: mark, mark_extra: data });
|
2023-04-20 00:19:48 +08:00
|
|
|
|
|
|
|
arrangeMarks();
|
2023-02-15 19:54:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function removeMark(mark) {
|
|
|
|
let i, modelItem;
|
|
|
|
for (i = 0; i < markList.count; i++) {
|
|
|
|
if (markList.get(i).mark_name === mark) {
|
|
|
|
markList.remove(i, 1);
|
2023-04-20 00:19:48 +08:00
|
|
|
arrangeMarks();
|
2023-02-15 19:54:35 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-04-20 00:19:48 +08:00
|
|
|
|
|
|
|
function arrangeMarks() {
|
|
|
|
let x = 0;
|
|
|
|
let y = 0;
|
|
|
|
let i;
|
|
|
|
let marks = [];
|
|
|
|
let long_marks = [];
|
|
|
|
for (i = 0; i < markRepeater.count; i++) {
|
|
|
|
let item = markRepeater.itemAt(i);
|
|
|
|
let w = item.width;
|
|
|
|
if (w < width / 2) marks.push(item);
|
|
|
|
else long_marks.push(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
marks.concat(long_marks).forEach(item => {
|
|
|
|
let w = item.width;
|
|
|
|
if (x === 0) {
|
|
|
|
item.x = x; item.y = y;
|
|
|
|
|
|
|
|
if (w < width / 2) {
|
|
|
|
x += width / 2;
|
|
|
|
} else {
|
|
|
|
x = 0; y += 22;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (w < width / 2) {
|
|
|
|
item.x = x; item.y = y;
|
|
|
|
x = 0; y += 22;
|
|
|
|
} else {
|
|
|
|
item.x = 0; item.y = y + 22;
|
|
|
|
x = 0; y += 44;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
height = x ? y + 22 : y;
|
|
|
|
});
|
|
|
|
|
|
|
|
if (i === 0) height = 0;
|
|
|
|
}
|
2023-02-15 19:54:35 +08:00
|
|
|
}
|