volume cfg
This commit is contained in:
parent
930826e664
commit
432bd5df4d
|
@ -17,6 +17,12 @@ Fk:loadTranslationTable{
|
||||||
["Room BG"] = "房间背景",
|
["Room BG"] = "房间背景",
|
||||||
["Game BGM"] = "游戏BGM",
|
["Game BGM"] = "游戏BGM",
|
||||||
["Poster Girl"] = "看板娘",
|
["Poster Girl"] = "看板娘",
|
||||||
|
["BGM Volume"] = "BGM音量",
|
||||||
|
["Effect Volume"] = "音效音量",
|
||||||
|
["Userinfo Settings"] = "个人信息",
|
||||||
|
["BG Settings"] = "游戏背景",
|
||||||
|
["Audio Settings"] = "音频",
|
||||||
|
["Disable message audio"] = "禁用聊天语音",
|
||||||
|
|
||||||
["Create Room"] = "创建房间",
|
["Create Room"] = "创建房间",
|
||||||
["Room Name"] = "房间名字",
|
["Room Name"] = "房间名字",
|
||||||
|
|
|
@ -20,6 +20,8 @@ QtObject {
|
||||||
property int preferedPlayerNum
|
property int preferedPlayerNum
|
||||||
property int preferredGeneralNum
|
property int preferredGeneralNum
|
||||||
property string ladyImg
|
property string ladyImg
|
||||||
|
property real bgmVolume
|
||||||
|
property bool disableMsgAudio
|
||||||
|
|
||||||
// Player property of client
|
// Player property of client
|
||||||
property string serverAddr
|
property string serverAddr
|
||||||
|
@ -51,6 +53,9 @@ QtObject {
|
||||||
preferedPlayerNum = conf.preferedPlayerNum ?? 2;
|
preferedPlayerNum = conf.preferedPlayerNum ?? 2;
|
||||||
preferredGeneralNum = conf.preferredGeneralNum ?? 3;
|
preferredGeneralNum = conf.preferredGeneralNum ?? 3;
|
||||||
ladyImg = conf.ladyImg ?? AppPath + "/image/lady";
|
ladyImg = conf.ladyImg ?? AppPath + "/image/lady";
|
||||||
|
Backend.volume = conf.effectVolume ?? 50.;
|
||||||
|
bgmVolume = conf.bgmVolume ?? 50.;
|
||||||
|
disableMsgAudio = conf.disableMsgAudio ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveConf() {
|
function saveConf() {
|
||||||
|
@ -69,6 +74,9 @@ QtObject {
|
||||||
conf.preferedPlayerNum = preferedPlayerNum;
|
conf.preferedPlayerNum = preferedPlayerNum;
|
||||||
conf.ladyImg = ladyImg;
|
conf.ladyImg = ladyImg;
|
||||||
conf.preferredGeneralNum = preferredGeneralNum;
|
conf.preferredGeneralNum = preferredGeneralNum;
|
||||||
|
conf.effectVolume = Backend.volume;
|
||||||
|
conf.bgmVolume = bgmVolume;
|
||||||
|
conf.disableMsgAudio = disableMsgAudio;
|
||||||
|
|
||||||
Backend.saveConf(JSON.stringify(conf, undefined, 2));
|
Backend.saveConf(JSON.stringify(conf, undefined, 2));
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls
|
||||||
|
import QtQuick.Layouts
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
RowLayout {
|
||||||
|
anchors.rightMargin: 8
|
||||||
|
spacing: 16
|
||||||
|
Text {
|
||||||
|
text: Backend.translate("BGM Volume")
|
||||||
|
}
|
||||||
|
Slider {
|
||||||
|
from: 0
|
||||||
|
to: 100
|
||||||
|
value: config.bgmVolume
|
||||||
|
onValueChanged: config.bgmVolume = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
anchors.rightMargin: 8
|
||||||
|
spacing: 16
|
||||||
|
Text {
|
||||||
|
text: Backend.translate("Effect Volume")
|
||||||
|
}
|
||||||
|
Slider {
|
||||||
|
from: 0
|
||||||
|
to: 100
|
||||||
|
value: Backend.volume
|
||||||
|
onValueChanged: Backend.volume = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckBox {
|
||||||
|
text: Backend.translate("Disable message audio")
|
||||||
|
checked: config.disableMsgAudio
|
||||||
|
onCheckedChanged: config.disableMsgAudio = checked;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,103 @@
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import QtQuick.Dialogs
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
RowLayout {
|
||||||
|
anchors.rightMargin: 8
|
||||||
|
spacing: 16
|
||||||
|
Text {
|
||||||
|
text: Backend.translate("Lobby BG")
|
||||||
|
}
|
||||||
|
TextField {
|
||||||
|
text: config.lobbyBg
|
||||||
|
}
|
||||||
|
Button {
|
||||||
|
text: "..."
|
||||||
|
onClicked: {
|
||||||
|
fdialog.nameFilters = ["Image Files (*.jpg *.png)"];
|
||||||
|
fdialog.configKey = "lobbyBg";
|
||||||
|
fdialog.open();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
anchors.rightMargin: 8
|
||||||
|
spacing: 16
|
||||||
|
Text {
|
||||||
|
text: Backend.translate("Room BG")
|
||||||
|
}
|
||||||
|
TextField {
|
||||||
|
text: config.roomBg
|
||||||
|
}
|
||||||
|
Button {
|
||||||
|
text: "..."
|
||||||
|
onClicked: {
|
||||||
|
fdialog.nameFilters = ["Image Files (*.jpg *.png)"];
|
||||||
|
fdialog.configKey = "roomBg";
|
||||||
|
fdialog.open();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
anchors.rightMargin: 8
|
||||||
|
spacing: 16
|
||||||
|
Text {
|
||||||
|
text: Backend.translate("Game BGM")
|
||||||
|
}
|
||||||
|
TextField {
|
||||||
|
text: config.bgmFile
|
||||||
|
}
|
||||||
|
Button {
|
||||||
|
text: "..."
|
||||||
|
onClicked: {
|
||||||
|
fdialog.nameFilters = ["Music Files (*.mp3)"];
|
||||||
|
fdialog.configKey = "bgmFile";
|
||||||
|
fdialog.open();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
anchors.rightMargin: 8
|
||||||
|
spacing: 16
|
||||||
|
Text {
|
||||||
|
text: Backend.translate("Poster Girl")
|
||||||
|
}
|
||||||
|
TextField {
|
||||||
|
text: config.ladyImg
|
||||||
|
}
|
||||||
|
Button {
|
||||||
|
text: "..."
|
||||||
|
onClicked: {
|
||||||
|
fdialog.nameFilters = ["Image Files (*.jpg *.png)"];
|
||||||
|
fdialog.configKey = "ladyImg";
|
||||||
|
fdialog.open();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
anchors.rightMargin: 8
|
||||||
|
spacing: 16
|
||||||
|
Text {
|
||||||
|
text: "Language"
|
||||||
|
}
|
||||||
|
ComboBox {
|
||||||
|
model: ["zh_CN", "en_US"]
|
||||||
|
currentIndex: model.indexOf(config.language)
|
||||||
|
onCurrentTextChanged: { config.language = currentText; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FileDialog {
|
||||||
|
id: fdialog
|
||||||
|
property string configKey
|
||||||
|
onAccepted: { config[configKey] = selectedFile; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,182 +3,38 @@
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import QtQuick.Dialogs
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
signal finished()
|
signal finished()
|
||||||
|
|
||||||
ColumnLayout {
|
TabBar {
|
||||||
anchors.centerIn: parent
|
id: bar
|
||||||
|
y: -height
|
||||||
RowLayout {
|
transformOrigin: Item.BottomLeft
|
||||||
anchors.rightMargin: 8
|
rotation: 90
|
||||||
spacing: 16
|
width: root.height
|
||||||
Text {
|
TabButton {
|
||||||
text: Backend.translate("Username")
|
text: Backend.translate("Userinfo Settings")
|
||||||
}
|
}
|
||||||
Text {
|
TabButton {
|
||||||
text: Self.screenName
|
text: Backend.translate("BG Settings")
|
||||||
font.pixelSize: 18
|
}
|
||||||
|
TabButton {
|
||||||
|
text: Backend.translate("Audio Settings")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
SwipeView {
|
||||||
anchors.rightMargin: 8
|
width: root.width - bar.height - 16
|
||||||
spacing: 16
|
x: bar.height + 16
|
||||||
Text {
|
height: root.height
|
||||||
text: Backend.translate("Avatar")
|
interactive: false
|
||||||
}
|
orientation: Qt.Vertical
|
||||||
TextField {
|
currentIndex: bar.currentIndex
|
||||||
id: avatarName
|
UserInfo {}
|
||||||
font.pixelSize: 18
|
BGSetting {}
|
||||||
text: Self.avatar
|
AudioSetting {}
|
||||||
}
|
|
||||||
Button {
|
|
||||||
text: Backend.translate("Update Avatar")
|
|
||||||
enabled: avatarName.text !== ""
|
|
||||||
onClicked: {
|
|
||||||
mainWindow.busy = true;
|
|
||||||
ClientInstance.notifyServer(
|
|
||||||
"UpdateAvatar",
|
|
||||||
JSON.stringify([avatarName.text])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
anchors.rightMargin: 8
|
|
||||||
spacing: 16
|
|
||||||
Text {
|
|
||||||
text: Backend.translate("Old Password")
|
|
||||||
}
|
|
||||||
TextField {
|
|
||||||
id: oldPassword
|
|
||||||
echoMode: TextInput.Password
|
|
||||||
passwordCharacter: "*"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
anchors.rightMargin: 8
|
|
||||||
spacing: 16
|
|
||||||
Text {
|
|
||||||
text: Backend.translate("New Password")
|
|
||||||
}
|
|
||||||
TextField {
|
|
||||||
id: newPassword
|
|
||||||
echoMode: TextInput.Password
|
|
||||||
passwordCharacter: "*"
|
|
||||||
}
|
|
||||||
Button {
|
|
||||||
text: Backend.translate("Update Password")
|
|
||||||
enabled: oldPassword.text !== "" && newPassword.text !== ""
|
|
||||||
onClicked: {
|
|
||||||
mainWindow.busy = true;
|
|
||||||
ClientInstance.notifyServer(
|
|
||||||
"UpdatePassword",
|
|
||||||
JSON.stringify([oldPassword.text, newPassword.text])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
anchors.rightMargin: 8
|
|
||||||
spacing: 16
|
|
||||||
Text {
|
|
||||||
text: Backend.translate("Lobby BG")
|
|
||||||
}
|
|
||||||
TextField {
|
|
||||||
text: config.lobbyBg
|
|
||||||
}
|
|
||||||
Button {
|
|
||||||
text: "..."
|
|
||||||
onClicked: {
|
|
||||||
fdialog.nameFilters = ["Image Files (*.jpg *.png)"];
|
|
||||||
fdialog.configKey = "lobbyBg";
|
|
||||||
fdialog.open();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
anchors.rightMargin: 8
|
|
||||||
spacing: 16
|
|
||||||
Text {
|
|
||||||
text: Backend.translate("Room BG")
|
|
||||||
}
|
|
||||||
TextField {
|
|
||||||
text: config.roomBg
|
|
||||||
}
|
|
||||||
Button {
|
|
||||||
text: "..."
|
|
||||||
onClicked: {
|
|
||||||
fdialog.nameFilters = ["Image Files (*.jpg *.png)"];
|
|
||||||
fdialog.configKey = "roomBg";
|
|
||||||
fdialog.open();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
anchors.rightMargin: 8
|
|
||||||
spacing: 16
|
|
||||||
Text {
|
|
||||||
text: Backend.translate("Game BGM")
|
|
||||||
}
|
|
||||||
TextField {
|
|
||||||
text: config.bgmFile
|
|
||||||
}
|
|
||||||
Button {
|
|
||||||
text: "..."
|
|
||||||
onClicked: {
|
|
||||||
fdialog.nameFilters = ["Music Files (*.mp3)"];
|
|
||||||
fdialog.configKey = "bgmFile";
|
|
||||||
fdialog.open();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
anchors.rightMargin: 8
|
|
||||||
spacing: 16
|
|
||||||
Text {
|
|
||||||
text: Backend.translate("Poster Girl")
|
|
||||||
}
|
|
||||||
TextField {
|
|
||||||
text: config.ladyImg
|
|
||||||
}
|
|
||||||
Button {
|
|
||||||
text: "..."
|
|
||||||
onClicked: {
|
|
||||||
fdialog.nameFilters = ["Image Files (*.jpg *.png)"];
|
|
||||||
fdialog.configKey = "ladyImg";
|
|
||||||
fdialog.open();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
anchors.rightMargin: 8
|
|
||||||
spacing: 16
|
|
||||||
Text {
|
|
||||||
text: "Language"
|
|
||||||
}
|
|
||||||
ComboBox {
|
|
||||||
model: ["zh_CN", "en_US"]
|
|
||||||
currentIndex: model.indexOf(config.language)
|
|
||||||
onCurrentTextChanged: { config.language = currentText; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FileDialog {
|
|
||||||
id: fdialog
|
|
||||||
property string configKey
|
|
||||||
onAccepted: { config[configKey] = selectedFile; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls
|
||||||
|
import QtQuick.Layouts
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
// anchors.centerIn: parent
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
anchors.rightMargin: 8
|
||||||
|
spacing: 16
|
||||||
|
Text {
|
||||||
|
text: Backend.translate("Username")
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
text: Self.screenName
|
||||||
|
font.pixelSize: 18
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
anchors.rightMargin: 8
|
||||||
|
spacing: 16
|
||||||
|
Text {
|
||||||
|
text: Backend.translate("Avatar")
|
||||||
|
}
|
||||||
|
TextField {
|
||||||
|
id: avatarName
|
||||||
|
font.pixelSize: 18
|
||||||
|
text: Self.avatar
|
||||||
|
}
|
||||||
|
Button {
|
||||||
|
text: Backend.translate("Update Avatar")
|
||||||
|
enabled: avatarName.text !== ""
|
||||||
|
onClicked: {
|
||||||
|
mainWindow.busy = true;
|
||||||
|
ClientInstance.notifyServer(
|
||||||
|
"UpdateAvatar",
|
||||||
|
JSON.stringify([avatarName.text])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
anchors.rightMargin: 8
|
||||||
|
spacing: 16
|
||||||
|
Text {
|
||||||
|
text: Backend.translate("Old Password")
|
||||||
|
}
|
||||||
|
TextField {
|
||||||
|
id: oldPassword
|
||||||
|
echoMode: TextInput.Password
|
||||||
|
passwordCharacter: "*"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
anchors.rightMargin: 8
|
||||||
|
spacing: 16
|
||||||
|
Text {
|
||||||
|
text: Backend.translate("New Password")
|
||||||
|
}
|
||||||
|
TextField {
|
||||||
|
id: newPassword
|
||||||
|
echoMode: TextInput.Password
|
||||||
|
passwordCharacter: "*"
|
||||||
|
}
|
||||||
|
Button {
|
||||||
|
text: Backend.translate("Update Password")
|
||||||
|
enabled: oldPassword.text !== "" && newPassword.text !== ""
|
||||||
|
onClicked: {
|
||||||
|
mainWindow.busy = true;
|
||||||
|
ClientInstance.notifyServer(
|
||||||
|
"UpdatePassword",
|
||||||
|
JSON.stringify([oldPassword.text, newPassword.text])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -54,7 +54,9 @@ Item {
|
||||||
if (playbackState == MediaPlayer.StoppedState && roomScene.isStarted)
|
if (playbackState == MediaPlayer.StoppedState && roomScene.isStarted)
|
||||||
play();
|
play();
|
||||||
}
|
}
|
||||||
audioOutput: AudioOutput {}
|
audioOutput: AudioOutput {
|
||||||
|
volume: config.bgmVolume / 100
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onIsStartedChanged: {
|
onIsStartedChanged: {
|
||||||
|
@ -719,6 +721,7 @@ Item {
|
||||||
} else if (msg.startsWith("~")) {
|
} else if (msg.startsWith("~")) {
|
||||||
let g = msg.slice(1);
|
let g = msg.slice(1);
|
||||||
let extension = JSON.parse(Backend.callLuaFunction("GetGeneralData", [g])).extension;
|
let extension = JSON.parse(Backend.callLuaFunction("GetGeneralData", [g])).extension;
|
||||||
|
if (!config.disableMsgAudio)
|
||||||
Backend.playSound("./packages/" + extension + "/audio/death/" + g);
|
Backend.playSound("./packages/" + extension + "/audio/death/" + g);
|
||||||
|
|
||||||
let m = Backend.translate("~" + g);
|
let m = Backend.translate("~" + g);
|
||||||
|
@ -744,6 +747,7 @@ Item {
|
||||||
let data2 = JSON.parse(Backend.callLuaFunction("GetSkillData", [skill]));
|
let data2 = JSON.parse(Backend.callLuaFunction("GetSkillData", [skill]));
|
||||||
if (!data2) return false;
|
if (!data2) return false;
|
||||||
let extension = data2.extension;
|
let extension = data2.extension;
|
||||||
|
if (!config.disableMsgAudio)
|
||||||
Backend.playSound("./packages/" + extension + "/audio/skill/" + skill, idx);
|
Backend.playSound("./packages/" + extension + "/audio/skill/" + skill, idx);
|
||||||
|
|
||||||
let m = Backend.translate("$" + skill + idx.toString());
|
let m = Backend.translate("$" + skill + idx.toString());
|
||||||
|
|
|
@ -263,7 +263,8 @@ void QmlBackend::playSound(const QString &name, int index) {
|
||||||
auto output = new QAudioOutput;
|
auto output = new QAudioOutput;
|
||||||
player->setAudioOutput(output);
|
player->setAudioOutput(output);
|
||||||
player->setSource(QUrl::fromLocalFile(fname));
|
player->setSource(QUrl::fromLocalFile(fname));
|
||||||
output->setVolume(50); // TODO: volume config
|
qDebug() << m_volume;
|
||||||
|
output->setVolume(m_volume / 100);
|
||||||
connect(player, &QMediaPlayer::playbackStateChanged, this, [=]() {
|
connect(player, &QMediaPlayer::playbackStateChanged, this, [=]() {
|
||||||
if (player->playbackState() == QMediaPlayer::StoppedState) {
|
if (player->playbackState() == QMediaPlayer::StoppedState) {
|
||||||
player->deleteLater();
|
player->deleteLater();
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
#include <qtmetamacros.h>
|
#include <qtmetamacros.h>
|
||||||
class QmlBackend : public QObject {
|
class QmlBackend : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(qreal volume READ volume WRITE setVolume NOTIFY volumeChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QmlBackend(QObject *parent = nullptr);
|
QmlBackend(QObject *parent = nullptr);
|
||||||
~QmlBackend();
|
~QmlBackend();
|
||||||
|
@ -47,13 +49,18 @@ public:
|
||||||
Q_INVOKABLE QString getAESKey() const;
|
Q_INVOKABLE QString getAESKey() const;
|
||||||
Q_INVOKABLE void installAESKey();
|
Q_INVOKABLE void installAESKey();
|
||||||
|
|
||||||
|
qreal volume() const { return m_volume; }
|
||||||
|
void setVolume(qreal v) { m_volume = v; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void notifyUI(const QString &command, const QString &jsonData);
|
void notifyUI(const QString &command, const QString &jsonData);
|
||||||
|
void volumeChanged(qreal);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QQmlApplicationEngine *engine;
|
QQmlApplicationEngine *engine;
|
||||||
RSA *rsa;
|
RSA *rsa;
|
||||||
QString aes_key;
|
QString aes_key;
|
||||||
|
qreal m_volume;
|
||||||
|
|
||||||
void pushLuaValue(lua_State *L, QVariant v);
|
void pushLuaValue(lua_State *L, QVariant v);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue