mirror of
https://github.com/RYGhub/the-cold-night.git
synced 2024-11-22 12:44:20 +00:00
🔧 Add functionality to the mute button
This commit is contained in:
parent
3e6f54f543
commit
cdb57f90e6
2 changed files with 18 additions and 15 deletions
|
@ -109,16 +109,6 @@ align = 2
|
||||||
valign = 1
|
valign = 1
|
||||||
script = SubResource( 1 )
|
script = SubResource( 1 )
|
||||||
|
|
||||||
[node name="HealthBar" type="ProgressBar" parent="UserInterface/TheDarkNightUI/Panel"]
|
|
||||||
visible = false
|
|
||||||
anchor_bottom = 1.0
|
|
||||||
margin_left = 14.0
|
|
||||||
margin_top = 14.0
|
|
||||||
margin_right = 320.0
|
|
||||||
margin_bottom = -14.0
|
|
||||||
grow_vertical = 2
|
|
||||||
value = 50.0
|
|
||||||
|
|
||||||
[node name="TextureProgress" type="TextureProgress" parent="UserInterface/TheDarkNightUI/Panel"]
|
[node name="TextureProgress" type="TextureProgress" parent="UserInterface/TheDarkNightUI/Panel"]
|
||||||
margin_left = 15.0
|
margin_left = 15.0
|
||||||
margin_top = 15.0
|
margin_top = 15.0
|
||||||
|
@ -129,7 +119,7 @@ texture_under = ExtResource( 10 )
|
||||||
texture_progress = ExtResource( 9 )
|
texture_progress = ExtResource( 9 )
|
||||||
texture_progress_offset = Vector2( 10, 5 )
|
texture_progress_offset = Vector2( 10, 5 )
|
||||||
|
|
||||||
[node name="Button" type="Button" parent="UserInterface/TheDarkNightUI/Panel"]
|
[node name="MuteButton" type="Button" parent="UserInterface/TheDarkNightUI/Panel"]
|
||||||
anchor_left = 1.0
|
anchor_left = 1.0
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
|
@ -139,8 +129,9 @@ margin_right = -50.0
|
||||||
margin_bottom = -10.0
|
margin_bottom = -10.0
|
||||||
flat = true
|
flat = true
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite" parent="UserInterface/TheDarkNightUI/Panel/Button"]
|
[node name="Sprite" type="Sprite" parent="UserInterface/TheDarkNightUI/Panel/MuteButton"]
|
||||||
position = Vector2( 25, 30 )
|
position = Vector2( 25, 30 )
|
||||||
texture = ExtResource( 12 )
|
texture = ExtResource( 12 )
|
||||||
|
|
||||||
[connection signal="intensity_changed" from="PhaseOne/Entities/Fire" to="PhaseOne/Music" method="_on_Fire_intensity_changed"]
|
[connection signal="intensity_changed" from="PhaseOne/Entities/Fire" to="PhaseOne/Music" method="_on_Fire_intensity_changed"]
|
||||||
|
[connection signal="pressed" from="UserInterface/TheDarkNightUI/Panel/MuteButton" to="PhaseOne/Music" method="_on_MuteButton_pressed"]
|
||||||
|
|
|
@ -7,14 +7,26 @@ 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
|
||||||
|
|
||||||
|
|
||||||
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 $Choir.volume_db > -60 else "Mute"
|
$Choir.bus = "Master" if not muted and $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 $Choir.volume_db > -60 else "Mute"
|
$Bell.bus = "Master" if not muted and $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 $Choir.volume_db > -60 else "Mute"
|
$Drum.bus = "Master" if not muted and $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"
|
||||||
|
|
||||||
|
|
||||||
|
func _on_MuteButton_pressed():
|
||||||
|
set_mute(not muted)
|
||||||
|
|
Loading…
Reference in a new issue