2022-03-01 05:18:00 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.0
|
2022-03-23 11:40:28 +00:00
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
import "RoomElement"
|
|
|
|
import "RoomLogic.js" as Logic
|
2022-03-01 05:18:00 +00:00
|
|
|
|
|
|
|
Item {
|
2022-03-23 11:40:28 +00:00
|
|
|
id: roomScene
|
|
|
|
|
|
|
|
property int playerNum: 0
|
|
|
|
property var dashboardModel
|
|
|
|
|
2022-03-27 06:49:41 +00:00
|
|
|
property bool isOwner: false
|
|
|
|
property bool isStarted: false
|
|
|
|
|
2022-03-30 06:14:40 +00:00
|
|
|
property alias popupBox: popupBox
|
|
|
|
|
2022-03-23 11:40:28 +00:00
|
|
|
// tmp
|
2022-03-01 05:18:00 +00:00
|
|
|
Button {
|
|
|
|
text: "quit"
|
2022-03-23 11:40:28 +00:00
|
|
|
anchors.bottom: parent.bottom
|
2022-03-01 05:18:00 +00:00
|
|
|
onClicked: {
|
2022-03-28 14:24:30 +00:00
|
|
|
ClientInstance.clearPlayers();
|
2022-03-27 06:49:41 +00:00
|
|
|
ClientInstance.notifyServer("QuitRoom", "[]");
|
2022-03-01 05:18:00 +00:00
|
|
|
}
|
|
|
|
}
|
2022-03-27 06:49:41 +00:00
|
|
|
Button {
|
|
|
|
text: "start game"
|
2022-03-30 06:14:40 +00:00
|
|
|
visible: dashboardModel.isOwner && !isStarted
|
2022-03-27 06:49:41 +00:00
|
|
|
anchors.centerIn: parent
|
|
|
|
}
|
2022-03-23 11:40:28 +00:00
|
|
|
|
|
|
|
// For debugging
|
|
|
|
RowLayout {
|
|
|
|
visible: Debugging ? true : false
|
|
|
|
width: parent.width
|
|
|
|
TextField {
|
|
|
|
id: lua
|
|
|
|
Layout.fillWidth: true
|
2022-03-24 13:23:42 +00:00
|
|
|
text: "print \"Hello world.\""
|
2022-03-23 11:40:28 +00:00
|
|
|
}
|
|
|
|
Button {
|
|
|
|
text: "DoLuaScript"
|
|
|
|
onClicked: {
|
2022-03-27 06:49:41 +00:00
|
|
|
ClientInstance.notifyServer("DoLuaScript", JSON.stringify([lua.text]));
|
2022-03-23 11:40:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Layout:
|
|
|
|
* +---------------------+
|
|
|
|
* | Photos, get more |
|
|
|
|
* | in arrangePhotos() |
|
|
|
|
* | tablePile |
|
|
|
|
* | progress,prompt,btn |
|
|
|
|
* +---------------------+
|
|
|
|
* | dashboard |
|
|
|
|
* +---------------------+
|
|
|
|
*/
|
|
|
|
|
2022-03-28 14:24:30 +00:00
|
|
|
ListModel {
|
|
|
|
id: photoModel
|
|
|
|
}
|
|
|
|
|
2022-03-23 11:40:28 +00:00
|
|
|
Item {
|
|
|
|
id: roomArea
|
|
|
|
width: roomScene.width
|
|
|
|
height: roomScene.height - dashboard.height
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
id: photos
|
|
|
|
model: photoModel
|
|
|
|
Photo {
|
2022-03-30 06:14:40 +00:00
|
|
|
general: model.general
|
|
|
|
screenName: model.screenName
|
|
|
|
role: model.role
|
|
|
|
kingdom: model.kingdom
|
|
|
|
netstate: model.netstate
|
|
|
|
maxHp: model.maxHp
|
|
|
|
hp: model.hp
|
|
|
|
seatNumber: model.seatNumber
|
|
|
|
isDead: model.isDead
|
|
|
|
dying: model.dying
|
|
|
|
faceturned: model.faceturned
|
|
|
|
chained: model.chained
|
|
|
|
drank: model.drank
|
|
|
|
isOwner: model.isOwner
|
2022-03-23 11:40:28 +00: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 13:23:42 +00: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 06:49:41 +00:00
|
|
|
self.isOwner: dashboardModel.isOwner
|
2022-03-23 11:40:28 +00:00
|
|
|
}
|
|
|
|
|
2022-03-30 06:14:40 +00:00
|
|
|
Loader {
|
|
|
|
id: popupBox
|
|
|
|
onSourceChanged: {
|
|
|
|
if (item === null)
|
|
|
|
return;
|
|
|
|
item.finished.connect(function(){
|
|
|
|
source = "";
|
|
|
|
});
|
|
|
|
item.widthChanged.connect(function(){
|
|
|
|
popupBox.moveToCenter();
|
|
|
|
});
|
|
|
|
item.heightChanged.connect(function(){
|
|
|
|
popupBox.moveToCenter();
|
|
|
|
});
|
|
|
|
moveToCenter();
|
|
|
|
}
|
|
|
|
|
|
|
|
function moveToCenter()
|
|
|
|
{
|
|
|
|
item.x = Math.round((roomArea.width - item.width) / 2);
|
|
|
|
item.y = Math.round(roomArea.height * 0.67 - item.height / 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-23 11:40:28 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
toast.show("Sucesessfully entered room.");
|
2022-03-24 13:23:42 +00:00
|
|
|
|
|
|
|
dashboardModel = {
|
2022-03-28 14:24:30 +00:00
|
|
|
id: Self.id,
|
2022-03-27 06:49:41 +00:00
|
|
|
general: Self.avatar,
|
|
|
|
screenName: Self.screenName,
|
2022-03-24 13:23:42 +00:00
|
|
|
role: "unknown",
|
|
|
|
kingdom: "qun",
|
|
|
|
netstate: "online",
|
|
|
|
maxHp: 0,
|
|
|
|
hp: 0,
|
|
|
|
seatNumber: 1,
|
|
|
|
isDead: false,
|
|
|
|
dying: false,
|
|
|
|
faceturned: false,
|
|
|
|
chained: false,
|
2022-03-27 06:49:41 +00:00
|
|
|
drank: false,
|
|
|
|
isOwner: false
|
2022-03-24 13:23:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
playerNum = config.roomCapacity;
|
|
|
|
|
|
|
|
let i;
|
|
|
|
for (i = 1; i < playerNum; i++) {
|
2022-03-28 14:24:30 +00:00
|
|
|
photoModel.append({
|
|
|
|
id: -1,
|
|
|
|
index: i - 1, // For animating seat swap
|
2022-03-30 06:14:40 +00:00
|
|
|
general: "",
|
|
|
|
screenName: "",
|
|
|
|
role: "unknown",
|
|
|
|
kingdom: "qun",
|
|
|
|
netstate: "online",
|
|
|
|
maxHp: 0,
|
|
|
|
hp: 0,
|
|
|
|
seatNumber: i + 1,
|
|
|
|
isDead: false,
|
|
|
|
dying: false,
|
|
|
|
faceturned: false,
|
|
|
|
chained: false,
|
|
|
|
drank: false,
|
|
|
|
isOwner: false
|
2022-03-24 13:23:42 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-03-23 11:40:28 +00:00
|
|
|
Logic.arrangePhotos();
|
|
|
|
}
|
2022-03-01 05:18:00 +00:00
|
|
|
}
|
|
|
|
|