1
Fork 0
mirror of https://github.com/RYGhub/the-cold-night.git synced 2024-11-24 13:44:18 +00:00

🔧 Make mute button mute sounds as well

This commit is contained in:
Steffo 2022-04-04 16:58:52 +02:00
parent f3b7c4a92e
commit 86efa55c12
Signed by: steffo
GPG key ID: 6965406171929D01

View file

@ -7,26 +7,28 @@ export var bell_min: float = 0.20
export var bell_max: float = 0.60 export var bell_max: float = 0.60
export var drum_min: float = 0.40 export var drum_min: float = 0.40
export var drum_max: float = 0.80 export var drum_max: float = 0.80
export var muted: bool = false setget set_mute export var muted: bool setget set_mute, get_mute
func _on_Fire_intensity_changed(value): func _on_Fire_intensity_changed(value):
$Choir.volume_db = (smoothstep(choir_min, choir_max, value) - 1) * 60 $Choir.volume_db = (smoothstep(choir_min, choir_max, value) - 1) * 60
$Choir.bus = "Master" if not muted and $Choir.volume_db > -60 else "Mute" $Choir.bus = "Master" if $Choir.volume_db > -60 else "Mute"
$Bell.volume_db = (smoothstep(bell_min, bell_max, value) - 1) * 60 $Bell.volume_db = (smoothstep(bell_min, bell_max, value) - 1) * 60
$Bell.bus = "Master" if not muted and $Bell.volume_db > -60 else "Mute" $Bell.bus = "Master" if $Bell.volume_db > -60 else "Mute"
$Drum.volume_db = (smoothstep(drum_min, drum_max, value) - 1) * 60 $Drum.volume_db = (smoothstep(drum_min, drum_max, value) - 1) * 60
$Drum.bus = "Master" if not muted and $Drum.volume_db > -60 else "Mute" $Drum.bus = "Master" if $Drum.volume_db > -60 else "Mute"
func set_mute(value): func set_mute(value):
muted = value var index = AudioServer.get_bus_index("Master")
$Choir.bus = "Master" if not muted and $Choir.volume_db > -60 else "Mute" AudioServer.set_bus_mute(index, value)
$Bell.bus = "Master" if not muted and $Bell.volume_db > -60 else "Mute"
$Drum.bus = "Master" if not muted and $Drum.volume_db > -60 else "Mute" func get_mute():
var index = AudioServer.get_bus_index("Master")
return AudioServer.is_bus_mute(index)
func _on_MuteButton_pressed(): func _on_MuteButton_pressed():
set_mute(not muted) set_mute(not get_mute())