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
|
|
|
|
|
|
2023-06-04 11:31:44 +00:00
|
|
|
|
Flickable {
|
|
|
|
|
flickableDirection: Flickable.AutoFlickIfNeeded
|
|
|
|
|
clip: true
|
|
|
|
|
contentHeight: layout.height
|
|
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
|
id: layout
|
|
|
|
|
RowLayout {
|
|
|
|
|
anchors.rightMargin: 8
|
|
|
|
|
spacing: 16
|
|
|
|
|
Text {
|
|
|
|
|
text: Backend.translate("Room Name")
|
|
|
|
|
}
|
|
|
|
|
TextField {
|
|
|
|
|
id: roomName
|
|
|
|
|
maximumLength: 64
|
|
|
|
|
font.pixelSize: 18
|
|
|
|
|
text: Backend.translate("$RoomName").arg(Self.screenName)
|
|
|
|
|
}
|
2023-03-14 06:12:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-04 11:31:44 +00:00
|
|
|
|
RowLayout {
|
|
|
|
|
anchors.rightMargin: 8
|
|
|
|
|
spacing: 16
|
|
|
|
|
Text {
|
|
|
|
|
text: Backend.translate("Player num")
|
|
|
|
|
}
|
|
|
|
|
SpinBox {
|
|
|
|
|
id: playerNum
|
|
|
|
|
from: 2
|
|
|
|
|
to: 8
|
|
|
|
|
value: config.preferedPlayerNum
|
|
|
|
|
|
|
|
|
|
onValueChanged: {
|
|
|
|
|
config.preferedPlayerNum = value;
|
|
|
|
|
}
|
2023-03-14 06:12:13 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-04 11:31:44 +00:00
|
|
|
|
RowLayout {
|
|
|
|
|
anchors.rightMargin: 8
|
|
|
|
|
spacing: 16
|
|
|
|
|
Text {
|
|
|
|
|
text: Backend.translate("Game Mode")
|
2023-03-14 06:12:13 +00:00
|
|
|
|
}
|
2023-06-04 11:31:44 +00:00
|
|
|
|
ComboBox {
|
|
|
|
|
id: gameModeCombo
|
|
|
|
|
textRole: "name"
|
|
|
|
|
model: ListModel {
|
|
|
|
|
id: gameModeList
|
|
|
|
|
}
|
2023-03-14 06:12:13 +00:00
|
|
|
|
|
2023-06-04 11:31:44 +00:00
|
|
|
|
onCurrentIndexChanged: {
|
2023-06-09 09:23:02 +00:00
|
|
|
|
const data = gameModeList.get(currentIndex);
|
2023-06-04 11:31:44 +00:00
|
|
|
|
playerNum.from = data.minPlayer;
|
|
|
|
|
playerNum.to = data.maxPlayer;
|
2023-03-14 06:12:13 +00:00
|
|
|
|
|
2023-06-04 11:31:44 +00:00
|
|
|
|
config.preferedMode = data.orig_name;
|
|
|
|
|
}
|
2023-03-14 06:12:13 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-04 11:31:44 +00:00
|
|
|
|
RowLayout {
|
|
|
|
|
anchors.rightMargin: 8
|
|
|
|
|
spacing: 16
|
|
|
|
|
Text {
|
2023-06-15 13:19:57 +00:00
|
|
|
|
text: Backend.translate("Select generals num")
|
2023-06-04 11:31:44 +00:00
|
|
|
|
}
|
|
|
|
|
SpinBox {
|
|
|
|
|
id: generalNum
|
|
|
|
|
from: 3
|
|
|
|
|
to: 18
|
|
|
|
|
value: config.preferredGeneralNum
|
|
|
|
|
|
|
|
|
|
onValueChanged: {
|
|
|
|
|
config.preferredGeneralNum = value;
|
|
|
|
|
}
|
2023-03-20 06:53:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-04-30 10:54:23 +00:00
|
|
|
|
|
2023-06-15 13:19:57 +00:00
|
|
|
|
Text {
|
|
|
|
|
id: warning
|
|
|
|
|
anchors.rightMargin: 8
|
2023-06-16 05:26:02 +00:00
|
|
|
|
visible: {
|
|
|
|
|
config.disabledPack; // 没什么用,只是为了禁包刷新时刷新visible罢了
|
2023-06-17 02:45:53 +00:00
|
|
|
|
const avail = JSON.parse(Backend.callLuaFunction("GetAvailableGeneralsNum", []));
|
2023-06-16 05:26:02 +00:00
|
|
|
|
const ret = avail < config.preferredGeneralNum * config.preferedPlayerNum;
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
2023-06-15 13:19:57 +00:00
|
|
|
|
text: Backend.translate("No enough generals")
|
|
|
|
|
color: "red"
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-04 11:31:44 +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-04-30 10:54:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-04 11:31:44 +00:00
|
|
|
|
RowLayout {
|
|
|
|
|
anchors.rightMargin: 8
|
|
|
|
|
spacing: 16
|
|
|
|
|
Text {
|
|
|
|
|
text: Backend.translate("Luck Card Times")
|
|
|
|
|
}
|
|
|
|
|
SpinBox {
|
|
|
|
|
from: 0
|
|
|
|
|
to: 8
|
|
|
|
|
value: config.preferredLuckTime
|
2023-05-18 23:45:21 +00:00
|
|
|
|
|
2023-06-04 11:31:44 +00:00
|
|
|
|
onValueChanged: {
|
|
|
|
|
config.preferredLuckTime = value;
|
|
|
|
|
}
|
2023-05-18 23:45:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-04 11:31:44 +00:00
|
|
|
|
RowLayout {
|
|
|
|
|
anchors.rightMargin: 8
|
|
|
|
|
spacing: 16
|
|
|
|
|
Text {
|
|
|
|
|
text: Backend.translate("Room Password")
|
|
|
|
|
}
|
|
|
|
|
TextField {
|
|
|
|
|
id: roomPassword
|
|
|
|
|
maximumLength: 16
|
|
|
|
|
font.pixelSize: 18
|
|
|
|
|
}
|
2023-05-27 13:58:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-04 11:31:44 +00:00
|
|
|
|
Switch {
|
|
|
|
|
id: freeAssignCheck
|
|
|
|
|
checked: Debugging ? true : false
|
|
|
|
|
text: Backend.translate("Enable free assign")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Switch {
|
|
|
|
|
id: deputyCheck
|
|
|
|
|
checked: Debugging ? true : false
|
|
|
|
|
text: Backend.translate("Enable deputy general")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
|
anchors.rightMargin: 8
|
|
|
|
|
spacing: 16
|
|
|
|
|
Button {
|
|
|
|
|
text: Backend.translate("OK")
|
2023-06-15 13:19:57 +00:00
|
|
|
|
enabled: !(warning.visible)
|
2023-06-04 11:31:44 +00:00
|
|
|
|
onClicked: {
|
2023-06-16 05:26:02 +00:00
|
|
|
|
config.saveConf();
|
2023-06-04 11:31:44 +00:00
|
|
|
|
root.finished();
|
|
|
|
|
mainWindow.busy = true;
|
|
|
|
|
|
|
|
|
|
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-08-03 07:24:17 +00:00
|
|
|
|
let disabledPack = config.disabledPack.slice();
|
|
|
|
|
config.serverHiddenPacks.forEach(p => {
|
|
|
|
|
if (!disabledPack.includes(p)) {
|
|
|
|
|
disabledPack.push(p);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
const generalPacks = JSON.parse(Backend.callLuaFunction("GetAllGeneralPack", []));
|
|
|
|
|
for (let pk of generalPacks) {
|
|
|
|
|
if (disabledPack.includes(pk)) continue;
|
|
|
|
|
let generals = JSON.parse(Backend.callLuaFunction("GetGenerals", [pk]));
|
|
|
|
|
let t = generals.filter(g => !disabledGenerals.includes(g));
|
|
|
|
|
if (t.length === 0) {
|
|
|
|
|
disabledPack.push(pk);
|
|
|
|
|
disabledGenerals = disabledGenerals.filter(g1 => !generals.includes(g1));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-04 11:31:44 +00:00
|
|
|
|
ClientInstance.notifyServer(
|
|
|
|
|
"CreateRoom",
|
|
|
|
|
JSON.stringify([roomName.text, playerNum.value, config.preferredTimeout, {
|
|
|
|
|
enableFreeAssign: freeAssignCheck.checked,
|
|
|
|
|
enableDeputy: deputyCheck.checked,
|
|
|
|
|
gameMode: config.preferedMode,
|
2023-08-03 07:24:17 +00:00
|
|
|
|
disabledPack: disabledPack,
|
2023-06-04 11:31:44 +00:00
|
|
|
|
generalNum: config.preferredGeneralNum,
|
|
|
|
|
luckTime: config.preferredLuckTime,
|
|
|
|
|
password: roomPassword.text,
|
|
|
|
|
disabledGenerals,
|
|
|
|
|
}])
|
|
|
|
|
);
|
2023-05-13 06:20:48 +00:00
|
|
|
|
}
|
2023-03-14 06:12:13 +00:00
|
|
|
|
}
|
2023-06-04 11:31:44 +00:00
|
|
|
|
Button {
|
|
|
|
|
text: Backend.translate("Cancel")
|
|
|
|
|
onClicked: {
|
|
|
|
|
root.finished();
|
|
|
|
|
}
|
2023-03-14 06:12:13 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-04 11:31:44 +00:00
|
|
|
|
Component.onCompleted: {
|
2023-06-09 09:23:02 +00:00
|
|
|
|
const mode_data = JSON.parse(Backend.callLuaFunction("GetGameModes", []));
|
2023-06-04 11:31:44 +00:00
|
|
|
|
let i = 0;
|
|
|
|
|
for (let d of mode_data) {
|
|
|
|
|
gameModeList.append(d);
|
|
|
|
|
if (d.orig_name == config.preferedMode) {
|
|
|
|
|
gameModeCombo.currentIndex = i;
|
|
|
|
|
}
|
|
|
|
|
i += 1;
|
2023-03-14 06:12:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-04 11:31:44 +00:00
|
|
|
|
playerNum.value = config.preferedPlayerNum;
|
2023-06-16 05:26:02 +00:00
|
|
|
|
|
|
|
|
|
config.disabledPack.forEach(p => {
|
|
|
|
|
Backend.callLuaFunction("UpdatePackageEnable", [p, false]);
|
|
|
|
|
});
|
|
|
|
|
config.disabledPackChanged();
|
2023-06-04 11:31:44 +00:00
|
|
|
|
}
|
2023-03-14 06:12:13 +00:00
|
|
|
|
}
|
|
|
|
|
}
|