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-05-19 02:08:36 +00:00
|
|
|
import Fk.LobbyElement
|
|
|
|
import Fk.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
|
2023-05-13 06:20:48 +00:00
|
|
|
|
2023-05-27 13:58:32 +00:00
|
|
|
property string password
|
|
|
|
|
2023-05-13 06:20:48 +00:00
|
|
|
Rectangle {
|
2023-07-02 05:21:13 +00:00
|
|
|
width: parent.width / 2 - roomListLayout.width / 2 - 50
|
2023-05-13 06:20:48 +00:00
|
|
|
height: parent.height * 0.7
|
|
|
|
anchors.top: exitButton.bottom
|
|
|
|
anchors.bottom: createRoomButton.top
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 20
|
|
|
|
color: "#88EEEEEE"
|
|
|
|
radius: 6
|
|
|
|
|
|
|
|
Flickable {
|
|
|
|
id: flickableContainer
|
|
|
|
ScrollBar.vertical: ScrollBar {}
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 10
|
|
|
|
flickableDirection: Flickable.VerticalFlick
|
|
|
|
width: parent.width - 10
|
|
|
|
height: parent.height - 10
|
2023-06-04 12:00:35 +00:00
|
|
|
contentHeight: bulletin_info.height
|
2023-05-13 06:20:48 +00:00
|
|
|
clip: true
|
|
|
|
|
|
|
|
Text {
|
2023-06-04 12:00:35 +00:00
|
|
|
id: bulletin_info
|
|
|
|
width: parent.width
|
2023-06-09 18:18:51 +00:00
|
|
|
wrapMode: TextEdit.WordWrap
|
2023-06-04 12:00:35 +00:00
|
|
|
textFormat: Text.MarkdownText
|
2023-08-03 07:24:17 +00:00
|
|
|
text: config.serverMotd + "\n___\n" + Backend.translate('Bulletin Info')
|
2023-05-13 06:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-30 07:27:56 +00:00
|
|
|
Component {
|
|
|
|
id: roomDelegate
|
2022-01-24 02:23:08 +00:00
|
|
|
|
2022-05-01 10:37:13 +00:00
|
|
|
Item {
|
2023-05-27 13:58:32 +00:00
|
|
|
height: 48
|
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
|
2023-05-27 13:58:32 +00:00
|
|
|
color: "grey"
|
2022-05-01 10:37:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
2023-05-27 13:58:32 +00:00
|
|
|
horizontalAlignment: Text.AlignLeft
|
2022-05-01 10:37:13 +00:00
|
|
|
Layout.fillWidth: true
|
2023-07-11 15:16:46 +00:00
|
|
|
text: (hasPassword ? Backend.translate("Has Password") : "") + roomName
|
2023-05-27 13:58:32 +00:00
|
|
|
font.pixelSize: 20
|
2023-07-11 15:16:46 +00:00
|
|
|
elide: Label.ElideRight
|
2022-05-01 10:37:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
2023-05-27 13:58:32 +00:00
|
|
|
text: Backend.translate(gameMode)
|
2022-05-01 10:37:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
color: (playerNum == capacity) ? "red" : "black"
|
|
|
|
text: playerNum + "/" + capacity
|
2023-05-27 13:58:32 +00:00
|
|
|
font.pixelSize: 20
|
|
|
|
font.bold: true
|
2022-05-01 10:37:13 +00:00
|
|
|
}
|
2023-02-15 11:54:35 +00:00
|
|
|
|
2023-05-27 13:58:32 +00:00
|
|
|
Button {
|
|
|
|
text: (playerNum < capacity) ? Backend.translate("Enter") :
|
|
|
|
Backend.translate("Observe")
|
2023-02-15 11:54:35 +00:00
|
|
|
|
2023-05-27 13:58:32 +00:00
|
|
|
onClicked: {
|
|
|
|
if (hasPassword) {
|
|
|
|
lobby_dialog.sourceComponent = enterPassword;
|
|
|
|
lobby_dialog.item.roomId = roomId;
|
|
|
|
lobby_dialog.item.playerNum = playerNum;
|
|
|
|
lobby_dialog.item.capacity = capacity;
|
|
|
|
lobby_drawer.open();
|
|
|
|
} else {
|
|
|
|
enterRoom(roomId, playerNum, capacity, "");
|
2023-02-15 11:54:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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 {
|
|
|
|
}
|
|
|
|
|
2023-07-02 05:21:13 +00:00
|
|
|
Timer {
|
|
|
|
id: opTimer
|
|
|
|
interval: 1000
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
2023-05-13 06:20:48 +00:00
|
|
|
id: roomListLayout
|
2023-07-02 05:21:13 +00:00
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 10
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
width: root.width * 0.48
|
|
|
|
height: root.height - 80
|
|
|
|
Button {
|
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
text: Backend.translate("Refresh Room List")
|
|
|
|
enabled: !opTimer.running
|
|
|
|
onClicked: {
|
|
|
|
opTimer.start();
|
|
|
|
ClientInstance.notifyServer("RefreshRoomList", "");
|
|
|
|
}
|
|
|
|
}
|
2022-05-01 10:37:13 +00:00
|
|
|
Item {
|
2023-07-02 05:21:13 +00:00
|
|
|
Layout.fillWidth: true
|
2022-04-30 07:27:56 +00:00
|
|
|
Layout.fillHeight: true
|
2022-05-01 10:37:13 +00:00
|
|
|
Rectangle {
|
2023-07-02 05:21:13 +00:00
|
|
|
anchors.fill: parent
|
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
|
2023-06-16 15:53:44 +00:00
|
|
|
clip: true
|
2022-05-01 10:37:13 +00:00
|
|
|
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 {
|
2023-05-13 06:20:48 +00:00
|
|
|
id: createRoomButton
|
2023-03-20 07:25:23 +00:00
|
|
|
anchors.bottom: buttonRow.top
|
|
|
|
anchors.right: parent.right
|
|
|
|
width: 120
|
|
|
|
display: AbstractButton.TextUnderIcon
|
|
|
|
icon.name: "media-playback-start"
|
|
|
|
text: Backend.translate("Create Room")
|
|
|
|
onClicked: {
|
2023-05-20 08:00:03 +00:00
|
|
|
lobby_dialog.sourceComponent = Qt.createComponent("../LobbyElement/CreateRoom.qml");
|
2023-03-20 07:25:23 +00:00
|
|
|
lobby_drawer.open();
|
|
|
|
config.observing = false;
|
2023-08-01 13:01:01 +00:00
|
|
|
config.replaying = false;
|
2023-03-20 07:25:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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")
|
2023-08-01 13:01:01 +00:00
|
|
|
onClicked: {
|
|
|
|
mainStack.push(mainWindow.replayPage);
|
|
|
|
}
|
2023-03-20 06:53:56 +00:00
|
|
|
}
|
|
|
|
Button {
|
|
|
|
text: Backend.translate("About")
|
|
|
|
onClicked: {
|
|
|
|
mainStack.push(mainWindow.aboutPage);
|
|
|
|
}
|
|
|
|
}
|
2023-03-20 07:25:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
2023-05-13 06:20:48 +00:00
|
|
|
id: exitButton
|
2023-03-20 07:25:23 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
text: Backend.translate("Exit Lobby")
|
|
|
|
display: AbstractButton.TextBesideIcon
|
|
|
|
icon.name: "application-exit"
|
|
|
|
onClicked: {
|
|
|
|
toast.show("Goodbye.");
|
|
|
|
mainStack.pop();
|
2023-06-10 15:55:39 +00:00
|
|
|
config.saveConf();
|
2023-05-19 08:23:24 +00:00
|
|
|
Backend.quitLobby();
|
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(() => {
|
2023-05-19 02:08:36 +00:00
|
|
|
sourceComponent = undefined;
|
2023-02-15 11:54:35 +00:00
|
|
|
lobby_drawer.close();
|
|
|
|
});
|
|
|
|
}
|
2023-05-19 02:08:36 +00:00
|
|
|
onSourceComponentChanged: sourceChanged();
|
2022-04-30 07:27:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-27 13:58:32 +00:00
|
|
|
Component {
|
|
|
|
id: enterPassword
|
|
|
|
ColumnLayout {
|
|
|
|
property int roomId
|
|
|
|
property int playerNum
|
|
|
|
property int capacity
|
|
|
|
signal finished()
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: 16
|
|
|
|
|
|
|
|
Text {
|
|
|
|
text: Backend.translate("Please input room's password")
|
|
|
|
}
|
|
|
|
|
|
|
|
TextField {
|
|
|
|
id: passwordEdit
|
|
|
|
onTextChanged: root.password = text;
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
|
|
|
text: "OK"
|
|
|
|
onClicked: {
|
|
|
|
enterRoom(roomId, playerNum, capacity, root.password);
|
|
|
|
parent.finished();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
passwordEdit.text = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function enterRoom(roomId, playerNum, capacity, pw) {
|
2023-08-01 13:01:01 +00:00
|
|
|
config.replaying = false;
|
2023-05-27 13:58:32 +00:00
|
|
|
if (playerNum < capacity) {
|
|
|
|
config.observing = false;
|
2023-06-27 08:50:24 +00:00
|
|
|
Backend.callLuaFunction("SetObserving", [false]);
|
2023-05-27 13:58:32 +00:00
|
|
|
mainWindow.busy = true;
|
|
|
|
ClientInstance.notifyServer(
|
|
|
|
"EnterRoom",
|
|
|
|
JSON.stringify([roomId, pw])
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
config.observing = true;
|
2023-06-27 08:50:24 +00:00
|
|
|
Backend.callLuaFunction("SetObserving", [true]);
|
2023-05-27 13:58:32 +00:00
|
|
|
mainWindow.busy = true;
|
|
|
|
ClientInstance.notifyServer(
|
|
|
|
"ObserveRoom",
|
|
|
|
JSON.stringify([roomId, pw])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2023-04-18 15:26:15 +00:00
|
|
|
Danmaku {
|
|
|
|
id: danmaku
|
|
|
|
width: parent.width
|
|
|
|
}
|
|
|
|
|
2023-04-05 07:13:58 +00:00
|
|
|
function addToChat(pid, raw, msg) {
|
|
|
|
if (raw.type !== 1) return;
|
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-05 07:13:58 +00:00
|
|
|
lobbyChat.append(msg);
|
2023-04-18 15:26:15 +00:00
|
|
|
danmaku.sendLog("<b>" + raw.userName + "</b>: " + raw.msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
function sendDanmaku(msg) {
|
|
|
|
danmaku.sendLog(msg);
|
2023-04-20 10:15:18 +00:00
|
|
|
lobbyChat.append(msg);
|
2023-04-05 07:13:58 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|