refactor volume slider

This commit is contained in:
zoe-bat 2021-11-28 21:19:18 +01:00
parent 86da05b21a
commit d5cd76a9a9
3 changed files with 8 additions and 3 deletions

View file

@ -1,4 +1,5 @@
extends HSlider
var changes_to_save = false
export var bus_channel = "Master"
@ -7,6 +8,9 @@ func _ready():
func _on_MusicVolumeSlider_value_changed(value):
AudioServer.set_bus_volume_db(AudioServer.get_bus_index(bus_channel), linear2db(value))
changes_to_save = true
func save_volume():
Saves.save_game()
if changes_to_save:
Saves.save_game()
changes_to_save = false;

View file

@ -19,7 +19,8 @@ __meta__ = {
[node name="ButtonSFX" parent="." instance=ExtResource( 3 )]
[connection signal="changed" from="." to="." method="save_volume"]
[connection signal="focus_entered" from="." to="ButtonSFX" method="on_hover"]
[connection signal="focus_exited" from="." to="." method="save_volume"]
[connection signal="mouse_entered" from="." to="ButtonSFX" method="on_hover"]
[connection signal="mouse_exited" from="." to="." method="save_volume"]
[connection signal="value_changed" from="." to="." method="_on_MusicVolumeSlider_value_changed"]

View file

@ -119,7 +119,7 @@ margin_left = 0.0
margin_right = 192.0
[node name="LevelInfo" parent="CanvasLayer/Control/TabContainer/Levels/HBoxContainer" instance=ExtResource( 7 )]
anchor_right = 0.0
anchor_top = 0.0
anchor_bottom = 0.0
margin_left = 196.0
margin_right = 313.0