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.Window
|
|
|
|
import QtQuick.Layouts
|
2023-03-20 06:53:56 +00:00
|
|
|
import "LobbyElement"
|
2023-04-05 07:13:58 +00:00
|
|
|
import "Common"
|
2022-03-27 12:00:29 +00:00
|
|
|
import "Logic.js" as Logic
|
2022-01-24 02:23:08 +00:00
|
|
|
|
|
|
|
Item {
|
2022-04-30 07:27:56 +00:00
|
|
|
id: root
|
|
|
|
property alias roomModel: roomModel
|
|
|
|
Component {
|
|
|
|
id: roomDelegate
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-05-01 10:37:13 +00:00
|
|
|
Item {
|
2023-02-15 11:54:35 +00:00
|
|
|
height: 22
|
2022-05-01 10:37:13 +00:00
|
|
|
width: roomList.width
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-05-01 10:37:13 +00: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 11:54:35 +00:00
|
|
|
|
|
|
|
Text {
|
|
|
|
text: Backend.translate("Enter")
|
|
|
|
font.pixelSize: 24
|
2023-03-18 07:34:42 +00:00
|
|
|
TapHandler {
|
|
|
|
onTapped: {
|
2023-02-15 11:54:35 +00:00
|
|
|
config.observing = false;
|
|
|
|
mainWindow.busy = true;
|
|
|
|
ClientInstance.notifyServer(
|
|
|
|
"EnterRoom",
|
|
|
|
JSON.stringify([roomId])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
text: Backend.translate("Observe")
|
2023-04-10 13:34:23 +00:00
|
|
|
visible: false // FIXME
|
2023-02-15 11:54:35 +00:00
|
|
|
font.pixelSize: 24
|
2023-03-18 07:34:42 +00:00
|
|
|
TapHandler {
|
|
|
|
onTapped: {
|
2023-02-15 11:54:35 +00:00
|
|
|
config.observing = true;
|
|
|
|
mainWindow.busy = true;
|
|
|
|
ClientInstance.notifyServer(
|
|
|
|
"ObserveRoom",
|
|
|
|
JSON.stringify([roomId])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-05-01 10:37:13 +00:00
|
|
|
}
|
2022-01-24 02:23:08 +00:00
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ListModel {
|
|
|
|
id: roomModel
|
|
|
|
}
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2023-03-20 06:53:56 +00:00
|
|
|
PersonalSettings {
|
|
|
|
}
|
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
RowLayout {
|
2023-03-20 06:53:56 +00:00
|
|
|
anchors.centerIn: parent
|
|
|
|
width: childrenRect.width
|
|
|
|
height: parent.height
|
2022-05-01 10:37:13 +00:00
|
|
|
Item {
|
2023-01-12 14:53:22 +00:00
|
|
|
Layout.preferredWidth: root.width * 0.6
|
2022-04-30 07:27:56 +00:00
|
|
|
Layout.fillHeight: true
|
2022-05-01 10:37:13 +00:00
|
|
|
Rectangle {
|
|
|
|
width: parent.width * 0.8
|
|
|
|
height: parent.height * 0.8
|
2022-04-30 07:27:56 +00:00
|
|
|
anchors.centerIn: parent
|
2023-03-20 06:53:56 +00:00
|
|
|
color: "#88EEEEEE"
|
2022-05-01 10:37:13 +00:00
|
|
|
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 07:27:56 +00:00
|
|
|
}
|
2022-01-24 02:23:08 +00:00
|
|
|
}
|
2023-03-20 06:53:56 +00:00
|
|
|
}
|
|
|
|
|
2023-03-20 07:25:23 +00:00
|
|
|
Button {
|
|
|
|
anchors.bottom: buttonRow.top
|
|
|
|
anchors.right: parent.right
|
|
|
|
width: 120
|
|
|
|
display: AbstractButton.TextUnderIcon
|
|
|
|
icon.name: "media-playback-start"
|
|
|
|
text: Backend.translate("Create Room")
|
|
|
|
onClicked: {
|
|
|
|
lobby_dialog.source = "LobbyElement/CreateRoom.qml";
|
|
|
|
lobby_drawer.open();
|
|
|
|
config.observing = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-20 06:53:56 +00:00
|
|
|
RowLayout {
|
2023-03-20 07:25:23 +00:00
|
|
|
id: buttonRow
|
2023-03-20 06:53:56 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
Button {
|
|
|
|
text: Backend.translate("Generals Overview")
|
|
|
|
onClicked: {
|
|
|
|
mainStack.push(mainWindow.generalsOverviewPage);
|
|
|
|
mainStack.currentItem.loadPackages();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Button {
|
|
|
|
text: Backend.translate("Cards Overview")
|
|
|
|
onClicked: {
|
|
|
|
mainStack.push(mainWindow.cardsOverviewPage);
|
|
|
|
mainStack.currentItem.loadPackages();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Button {
|
|
|
|
text: Backend.translate("Scenarios Overview")
|
|
|
|
onClicked: {
|
|
|
|
mainStack.push(mainWindow.modesOverviewPage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Button {
|
|
|
|
text: Backend.translate("Replay")
|
|
|
|
}
|
|
|
|
Button {
|
|
|
|
text: Backend.translate("About")
|
|
|
|
onClicked: {
|
|
|
|
mainStack.push(mainWindow.aboutPage);
|
|
|
|
}
|
|
|
|
}
|
2023-03-20 07:25:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
|
|
|
anchors.right: parent.right
|
|
|
|
text: Backend.translate("Exit Lobby")
|
|
|
|
display: AbstractButton.TextBesideIcon
|
|
|
|
icon.name: "application-exit"
|
|
|
|
onClicked: {
|
|
|
|
toast.show("Goodbye.");
|
|
|
|
Backend.quitLobby();
|
|
|
|
mainStack.pop();
|
2023-03-20 06:53:56 +00:00
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
}
|
2022-03-01 05:18:00 +00:00
|
|
|
|
2023-02-15 11:54:35 +00: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 07:27:56 +00:00
|
|
|
|
2023-02-15 11:54:35 +00:00
|
|
|
Loader {
|
|
|
|
id: lobby_dialog
|
2023-03-14 06:12:13 +00:00
|
|
|
anchors.fill: parent
|
2023-02-15 11:54:35 +00:00
|
|
|
onSourceChanged: {
|
|
|
|
if (item === null)
|
|
|
|
return;
|
|
|
|
item.finished.connect(() => {
|
|
|
|
source = "";
|
|
|
|
lobby_drawer.close();
|
|
|
|
});
|
|
|
|
}
|
2022-04-30 07:27:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-05 07:13:58 +00:00
|
|
|
property int lobbyPlayerNum: 0
|
|
|
|
property int serverPlayerNum: 0
|
|
|
|
|
|
|
|
function updateOnlineInfo() {
|
|
|
|
}
|
|
|
|
|
|
|
|
onLobbyPlayerNumChanged: updateOnlineInfo();
|
|
|
|
onServerPlayerNumChanged: updateOnlineInfo();
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: info
|
|
|
|
color: "#88EEEEEE"
|
|
|
|
width: childrenRect.width + 8
|
|
|
|
height: childrenRect.height + 4
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.left: parent.left
|
|
|
|
radius: 4
|
|
|
|
|
|
|
|
Text {
|
|
|
|
x: 4; y: 2
|
|
|
|
font.pixelSize: 16
|
|
|
|
text: Backend.translate("$OnlineInfo")
|
|
|
|
.arg(lobbyPlayerNum).arg(serverPlayerNum) + "\n"
|
|
|
|
+ "Powered by FreeKill " + FkVersion
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ChatBox {
|
|
|
|
id: lobbyChat
|
|
|
|
anchors.bottom: info.top
|
|
|
|
width: info.width
|
|
|
|
height: root.height * 0.6
|
|
|
|
isLobby: true
|
|
|
|
color: "#88EEEEEE"
|
|
|
|
radius: 4
|
|
|
|
}
|
|
|
|
|
|
|
|
function addToChat(pid, raw, msg) {
|
|
|
|
if (raw.type !== 1) return;
|
|
|
|
lobbyChat.append(msg);
|
|
|
|
toast.show("<b>" + raw.userName + "</b>: " + raw.msg);
|
|
|
|
}
|
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
Component.onCompleted: {
|
2022-05-01 10:37:13 +00:00
|
|
|
toast.show(Backend.translate("$WelcomeToLobby"));
|
2022-04-30 07:27:56 +00:00
|
|
|
}
|
2022-01-24 02:23:08 +00:00
|
|
|
}
|
|
|
|
|