From 86efa55c122d080cce1a603156822806bdcb6604 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 4 Apr 2022 16:58:52 +0200 Subject: [PATCH] :wrench: Make mute button mute sounds as well --- src/levels/PhaseOneMusic.gd | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/levels/PhaseOneMusic.gd b/src/levels/PhaseOneMusic.gd index 10d8f4d..490d7a8 100644 --- a/src/levels/PhaseOneMusic.gd +++ b/src/levels/PhaseOneMusic.gd @@ -7,26 +7,28 @@ export var bell_min: float = 0.20 export var bell_max: float = 0.60 export var drum_min: float = 0.40 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): $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.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.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): - muted = value - $Choir.bus = "Master" if not muted and $Choir.volume_db > -60 else "Mute" - $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" + var index = AudioServer.get_bus_index("Master") + AudioServer.set_bus_mute(index, value) + +func get_mute(): + var index = AudioServer.get_bus_index("Master") + return AudioServer.is_bus_mute(index) func _on_MuteButton_pressed(): - set_mute(not muted) + set_mute(not get_mute())