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
|
|
|
|
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
|
|
|
|
|
|
|
|
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
|
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: ({})
|
2022-04-30 07:27:56 +00:00
|
|
|
|
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-04-30 10:51:05 +00:00
|
|
|
DelayButton {
|
2023-04-19 16:19:48 +00:00
|
|
|
id: quitButton
|
2022-04-30 07:27:56 +00:00
|
|
|
text: "quit"
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.right: parent.right
|
2023-04-30 10:51:05 +00:00
|
|
|
delay: Debugging ? 10 : 1000
|
|
|
|
onActivated: {
|
2022-12-18 04:52:52 +00:00
|
|
|
// ClientInstance.clearPlayers();
|
2022-04-30 07:27:56 +00:00
|
|
|
ClientInstance.notifyServer("QuitRoom", "[]");
|
2022-04-14 10:22:00 +00:00
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
}
|
|
|
|
Button {
|
|
|
|
text: "add robot"
|
2023-04-27 06:15:08 +00:00
|
|
|
visible: isOwner && !isStarted
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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 = "";
|
|
|
|
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();
|
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;
|
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;
|
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;
|
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-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
|
|
|
|
|
|
|
|
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
|
|
|
|
ColumnLayout {
|
|
|
|
MetroButton {
|
|
|
|
text: Backend.translate("Trust")
|
|
|
|
}
|
|
|
|
MetroButton {
|
|
|
|
text: Backend.translate("Sort Cards")
|
|
|
|
}
|
|
|
|
MetroButton {
|
|
|
|
text: Backend.translate("Chat")
|
|
|
|
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") {
|
|
|
|
let skills = JSON.parse(Backend.callLuaFunction("GetCardSpecialSkills", [card]));
|
|
|
|
skills.unshift("_normal_use");
|
|
|
|
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 ...")
|
|
|
|
visible: config.observing
|
|
|
|
color: "#4B83CD"
|
|
|
|
font.family: fontLi2.name
|
|
|
|
font.pixelSize: 48
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
visible: roomScene.state == "playing" && specialCardSkills.count > 1
|
|
|
|
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
|
|
|
|
|
|
|
|
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;
|
|
|
|
item.finished.connect(function(){
|
2023-05-19 02:08:36 +00:00
|
|
|
sourceComponent = undefined;
|
2022-04-30 07:27:56 +00:00
|
|
|
});
|
|
|
|
item.widthChanged.connect(function(){
|
|
|
|
popupBox.moveToCenter();
|
|
|
|
});
|
|
|
|
item.heightChanged.connect(function(){
|
|
|
|
popupBox.moveToCenter();
|
|
|
|
});
|
|
|
|
moveToCenter();
|
|
|
|
}
|
2023-05-19 02:08:36 +00:00
|
|
|
onSourceComponentChanged: sourceChanged();
|
2022-03-24 13:23:42 +00:00
|
|
|
|
2022-04-30 07:27:56 +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-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-04-04 16:49:54 +00:00
|
|
|
let data = JSON.parse(Backend.callLuaFunction("GetInteractionOfSkill", [skill_name]));
|
|
|
|
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-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-02-15 11:54:35 +00:00
|
|
|
width: parent.width * 0.3 / mainWindow.scale
|
|
|
|
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 {
|
|
|
|
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
|
|
|
|
anchors.right: quitButton.left
|
|
|
|
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() {
|
|
|
|
for (let i = 1; i < specialCardSkills.count; i++) {
|
|
|
|
let item = specialCardSkills.itemAt(i);
|
|
|
|
if (item.checked) {
|
|
|
|
let ret = item.orig_text;
|
|
|
|
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-04-28 02:27:56 +00:00
|
|
|
let photo = Logic.getPhoto(pid);
|
2023-04-18 15:26:15 +00:00
|
|
|
if (photo === undefined) {
|
|
|
|
let user = raw.userName;
|
|
|
|
let m = raw.msg;
|
|
|
|
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
|
|
|
|
|
|
|
let time = data.time;
|
|
|
|
let userName = data.userName;
|
|
|
|
let general = Backend.translate(data.general);
|
|
|
|
|
2023-05-19 15:03:39 +00:00
|
|
|
if (msg.startsWith("!")) {
|
2023-04-10 13:34:23 +00:00
|
|
|
let splited = msg.split(":");
|
|
|
|
let type = splited[0].slice(1);
|
|
|
|
switch (type) {
|
2023-05-19 15:03:39 +00:00
|
|
|
case "Egg":
|
|
|
|
case "Flower": {
|
|
|
|
const fromId = pid;
|
|
|
|
const toId = parseInt(splited[1]);
|
|
|
|
const component = Qt.createComponent("../ChatAnim/" + type + ".qml");
|
|
|
|
//if (component.status !== Component.Ready)
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
const fromItem = Logic.getPhoto(fromId);
|
|
|
|
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("~")) {
|
|
|
|
let g = msg.slice(1);
|
|
|
|
let 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
|
|
|
|
|
|
|
let m = Backend.translate("~" + g);
|
|
|
|
if (general === "")
|
|
|
|
chat.append(`[${time}] ${userName}: ${m}`);
|
|
|
|
else
|
|
|
|
chat.append(`[${time}] ${userName}(${general}): ${m}`);
|
|
|
|
|
2023-04-28 02:27:56 +00:00
|
|
|
let 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 {
|
|
|
|
let splited = msg.split(":");
|
|
|
|
if (splited.length < 2) return false;
|
|
|
|
let skill = splited[0];
|
|
|
|
let idx = parseInt(splited[1]);
|
|
|
|
|
|
|
|
let data2 = JSON.parse(Backend.callLuaFunction("GetSkillData", [skill]));
|
|
|
|
if (!data2) return false;
|
|
|
|
let 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
|
|
|
|
|
|
|
let m = Backend.translate("$" + skill + idx.toString());
|
|
|
|
if (general === "")
|
|
|
|
chat.append(`[${time}] ${userName}: ${m}`);
|
|
|
|
else
|
|
|
|
chat.append(`[${time}] ${userName}(${general}): ${m}`);
|
|
|
|
|
2023-04-28 02:27:56 +00:00
|
|
|
let 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++) {
|
|
|
|
let item = photos.itemAt(i);
|
|
|
|
if (show) {
|
|
|
|
let dis = Backend.callLuaFunction("DistanceTo",[Self.id, item.playerid]);
|
|
|
|
item.distance = parseInt(dis);
|
|
|
|
} else {
|
|
|
|
item.distance = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
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-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,
|
2022-04-30 07:27:56 +00:00
|
|
|
isOwner: false
|
|
|
|
});
|
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
|
|
|
}
|