mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 08:14:48 +02:00
Fix a bug and remove magic numbers
This commit is contained in:
parent
7a88c8362b
commit
46ee148a69
4 changed files with 38 additions and 17 deletions
|
@ -73,7 +73,7 @@ Flickable {
|
|||
Layout.topMargin: simplifiedUI.margins.settings.settingsGroupTopMargin
|
||||
height: 30
|
||||
labelText: "People Volume"
|
||||
from: -60.0
|
||||
from: simplifiedUI.numericConstants.mutedValue
|
||||
to: 20.0
|
||||
defaultValue: 0.0
|
||||
stepSize: 5.0
|
||||
|
@ -101,7 +101,7 @@ Flickable {
|
|||
Layout.topMargin: 2
|
||||
height: 30
|
||||
labelText: "Environment Volume"
|
||||
from: -60.0
|
||||
from: simplifiedUI.numericConstants.mutedValue
|
||||
to: 20.0
|
||||
defaultValue: 0.0
|
||||
stepSize: 5.0
|
||||
|
@ -130,7 +130,7 @@ Flickable {
|
|||
Layout.topMargin: 2
|
||||
height: 30
|
||||
labelText: "System Sound Volume"
|
||||
from: -60.0
|
||||
from: simplifiedUI.numericConstants.mutedValue
|
||||
to: 20.0
|
||||
defaultValue: 0.0
|
||||
stepSize: 5.0
|
||||
|
|
|
@ -221,4 +221,8 @@ QtObject {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
readonly property QtObject numericConstants: QtObject {
|
||||
readonly property real mutedValue: -60.0
|
||||
}
|
||||
}
|
||||
|
|
|
@ -203,8 +203,10 @@ Rectangle {
|
|||
|
||||
Image {
|
||||
id: outputDeviceButton
|
||||
property bool outputMuted: AudioScriptingInterface.avatarGain === -60 &&
|
||||
AudioScriptingInterface.serverInjectorGain === -60 && AudioScriptingInterface.localInjectorGain === -60 && AudioScriptingInterface.systemInjectorGain === -60
|
||||
property bool outputMuted: AudioScriptingInterface.avatarGain === simplifiedUI.numericConstants.mutedValue &&
|
||||
AudioScriptingInterface.serverInjectorGain === simplifiedUI.numericConstants.mutedValue &&
|
||||
AudioScriptingInterface.localInjectorGain === simplifiedUI.numericConstants.mutedValue &&
|
||||
AudioScriptingInterface.systemInjectorGain === simplifiedUI.numericConstants.mutedValue
|
||||
source: outputDeviceButton.outputMuted ? "./images/outputDeviceMuted.svg" : "./images/outputDeviceLoud.svg"
|
||||
anchors.centerIn: parent
|
||||
width: 20
|
||||
|
@ -230,7 +232,7 @@ Rectangle {
|
|||
onClicked: {
|
||||
Tablet.playSound(TabletEnums.ButtonClick);
|
||||
|
||||
if (outputDeviceButton.outputMuted && !AudioScriptingInterface.muted) {
|
||||
if (!outputDeviceButton.outputMuted && !AudioScriptingInterface.muted) {
|
||||
AudioScriptingInterface.muted = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -242,33 +242,32 @@ var savedAvatarGain = Audio.avatarGain;
|
|||
var savedServerInjectorGain = Audio.serverInjectorGain;
|
||||
var savedLocalInjectorGain = Audio.localInjectorGain;
|
||||
var savedSystemInjectorGain = Audio.systemInjectorGain;
|
||||
var MUTED_VALUE_DB = -60; // This should always match `SimplifiedConstants.qml` -> numericConstants -> mutedValue!
|
||||
function setOutputMuted(outputMuted) {
|
||||
updateOutputDeviceMutedOverlay(outputMuted);
|
||||
|
||||
if (outputMuted) {
|
||||
savedAvatarGain = Audio.avatarGain;
|
||||
savedServerInjectorGain = Audio.serverInjectorGain;
|
||||
savedLocalInjectorGain = Audio.localInjectorGain;
|
||||
savedSystemInjectorGain = Audio.systemInjectorGain;
|
||||
|
||||
Audio.avatarGain = -60;
|
||||
Audio.serverInjectorGain = -60;
|
||||
Audio.localInjectorGain = -60;
|
||||
Audio.systemInjectorGain = -60;
|
||||
Audio.avatarGain = MUTED_VALUE_DB;
|
||||
Audio.serverInjectorGain = MUTED_VALUE_DB;
|
||||
Audio.localInjectorGain = MUTED_VALUE_DB;
|
||||
Audio.systemInjectorGain = MUTED_VALUE_DB;
|
||||
} else {
|
||||
if (savedAvatarGain === -60) {
|
||||
if (savedAvatarGain === MUTED_VALUE_DB) {
|
||||
savedAvatarGain = 0;
|
||||
}
|
||||
Audio.avatarGain = savedAvatarGain;
|
||||
if (savedServerInjectorGain === -60) {
|
||||
if (savedServerInjectorGain === MUTED_VALUE_DB) {
|
||||
savedServerInjectorGain = 0;
|
||||
}
|
||||
Audio.serverInjectorGain = savedServerInjectorGain;
|
||||
if (savedLocalInjectorGain === -60) {
|
||||
if (savedLocalInjectorGain === MUTED_VALUE_DB) {
|
||||
savedLocalInjectorGain = 0;
|
||||
}
|
||||
Audio.localInjectorGain = savedLocalInjectorGain;
|
||||
if (savedSystemInjectorGain === -60) {
|
||||
if (savedSystemInjectorGain === MUTED_VALUE_DB) {
|
||||
savedSystemInjectorGain = 0;
|
||||
}
|
||||
Audio.systemInjectorGain = savedSystemInjectorGain;
|
||||
|
@ -334,7 +333,10 @@ function onTopBarClosed() {
|
|||
|
||||
|
||||
function isOutputMuted() {
|
||||
return Audio.avatarGain === -60 && Audio.serverInjectorGain === -60 && Audio.localInjectorGain === -60 && Audio.systemInjectorGain === -60;
|
||||
return Audio.avatarGain === MUTED_VALUE_DB &&
|
||||
Audio.serverInjectorGain === MUTED_VALUE_DB &&
|
||||
Audio.localInjectorGain === MUTED_VALUE_DB &&
|
||||
Audio.systemInjectorGain === MUTED_VALUE_DB;
|
||||
}
|
||||
|
||||
|
||||
|
@ -461,6 +463,11 @@ function onStatusChanged() {
|
|||
}
|
||||
|
||||
|
||||
function maybeUpdateOutputDeviceMutedOverlay() {
|
||||
updateOutputDeviceMutedOverlay(isOutputMuted());
|
||||
}
|
||||
|
||||
|
||||
var simplifiedNametag = Script.require("./simplifiedNametag/simplifiedNametag.js?" + Date.now());
|
||||
var SimplifiedStatusIndicator = Script.require("./simplifiedStatusIndicator/simplifiedStatusIndicator.js?" + Date.now());
|
||||
var si;
|
||||
|
@ -493,6 +500,10 @@ function startup() {
|
|||
Audio.mutedDesktopChanged.connect(onDesktopInputDeviceMutedChanged);
|
||||
Window.geometryChanged.connect(onGeometryChanged);
|
||||
HMD.displayModeChanged.connect(ensureFirstPersonCameraInHMD);
|
||||
Audio.avatarGainChanged.connect(maybeUpdateOutputDeviceMutedOverlay);
|
||||
Audio.localInjectorGainChanged.connect(maybeUpdateOutputDeviceMutedOverlay);
|
||||
Audio.serverInjectorGainChanged.connect(maybeUpdateOutputDeviceMutedOverlay);
|
||||
Audio.systemInjectorGainChanged.connect(maybeUpdateOutputDeviceMutedOverlay);
|
||||
|
||||
oldShowAudioTools = AvatarInputs.showAudioTools;
|
||||
AvatarInputs.showAudioTools = false;
|
||||
|
@ -543,6 +554,10 @@ function shutdown() {
|
|||
Audio.mutedDesktopChanged.disconnect(onDesktopInputDeviceMutedChanged);
|
||||
Window.geometryChanged.disconnect(onGeometryChanged);
|
||||
HMD.displayModeChanged.disconnect(ensureFirstPersonCameraInHMD);
|
||||
Audio.avatarGainChanged.disconnect(maybeUpdateOutputDeviceMutedOverlay);
|
||||
Audio.localInjectorGainChanged.disconnect(maybeUpdateOutputDeviceMutedOverlay);
|
||||
Audio.serverInjectorGainChanged.disconnect(maybeUpdateOutputDeviceMutedOverlay);
|
||||
Audio.systemInjectorGainChanged.disconnect(maybeUpdateOutputDeviceMutedOverlay);
|
||||
|
||||
AvatarInputs.showAudioTools = oldShowAudioTools;
|
||||
AvatarInputs.showBubbleTools = oldShowBubbleTools;
|
||||
|
|
Loading…
Reference in a new issue