2023-04-09 05:35:35 +00:00
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
2022-09-14 05:01:10 +00:00
|
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Controls
|
2023-07-02 12:39:42 +00:00
|
|
|
|
import QtQuick.Dialogs
|
2022-09-14 05:01:10 +00:00
|
|
|
|
import QtQuick.Layouts
|
2023-01-29 10:11:41 +00:00
|
|
|
|
import QtMultimedia
|
2023-05-19 02:08:36 +00:00
|
|
|
|
import Fk
|
|
|
|
|
import Fk.Common
|
|
|
|
|
import Fk.RoomElement
|
2022-03-23 11:40:28 +00:00
|
|
|
|
import "RoomLogic.js" as Logic
|
2022-12-20 04:51:54 +00:00
|
|
|
|
|
2022-03-01 05:18:00 +00:00
|
|
|
|
Item {
|
2022-04-30 07:27:56 +00:00
|
|
|
|
id: roomScene
|
|
|
|
|
|
|
|
|
|
property int playerNum: 0
|
2023-04-27 06:15:08 +00:00
|
|
|
|
// property var dashboardModel
|
2022-04-30 07:27:56 +00:00
|
|
|
|
|
|
|
|
|
property bool isOwner: false
|
|
|
|
|
property bool isStarted: false
|
2023-06-04 11:31:44 +00:00
|
|
|
|
property bool isFull: false
|
|
|
|
|
property bool isAllReady: false
|
|
|
|
|
property bool isReady: false
|
2022-04-30 07:27:56 +00:00
|
|
|
|
|
|
|
|
|
property alias popupBox: popupBox
|
2023-03-01 13:41:16 +00:00
|
|
|
|
property alias manualBox: manualBox
|
2023-02-21 05:44:24 +00:00
|
|
|
|
property alias bigAnim: bigAnim
|
2022-04-30 07:27:56 +00:00
|
|
|
|
property alias promptText: prompt.text
|
2023-06-16 02:58:28 +00:00
|
|
|
|
property var currentPrompt
|
2022-12-18 04:52:52 +00:00
|
|
|
|
property alias okCancel: okCancel
|
|
|
|
|
property alias okButton: okButton
|
|
|
|
|
property alias cancelButton: cancelButton
|
|
|
|
|
property alias dynamicCardArea: dynamicCardArea
|
2023-01-29 10:11:41 +00:00
|
|
|
|
property alias tableCards: tablePile.cards
|
2023-04-04 16:49:54 +00:00
|
|
|
|
property alias dashboard: dashboard
|
2023-04-27 06:15:08 +00:00
|
|
|
|
property alias drawPile: drawPile
|
2023-04-08 12:45:55 +00:00
|
|
|
|
property alias skillInteraction: skillInteraction
|
2023-04-19 16:19:48 +00:00
|
|
|
|
property alias miscStatus: miscStatus
|
2022-04-30 07:27:56 +00:00
|
|
|
|
|
|
|
|
|
property var selected_targets: []
|
2022-12-18 13:19:35 +00:00
|
|
|
|
property string responding_card
|
|
|
|
|
property bool respond_play: false
|
2023-04-19 16:19:48 +00:00
|
|
|
|
property bool autoPending: false
|
2023-01-16 11:13:07 +00:00
|
|
|
|
property var extra_data: ({})
|
2023-07-16 11:18:43 +00:00
|
|
|
|
property var skippedUseEventId: []
|
2022-04-30 07:27:56 +00:00
|
|
|
|
|
2023-08-01 13:01:01 +00:00
|
|
|
|
property real replayerSpeed
|
|
|
|
|
property int replayerElapsed
|
|
|
|
|
property int replayerDuration
|
|
|
|
|
|
2022-05-01 10:37:13 +00:00
|
|
|
|
Image {
|
2023-02-15 11:54:35 +00:00
|
|
|
|
source: config.roomBg
|
2022-05-01 10:37:13 +00:00
|
|
|
|
anchors.fill: parent
|
|
|
|
|
fillMode: Image.PreserveAspectCrop
|
2022-04-30 07:27:56 +00:00
|
|
|
|
}
|
2022-05-01 10:37:13 +00:00
|
|
|
|
|
2023-01-29 10:11:41 +00:00
|
|
|
|
MediaPlayer {
|
|
|
|
|
id: bgm
|
2023-02-15 11:54:35 +00:00
|
|
|
|
source: config.bgmFile
|
2023-02-26 08:51:29 +00:00
|
|
|
|
|
2023-01-29 10:11:41 +00:00
|
|
|
|
// loops: MediaPlayer.Infinite
|
|
|
|
|
onPlaybackStateChanged: {
|
|
|
|
|
if (playbackState == MediaPlayer.StoppedState && roomScene.isStarted)
|
|
|
|
|
play();
|
|
|
|
|
}
|
2023-04-28 10:24:31 +00:00
|
|
|
|
audioOutput: AudioOutput {
|
|
|
|
|
volume: config.bgmVolume / 100
|
|
|
|
|
}
|
2023-01-29 10:11:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onIsStartedChanged: {
|
|
|
|
|
if (isStarted) {
|
|
|
|
|
bgm.play();
|
|
|
|
|
} else {
|
|
|
|
|
// bgm.stop();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-01 10:37:13 +00:00
|
|
|
|
// tmp
|
2023-07-02 12:39:42 +00:00
|
|
|
|
Button {
|
|
|
|
|
id: menuButton
|
2022-04-30 07:27:56 +00:00
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.right: parent.right
|
2023-07-02 12:39:42 +00:00
|
|
|
|
anchors.rightMargin: 10
|
|
|
|
|
text: Backend.translate("Menu")
|
|
|
|
|
z: 2
|
|
|
|
|
onClicked: {
|
|
|
|
|
menuContainer.visible || menuContainer.open();
|
2022-04-14 10:22:00 +00:00
|
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
|
}
|
2023-07-02 12:47:10 +00:00
|
|
|
|
|
|
|
|
|
Menu {
|
|
|
|
|
id: menuContainer
|
|
|
|
|
x: parent.width - menuButton.width - menuContainer.width - 17
|
|
|
|
|
width: menuRow.width
|
|
|
|
|
height: menuRow.height
|
|
|
|
|
verticalPadding: 0
|
|
|
|
|
spacing: 7
|
|
|
|
|
z: 2
|
|
|
|
|
|
|
|
|
|
Row {
|
|
|
|
|
id: menuRow
|
|
|
|
|
spacing: 7
|
|
|
|
|
|
|
|
|
|
Button {
|
|
|
|
|
id: surrenderButton
|
2023-08-01 13:01:01 +00:00
|
|
|
|
enabled: !config.observing && !config.replaying
|
2023-07-02 12:47:10 +00:00
|
|
|
|
text: Backend.translate("Surrender")
|
|
|
|
|
onClicked: {
|
2023-07-02 14:13:51 +00:00
|
|
|
|
if (isStarted && !getPhoto(Self.id).dead) {
|
2023-07-02 12:47:10 +00:00
|
|
|
|
const surrenderCheck = JSON.parse(Backend.callLuaFunction('CheckSurrenderAvailable', [miscStatus.playedTime]));
|
|
|
|
|
if (!surrenderCheck.length) {
|
|
|
|
|
surrenderDialog.informativeText = Backend.translate('Surrender is disabled in this mode');
|
|
|
|
|
} else {
|
|
|
|
|
surrenderDialog.informativeText = surrenderCheck.map(str => `${Backend.translate(str.text)}(${str.passed ? '√' : '×'})`).join('<br>');
|
|
|
|
|
}
|
|
|
|
|
surrenderDialog.open();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MessageDialog {
|
|
|
|
|
id: surrenderDialog
|
|
|
|
|
title: Backend.translate("Surrender")
|
|
|
|
|
informativeText: ''
|
|
|
|
|
buttons: MessageDialog.Ok | MessageDialog.Cancel
|
|
|
|
|
onButtonClicked: function (button, role) {
|
|
|
|
|
switch (button) {
|
|
|
|
|
case MessageDialog.Ok: {
|
|
|
|
|
const surrenderCheck = JSON.parse(Backend.callLuaFunction('CheckSurrenderAvailable', [miscStatus.playedTime]));
|
|
|
|
|
if (surrenderCheck.length && !surrenderCheck.find(check => !check.passed)) {
|
|
|
|
|
ClientInstance.notifyServer("PushRequest", [
|
|
|
|
|
"surrender", true
|
|
|
|
|
]);
|
|
|
|
|
}
|
2023-07-02 14:43:56 +00:00
|
|
|
|
surrenderDialog.close();
|
2023-07-02 12:47:10 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case MessageDialog.Cancel: {
|
|
|
|
|
surrenderDialog.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Button {
|
|
|
|
|
id: quitButton
|
|
|
|
|
text: Backend.translate("Quit")
|
|
|
|
|
onClicked: {
|
2023-08-01 13:01:01 +00:00
|
|
|
|
if (config.replaying) {
|
|
|
|
|
Backend.controlReplayer("shutdown");
|
|
|
|
|
mainStack.pop();
|
|
|
|
|
} else if (config.observing) {
|
2023-07-02 14:43:56 +00:00
|
|
|
|
ClientInstance.notifyServer("QuitRoom", "[]");
|
|
|
|
|
} else {
|
|
|
|
|
quitDialog.open();
|
|
|
|
|
}
|
2023-07-02 12:47:10 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MessageDialog {
|
|
|
|
|
id: quitDialog
|
|
|
|
|
title: Backend.translate("Quit")
|
|
|
|
|
informativeText: Backend.translate("Are you sure to quit?")
|
|
|
|
|
buttons: MessageDialog.Ok | MessageDialog.Cancel
|
2023-07-02 14:13:51 +00:00
|
|
|
|
onButtonClicked: function (button) {
|
2023-07-02 12:47:10 +00:00
|
|
|
|
switch (button) {
|
|
|
|
|
case MessageDialog.Ok: {
|
|
|
|
|
ClientInstance.notifyServer("QuitRoom", "[]");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case MessageDialog.Cancel: {
|
|
|
|
|
quitDialog.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
|
Button {
|
2023-06-04 11:31:44 +00:00
|
|
|
|
text: Backend.translate("Add Robot")
|
|
|
|
|
visible: isOwner && !isStarted && !isFull
|
2022-04-30 07:27:56 +00:00
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
onClicked: {
|
|
|
|
|
ClientInstance.notifyServer("AddRobot", "[]");
|
2022-03-01 05:18:00 +00:00
|
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
|
}
|
2023-06-04 11:31:44 +00:00
|
|
|
|
Button {
|
|
|
|
|
text: Backend.translate("Start Game")
|
|
|
|
|
visible: isOwner && !isStarted && isFull
|
|
|
|
|
enabled: isAllReady
|
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
onClicked: {
|
|
|
|
|
ClientInstance.notifyServer("StartGame", "[]");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Timer {
|
|
|
|
|
id: opTimer
|
|
|
|
|
interval: 1000
|
|
|
|
|
}
|
|
|
|
|
Button {
|
|
|
|
|
text: isReady ? Backend.translate("Cancel Ready") : Backend.translate("Ready")
|
|
|
|
|
visible: !isOwner && !isStarted
|
|
|
|
|
enabled: !opTimer.running
|
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
onClicked: {
|
|
|
|
|
opTimer.start();
|
|
|
|
|
ClientInstance.notifyServer("Ready", "");
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-06-04 12:00:35 +00:00
|
|
|
|
Rectangle {
|
|
|
|
|
x: parent.width / 2 + 80
|
|
|
|
|
y: parent.height / 2
|
|
|
|
|
color: "snow"
|
|
|
|
|
opacity: 0.8
|
|
|
|
|
radius: 6
|
|
|
|
|
height: childrenRect.height + 16
|
|
|
|
|
width: childrenRect.width + 16
|
|
|
|
|
visible: !isStarted
|
|
|
|
|
|
|
|
|
|
Text {
|
|
|
|
|
x: 8; y: 8
|
|
|
|
|
Component.onCompleted: {
|
2023-06-09 09:23:02 +00:00
|
|
|
|
const data = JSON.parse(Backend.callLuaFunction("GetRoomConfig", []));
|
2023-06-04 12:00:35 +00:00
|
|
|
|
text = "手气卡次数:" + data.luckTime + "<br />出手时间:" + config.roomTimeout
|
2023-06-16 15:53:44 +00:00
|
|
|
|
+ "<br />选将框数:" + data.generalNum + (data.enableFreeAssign ? "<br /><font color=\"red\">可自由点将</font>" : "")
|
|
|
|
|
+ (data.enableDeputy ? "<br /><font color=\"red\">启用副将机制</font>" : "")
|
2023-06-04 12:00:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
|
|
|
|
|
|
states: [
|
|
|
|
|
State { name: "notactive" }, // Normal status
|
|
|
|
|
State { name: "playing" }, // Playing cards in playing phase
|
|
|
|
|
State { name: "responding" }, // all requests need to operate dashboard
|
|
|
|
|
State { name: "replying" } // requests only operate a popup window
|
|
|
|
|
]
|
|
|
|
|
state: "notactive"
|
|
|
|
|
transitions: [
|
|
|
|
|
Transition {
|
|
|
|
|
from: "*"; to: "notactive"
|
|
|
|
|
ScriptAction {
|
|
|
|
|
script: {
|
2023-05-19 02:08:36 +00:00
|
|
|
|
skillInteraction.sourceComponent = undefined;
|
2022-04-30 07:27:56 +00:00
|
|
|
|
promptText = "";
|
2023-06-16 02:58:28 +00:00
|
|
|
|
currentPrompt = "";
|
2022-04-30 07:27:56 +00:00
|
|
|
|
progress.visible = false;
|
|
|
|
|
okCancel.visible = false;
|
|
|
|
|
endPhaseButton.visible = false;
|
2022-12-20 13:15:49 +00:00
|
|
|
|
respond_play = false;
|
2023-01-29 10:11:41 +00:00
|
|
|
|
extra_data = {};
|
2023-04-27 06:15:08 +00:00
|
|
|
|
mainWindow.pending_message = [];
|
|
|
|
|
mainWindow.is_pending = false;
|
2022-04-30 07:27:56 +00:00
|
|
|
|
|
|
|
|
|
if (dashboard.pending_skill !== "")
|
|
|
|
|
dashboard.stopPending();
|
2023-06-23 14:18:11 +00:00
|
|
|
|
dashboard.updateHandcards();
|
2022-09-15 03:17:13 +00:00
|
|
|
|
dashboard.disableAllCards();
|
|
|
|
|
dashboard.disableSkills();
|
2023-01-29 10:11:41 +00:00
|
|
|
|
dashboard.retractAllPiles();
|
2022-04-30 07:27:56 +00:00
|
|
|
|
selected_targets = [];
|
|
|
|
|
|
|
|
|
|
if (popupBox.item != null) {
|
|
|
|
|
popupBox.item.finished();
|
2023-02-26 08:51:29 +00:00
|
|
|
|
}
|
2022-04-02 22:41:55 +00:00
|
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
Transition {
|
|
|
|
|
from: "*"; to: "playing"
|
|
|
|
|
ScriptAction {
|
|
|
|
|
script: {
|
2023-05-19 02:08:36 +00:00
|
|
|
|
skillInteraction.sourceComponent = undefined;
|
2023-06-23 14:18:11 +00:00
|
|
|
|
dashboard.updateHandcards();
|
2022-04-30 07:27:56 +00:00
|
|
|
|
dashboard.enableCards();
|
2022-09-14 05:01:10 +00:00
|
|
|
|
dashboard.enableSkills();
|
2022-04-30 07:27:56 +00:00
|
|
|
|
progress.visible = true;
|
|
|
|
|
okCancel.visible = true;
|
|
|
|
|
endPhaseButton.visible = true;
|
2022-12-20 13:15:49 +00:00
|
|
|
|
respond_play = false;
|
2022-03-23 11:40:28 +00:00
|
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
Transition {
|
|
|
|
|
from: "*"; to: "responding"
|
|
|
|
|
ScriptAction {
|
|
|
|
|
script: {
|
2023-05-19 02:08:36 +00:00
|
|
|
|
skillInteraction.sourceComponent = undefined;
|
2023-06-23 14:18:11 +00:00
|
|
|
|
dashboard.updateHandcards();
|
2022-12-18 13:19:35 +00:00
|
|
|
|
dashboard.enableCards(responding_card);
|
2023-04-30 10:55:59 +00:00
|
|
|
|
dashboard.enableSkills(responding_card, respond_play);
|
2023-04-19 16:19:48 +00:00
|
|
|
|
autoPending = false;
|
2022-04-30 07:27:56 +00:00
|
|
|
|
progress.visible = true;
|
|
|
|
|
okCancel.visible = true;
|
2022-03-23 11:40:28 +00:00
|
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
Transition {
|
|
|
|
|
from: "*"; to: "replying"
|
|
|
|
|
ScriptAction {
|
|
|
|
|
script: {
|
2023-05-19 02:08:36 +00:00
|
|
|
|
skillInteraction.sourceComponent = undefined;
|
2023-06-23 14:18:11 +00:00
|
|
|
|
dashboard.updateHandcards();
|
2022-09-14 05:01:10 +00:00
|
|
|
|
dashboard.disableAllCards();
|
|
|
|
|
dashboard.disableSkills();
|
2022-04-30 07:27:56 +00:00
|
|
|
|
progress.visible = true;
|
2022-12-20 13:15:49 +00:00
|
|
|
|
respond_play = false;
|
2023-01-29 10:11:41 +00:00
|
|
|
|
roomScene.okCancel.visible = false;
|
|
|
|
|
roomScene.okButton.enabled = false;
|
|
|
|
|
roomScene.cancelButton.enabled = false;
|
2022-03-23 11:40:28 +00:00
|
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
|
}
|
2022-03-23 11:40:28 +00:00
|
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
/* Layout:
|
|
|
|
|
* +---------------------+
|
|
|
|
|
* | Photos, get more |
|
|
|
|
|
* | in arrangePhotos() |
|
|
|
|
|
* | tablePile |
|
|
|
|
|
* | progress,prompt,btn |
|
|
|
|
|
* +---------------------+
|
|
|
|
|
* | dashboard |
|
|
|
|
|
* +---------------------+
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
ListModel {
|
|
|
|
|
id: photoModel
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
id: roomArea
|
|
|
|
|
width: roomScene.width
|
2022-09-14 05:01:10 +00:00
|
|
|
|
height: roomScene.height - dashboard.height + 20
|
2022-04-30 07:27:56 +00:00
|
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
|
id: photos
|
|
|
|
|
model: photoModel
|
|
|
|
|
Photo {
|
|
|
|
|
playerid: model.id
|
|
|
|
|
general: model.general
|
2023-06-04 11:31:44 +00:00
|
|
|
|
avatar: model.avatar
|
2023-04-19 06:07:16 +00:00
|
|
|
|
deputyGeneral: model.deputyGeneral
|
2022-04-30 07:27:56 +00:00
|
|
|
|
screenName: model.screenName
|
|
|
|
|
role: model.role
|
|
|
|
|
kingdom: model.kingdom
|
|
|
|
|
netstate: model.netstate
|
|
|
|
|
maxHp: model.maxHp
|
|
|
|
|
hp: model.hp
|
2023-04-13 12:17:39 +00:00
|
|
|
|
shield: model.shield
|
2022-04-30 07:27:56 +00:00
|
|
|
|
seatNumber: model.seatNumber
|
2022-12-20 04:51:54 +00:00
|
|
|
|
dead: model.dead
|
2022-04-30 07:27:56 +00:00
|
|
|
|
dying: model.dying
|
|
|
|
|
faceup: model.faceup
|
|
|
|
|
chained: model.chained
|
|
|
|
|
drank: model.drank
|
|
|
|
|
isOwner: model.isOwner
|
2023-06-04 11:31:44 +00:00
|
|
|
|
ready: model.ready
|
2023-07-02 12:39:42 +00:00
|
|
|
|
surrendered: model.surrendered
|
2022-04-30 07:27:56 +00:00
|
|
|
|
|
|
|
|
|
onSelectedChanged: {
|
|
|
|
|
Logic.updateSelectedTargets(playerid, selected);
|
|
|
|
|
}
|
2023-04-27 06:15:08 +00:00
|
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
|
if (index === 0) dashboard.self = this;
|
|
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
|
}
|
2022-03-23 11:40:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
|
onWidthChanged: Logic.arrangePhotos();
|
|
|
|
|
onHeightChanged: Logic.arrangePhotos();
|
2022-04-02 07:11:13 +00:00
|
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
|
InvisibleCardArea {
|
|
|
|
|
id: drawPile
|
|
|
|
|
x: parent.width / 2
|
|
|
|
|
y: roomScene.height / 2
|
|
|
|
|
}
|
2022-04-02 07:11:13 +00:00
|
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
|
TablePile {
|
|
|
|
|
id: tablePile
|
|
|
|
|
width: parent.width * 0.6
|
|
|
|
|
height: 150
|
|
|
|
|
x: parent.width * 0.2
|
2023-01-29 10:11:41 +00:00
|
|
|
|
y: parent.height * 0.6 + 10
|
2022-04-30 07:27:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-18 04:52:52 +00:00
|
|
|
|
Item {
|
|
|
|
|
id: dashboardBtn
|
|
|
|
|
width: childrenRect.width
|
|
|
|
|
height: childrenRect.height
|
|
|
|
|
anchors.bottom: parent.bottom
|
2023-06-30 20:12:19 +00:00
|
|
|
|
anchors.bottomMargin: 8
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.leftMargin: 8
|
2022-12-18 04:52:52 +00:00
|
|
|
|
ColumnLayout {
|
|
|
|
|
MetroButton {
|
2023-06-24 06:48:49 +00:00
|
|
|
|
text: Backend.translate("Revert Selection")
|
2023-06-30 20:12:19 +00:00
|
|
|
|
textFont.pixelSize: 28
|
2023-06-24 06:48:49 +00:00
|
|
|
|
enabled: dashboard.pending_skill !== ""
|
|
|
|
|
onClicked: dashboard.revertSelection();
|
2022-12-18 04:52:52 +00:00
|
|
|
|
}
|
2023-06-24 06:48:49 +00:00
|
|
|
|
// MetroButton {
|
|
|
|
|
// text: Backend.translate("Trust")
|
|
|
|
|
// }
|
2022-12-18 04:52:52 +00:00
|
|
|
|
MetroButton {
|
|
|
|
|
text: Backend.translate("Sort Cards")
|
2023-06-30 20:12:19 +00:00
|
|
|
|
textFont.pixelSize: 28
|
2023-07-02 12:39:42 +00:00
|
|
|
|
onClicked: Logic.resortHandcards();
|
2022-12-18 04:52:52 +00:00
|
|
|
|
}
|
|
|
|
|
MetroButton {
|
|
|
|
|
text: Backend.translate("Chat")
|
2023-06-30 20:12:19 +00:00
|
|
|
|
textFont.pixelSize: 28
|
2022-12-18 04:52:52 +00:00
|
|
|
|
onClicked: roomDrawer.open();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
|
Dashboard {
|
|
|
|
|
id: dashboard
|
2022-12-18 04:52:52 +00:00
|
|
|
|
width: roomScene.width - dashboardBtn.width
|
2022-04-30 07:27:56 +00:00
|
|
|
|
anchors.top: roomArea.bottom
|
2022-12-18 04:52:52 +00:00
|
|
|
|
anchors.left: dashboardBtn.right
|
2022-04-30 07:27:56 +00:00
|
|
|
|
|
2022-09-14 05:01:10 +00:00
|
|
|
|
onCardSelected: function(card) {
|
2022-04-30 07:27:56 +00:00
|
|
|
|
Logic.enableTargets(card);
|
2023-03-20 12:15:24 +00:00
|
|
|
|
|
|
|
|
|
if (typeof card === "number" && card !== -1 && roomScene.state === "playing") {
|
2023-06-09 09:23:02 +00:00
|
|
|
|
const skills = JSON.parse(Backend.callLuaFunction("GetCardSpecialSkills", [card]));
|
2023-05-28 04:22:43 +00:00
|
|
|
|
if (JSON.parse(Backend.callLuaFunction("CanUseCard", [card, Self.id]))) {
|
|
|
|
|
skills.unshift("_normal_use");
|
|
|
|
|
}
|
2023-03-20 12:15:24 +00:00
|
|
|
|
specialCardSkills.model = skills;
|
|
|
|
|
} else {
|
|
|
|
|
specialCardSkills.model = [];
|
|
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-15 11:54:35 +00:00
|
|
|
|
GlowText {
|
|
|
|
|
text: Backend.translate("Observing ...")
|
2023-08-01 13:01:01 +00:00
|
|
|
|
visible: config.observing && !config.replaying
|
2023-02-15 11:54:35 +00:00
|
|
|
|
color: "#4B83CD"
|
|
|
|
|
font.family: fontLi2.name
|
|
|
|
|
font.pixelSize: 48
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-01 13:01:01 +00:00
|
|
|
|
Rectangle {
|
|
|
|
|
id: replayControls
|
|
|
|
|
visible: config.replaying
|
|
|
|
|
anchors.bottom: dashboard.top
|
|
|
|
|
anchors.bottomMargin: -60
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
width: childrenRect.width + 8
|
|
|
|
|
height: childrenRect.height + 8
|
|
|
|
|
|
|
|
|
|
color: "#88EEEEEE"
|
|
|
|
|
radius: 4
|
|
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
|
x: 4; y: 4
|
|
|
|
|
Text {
|
|
|
|
|
font.pixelSize: 20
|
|
|
|
|
font.bold: true
|
|
|
|
|
text: {
|
|
|
|
|
const elapsedMin = Math.floor(replayerElapsed / 60);
|
|
|
|
|
const elapsedSec = replayerElapsed % 60;
|
|
|
|
|
const totalMin = Math.floor(replayerDuration / 60);
|
|
|
|
|
const totalSec = replayerDuration % 60;
|
|
|
|
|
|
|
|
|
|
return elapsedMin.toString() + ":" + elapsedSec + "/" + totalMin + ":" + totalSec;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Switch {
|
|
|
|
|
text: "匀速"
|
|
|
|
|
checked: false
|
|
|
|
|
onCheckedChanged: Backend.controlReplayer("uniform");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Button {
|
|
|
|
|
text: "减速"
|
|
|
|
|
onClicked: Backend.controlReplayer("slowdown");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Text {
|
|
|
|
|
font.pixelSize: 20
|
|
|
|
|
font.bold: true
|
|
|
|
|
text: "x" + replayerSpeed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Button {
|
|
|
|
|
text: "加速"
|
|
|
|
|
onClicked: Backend.controlReplayer("speedup");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Button {
|
|
|
|
|
property bool running: true
|
|
|
|
|
text: running ? "暂停" : "继续"
|
|
|
|
|
onClicked: {
|
|
|
|
|
running = !running;
|
|
|
|
|
Backend.controlReplayer("toggle");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
|
Item {
|
|
|
|
|
id: controls
|
|
|
|
|
anchors.bottom: dashboard.top
|
2022-09-14 05:01:10 +00:00
|
|
|
|
anchors.bottomMargin: -60
|
2022-04-30 07:27:56 +00:00
|
|
|
|
width: roomScene.width
|
|
|
|
|
|
|
|
|
|
Text {
|
|
|
|
|
id: prompt
|
|
|
|
|
visible: progress.visible
|
2023-04-04 07:59:21 +00:00
|
|
|
|
anchors.bottom: progress.bottom
|
2022-12-18 04:52:52 +00:00
|
|
|
|
z: 1
|
2023-04-04 07:59:21 +00:00
|
|
|
|
color: "#F0E5DA"
|
|
|
|
|
font.pixelSize: 16
|
|
|
|
|
font.family: fontLibian.name
|
|
|
|
|
style: Text.Outline
|
|
|
|
|
styleColor: "#3D2D1C"
|
|
|
|
|
textFormat: TextEdit.RichText
|
2022-04-30 07:27:56 +00:00
|
|
|
|
anchors.horizontalCenter: progress.horizontalCenter
|
2022-04-02 07:11:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
|
ProgressBar {
|
|
|
|
|
id: progress
|
|
|
|
|
width: parent.width * 0.6
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
anchors.bottom: okCancel.top
|
2022-12-18 04:52:52 +00:00
|
|
|
|
anchors.bottomMargin: 4
|
2022-04-30 07:27:56 +00:00
|
|
|
|
from: 0.0
|
|
|
|
|
to: 100.0
|
|
|
|
|
|
|
|
|
|
visible: false
|
2022-12-18 04:52:52 +00:00
|
|
|
|
|
|
|
|
|
background: Rectangle {
|
|
|
|
|
implicitWidth: 200
|
2023-04-04 07:59:21 +00:00
|
|
|
|
implicitHeight: 12
|
2022-12-18 04:52:52 +00:00
|
|
|
|
color: "black"
|
2023-04-04 07:59:21 +00:00
|
|
|
|
radius: 6
|
2022-12-18 04:52:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
contentItem: Item {
|
2023-04-04 07:59:21 +00:00
|
|
|
|
implicitWidth: 196
|
|
|
|
|
implicitHeight: 10
|
2022-12-18 04:52:52 +00:00
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
width: progress.visualPosition * parent.width
|
|
|
|
|
height: parent.height
|
2023-04-04 07:59:21 +00:00
|
|
|
|
radius: 6
|
|
|
|
|
gradient: Gradient {
|
|
|
|
|
GradientStop { position: 0.0; color: "orange" }
|
|
|
|
|
GradientStop { position: 0.3; color: "red" }
|
|
|
|
|
GradientStop { position: 0.7; color: "red" }
|
|
|
|
|
GradientStop { position: 1.0; color: "orange" }
|
|
|
|
|
}
|
2022-12-18 04:52:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
|
NumberAnimation on value {
|
|
|
|
|
running: progress.visible
|
|
|
|
|
from: 100.0
|
|
|
|
|
to: 0.0
|
|
|
|
|
duration: config.roomTimeout * 1000
|
|
|
|
|
|
|
|
|
|
onFinished: {
|
|
|
|
|
roomScene.state = "notactive"
|
2022-03-30 06:14:40 +00:00
|
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-03-30 06:14:40 +00:00
|
|
|
|
|
2023-03-20 12:15:24 +00:00
|
|
|
|
Rectangle {
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
anchors.bottomMargin: 8
|
|
|
|
|
anchors.right: okCancel.left
|
|
|
|
|
anchors.rightMargin: 20
|
|
|
|
|
color: "#88EEEEEE"
|
|
|
|
|
radius: 8
|
2023-06-16 05:26:02 +00:00
|
|
|
|
visible: {
|
|
|
|
|
if (roomScene.state !== "playing") {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (!specialCardSkills) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (specialCardSkills.count > 1) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return (specialCardSkills.model ?? false)
|
|
|
|
|
&& specialCardSkills.model[0] !== "_normal_use"
|
|
|
|
|
}
|
2023-03-20 12:15:24 +00:00
|
|
|
|
width: childrenRect.width
|
|
|
|
|
height: childrenRect.height - 20
|
|
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
|
y: -10
|
|
|
|
|
Repeater {
|
|
|
|
|
id: specialCardSkills
|
|
|
|
|
RadioButton {
|
|
|
|
|
property string orig_text: modelData
|
|
|
|
|
text: Backend.translate(modelData)
|
|
|
|
|
checked: index === 0
|
|
|
|
|
onCheckedChanged: {
|
|
|
|
|
if (modelData === "_normal_use") {
|
|
|
|
|
Logic.enableTargets(dashboard.selected_card);
|
|
|
|
|
} else {
|
|
|
|
|
Logic.enableTargets(JSON.stringify({
|
|
|
|
|
skill: modelData,
|
|
|
|
|
subcards: [dashboard.selected_card],
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-04 16:49:54 +00:00
|
|
|
|
Loader {
|
|
|
|
|
id: skillInteraction
|
|
|
|
|
visible: dashboard.pending_skill !== ""
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
anchors.bottomMargin: 8
|
|
|
|
|
anchors.right: okCancel.left
|
|
|
|
|
anchors.rightMargin: 20
|
|
|
|
|
}
|
2023-03-20 12:15:24 +00:00
|
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
|
Row {
|
|
|
|
|
id: okCancel
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
anchors.horizontalCenter: progress.horizontalCenter
|
|
|
|
|
spacing: 20
|
|
|
|
|
visible: false
|
|
|
|
|
|
2023-07-16 11:18:43 +00:00
|
|
|
|
Button {
|
|
|
|
|
id: skipNullificationButton
|
|
|
|
|
text: Backend.translate("SkipNullification")
|
|
|
|
|
visible: !!extra_data.useEventId && !skippedUseEventId.find(id => id === extra_data.useEventId)
|
|
|
|
|
onClicked: {
|
|
|
|
|
skippedUseEventId.push(extra_data.useEventId);
|
|
|
|
|
Logic.doCancelButton();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
|
Button {
|
|
|
|
|
id: okButton
|
2022-05-01 10:37:13 +00:00
|
|
|
|
text: Backend.translate("OK")
|
2022-04-30 07:27:56 +00:00
|
|
|
|
onClicked: Logic.doOkButton();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Button {
|
|
|
|
|
id: cancelButton
|
2022-05-01 10:37:13 +00:00
|
|
|
|
text: Backend.translate("Cancel")
|
2022-04-30 07:27:56 +00:00
|
|
|
|
onClicked: Logic.doCancelButton();
|
|
|
|
|
}
|
2022-03-30 06:14:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
|
Button {
|
|
|
|
|
id: endPhaseButton
|
2022-05-01 10:37:13 +00:00
|
|
|
|
text: Backend.translate("End")
|
2022-04-30 07:27:56 +00:00
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
anchors.bottomMargin: 40
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.rightMargin: 30
|
|
|
|
|
visible: false;
|
2022-09-15 03:17:13 +00:00
|
|
|
|
onClicked: Logic.replyToServer("");
|
2022-04-30 07:27:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
|
id: popupBox
|
2022-09-14 05:01:10 +00:00
|
|
|
|
z: 999
|
2022-04-30 07:27:56 +00:00
|
|
|
|
onSourceChanged: {
|
|
|
|
|
if (item === null)
|
|
|
|
|
return;
|
2023-06-16 05:26:02 +00:00
|
|
|
|
item.finished.connect(() => {
|
2023-05-19 02:08:36 +00:00
|
|
|
|
sourceComponent = undefined;
|
2022-04-30 07:27:56 +00:00
|
|
|
|
});
|
2023-06-16 05:26:02 +00:00
|
|
|
|
item.widthChanged.connect(() => {
|
2022-04-30 07:27:56 +00:00
|
|
|
|
popupBox.moveToCenter();
|
|
|
|
|
});
|
2023-06-16 05:26:02 +00:00
|
|
|
|
item.heightChanged.connect(() => {
|
2022-04-30 07:27:56 +00:00
|
|
|
|
popupBox.moveToCenter();
|
|
|
|
|
});
|
|
|
|
|
moveToCenter();
|
|
|
|
|
}
|
2023-05-19 02:08:36 +00:00
|
|
|
|
onSourceComponentChanged: sourceChanged();
|
2022-03-24 13:23:42 +00:00
|
|
|
|
|
2023-06-16 05:26:02 +00:00
|
|
|
|
function moveToCenter() {
|
2022-04-30 07:27:56 +00:00
|
|
|
|
item.x = Math.round((roomArea.width - item.width) / 2);
|
|
|
|
|
item.y = Math.round(roomArea.height * 0.67 - item.height / 2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-01 13:41:16 +00:00
|
|
|
|
// manualBox: same as popupBox, but must be closed manually
|
|
|
|
|
Loader {
|
|
|
|
|
id: manualBox
|
|
|
|
|
z: 999
|
|
|
|
|
onSourceChanged: {
|
|
|
|
|
if (item === null)
|
|
|
|
|
return;
|
2023-05-19 02:08:36 +00:00
|
|
|
|
item.finished.connect(() => sourceComponent = undefined);
|
2023-03-01 13:41:16 +00:00
|
|
|
|
item.widthChanged.connect(() => manualBox.moveToCenter());
|
|
|
|
|
item.heightChanged.connect(() => manualBox.moveToCenter());
|
|
|
|
|
moveToCenter();
|
|
|
|
|
}
|
2023-05-19 02:08:36 +00:00
|
|
|
|
onSourceComponentChanged: sourceChanged();
|
2023-03-01 13:41:16 +00:00
|
|
|
|
|
|
|
|
|
function moveToCenter()
|
|
|
|
|
{
|
|
|
|
|
item.x = Math.round((roomArea.width - item.width) / 2);
|
|
|
|
|
item.y = Math.round(roomArea.height * 0.67 - item.height / 2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-21 05:44:24 +00:00
|
|
|
|
Loader {
|
|
|
|
|
id: bigAnim
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
z: 999
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-14 05:01:10 +00:00
|
|
|
|
function activateSkill(skill_name, pressed) {
|
|
|
|
|
if (pressed) {
|
2023-06-09 09:23:02 +00:00
|
|
|
|
const data = JSON.parse(Backend.callLuaFunction("GetInteractionOfSkill", [skill_name]));
|
2023-04-04 16:49:54 +00:00
|
|
|
|
if (data) {
|
|
|
|
|
Backend.callLuaFunction("SetInteractionDataOfSkill", [skill_name, "null"]);
|
|
|
|
|
switch (data.type) {
|
|
|
|
|
case "combo":
|
2023-05-20 08:00:03 +00:00
|
|
|
|
skillInteraction.sourceComponent = Qt.createComponent("../SkillInteraction/SkillCombo.qml");
|
2023-04-04 16:49:54 +00:00
|
|
|
|
skillInteraction.item.skill = skill_name;
|
|
|
|
|
skillInteraction.item.default_choice = data["default"];
|
|
|
|
|
skillInteraction.item.choices = data.choices;
|
2023-06-15 13:19:57 +00:00
|
|
|
|
skillInteraction.item.detailed = data.detailed;
|
2023-07-16 07:29:20 +00:00
|
|
|
|
skillInteraction.item.all_choices = data.all_choices;
|
2023-05-19 02:08:36 +00:00
|
|
|
|
// skillInteraction.item.clicked();
|
2023-04-29 16:52:39 +00:00
|
|
|
|
break;
|
|
|
|
|
case "spin":
|
2023-05-20 08:00:03 +00:00
|
|
|
|
skillInteraction.sourceComponent = Qt.createComponent("../SkillInteraction/SkillSpin.qml");
|
2023-04-29 16:52:39 +00:00
|
|
|
|
skillInteraction.item.skill = skill_name;
|
|
|
|
|
skillInteraction.item.from = data.from;
|
|
|
|
|
skillInteraction.item.to = data.to;
|
2023-04-04 16:49:54 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2023-05-19 02:08:36 +00:00
|
|
|
|
skillInteraction.sourceComponent = undefined;
|
2023-04-04 16:49:54 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2023-05-19 02:08:36 +00:00
|
|
|
|
skillInteraction.sourceComponent = undefined;
|
2023-04-04 16:49:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-09-14 05:01:10 +00:00
|
|
|
|
dashboard.startPending(skill_name);
|
|
|
|
|
cancelButton.enabled = true;
|
|
|
|
|
} else {
|
2023-05-19 02:08:36 +00:00
|
|
|
|
skillInteraction.sourceComponent = undefined;
|
2022-09-14 05:01:10 +00:00
|
|
|
|
Logic.doCancelButton();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-18 04:52:52 +00:00
|
|
|
|
Drawer {
|
|
|
|
|
id: roomDrawer
|
2023-06-19 13:56:06 +00:00
|
|
|
|
width: parent.width * 0.3 / mainWindow.scale
|
2023-02-15 11:54:35 +00:00
|
|
|
|
height: parent.height / mainWindow.scale
|
2022-12-18 04:52:52 +00:00
|
|
|
|
dim: false
|
|
|
|
|
clip: true
|
|
|
|
|
dragMargin: 0
|
2023-02-15 11:54:35 +00:00
|
|
|
|
scale: mainWindow.scale
|
|
|
|
|
transformOrigin: Item.TopLeft
|
2023-02-26 08:51:29 +00:00
|
|
|
|
|
2022-12-18 04:52:52 +00:00
|
|
|
|
ColumnLayout {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
|
|
SwipeView {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
interactive: false
|
|
|
|
|
currentIndex: drawerBar.currentIndex
|
|
|
|
|
Item {
|
|
|
|
|
LogEdit {
|
|
|
|
|
id: log
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Item {
|
2023-08-01 13:01:01 +00:00
|
|
|
|
visible: !config.replaying
|
2022-12-18 04:52:52 +00:00
|
|
|
|
ChatBox {
|
|
|
|
|
id: chat
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TabBar {
|
|
|
|
|
id: drawerBar
|
|
|
|
|
width: roomDrawer.width
|
|
|
|
|
TabButton {
|
|
|
|
|
width: roomDrawer.width / 2
|
|
|
|
|
text: Backend.translate("Log")
|
|
|
|
|
}
|
|
|
|
|
TabButton {
|
|
|
|
|
width: roomDrawer.width / 2
|
|
|
|
|
text: Backend.translate("Chat")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-15 11:54:35 +00:00
|
|
|
|
Drawer {
|
|
|
|
|
id: cheatDrawer
|
|
|
|
|
edge: Qt.RightEdge
|
|
|
|
|
width: parent.width * 0.4 / mainWindow.scale
|
|
|
|
|
height: parent.height / mainWindow.scale
|
|
|
|
|
dim: false
|
|
|
|
|
clip: true
|
|
|
|
|
dragMargin: 0
|
|
|
|
|
scale: mainWindow.scale
|
|
|
|
|
transformOrigin: Item.TopRight
|
|
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
|
id: cheatLoader
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
onSourceChanged: {
|
|
|
|
|
if (item === null)
|
|
|
|
|
return;
|
|
|
|
|
item.finish.connect(() => {
|
|
|
|
|
cheatDrawer.close();
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-05-19 02:08:36 +00:00
|
|
|
|
onSourceComponentChanged: sourceChanged();
|
2023-02-15 11:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-18 04:52:52 +00:00
|
|
|
|
Item {
|
|
|
|
|
id: dynamicCardArea
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
id: easyChat
|
|
|
|
|
width: parent.width
|
|
|
|
|
height: 28
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
visible: false
|
|
|
|
|
color: "#040403"
|
|
|
|
|
radius: 3
|
|
|
|
|
border.width: 1
|
|
|
|
|
border.color: "#A6967A"
|
|
|
|
|
|
|
|
|
|
TextInput {
|
|
|
|
|
id: easyChatEdit
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
anchors.margins: 6
|
|
|
|
|
color: "white"
|
|
|
|
|
clip: true
|
|
|
|
|
font.pixelSize: 14
|
|
|
|
|
|
|
|
|
|
onAccepted: {
|
|
|
|
|
if (text != "") {
|
|
|
|
|
ClientInstance.notifyServer(
|
|
|
|
|
"Chat",
|
|
|
|
|
JSON.stringify({
|
|
|
|
|
type: 0,
|
|
|
|
|
msg: text
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
text = "";
|
|
|
|
|
easyChat.visible = false;
|
|
|
|
|
easyChatEdit.enabled = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-19 16:19:48 +00:00
|
|
|
|
MiscStatus {
|
|
|
|
|
id: miscStatus
|
2023-07-02 12:39:42 +00:00
|
|
|
|
anchors.right: menuButton.left
|
2023-04-19 16:19:48 +00:00
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.rightMargin: 16
|
|
|
|
|
anchors.topMargin: 8
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-18 15:26:15 +00:00
|
|
|
|
Danmaku {
|
|
|
|
|
id: danmaku
|
|
|
|
|
width: parent.width
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-18 04:52:52 +00:00
|
|
|
|
Shortcut {
|
|
|
|
|
sequence: "T"
|
|
|
|
|
onActivated: {
|
|
|
|
|
easyChat.visible = true;
|
|
|
|
|
easyChatEdit.enabled = true;
|
|
|
|
|
easyChatEdit.forceActiveFocus();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-20 04:51:54 +00:00
|
|
|
|
Shortcut {
|
|
|
|
|
sequence: "D"
|
|
|
|
|
property bool show_distance: false
|
|
|
|
|
onActivated: {
|
|
|
|
|
show_distance = !show_distance;
|
|
|
|
|
showDistance(show_distance);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-18 04:52:52 +00:00
|
|
|
|
Shortcut {
|
|
|
|
|
sequence: "Esc"
|
|
|
|
|
onActivated: {
|
|
|
|
|
easyChat.visible = false;
|
|
|
|
|
easyChatEdit.enabled = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Shortcut {
|
|
|
|
|
sequence: "Return"
|
|
|
|
|
enabled: okButton.enabled
|
|
|
|
|
onActivated: Logic.doOkButton();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Shortcut {
|
|
|
|
|
sequence: "Space"
|
|
|
|
|
enabled: cancelButton.enabled
|
|
|
|
|
onActivated: Logic.doCancelButton();
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-20 12:15:24 +00:00
|
|
|
|
function getCurrentCardUseMethod() {
|
2023-05-28 04:22:43 +00:00
|
|
|
|
if (specialCardSkills.count === 1 && specialCardSkills.model[0] !== "_normal_use") {
|
|
|
|
|
return specialCardSkills.model[0];
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-20 12:15:24 +00:00
|
|
|
|
for (let i = 1; i < specialCardSkills.count; i++) {
|
2023-06-09 09:23:02 +00:00
|
|
|
|
const item = specialCardSkills.itemAt(i);
|
2023-03-20 12:15:24 +00:00
|
|
|
|
if (item.checked) {
|
2023-06-09 09:23:02 +00:00
|
|
|
|
const ret = item.orig_text;
|
2023-03-20 12:15:24 +00:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-18 04:52:52 +00:00
|
|
|
|
function addToChat(pid, raw, msg) {
|
2023-04-05 07:13:58 +00:00
|
|
|
|
if (raw.type === 1) return;
|
2023-04-10 13:34:23 +00:00
|
|
|
|
|
2023-05-19 15:03:39 +00:00
|
|
|
|
msg = msg.replace(/\{emoji([0-9]+)\}/g, '<img src="../../image/emoji/$1.png" height="24" width="24" />');
|
|
|
|
|
raw.msg = raw.msg.replace(/\{emoji([0-9]+)\}/g, '<img src="../../image/emoji/$1.png" height="24" width="24" />');
|
|
|
|
|
|
2023-04-10 13:34:23 +00:00
|
|
|
|
if (raw.msg.startsWith("$")) {
|
2023-04-18 15:26:15 +00:00
|
|
|
|
if (specialChat(pid, raw, raw.msg.slice(1))) return;
|
2023-04-10 13:34:23 +00:00
|
|
|
|
}
|
2022-12-18 04:52:52 +00:00
|
|
|
|
chat.append(msg);
|
2023-06-09 09:23:02 +00:00
|
|
|
|
const photo = Logic.getPhoto(pid);
|
2023-04-18 15:26:15 +00:00
|
|
|
|
if (photo === undefined) {
|
2023-06-09 09:23:02 +00:00
|
|
|
|
const user = raw.userName;
|
|
|
|
|
const m = raw.msg;
|
2023-04-18 15:26:15 +00:00
|
|
|
|
danmaku.sendLog(`${user}: ${m}`);
|
2023-02-15 11:54:35 +00:00
|
|
|
|
return;
|
2023-04-18 15:26:15 +00:00
|
|
|
|
}
|
2022-12-18 04:52:52 +00:00
|
|
|
|
photo.chat(raw.msg);
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-10 13:34:23 +00:00
|
|
|
|
function specialChat(pid, data, msg) {
|
|
|
|
|
// skill audio: %s%d
|
|
|
|
|
// death audio: ~%s
|
2023-05-19 15:03:39 +00:00
|
|
|
|
// something special: !%s:...
|
2023-04-10 13:34:23 +00:00
|
|
|
|
|
2023-06-09 09:23:02 +00:00
|
|
|
|
const time = data.time;
|
|
|
|
|
const userName = data.userName;
|
|
|
|
|
const general = Backend.translate(data.general);
|
2023-04-10 13:34:23 +00:00
|
|
|
|
|
2023-05-19 15:03:39 +00:00
|
|
|
|
if (msg.startsWith("!")) {
|
2023-06-09 09:23:02 +00:00
|
|
|
|
const splited = msg.split(":");
|
|
|
|
|
const type = splited[0].slice(1);
|
2023-04-10 13:34:23 +00:00
|
|
|
|
switch (type) {
|
2023-05-19 15:03:39 +00:00
|
|
|
|
case "Egg":
|
2023-05-26 12:53:45 +00:00
|
|
|
|
case "GiantEgg":
|
|
|
|
|
case "Shoe":
|
2023-06-24 04:29:08 +00:00
|
|
|
|
case "Wine":
|
2023-05-19 15:03:39 +00:00
|
|
|
|
case "Flower": {
|
|
|
|
|
const fromId = pid;
|
|
|
|
|
const toId = parseInt(splited[1]);
|
|
|
|
|
const component = Qt.createComponent("../ChatAnim/" + type + ".qml");
|
|
|
|
|
//if (component.status !== Component.Ready)
|
|
|
|
|
// return false;
|
|
|
|
|
|
2023-05-26 12:53:45 +00:00
|
|
|
|
const fromItem = Logic.getPhotoOrDashboard(fromId);
|
2023-05-19 15:03:39 +00:00
|
|
|
|
const fromPos = mapFromItem(fromItem, fromItem.width / 2, fromItem.height / 2);
|
|
|
|
|
const toItem = Logic.getPhoto(toId);
|
|
|
|
|
const toPos = mapFromItem(toItem, toItem.width / 2, toItem.height / 2);
|
|
|
|
|
const egg = component.createObject(roomScene, { start: fromPos, end: toPos });
|
|
|
|
|
egg.finished.connect(() => egg.destroy());
|
|
|
|
|
egg.running = true;
|
|
|
|
|
|
2023-04-10 13:34:23 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} else if (msg.startsWith("~")) {
|
2023-06-09 09:23:02 +00:00
|
|
|
|
const g = msg.slice(1);
|
|
|
|
|
const extension = JSON.parse(Backend.callLuaFunction("GetGeneralData", [g])).extension;
|
2023-04-28 10:24:31 +00:00
|
|
|
|
if (!config.disableMsgAudio)
|
|
|
|
|
Backend.playSound("./packages/" + extension + "/audio/death/" + g);
|
2023-04-10 13:34:23 +00:00
|
|
|
|
|
2023-06-09 09:23:02 +00:00
|
|
|
|
const m = Backend.translate("~" + g);
|
2023-04-10 13:34:23 +00:00
|
|
|
|
if (general === "")
|
|
|
|
|
chat.append(`[${time}] ${userName}: ${m}`);
|
|
|
|
|
else
|
|
|
|
|
chat.append(`[${time}] ${userName}(${general}): ${m}`);
|
|
|
|
|
|
2023-06-09 09:23:02 +00:00
|
|
|
|
const photo = Logic.getPhoto(pid);
|
2023-04-18 15:26:15 +00:00
|
|
|
|
if (photo === undefined) {
|
|
|
|
|
danmaku.sendLog(`${userName}: ${m}`);
|
2023-04-10 13:34:23 +00:00
|
|
|
|
return true;
|
2023-04-18 15:26:15 +00:00
|
|
|
|
}
|
2023-04-10 13:34:23 +00:00
|
|
|
|
photo.chat(m);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
2023-06-09 09:23:02 +00:00
|
|
|
|
const splited = msg.split(":");
|
2023-04-10 13:34:23 +00:00
|
|
|
|
if (splited.length < 2) return false;
|
2023-06-09 09:23:02 +00:00
|
|
|
|
const skill = splited[0];
|
|
|
|
|
const idx = parseInt(splited[1]);
|
2023-04-10 13:34:23 +00:00
|
|
|
|
|
2023-06-09 09:23:02 +00:00
|
|
|
|
const data2 = JSON.parse(Backend.callLuaFunction("GetSkillData", [skill]));
|
2023-04-10 13:34:23 +00:00
|
|
|
|
if (!data2) return false;
|
2023-06-09 09:23:02 +00:00
|
|
|
|
const extension = data2.extension;
|
2023-04-28 10:24:31 +00:00
|
|
|
|
if (!config.disableMsgAudio)
|
|
|
|
|
Backend.playSound("./packages/" + extension + "/audio/skill/" + skill, idx);
|
2023-04-10 13:34:23 +00:00
|
|
|
|
|
2023-06-09 09:23:02 +00:00
|
|
|
|
const m = Backend.translate("$" + skill + idx.toString());
|
2023-04-10 13:34:23 +00:00
|
|
|
|
if (general === "")
|
|
|
|
|
chat.append(`[${time}] ${userName}: ${m}`);
|
|
|
|
|
else
|
|
|
|
|
chat.append(`[${time}] ${userName}(${general}): ${m}`);
|
|
|
|
|
|
2023-06-09 09:23:02 +00:00
|
|
|
|
const photo = Logic.getPhoto(pid);
|
2023-04-18 15:26:15 +00:00
|
|
|
|
if (photo === undefined) {
|
|
|
|
|
danmaku.sendLog(`${userName}: ${m}`);
|
2023-04-10 13:34:23 +00:00
|
|
|
|
return true;
|
2023-04-18 15:26:15 +00:00
|
|
|
|
}
|
2023-04-10 13:34:23 +00:00
|
|
|
|
photo.chat(m);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-18 04:52:52 +00:00
|
|
|
|
function addToLog(msg) {
|
|
|
|
|
log.append(msg);
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-18 15:26:15 +00:00
|
|
|
|
function sendDanmaku(msg) {
|
|
|
|
|
danmaku.sendLog(msg);
|
2023-04-20 10:15:18 +00:00
|
|
|
|
chat.append(msg);
|
2023-04-18 15:26:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-12-20 04:51:54 +00:00
|
|
|
|
function showDistance(show) {
|
|
|
|
|
for (let i = 0; i < photoModel.count; i++) {
|
2023-06-09 09:23:02 +00:00
|
|
|
|
const item = photos.itemAt(i);
|
2022-12-20 04:51:54 +00:00
|
|
|
|
if (show) {
|
2023-06-09 09:23:02 +00:00
|
|
|
|
const dis = Backend.callLuaFunction("DistanceTo",[Self.id, item.playerid]);
|
2022-12-20 04:51:54 +00:00
|
|
|
|
item.distance = parseInt(dis);
|
|
|
|
|
} else {
|
2023-06-10 15:51:09 +00:00
|
|
|
|
item.distance = -1;
|
2022-12-20 04:51:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-19 02:08:36 +00:00
|
|
|
|
function startCheat(type, data) {
|
2023-05-20 08:00:03 +00:00
|
|
|
|
cheatLoader.sourceComponent = Qt.createComponent(`../Cheat/${type}.qml`);
|
2023-02-15 11:54:35 +00:00
|
|
|
|
cheatLoader.item.extra_data = data;
|
|
|
|
|
cheatDrawer.open();
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-04 11:31:44 +00:00
|
|
|
|
function resetToInit() {
|
2023-06-09 09:23:02 +00:00
|
|
|
|
const datalist = [];
|
2023-06-04 11:31:44 +00:00
|
|
|
|
for (let i = 0; i < photoModel.count; i++) {
|
2023-06-09 09:23:02 +00:00
|
|
|
|
const item = photoModel.get(i);
|
2023-06-19 13:56:06 +00:00
|
|
|
|
let gameData;
|
|
|
|
|
try {
|
|
|
|
|
gameData = JSON.parse(Backend.callLuaFunction("GetPlayerGameData", [item.id]));
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.log(e);
|
|
|
|
|
gameData = [0, 0, 0];
|
|
|
|
|
}
|
2023-06-04 11:31:44 +00:00
|
|
|
|
if (item.id > 0) {
|
|
|
|
|
datalist.push({
|
|
|
|
|
id: item.id,
|
|
|
|
|
avatar: item.avatar,
|
|
|
|
|
name: item.screenName,
|
|
|
|
|
isOwner: item.isOwner,
|
|
|
|
|
ready: item.ready,
|
2023-06-19 13:56:06 +00:00
|
|
|
|
gameData: gameData,
|
2023-06-04 11:31:44 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
mainStack.pop();
|
2023-06-04 12:00:35 +00:00
|
|
|
|
Backend.callLuaFunction("ResetClientLua", []);
|
2023-06-04 11:31:44 +00:00
|
|
|
|
mainStack.push(room);
|
|
|
|
|
mainStack.currentItem.loadPlayerData(datalist);
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-16 02:58:28 +00:00
|
|
|
|
function setPrompt(text, iscur) {
|
|
|
|
|
promptText = text;
|
|
|
|
|
if (iscur) currentPrompt = text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function resetPrompt() {
|
|
|
|
|
promptText = currentPrompt;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-04 11:31:44 +00:00
|
|
|
|
function loadPlayerData(datalist) {
|
|
|
|
|
datalist.forEach(d => {
|
|
|
|
|
if (d.id == Self.id) {
|
|
|
|
|
roomScene.isOwner = d.isOwner;
|
|
|
|
|
} else {
|
2023-06-04 12:00:35 +00:00
|
|
|
|
Backend.callLuaFunction("ResetAddPlayer", [JSON.stringify([d.id, d.name, d.avatar, d.ready])]);
|
2023-06-04 11:31:44 +00:00
|
|
|
|
}
|
2023-06-27 08:50:24 +00:00
|
|
|
|
Backend.callLuaFunction("SetPlayerGameData", [d.id, d.gameData]);
|
2023-06-04 11:31:44 +00:00
|
|
|
|
Logic.getPhotoModel(d.id).isOwner = d.isOwner;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-02 05:21:13 +00:00
|
|
|
|
function getPhoto(id) {
|
|
|
|
|
return Logic.getPhoto(id);
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
|
Component.onCompleted: {
|
2022-05-01 10:37:13 +00:00
|
|
|
|
toast.show(Backend.translate("$EnterRoom"));
|
2022-04-30 07:27:56 +00:00
|
|
|
|
playerNum = config.roomCapacity;
|
|
|
|
|
|
2023-04-27 06:15:08 +00:00
|
|
|
|
for (let i = 0; i < playerNum; i++) {
|
2022-04-30 07:27:56 +00:00
|
|
|
|
photoModel.append({
|
2023-04-27 06:15:08 +00:00
|
|
|
|
id: i ? -1 : Self.id,
|
|
|
|
|
index: i, // For animating seat swap
|
|
|
|
|
general: i ? "" : Self.avatar,
|
2023-06-04 11:31:44 +00:00
|
|
|
|
avatar: i ? "" : Self.avatar,
|
2023-04-19 06:07:16 +00:00
|
|
|
|
deputyGeneral: "",
|
2023-04-27 06:15:08 +00:00
|
|
|
|
screenName: i ? "" : Self.screenName,
|
2022-04-30 07:27:56 +00:00
|
|
|
|
role: "unknown",
|
2023-04-23 13:10:07 +00:00
|
|
|
|
kingdom: "unknown",
|
2022-04-30 07:27:56 +00:00
|
|
|
|
netstate: "online",
|
|
|
|
|
maxHp: 0,
|
|
|
|
|
hp: 0,
|
2023-04-13 12:17:39 +00:00
|
|
|
|
shield: 0,
|
2022-04-30 07:27:56 +00:00
|
|
|
|
seatNumber: i + 1,
|
2022-12-20 04:51:54 +00:00
|
|
|
|
dead: false,
|
2022-04-30 07:27:56 +00:00
|
|
|
|
dying: false,
|
|
|
|
|
faceup: true,
|
|
|
|
|
chained: false,
|
2023-03-14 12:48:08 +00:00
|
|
|
|
drank: 0,
|
2023-06-04 11:31:44 +00:00
|
|
|
|
isOwner: false,
|
|
|
|
|
ready: false,
|
2023-07-02 12:39:42 +00:00
|
|
|
|
surrendered: false,
|
2022-04-30 07:27:56 +00:00
|
|
|
|
});
|
2022-03-23 11:40:28 +00:00
|
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
|
|
|
|
|
|
Logic.arrangePhotos();
|
|
|
|
|
}
|
2022-03-01 05:18:00 +00:00
|
|
|
|
}
|