2022-03-01 13:18:00 +08:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.0
|
2022-03-23 19:40:28 +08:00
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
import "RoomElement"
|
|
|
|
import "RoomLogic.js" as Logic
|
2022-03-01 13:18:00 +08:00
|
|
|
|
|
|
|
Item {
|
2022-03-23 19:40:28 +08:00
|
|
|
id: roomScene
|
|
|
|
|
|
|
|
property var photoModel: []
|
|
|
|
property int playerNum: 0
|
|
|
|
property var dashboardModel
|
|
|
|
|
2022-03-27 14:49:41 +08:00
|
|
|
property bool isOwner: false
|
|
|
|
property bool isStarted: false
|
|
|
|
|
2022-03-23 19:40:28 +08:00
|
|
|
// tmp
|
2022-03-01 13:18:00 +08:00
|
|
|
Text {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
text: "You are in room."
|
|
|
|
}
|
|
|
|
Button {
|
|
|
|
text: "quit"
|
2022-03-23 19:40:28 +08:00
|
|
|
anchors.bottom: parent.bottom
|
2022-03-01 13:18:00 +08:00
|
|
|
onClicked: {
|
2022-03-27 14:49:41 +08:00
|
|
|
ClientInstance.notifyServer("QuitRoom", "[]");
|
2022-03-01 13:18:00 +08:00
|
|
|
}
|
|
|
|
}
|
2022-03-27 14:49:41 +08:00
|
|
|
Button {
|
|
|
|
text: "start game"
|
|
|
|
visible: isOwner && !isStarted
|
|
|
|
anchors.centerIn: parent
|
|
|
|
}
|
2022-03-23 19:40:28 +08:00
|
|
|
|
|
|
|
// For debugging
|
|
|
|
RowLayout {
|
|
|
|
visible: Debugging ? true : false
|
|
|
|
width: parent.width
|
|
|
|
TextField {
|
|
|
|
id: lua
|
|
|
|
Layout.fillWidth: true
|
2022-03-24 21:23:42 +08:00
|
|
|
text: "print \"Hello world.\""
|
2022-03-23 19:40:28 +08:00
|
|
|
}
|
|
|
|
Button {
|
|
|
|
text: "DoLuaScript"
|
|
|
|
onClicked: {
|
2022-03-27 14:49:41 +08:00
|
|
|
ClientInstance.notifyServer("DoLuaScript", JSON.stringify([lua.text]));
|
2022-03-23 19:40:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Layout:
|
|
|
|
* +---------------------+
|
|
|
|
* | Photos, get more |
|
|
|
|
* | in arrangePhotos() |
|
|
|
|
* | tablePile |
|
|
|
|
* | progress,prompt,btn |
|
|
|
|
* +---------------------+
|
|
|
|
* | dashboard |
|
|
|
|
* +---------------------+
|
|
|
|
*/
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: roomArea
|
|
|
|
width: roomScene.width
|
|
|
|
height: roomScene.height - dashboard.height
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
id: photos
|
|
|
|
model: photoModel
|
|
|
|
Photo {
|
2022-03-24 21:23:42 +08:00
|
|
|
general: modelData.general
|
|
|
|
screenName: modelData.screenName
|
|
|
|
role: modelData.role
|
|
|
|
kingdom: modelData.kingdom
|
|
|
|
netstate: modelData.netstate
|
|
|
|
maxHp: modelData.maxHp
|
|
|
|
hp: modelData.hp
|
|
|
|
seatNumber: modelData.seatNumber
|
|
|
|
isDead: modelData.isDead
|
|
|
|
dying: modelData.dying
|
|
|
|
faceturned: modelData.faceturned
|
|
|
|
chained: modelData.chained
|
|
|
|
drank: modelData.drank
|
2022-03-27 14:49:41 +08:00
|
|
|
isOwner: modelData.isOwner
|
2022-03-23 19:40:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onWidthChanged: Logic.arrangePhotos();
|
|
|
|
onHeightChanged: Logic.arrangePhotos();
|
|
|
|
|
|
|
|
InvisibleCardArea {
|
|
|
|
id: drawPile
|
|
|
|
x: parent.width / 2
|
|
|
|
y: roomScene.height / 2
|
|
|
|
}
|
|
|
|
|
|
|
|
TablePile {
|
|
|
|
id: tablePile
|
|
|
|
width: parent.width * 0.6
|
|
|
|
height: 150
|
|
|
|
x: parent.width * 0.2
|
|
|
|
y: parent.height * 0.5
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Dashboard {
|
|
|
|
id: dashboard
|
|
|
|
width: roomScene.width
|
|
|
|
anchors.top: roomArea.bottom
|
2022-03-24 21:23:42 +08:00
|
|
|
|
|
|
|
self.general: dashboardModel.general
|
|
|
|
self.screenName: dashboardModel.screenName
|
|
|
|
self.role: dashboardModel.role
|
|
|
|
self.kingdom: dashboardModel.kingdom
|
|
|
|
self.netstate: dashboardModel.netstate
|
|
|
|
self.maxHp: dashboardModel.maxHp
|
|
|
|
self.hp: dashboardModel.hp
|
|
|
|
self.seatNumber: dashboardModel.seatNumber
|
|
|
|
self.isDead: dashboardModel.isDead
|
|
|
|
self.dying: dashboardModel.dying
|
|
|
|
self.faceturned: dashboardModel.faceturned
|
|
|
|
self.chained: dashboardModel.chained
|
|
|
|
self.drank: dashboardModel.drank
|
2022-03-27 14:49:41 +08:00
|
|
|
self.isOwner: dashboardModel.isOwner
|
2022-03-23 19:40:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
toast.show("Sucesessfully entered room.");
|
2022-03-24 21:23:42 +08:00
|
|
|
|
|
|
|
dashboardModel = {
|
2022-03-27 14:49:41 +08:00
|
|
|
general: Self.avatar,
|
|
|
|
screenName: Self.screenName,
|
2022-03-24 21:23:42 +08:00
|
|
|
role: "unknown",
|
|
|
|
kingdom: "qun",
|
|
|
|
netstate: "online",
|
|
|
|
maxHp: 0,
|
|
|
|
hp: 0,
|
|
|
|
seatNumber: 1,
|
|
|
|
isDead: false,
|
|
|
|
dying: false,
|
|
|
|
faceturned: false,
|
|
|
|
chained: false,
|
2022-03-27 14:49:41 +08:00
|
|
|
drank: false,
|
|
|
|
isOwner: false
|
2022-03-24 21:23:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
playerNum = config.roomCapacity;
|
|
|
|
|
|
|
|
let i;
|
|
|
|
for (i = 1; i < playerNum; i++) {
|
|
|
|
photoModel.push({
|
|
|
|
general: "",
|
|
|
|
screenName: "",
|
|
|
|
role: "unknown",
|
|
|
|
kingdom: "qun",
|
|
|
|
netstate: "online",
|
|
|
|
maxHp: 0,
|
|
|
|
hp: 0,
|
|
|
|
seatNumber: i + 1,
|
|
|
|
isDead: false,
|
|
|
|
dying: false,
|
|
|
|
faceturned: false,
|
|
|
|
chained: false,
|
2022-03-27 14:49:41 +08:00
|
|
|
drank: false,
|
|
|
|
isOwner: false
|
2022-03-24 21:23:42 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
photoModel = photoModel; // Force the Repeater reload
|
|
|
|
|
2022-03-23 19:40:28 +08:00
|
|
|
Logic.arrangePhotos();
|
|
|
|
}
|
2022-03-01 13:18:00 +08:00
|
|
|
}
|
|
|
|
|