2023-04-09 13:35:35 +08:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-04-09 11:44:19 +08:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
|
|
|
Flickable {
|
|
|
|
id: root
|
|
|
|
anchors.fill: parent
|
|
|
|
property var extra_data: ({})
|
2023-05-19 23:03:39 +08:00
|
|
|
property int pid
|
2023-04-09 11:44:19 +08:00
|
|
|
|
|
|
|
signal finish()
|
|
|
|
|
|
|
|
contentHeight: details.height
|
|
|
|
ScrollBar.vertical: ScrollBar {}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: details
|
2023-05-19 07:45:21 +08:00
|
|
|
width: parent.width - 40
|
|
|
|
x: 20
|
2023-04-09 11:44:19 +08:00
|
|
|
|
2023-06-29 20:42:07 +08:00
|
|
|
// TODO: player details
|
|
|
|
Text {
|
|
|
|
id: screenName
|
|
|
|
font.pixelSize: 18
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
id: playerGameData
|
|
|
|
Layout.fillWidth: true
|
|
|
|
font.pixelSize: 18
|
|
|
|
}
|
|
|
|
|
|
|
|
TextEdit {
|
|
|
|
id: skillDesc
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
font.pixelSize: 18
|
|
|
|
|
|
|
|
readOnly: true
|
|
|
|
selectByKeyboard: true
|
|
|
|
selectByMouse: false
|
|
|
|
wrapMode: TextEdit.WordWrap
|
|
|
|
textFormat: TextEdit.RichText
|
|
|
|
}
|
|
|
|
|
2023-05-19 23:03:39 +08:00
|
|
|
RowLayout {
|
|
|
|
Button {
|
|
|
|
text: Backend.translate("Give Flower")
|
|
|
|
onClicked: {
|
2023-06-24 12:29:08 +08:00
|
|
|
enabled = false;
|
2023-05-19 23:03:39 +08:00
|
|
|
root.givePresent("Flower");
|
|
|
|
root.finish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
|
|
|
text: Backend.translate("Give Egg")
|
|
|
|
onClicked: {
|
2023-06-24 12:29:08 +08:00
|
|
|
enabled = false;
|
2023-05-26 20:53:45 +08:00
|
|
|
if (Math.random() < 0.03) {
|
|
|
|
root.givePresent("GiantEgg");
|
|
|
|
} else {
|
|
|
|
root.givePresent("Egg");
|
|
|
|
}
|
|
|
|
root.finish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-24 12:29:08 +08:00
|
|
|
Button {
|
|
|
|
text: Backend.translate("Give Wine")
|
|
|
|
enabled: Math.random() < 0.3
|
|
|
|
onClicked: {
|
|
|
|
enabled = false;
|
|
|
|
root.givePresent("Wine");
|
|
|
|
root.finish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-26 20:53:45 +08:00
|
|
|
Button {
|
|
|
|
text: Backend.translate("Give Shoe")
|
2023-06-04 19:31:44 +08:00
|
|
|
enabled: Math.random() < 0.3
|
2023-05-26 20:53:45 +08:00
|
|
|
onClicked: {
|
2023-06-24 12:29:08 +08:00
|
|
|
enabled = false;
|
2023-05-26 20:53:45 +08:00
|
|
|
root.givePresent("Shoe");
|
2023-05-19 23:03:39 +08:00
|
|
|
root.finish();
|
2023-06-04 19:31:44 +08:00
|
|
|
}
|
|
|
|
}
|
2023-06-29 20:42:07 +08:00
|
|
|
}
|
2023-06-04 19:31:44 +08:00
|
|
|
|
2023-06-29 20:42:07 +08:00
|
|
|
RowLayout {
|
|
|
|
Button {
|
|
|
|
text: config.blockedUsers.indexOf(screenName.text) === -1 ? Backend.translate("Block Chatter") : Backend.translate("Unblock Chatter")
|
|
|
|
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-06-04 19:31:44 +08:00
|
|
|
Button {
|
|
|
|
text: Backend.translate("Kick From Room")
|
|
|
|
visible: !roomScene.isStarted && roomScene.isOwner
|
|
|
|
enabled: pid !== Self.id
|
|
|
|
onClicked: {
|
|
|
|
ClientInstance.notifyServer("KickPlayer", pid.toString());
|
|
|
|
root.finish();
|
2023-05-19 23:03:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-04-09 11:44:19 +08:00
|
|
|
}
|
|
|
|
|
2023-05-19 23:03:39 +08:00
|
|
|
function givePresent(p) {
|
|
|
|
ClientInstance.notifyServer(
|
|
|
|
"Chat",
|
|
|
|
JSON.stringify({
|
|
|
|
type: 2,
|
|
|
|
msg: "$!" + p + ":" + pid
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-04-09 11:44:19 +08:00
|
|
|
onExtra_dataChanged: {
|
|
|
|
if (!extra_data.photo) return;
|
|
|
|
screenName.text = "";
|
2023-06-16 23:04:31 +08:00
|
|
|
playerGameData.text = "";
|
2023-04-09 11:44:19 +08:00
|
|
|
skillDesc.text = "";
|
|
|
|
|
2023-06-09 17:23:02 +08:00
|
|
|
const id = extra_data.photo.playerid;
|
2023-04-09 11:44:19 +08:00
|
|
|
if (id == 0) return;
|
2023-05-19 23:03:39 +08:00
|
|
|
root.pid = id;
|
|
|
|
|
|
|
|
screenName.text = extra_data.photo.screenName;
|
2023-04-09 11:44:19 +08:00
|
|
|
|
2023-06-18 16:24:12 +08:00
|
|
|
if (!config.observing) {
|
|
|
|
const gamedata = JSON.parse(Backend.callLuaFunction("GetPlayerGameData", [id]));
|
|
|
|
const total = gamedata[0];
|
|
|
|
const win = gamedata[1];
|
|
|
|
const run = gamedata[2];
|
|
|
|
const winRate = (win / total) * 100;
|
|
|
|
const runRate = (run / total) * 100;
|
2023-06-29 20:42:07 +08:00
|
|
|
playerGameData.text = total === 0 ? Backend.translate("Newbie") :
|
|
|
|
Backend.translate("Win=%1 Run=%2 Total=%3").arg(winRate.toFixed(2))
|
2023-06-18 16:24:12 +08:00
|
|
|
.arg(runRate.toFixed(2)).arg(total);
|
|
|
|
}
|
2023-06-16 23:04:31 +08:00
|
|
|
|
2023-06-09 17:23:02 +08:00
|
|
|
const data = JSON.parse(Backend.callLuaFunction("GetPlayerSkills", [id]));
|
2023-04-09 11:44:19 +08:00
|
|
|
data.forEach(t => {
|
|
|
|
skillDesc.append("<b>" + Backend.translate(t.name) + "</b>: " + t.description)
|
|
|
|
});
|
2023-06-18 16:24:12 +08:00
|
|
|
|
|
|
|
const equips = JSON.parse(Backend.callLuaFunction("GetPlayerEquips", [id]));
|
|
|
|
equips.forEach(cid => {
|
|
|
|
const t = JSON.parse(Backend.callLuaFunction("GetCardData", [cid]));
|
|
|
|
skillDesc.append("--------------------");
|
|
|
|
skillDesc.append("<b>" + Backend.translate(t.name) + "</b>: " + Backend.translate(":" + t.name));
|
|
|
|
});
|
2023-04-09 11:44:19 +08:00
|
|
|
}
|
|
|
|
}
|