2023-04-09 05:35:35 +00:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-04-09 03:44:19 +00:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
|
|
|
import QtQuick.Layouts
|
2023-12-06 13:07:35 +00:00
|
|
|
import Fk.Pages
|
|
|
|
import Fk.RoomElement
|
2023-04-09 03:44:19 +00:00
|
|
|
|
|
|
|
Flickable {
|
|
|
|
id: root
|
|
|
|
anchors.fill: parent
|
|
|
|
property var extra_data: ({})
|
2023-05-19 15:03:39 +00:00
|
|
|
property int pid
|
2023-04-09 03:44:19 +00:00
|
|
|
|
|
|
|
signal finish()
|
|
|
|
|
|
|
|
contentHeight: details.height
|
|
|
|
ScrollBar.vertical: ScrollBar {}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: details
|
2023-05-18 23:45:21 +00:00
|
|
|
width: parent.width - 40
|
|
|
|
x: 20
|
2023-04-09 03:44:19 +00:00
|
|
|
|
2023-06-29 12:42:07 +00:00
|
|
|
// TODO: player details
|
|
|
|
Text {
|
|
|
|
id: screenName
|
|
|
|
font.pixelSize: 18
|
2023-12-06 13:07:35 +00:00
|
|
|
color: "#E4D5A0"
|
2023-06-29 12:42:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
id: playerGameData
|
|
|
|
Layout.fillWidth: true
|
|
|
|
font.pixelSize: 18
|
2023-12-06 13:07:35 +00:00
|
|
|
color: "#E4D5A0"
|
2023-06-29 12:42:07 +00:00
|
|
|
}
|
|
|
|
|
2023-05-19 15:03:39 +00:00
|
|
|
RowLayout {
|
2023-12-06 13:07:35 +00:00
|
|
|
MetroButton {
|
2024-01-24 19:23:29 +00:00
|
|
|
text: luatr("Give Flower")
|
2023-05-19 15:03:39 +00:00
|
|
|
onClicked: {
|
2023-06-24 04:29:08 +00:00
|
|
|
enabled = false;
|
2023-05-19 15:03:39 +00:00
|
|
|
root.givePresent("Flower");
|
|
|
|
root.finish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-06 13:07:35 +00:00
|
|
|
MetroButton {
|
2024-01-24 19:23:29 +00:00
|
|
|
text: luatr("Give Egg")
|
2023-05-19 15:03:39 +00:00
|
|
|
onClicked: {
|
2023-06-24 04:29:08 +00:00
|
|
|
enabled = false;
|
2023-05-26 12:53:45 +00:00
|
|
|
if (Math.random() < 0.03) {
|
|
|
|
root.givePresent("GiantEgg");
|
|
|
|
} else {
|
|
|
|
root.givePresent("Egg");
|
|
|
|
}
|
|
|
|
root.finish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-06 13:07:35 +00:00
|
|
|
MetroButton {
|
2024-01-24 19:23:29 +00:00
|
|
|
text: luatr("Give Wine")
|
2023-06-24 04:29:08 +00:00
|
|
|
enabled: Math.random() < 0.3
|
|
|
|
onClicked: {
|
|
|
|
enabled = false;
|
|
|
|
root.givePresent("Wine");
|
|
|
|
root.finish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-06 13:07:35 +00:00
|
|
|
MetroButton {
|
2024-01-24 19:23:29 +00:00
|
|
|
text: luatr("Give Shoe")
|
2023-06-04 11:31:44 +00:00
|
|
|
enabled: Math.random() < 0.3
|
2023-05-26 12:53:45 +00:00
|
|
|
onClicked: {
|
2023-06-24 04:29:08 +00:00
|
|
|
enabled = false;
|
2023-05-26 12:53:45 +00:00
|
|
|
root.givePresent("Shoe");
|
2023-05-19 15:03:39 +00:00
|
|
|
root.finish();
|
2023-06-04 11:31:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-06 13:07:35 +00:00
|
|
|
MetroButton {
|
2024-01-24 19:23:29 +00:00
|
|
|
text: {
|
|
|
|
const blocked = !config.blockedUsers.includes(screenName.text);
|
|
|
|
return blocked ? luatr("Block Chatter") : luatr("Unblock Chatter");
|
|
|
|
}
|
2023-06-29 12:42:07 +00:00
|
|
|
enabled: pid !== Self.id && pid > 0
|
|
|
|
onClicked: {
|
|
|
|
const idx = config.blockedUsers.indexOf(screenName.text);
|
|
|
|
if (idx === -1) {
|
|
|
|
config.blockedUsers.push(screenName.text);
|
|
|
|
} else {
|
|
|
|
config.blockedUsers.splice(idx, 1);
|
|
|
|
}
|
|
|
|
config.blockedUsersChanged();
|
|
|
|
}
|
|
|
|
}
|
2023-12-28 04:11:24 +00:00
|
|
|
|
2023-12-06 13:07:35 +00:00
|
|
|
MetroButton {
|
2024-01-24 19:23:29 +00:00
|
|
|
text: luatr("Kick From Room")
|
2023-06-04 11:31:44 +00:00
|
|
|
visible: !roomScene.isStarted && roomScene.isOwner
|
|
|
|
enabled: pid !== Self.id
|
|
|
|
onClicked: {
|
|
|
|
ClientInstance.notifyServer("KickPlayer", pid.toString());
|
|
|
|
root.finish();
|
2023-05-19 15:03:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-12-06 13:07:35 +00:00
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
spacing: 20
|
|
|
|
ColumnLayout {
|
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
Layout.topMargin: 16
|
|
|
|
|
|
|
|
GeneralCardItem {
|
|
|
|
id: mainChara
|
|
|
|
name: "caocao"
|
|
|
|
visible: name !== ""
|
|
|
|
}
|
|
|
|
GeneralCardItem {
|
|
|
|
id: deputyChara
|
|
|
|
name: "caocao"
|
|
|
|
visible: name !== ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TextEdit {
|
|
|
|
id: skillDesc
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
Layout.topMargin: 10
|
|
|
|
font.pixelSize: 18
|
|
|
|
color: "#E4D5A0"
|
|
|
|
|
|
|
|
readOnly: true
|
|
|
|
selectByKeyboard: true
|
|
|
|
selectByMouse: false
|
|
|
|
wrapMode: TextEdit.WordWrap
|
|
|
|
textFormat: TextEdit.RichText
|
|
|
|
}
|
|
|
|
}
|
2023-04-09 03:44:19 +00:00
|
|
|
}
|
|
|
|
|
2023-05-19 15:03:39 +00:00
|
|
|
function givePresent(p) {
|
|
|
|
ClientInstance.notifyServer(
|
|
|
|
"Chat",
|
|
|
|
JSON.stringify({
|
|
|
|
type: 2,
|
|
|
|
msg: "$!" + p + ":" + pid
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-04-09 03:44:19 +00:00
|
|
|
onExtra_dataChanged: {
|
|
|
|
if (!extra_data.photo) return;
|
|
|
|
screenName.text = "";
|
2023-06-16 15:04:31 +00:00
|
|
|
playerGameData.text = "";
|
2023-04-09 03:44:19 +00:00
|
|
|
skillDesc.text = "";
|
|
|
|
|
2023-06-09 09:23:02 +00:00
|
|
|
const id = extra_data.photo.playerid;
|
2024-01-24 19:23:29 +00:00
|
|
|
if (id === 0) return;
|
2023-05-19 15:03:39 +00:00
|
|
|
root.pid = id;
|
|
|
|
|
|
|
|
screenName.text = extra_data.photo.screenName;
|
2023-12-06 13:07:35 +00:00
|
|
|
mainChara.name = extra_data.photo.general;
|
|
|
|
deputyChara.name = extra_data.photo.deputyGeneral;
|
2023-04-09 03:44:19 +00:00
|
|
|
|
2023-06-18 08:24:12 +00:00
|
|
|
if (!config.observing) {
|
2024-01-24 19:23:29 +00:00
|
|
|
const gamedata = lcall("GetPlayerGameData", id);
|
2023-06-18 08:24:12 +00:00
|
|
|
const total = gamedata[0];
|
|
|
|
const win = gamedata[1];
|
|
|
|
const run = gamedata[2];
|
2023-12-28 04:11:24 +00:00
|
|
|
const totalTime = gamedata[3];
|
2023-06-18 08:24:12 +00:00
|
|
|
const winRate = (win / total) * 100;
|
|
|
|
const runRate = (run / total) * 100;
|
2024-01-24 19:23:29 +00:00
|
|
|
playerGameData.text = total === 0 ? luatr("Newbie") :
|
|
|
|
luatr("Win=%1 Run=%2 Total=%3").arg(winRate.toFixed(2))
|
2023-06-18 08:24:12 +00:00
|
|
|
.arg(runRate.toFixed(2)).arg(total);
|
2023-12-28 04:11:24 +00:00
|
|
|
|
|
|
|
const h = (totalTime / 3600).toFixed(2);
|
|
|
|
const m = Math.floor(totalTime / 60);
|
|
|
|
if (m < 100) {
|
2024-01-24 19:23:29 +00:00
|
|
|
playerGameData.text += " " + luatr("TotalGameTime: %1 min").arg(m);
|
2023-12-28 04:11:24 +00:00
|
|
|
} else {
|
2024-01-24 19:23:29 +00:00
|
|
|
playerGameData.text += " " + luatr("TotalGameTime: %1 h").arg(h);
|
2023-12-28 04:11:24 +00:00
|
|
|
}
|
2023-06-18 08:24:12 +00:00
|
|
|
}
|
2023-06-16 15:04:31 +00:00
|
|
|
|
2024-01-24 19:23:29 +00:00
|
|
|
lcall("GetPlayerSkills", id).forEach(t => {
|
|
|
|
skillDesc.append("<b>" + luatr(t.name) + "</b>: " + t.description)
|
2023-04-09 03:44:19 +00:00
|
|
|
});
|
2023-06-18 08:24:12 +00:00
|
|
|
|
2024-01-24 19:23:29 +00:00
|
|
|
lcall("GetPlayerEquips", id).forEach(cid => {
|
|
|
|
const t = lcall("GetCardData", cid);
|
2023-06-18 08:24:12 +00:00
|
|
|
skillDesc.append("--------------------");
|
2024-01-24 19:23:29 +00:00
|
|
|
skillDesc.append("<b>" + luatr(t.name) + "</b>: " + luatr(":" + t.name));
|
2023-06-18 08:24:12 +00:00
|
|
|
});
|
2023-04-09 03:44:19 +00:00
|
|
|
}
|
|
|
|
}
|