update freeassign

This commit is contained in:
notify 2023-04-28 19:19:45 +08:00
parent 432bd5df4d
commit 417ec49de9
6 changed files with 94 additions and 30 deletions

View File

@ -23,6 +23,7 @@ Fk:loadTranslationTable{
["BG Settings"] = "游戏背景",
["Audio Settings"] = "音频",
["Disable message audio"] = "禁用聊天语音",
["Back"] = "返回",
["Create Room"] = "创建房间",
["Room Name"] = "房间名字",

View File

@ -33,7 +33,7 @@ ColumnLayout {
}
}
CheckBox {
Switch {
text: Backend.translate("Disable message audio")
checked: config.disableMsgAudio
onCheckedChanged: config.disableMsgAudio = checked;

View File

@ -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")

View File

@ -21,7 +21,7 @@ Flickable {
anchors.top: parent.top
anchors.topMargin: 8
CheckBox {
Switch {
text: "禁用Lua拓展 (重启后生效)"
}

View File

@ -3,35 +3,102 @@
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 {
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
}
onClicked: {
generalModel = JSON.parse(Backend.callLuaFunction("GetGenerals",
[packages.get(index).name]));
stack.push(generalList);
}
}
}
}
Component {
id: generalList
ColumnLayout {
Text { text: Backend.translate(name) }
GridLayout {
columns: 5
Repeater {
model: JSON.parse(Backend.callLuaFunction("GetGenerals", [name]))
Button {
text: Backend.translate(modelData)
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();
@ -40,9 +107,6 @@ Item {
}
}
}
}
}
}
function load() {
let packs = JSON.parse(Backend.callLuaFunction("GetAllGeneralPack", []));

View File

@ -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) {