From 417ec49de9c6b86849029b07de5efbe9d09af684 Mon Sep 17 00:00:00 2001 From: notify Date: Fri, 28 Apr 2023 19:19:45 +0800 Subject: [PATCH] update freeassign --- lua/client/i18n/zh_CN.lua | 1 + qml/Pages/LobbyElement/AudioSetting.qml | 2 +- .../LobbyElement/RoomGeneralSettings.qml | 4 +- .../LobbyElement/RoomPackageSettings.qml | 2 +- qml/Pages/RoomElement/Cheat/FreeAssign.qml | 114 ++++++++++++++---- src/ui/qmlbackend.cpp | 1 - 6 files changed, 94 insertions(+), 30 deletions(-) diff --git a/lua/client/i18n/zh_CN.lua b/lua/client/i18n/zh_CN.lua index b0f38e16..811e0532 100644 --- a/lua/client/i18n/zh_CN.lua +++ b/lua/client/i18n/zh_CN.lua @@ -23,6 +23,7 @@ Fk:loadTranslationTable{ ["BG Settings"] = "游戏背景", ["Audio Settings"] = "音频", ["Disable message audio"] = "禁用聊天语音", + ["Back"] = "返回", ["Create Room"] = "创建房间", ["Room Name"] = "房间名字", diff --git a/qml/Pages/LobbyElement/AudioSetting.qml b/qml/Pages/LobbyElement/AudioSetting.qml index ffa963f9..f7e45652 100644 --- a/qml/Pages/LobbyElement/AudioSetting.qml +++ b/qml/Pages/LobbyElement/AudioSetting.qml @@ -33,7 +33,7 @@ ColumnLayout { } } - CheckBox { + Switch { text: Backend.translate("Disable message audio") checked: config.disableMsgAudio onCheckedChanged: config.disableMsgAudio = checked; diff --git a/qml/Pages/LobbyElement/RoomGeneralSettings.qml b/qml/Pages/LobbyElement/RoomGeneralSettings.qml index 082ae5a4..3b0eb07b 100644 --- a/qml/Pages/LobbyElement/RoomGeneralSettings.qml +++ b/qml/Pages/LobbyElement/RoomGeneralSettings.qml @@ -79,13 +79,13 @@ ColumnLayout { } } - CheckBox { + Switch { id: freeAssignCheck checked: Debugging ? true : false text: Backend.translate("Enable free assign") } - CheckBox { + Switch { id: deputyCheck checked: Debugging ? true : false text: Backend.translate("Enable deputy general") diff --git a/qml/Pages/LobbyElement/RoomPackageSettings.qml b/qml/Pages/LobbyElement/RoomPackageSettings.qml index d12414f8..530a756f 100644 --- a/qml/Pages/LobbyElement/RoomPackageSettings.qml +++ b/qml/Pages/LobbyElement/RoomPackageSettings.qml @@ -21,7 +21,7 @@ Flickable { anchors.top: parent.top anchors.topMargin: 8 - CheckBox { + Switch { text: "禁用Lua拓展 (重启后生效)" } diff --git a/qml/Pages/RoomElement/Cheat/FreeAssign.qml b/qml/Pages/RoomElement/Cheat/FreeAssign.qml index 01004a85..410b17c1 100644 --- a/qml/Pages/RoomElement/Cheat/FreeAssign.qml +++ b/qml/Pages/RoomElement/Cheat/FreeAssign.qml @@ -3,41 +3,105 @@ import QtQuick import QtQuick.Controls import QtQuick.Layouts +import ".." Item { id: root anchors.fill: parent + property var generalModel property var extra_data: ({}) signal finish() - Flickable { - height: parent.height - width: generalButtons.width - anchors.centerIn: parent - contentHeight: generalButtons.height - ScrollBar.vertical: ScrollBar {} - ColumnLayout { - id: generalButtons - Repeater { - model: ListModel { - id: packages + ToolBar { + id: bar + width: parent.width + RowLayout { + anchors.fill: parent + ToolButton { + opacity: stack.depth > 1 ? 1 : 0 + Behavior on opacity { NumberAnimation { duration: 100 } } + text: Backend.translate("Back") + onClicked: stack.pop() + } + Label { + text: Backend.translate("Enable free assign") + elide: Label.ElideRight + horizontalAlignment: Qt.AlignHCenter + verticalAlignment: Qt.AlignVCenter + Layout.fillWidth: true + } + ToolButton { + opacity: 0 + } + } + } + + StackView { + id: stack + width: parent.width + height: parent.height - bar.height + anchors.top: bar.bottom + initialItem: pkgList + } + + ListModel { + id: packages + } + + Component { + id: pkgList + GridView { + id: listView + width: parent.width + height: stack.height + ScrollBar.vertical: ScrollBar {} + model: packages + clip: true + cellWidth: width / 3 + cellHeight: 40 + + delegate: ItemDelegate { + width: listView.width / 3 + height: 40 + + Text { + text: Backend.translate(name) + anchors.centerIn: parent } - ColumnLayout { - Text { text: Backend.translate(name) } - GridLayout { - columns: 5 - Repeater { - model: JSON.parse(Backend.callLuaFunction("GetGenerals", [name])) - Button { - text: Backend.translate(modelData) - onClicked: { - extra_data.card.name = modelData; - root.finish(); - } - } - } + onClicked: { + generalModel = JSON.parse(Backend.callLuaFunction("GetGenerals", + [packages.get(index).name])); + stack.push(generalList); + } + } + } + } + + Component { + id: generalList + ColumnLayout { + clip: true + width: stack.width + height: stack.height + Item { height: 6 } + GridView { + Layout.preferredWidth: stack.width - stack.width % 100 + 10 + Layout.fillHeight: true + Layout.alignment: Qt.AlignHCenter + model: generalModel + ScrollBar.vertical: ScrollBar {} + + cellHeight: 140 + cellWidth: 100 + + delegate: GeneralCardItem { + autoBack: false + name: modelData + onClicked: { + extra_data.card.name = modelData; + root.finish(); } } } diff --git a/src/ui/qmlbackend.cpp b/src/ui/qmlbackend.cpp index 797a6bfb..3d6dc1c9 100644 --- a/src/ui/qmlbackend.cpp +++ b/src/ui/qmlbackend.cpp @@ -263,7 +263,6 @@ void QmlBackend::playSound(const QString &name, int index) { auto output = new QAudioOutput; player->setAudioOutput(output); player->setSource(QUrl::fromLocalFile(fname)); - qDebug() << m_volume; output->setVolume(m_volume / 100); connect(player, &QMediaPlayer::playbackStateChanged, this, [=]() { if (player->playbackState() == QMediaPlayer::StoppedState) {