2022-09-14 13:01:10 +08:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
|
|
|
import QtQuick.Window
|
|
|
|
import QtQuick.Layouts
|
2022-03-27 20:00:29 +08:00
|
|
|
import "Logic.js" as Logic
|
2022-01-24 10:23:08 +08:00
|
|
|
|
|
|
|
Item {
|
2022-04-30 15:27:56 +08:00
|
|
|
id: root
|
|
|
|
property alias roomModel: roomModel
|
|
|
|
Component {
|
|
|
|
id: roomDelegate
|
2022-01-24 10:23:08 +08:00
|
|
|
|
2022-05-01 18:37:13 +08:00
|
|
|
Item {
|
2023-02-15 19:54:35 +08:00
|
|
|
height: 22
|
2022-05-01 18:37:13 +08:00
|
|
|
width: roomList.width
|
2022-01-24 10:23:08 +08:00
|
|
|
|
2022-05-01 18:37:13 +08:00
|
|
|
RowLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
spacing: 16
|
|
|
|
Text {
|
|
|
|
text: roomId
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
Layout.fillWidth: true
|
|
|
|
text: roomName
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
text: gameMode
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
color: (playerNum == capacity) ? "red" : "black"
|
|
|
|
text: playerNum + "/" + capacity
|
|
|
|
}
|
2023-02-15 19:54:35 +08:00
|
|
|
|
|
|
|
Text {
|
|
|
|
text: Backend.translate("Enter")
|
|
|
|
font.pixelSize: 24
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: {
|
|
|
|
config.observing = false;
|
|
|
|
mainWindow.busy = true;
|
|
|
|
ClientInstance.notifyServer(
|
|
|
|
"EnterRoom",
|
|
|
|
JSON.stringify([roomId])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
text: Backend.translate("Observe")
|
|
|
|
font.pixelSize: 24
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: {
|
|
|
|
config.observing = true;
|
|
|
|
mainWindow.busy = true;
|
|
|
|
ClientInstance.notifyServer(
|
|
|
|
"ObserveRoom",
|
|
|
|
JSON.stringify([roomId])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-05-01 18:37:13 +08:00
|
|
|
}
|
2022-01-24 10:23:08 +08:00
|
|
|
}
|
2022-04-30 15:27:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ListModel {
|
|
|
|
id: roomModel
|
|
|
|
}
|
2022-01-24 10:23:08 +08:00
|
|
|
|
2022-04-30 15:27:56 +08:00
|
|
|
RowLayout {
|
|
|
|
anchors.fill: parent
|
2022-05-01 18:37:13 +08:00
|
|
|
Item {
|
2023-01-12 22:53:22 +08:00
|
|
|
Layout.preferredWidth: root.width * 0.6
|
2022-04-30 15:27:56 +08:00
|
|
|
Layout.fillHeight: true
|
2022-05-01 18:37:13 +08:00
|
|
|
Rectangle {
|
|
|
|
width: parent.width * 0.8
|
|
|
|
height: parent.height * 0.8
|
2022-04-30 15:27:56 +08:00
|
|
|
anchors.centerIn: parent
|
2022-05-01 18:37:13 +08:00
|
|
|
color: "#88888888"
|
|
|
|
radius: 16
|
|
|
|
Text {
|
|
|
|
width: parent.width
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
text: Backend.translate("Room List")
|
|
|
|
}
|
|
|
|
ListView {
|
|
|
|
id: roomList
|
|
|
|
height: parent.height * 0.9
|
|
|
|
width: parent.width * 0.95
|
|
|
|
contentHeight: roomDelegate.height * count
|
|
|
|
ScrollBar.vertical: ScrollBar {}
|
|
|
|
anchors.centerIn: parent
|
|
|
|
delegate: roomDelegate
|
|
|
|
model: roomModel
|
|
|
|
}
|
2022-04-30 15:27:56 +08:00
|
|
|
}
|
2022-01-24 10:23:08 +08:00
|
|
|
}
|
|
|
|
|
2023-01-12 22:53:22 +08:00
|
|
|
GridLayout {
|
|
|
|
flow: GridLayout.TopToBottom
|
|
|
|
rows: 4
|
|
|
|
TileButton {
|
|
|
|
iconSource: "configure"
|
2022-05-01 18:37:13 +08:00
|
|
|
text: Backend.translate("Edit Profile")
|
2022-04-30 15:27:56 +08:00
|
|
|
onClicked: {
|
2023-02-15 19:54:35 +08:00
|
|
|
lobby_dialog.source = "LobbyElement/EditProfile.qml";
|
|
|
|
lobby_drawer.open();
|
2022-01-24 10:23:08 +08:00
|
|
|
}
|
2022-04-30 15:27:56 +08:00
|
|
|
}
|
2023-01-12 22:53:22 +08:00
|
|
|
TileButton {
|
|
|
|
iconSource: "create_room"
|
2022-05-01 18:37:13 +08:00
|
|
|
text: Backend.translate("Create Room")
|
2022-04-30 15:27:56 +08:00
|
|
|
onClicked: {
|
2023-02-15 19:54:35 +08:00
|
|
|
lobby_dialog.source = "LobbyElement/CreateRoom.qml";
|
|
|
|
lobby_drawer.open();
|
2023-02-21 13:44:24 +08:00
|
|
|
config.observing = false;
|
2022-01-24 10:23:08 +08:00
|
|
|
}
|
2022-04-30 15:27:56 +08:00
|
|
|
}
|
2023-01-12 22:53:22 +08:00
|
|
|
TileButton {
|
|
|
|
iconSource: "general_overview"
|
2022-05-01 18:37:13 +08:00
|
|
|
text: Backend.translate("Generals Overview")
|
2022-04-30 15:27:56 +08:00
|
|
|
onClicked: {
|
2022-05-01 18:37:13 +08:00
|
|
|
mainStack.push(mainWindow.generalsOverviewPage);
|
2022-04-30 15:27:56 +08:00
|
|
|
mainStack.currentItem.loadPackages();
|
2022-03-01 13:18:00 +08:00
|
|
|
}
|
2022-04-30 15:27:56 +08:00
|
|
|
}
|
2023-01-12 22:53:22 +08:00
|
|
|
TileButton {
|
|
|
|
iconSource: "card_overview"
|
2022-05-01 18:37:13 +08:00
|
|
|
text: Backend.translate("Cards Overview")
|
2022-04-30 15:27:56 +08:00
|
|
|
onClicked: {
|
2022-05-01 18:37:13 +08:00
|
|
|
mainStack.push(mainWindow.cardsOverviewPage);
|
2022-04-30 15:27:56 +08:00
|
|
|
mainStack.currentItem.loadPackages();
|
|
|
|
}
|
|
|
|
}
|
2023-01-12 22:53:22 +08:00
|
|
|
TileButton {
|
|
|
|
iconSource: "rule_summary"
|
2022-05-01 18:37:13 +08:00
|
|
|
text: Backend.translate("Scenarios Overview")
|
2022-04-30 15:27:56 +08:00
|
|
|
}
|
2023-01-12 22:53:22 +08:00
|
|
|
TileButton {
|
|
|
|
iconSource: "replay"
|
|
|
|
text: Backend.translate("Replay")
|
|
|
|
}
|
|
|
|
TileButton {
|
|
|
|
iconSource: "about"
|
2022-05-01 18:37:13 +08:00
|
|
|
text: Backend.translate("About")
|
2023-01-12 22:53:22 +08:00
|
|
|
onClicked: {
|
|
|
|
mainStack.push(mainWindow.aboutPage);
|
|
|
|
}
|
2022-04-30 15:27:56 +08:00
|
|
|
}
|
2023-01-12 22:53:22 +08:00
|
|
|
TileButton {
|
|
|
|
iconSource: "quit"
|
2022-05-01 18:37:13 +08:00
|
|
|
text: Backend.translate("Exit Lobby")
|
2022-04-30 15:27:56 +08:00
|
|
|
onClicked: {
|
|
|
|
toast.show("Goodbye.");
|
|
|
|
Backend.quitLobby();
|
|
|
|
mainStack.pop();
|
2022-03-01 13:18:00 +08:00
|
|
|
}
|
2022-04-30 15:27:56 +08:00
|
|
|
}
|
2022-03-01 13:18:00 +08:00
|
|
|
}
|
2022-04-30 15:27:56 +08:00
|
|
|
}
|
2022-03-01 13:18:00 +08:00
|
|
|
|
2023-02-15 19:54:35 +08:00
|
|
|
Drawer {
|
|
|
|
id: lobby_drawer
|
|
|
|
width: parent.width * 0.4 / mainWindow.scale
|
|
|
|
height: parent.height / mainWindow.scale
|
|
|
|
dim: false
|
|
|
|
clip: true
|
|
|
|
dragMargin: 0
|
|
|
|
scale: mainWindow.scale
|
|
|
|
transformOrigin: Item.TopLeft
|
2022-04-30 15:27:56 +08:00
|
|
|
|
2023-02-15 19:54:35 +08:00
|
|
|
Loader {
|
|
|
|
id: lobby_dialog
|
2023-03-14 14:12:13 +08:00
|
|
|
anchors.fill: parent
|
2023-02-15 19:54:35 +08:00
|
|
|
onSourceChanged: {
|
|
|
|
if (item === null)
|
|
|
|
return;
|
|
|
|
item.finished.connect(() => {
|
|
|
|
source = "";
|
|
|
|
lobby_drawer.close();
|
|
|
|
});
|
|
|
|
}
|
2022-04-30 15:27:56 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
2022-05-01 18:37:13 +08:00
|
|
|
toast.show(Backend.translate("$WelcomeToLobby"));
|
2022-04-30 15:27:56 +08:00
|
|
|
}
|
2022-01-24 10:23:08 +08:00
|
|
|
}
|
|
|
|
|