mirror of
https://github.com/JohnBreaux/Boat-Battle.git
synced 2024-11-15 05:25:57 +00:00
Refactoring: parametrize set volume function
This commit is contained in:
parent
7bae715ba5
commit
425e4428c7
@ -21,25 +21,20 @@ func _on_Button_pressed():
|
||||
|
||||
func _on_Master_Slider_value_changed(value):
|
||||
AudioBus.emit_signal("button_clicked")
|
||||
OptionsController.set_mas_vol(value)
|
||||
OptionsController.save_options()
|
||||
OptionsController.set_vol(value, "mas_vol")
|
||||
|
||||
func _on_Music_Slider_value_changed(value):
|
||||
AudioBus.emit_signal("button_clicked")
|
||||
OptionsController.set_mus_vol(value)
|
||||
OptionsController.save_options()
|
||||
OptionsController.set_vol(value, "mus_vol")
|
||||
|
||||
func _on_SFX_Slider_value_changed(value):
|
||||
AudioBus.emit_signal("button_clicked")
|
||||
OptionsController.set_sfx_vol(value)
|
||||
OptionsController.save_options()
|
||||
OptionsController.set_vol(value, "sfx_vol")
|
||||
|
||||
func _on_Light_pressed():
|
||||
AudioBus.emit_signal("button_clicked")
|
||||
OptionsController.set_theme("light")
|
||||
OptionsController.save_options()
|
||||
|
||||
func _on_Dark_pressed():
|
||||
AudioBus.emit_signal("button_clicked")
|
||||
OptionsController.set_theme("dark")
|
||||
OptionsController.save_options()
|
||||
|
@ -22,15 +22,28 @@ func set_theme(theme_name):
|
||||
theme = String(theme_name)
|
||||
save_options()
|
||||
emit_signal("change_theme", theme)
|
||||
func set_mas_vol(volume):
|
||||
save_options()
|
||||
func set_vol(volume, type):
|
||||
if type == "mas_vol":
|
||||
mas_vol = volume
|
||||
AudioServer.set_bus_volume_db(AudioServer.get_bus_index("Master"), mas_vol)
|
||||
func set_mus_vol(volume):
|
||||
elif type == "mus_vol":
|
||||
mus_vol = volume
|
||||
AudioServer.set_bus_volume_db(AudioServer.get_bus_index("BGM"), mus_vol)
|
||||
func set_sfx_vol(volume):
|
||||
elif type == "sfx_vol":
|
||||
sfx_vol = volume
|
||||
AudioServer.set_bus_volume_db(AudioServer.get_bus_index("SFX"), sfx_vol)
|
||||
save_options()
|
||||
|
||||
#func set_mas_vol(volume):
|
||||
# mas_vol = volume
|
||||
# AudioServer.set_bus_volume_db(AudioServer.get_bus_index("Master"), mas_vol)
|
||||
#func set_mus_vol(volume):
|
||||
# mus_vol = volume
|
||||
# AudioServer.set_bus_volume_db(AudioServer.get_bus_index("BGM"), mus_vol)
|
||||
#func set_sfx_vol(volume):
|
||||
# sfx_vol = volume
|
||||
# AudioServer.set_bus_volume_db(AudioServer.get_bus_index("SFX"), sfx_vol)
|
||||
|
||||
#Option Save File
|
||||
func save_options():
|
||||
|
Loading…
Reference in New Issue
Block a user