2023-04-09 05:35:35 +00:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-02-15 11:54:35 +00:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
width: 138
|
2023-12-06 13:07:35 +00:00
|
|
|
property var bgColor: "#3C3229"
|
2023-02-15 11:54:35 +00:00
|
|
|
|
|
|
|
ListModel {
|
|
|
|
id: markList
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
width: parent.width
|
|
|
|
height: parent.height
|
2023-12-06 13:07:35 +00:00
|
|
|
color: bgColor
|
2023-02-15 11:54:35 +00:00
|
|
|
opacity: 0.8
|
|
|
|
radius: 4
|
|
|
|
border.color: "white"
|
|
|
|
border.width: 1
|
2023-04-27 06:15:08 +00:00
|
|
|
|
|
|
|
Behavior on height {
|
|
|
|
NumberAnimation { duration: 300; easing.type: Easing.InOutQuad }
|
|
|
|
}
|
2023-02-15 11:54:35 +00:00
|
|
|
}
|
|
|
|
|
2023-04-19 16:19:48 +00:00
|
|
|
Repeater {
|
|
|
|
id: markRepeater
|
|
|
|
model: markList
|
|
|
|
Item {
|
|
|
|
width: childrenRect.width
|
|
|
|
height: 22
|
|
|
|
Text {
|
2024-01-24 19:23:29 +00:00
|
|
|
text: luatr(mark_name) + ' '
|
|
|
|
+ (special_value !== '' ? special_value : mark_extra)
|
2023-04-19 16:19:48 +00:00
|
|
|
font.family: fontLibian.name
|
|
|
|
font.pixelSize: 22
|
|
|
|
font.letterSpacing: -0.6
|
|
|
|
color: "white"
|
|
|
|
style: Text.Outline
|
|
|
|
textFormat: Text.RichText
|
|
|
|
}
|
2023-02-15 11:54:35 +00:00
|
|
|
|
2023-04-27 06:15:08 +00:00
|
|
|
Behavior on x {
|
|
|
|
NumberAnimation { duration: 300; easing.type: Easing.InOutQuad }
|
|
|
|
}
|
|
|
|
|
|
|
|
Behavior on y {
|
|
|
|
NumberAnimation { duration: 300; easing.type: Easing.InOutQuad }
|
|
|
|
}
|
|
|
|
|
2023-04-19 16:19:48 +00:00
|
|
|
TapHandler {
|
|
|
|
enabled: root.parent.state != "candidate" || !root.parent.selectable
|
|
|
|
onTapped: {
|
2023-05-20 08:00:03 +00:00
|
|
|
const params = { name: mark_name };
|
2023-08-11 16:50:17 +00:00
|
|
|
|
|
|
|
if (mark_name.startsWith('@&')) {
|
|
|
|
params.cardNames = mark_extra.split(',');
|
|
|
|
roomScene.startCheat("../RoomElement/ViewGeneralPile", params);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-05-20 08:00:03 +00:00
|
|
|
if (mark_name.startsWith('@$')) {
|
2023-09-19 06:27:54 +00:00
|
|
|
let data = mark_extra.split(',');
|
|
|
|
if (!Object.is(parseInt(data[0]), NaN)) {
|
|
|
|
params.ids = data.map(s => parseInt(s));
|
|
|
|
} else {
|
|
|
|
params.cardNames = data;
|
|
|
|
}
|
2023-12-06 13:07:35 +00:00
|
|
|
} else if (mark_name.startsWith('@[')) {
|
|
|
|
// @[xxx]yyy 怀疑是不是qml标记
|
|
|
|
const close_br = mark_name.indexOf(']');
|
|
|
|
if (close_br === -1) return;
|
|
|
|
|
|
|
|
const mark_type = mark_name.slice(2, close_br);
|
2023-12-28 04:11:24 +00:00
|
|
|
const _data = mark_extra;
|
2024-01-24 19:23:29 +00:00
|
|
|
let data = lcall("GetQmlMark", mark_type, mark_name, _data,
|
|
|
|
root.parent?.playerid);
|
2023-12-06 13:07:35 +00:00
|
|
|
if (data && data.qml_path) {
|
2023-12-28 04:11:24 +00:00
|
|
|
params.data = JSON.parse(_data);
|
2023-12-06 13:07:35 +00:00
|
|
|
roomScene.startCheat("../../" + data.qml_path, params);
|
|
|
|
}
|
|
|
|
return;
|
2023-05-20 08:00:03 +00:00
|
|
|
} else {
|
2023-12-06 13:07:35 +00:00
|
|
|
if (!root.parent.playerid) return;
|
2024-01-24 19:23:29 +00:00
|
|
|
let data = lcall("GetPile", root.parent.playerid, mark_name);
|
2023-05-20 08:00:03 +00:00
|
|
|
data = data.filter((e) => e !== -1);
|
|
|
|
if (data.length === 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
params.ids = data;
|
|
|
|
}
|
2023-04-19 16:19:48 +00:00
|
|
|
|
|
|
|
// Just for using room's right drawer
|
2023-05-20 08:00:03 +00:00
|
|
|
roomScene.startCheat("../RoomElement/ViewPile", params);
|
2023-02-21 05:44:24 +00:00
|
|
|
}
|
2023-02-15 11:54:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-19 16:19:48 +00:00
|
|
|
ColumnLayout {
|
|
|
|
id: markTxtList
|
|
|
|
x: 2
|
|
|
|
spacing: 0
|
|
|
|
}
|
|
|
|
|
2023-02-15 11:54:35 +00: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;
|
|
|
|
}
|
|
|
|
}
|
2023-05-13 06:20:34 +00:00
|
|
|
|
2023-05-20 08:00:03 +00:00
|
|
|
let special_value = '';
|
2023-08-11 16:50:17 +00:00
|
|
|
if (mark.startsWith('@$') || mark.startsWith('@&')) {
|
2023-05-20 08:11:16 +00:00
|
|
|
special_value += data.length;
|
2023-05-20 08:00:03 +00:00
|
|
|
data = data.join(',');
|
2023-12-06 13:07:35 +00:00
|
|
|
} else if (mark.startsWith('@[')) {
|
|
|
|
const close_br = mark.indexOf(']');
|
|
|
|
if (close_br !== -1) {
|
|
|
|
const mark_type = mark.slice(2, close_br);
|
2023-12-28 04:11:24 +00:00
|
|
|
data = JSON.stringify(data);
|
2024-01-24 19:23:29 +00:00
|
|
|
const _data = lcall("GetQmlMark", mark_type, mark, data,
|
|
|
|
root.parent?.playerid);
|
2023-12-06 13:07:35 +00:00
|
|
|
if (_data && _data.text) {
|
|
|
|
special_value = _data.text;
|
|
|
|
}
|
|
|
|
}
|
2023-05-20 08:00:03 +00:00
|
|
|
} else {
|
2024-01-24 19:23:29 +00:00
|
|
|
data = data instanceof Array
|
|
|
|
? data.map((markText) => luatr(markText)).join(' ')
|
|
|
|
: luatr(data);
|
2023-05-20 08:00:03 +00:00
|
|
|
}
|
|
|
|
|
2023-05-20 08:11:16 +00:00
|
|
|
if (modelItem) {
|
|
|
|
modelItem.special_value = special_value;
|
2023-02-15 11:54:35 +00:00
|
|
|
modelItem.mark_extra = data;
|
2023-05-20 08:11:16 +00:00
|
|
|
} else {
|
2023-05-20 08:00:03 +00:00
|
|
|
markList.append({ mark_name: mark, mark_extra: data, special_value });
|
2023-05-20 08:11:16 +00:00
|
|
|
}
|
2023-04-19 16:19:48 +00:00
|
|
|
|
|
|
|
arrangeMarks();
|
2023-02-15 11:54:35 +00: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-19 16:19:48 +00:00
|
|
|
arrangeMarks();
|
2023-02-15 11:54:35 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-04-19 16:19:48 +00:00
|
|
|
|
|
|
|
function arrangeMarks() {
|
|
|
|
let x = 0;
|
|
|
|
let y = 0;
|
|
|
|
let i;
|
2023-06-09 09:23:02 +00:00
|
|
|
const marks = [];
|
|
|
|
const long_marks = [];
|
2023-04-19 16:19:48 +00:00
|
|
|
for (i = 0; i < markRepeater.count; i++) {
|
2023-06-09 09:23:02 +00:00
|
|
|
const item = markRepeater.itemAt(i);
|
|
|
|
const w = item.width;
|
2023-04-19 16:19:48 +00:00
|
|
|
if (w < width / 2) marks.push(item);
|
|
|
|
else long_marks.push(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
marks.concat(long_marks).forEach(item => {
|
2023-06-09 09:23:02 +00:00
|
|
|
const w = item.width;
|
2023-04-19 16:19:48 +00:00
|
|
|
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 11:54:35 +00:00
|
|
|
}
|