2023-04-09 05:35:35 +00:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-03-14 06:12:13 +00:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
RowLayout {
|
|
|
|
anchors.rightMargin: 8
|
|
|
|
spacing: 16
|
|
|
|
Text {
|
|
|
|
text: Backend.translate("Room Name")
|
|
|
|
}
|
|
|
|
TextField {
|
|
|
|
id: roomName
|
2023-04-30 10:51:05 +00:00
|
|
|
maximumLength: 64
|
2023-03-14 06:12:13 +00:00
|
|
|
font.pixelSize: 18
|
|
|
|
text: Backend.translate("$RoomName").arg(Self.screenName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
anchors.rightMargin: 8
|
|
|
|
spacing: 16
|
|
|
|
Text {
|
|
|
|
text: Backend.translate("Player num")
|
|
|
|
}
|
|
|
|
SpinBox {
|
|
|
|
id: playerNum
|
|
|
|
from: 2
|
|
|
|
to: 8
|
2023-03-20 06:53:56 +00:00
|
|
|
value: config.preferedPlayerNum
|
2023-03-14 06:12:13 +00:00
|
|
|
|
|
|
|
onValueChanged: {
|
|
|
|
config.preferedPlayerNum = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
anchors.rightMargin: 8
|
|
|
|
spacing: 16
|
|
|
|
Text {
|
|
|
|
text: Backend.translate("Game Mode")
|
|
|
|
}
|
|
|
|
ComboBox {
|
|
|
|
id: gameModeCombo
|
|
|
|
textRole: "name"
|
|
|
|
model: ListModel {
|
|
|
|
id: gameModeList
|
|
|
|
}
|
|
|
|
|
|
|
|
onCurrentIndexChanged: {
|
|
|
|
let data = gameModeList.get(currentIndex);
|
|
|
|
playerNum.from = data.minPlayer;
|
|
|
|
playerNum.to = data.maxPlayer;
|
|
|
|
|
|
|
|
config.preferedMode = data.orig_name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-20 06:53:56 +00:00
|
|
|
RowLayout {
|
|
|
|
anchors.rightMargin: 8
|
|
|
|
spacing: 16
|
|
|
|
Text {
|
|
|
|
text: Backend.translate("Select general num")
|
|
|
|
}
|
|
|
|
SpinBox {
|
|
|
|
id: generalNum
|
|
|
|
from: 3
|
2023-04-30 10:51:05 +00:00
|
|
|
to: 18
|
2023-03-20 06:53:56 +00:00
|
|
|
value: config.preferredGeneralNum
|
|
|
|
|
|
|
|
onValueChanged: {
|
|
|
|
config.preferredGeneralNum = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-30 10:54:23 +00:00
|
|
|
RowLayout {
|
|
|
|
anchors.rightMargin: 8
|
|
|
|
spacing: 16
|
|
|
|
Text {
|
|
|
|
text: Backend.translate("Operation timeout")
|
|
|
|
}
|
|
|
|
SpinBox {
|
|
|
|
from: 10
|
|
|
|
to: 60
|
|
|
|
editable: true
|
|
|
|
value: config.preferredTimeout
|
|
|
|
|
|
|
|
onValueChanged: {
|
|
|
|
config.preferredTimeout = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-18 23:45:21 +00:00
|
|
|
RowLayout {
|
|
|
|
anchors.rightMargin: 8
|
|
|
|
spacing: 16
|
|
|
|
Text {
|
|
|
|
text: Backend.translate("Luck Card Times")
|
|
|
|
}
|
|
|
|
SpinBox {
|
|
|
|
from: 0
|
|
|
|
to: 8
|
|
|
|
value: config.preferredLuckTime
|
|
|
|
|
|
|
|
onValueChanged: {
|
|
|
|
config.preferredLuckTime = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-28 11:19:45 +00:00
|
|
|
Switch {
|
2023-03-14 06:12:13 +00:00
|
|
|
id: freeAssignCheck
|
|
|
|
checked: Debugging ? true : false
|
|
|
|
text: Backend.translate("Enable free assign")
|
|
|
|
}
|
|
|
|
|
2023-04-28 11:19:45 +00:00
|
|
|
Switch {
|
2023-04-19 06:07:16 +00:00
|
|
|
id: deputyCheck
|
|
|
|
checked: Debugging ? true : false
|
|
|
|
text: Backend.translate("Enable deputy general")
|
|
|
|
}
|
|
|
|
|
2023-03-14 06:12:13 +00:00
|
|
|
RowLayout {
|
|
|
|
anchors.rightMargin: 8
|
|
|
|
spacing: 16
|
|
|
|
Button {
|
|
|
|
text: Backend.translate("OK")
|
|
|
|
onClicked: {
|
|
|
|
root.finished();
|
|
|
|
mainWindow.busy = true;
|
2023-05-13 06:20:48 +00:00
|
|
|
|
|
|
|
let disabledGenerals = config.disabledGenerals.slice();
|
|
|
|
if (disabledGenerals.length) {
|
|
|
|
const availablePack = JSON.parse(Backend.callLuaFunction("GetAllGeneralPack", [])).
|
|
|
|
filter((pack) => !config.disabledPack.includes(pack));
|
|
|
|
disabledGenerals = disabledGenerals.filter((general) => {
|
|
|
|
return availablePack.find((pack) => JSON.parse(Backend.callLuaFunction("GetGenerals", [pack])).includes(general));
|
|
|
|
});
|
|
|
|
|
|
|
|
disabledGenerals = Array.from(new Set(disabledGenerals));
|
|
|
|
}
|
|
|
|
|
2023-03-14 06:12:13 +00:00
|
|
|
ClientInstance.notifyServer(
|
|
|
|
"CreateRoom",
|
2023-04-30 10:54:23 +00:00
|
|
|
JSON.stringify([roomName.text, playerNum.value, config.preferredTimeout, {
|
2023-03-14 06:12:13 +00:00
|
|
|
enableFreeAssign: freeAssignCheck.checked,
|
2023-04-19 06:07:16 +00:00
|
|
|
enableDeputy: deputyCheck.checked,
|
2023-03-14 06:12:13 +00:00
|
|
|
gameMode: config.preferedMode,
|
|
|
|
disabledPack: config.disabledPack,
|
2023-03-20 06:53:56 +00:00
|
|
|
generalNum: config.preferredGeneralNum,
|
2023-05-18 23:45:21 +00:00
|
|
|
luckTime: config.preferredLuckTime,
|
2023-05-13 06:20:48 +00:00
|
|
|
disabledGenerals,
|
2023-03-14 06:12:13 +00:00
|
|
|
}])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Button {
|
|
|
|
text: Backend.translate("Cancel")
|
|
|
|
onClicked: {
|
|
|
|
root.finished();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
let mode_data = JSON.parse(Backend.callLuaFunction("GetGameModes", []));
|
|
|
|
let i = 0;
|
|
|
|
for (let d of mode_data) {
|
|
|
|
gameModeList.append(d);
|
|
|
|
if (d.orig_name == config.preferedMode) {
|
|
|
|
gameModeCombo.currentIndex = i;
|
|
|
|
}
|
|
|
|
i += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
playerNum.value = config.preferedPlayerNum;
|
|
|
|
}
|
|
|
|
}
|