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):
|
func _on_Master_Slider_value_changed(value):
|
||||||
AudioBus.emit_signal("button_clicked")
|
AudioBus.emit_signal("button_clicked")
|
||||||
OptionsController.set_mas_vol(value)
|
OptionsController.set_vol(value, "mas_vol")
|
||||||
OptionsController.save_options()
|
|
||||||
|
|
||||||
func _on_Music_Slider_value_changed(value):
|
func _on_Music_Slider_value_changed(value):
|
||||||
AudioBus.emit_signal("button_clicked")
|
AudioBus.emit_signal("button_clicked")
|
||||||
OptionsController.set_mus_vol(value)
|
OptionsController.set_vol(value, "mus_vol")
|
||||||
OptionsController.save_options()
|
|
||||||
|
|
||||||
func _on_SFX_Slider_value_changed(value):
|
func _on_SFX_Slider_value_changed(value):
|
||||||
AudioBus.emit_signal("button_clicked")
|
AudioBus.emit_signal("button_clicked")
|
||||||
OptionsController.set_sfx_vol(value)
|
OptionsController.set_vol(value, "sfx_vol")
|
||||||
OptionsController.save_options()
|
|
||||||
|
|
||||||
func _on_Light_pressed():
|
func _on_Light_pressed():
|
||||||
AudioBus.emit_signal("button_clicked")
|
AudioBus.emit_signal("button_clicked")
|
||||||
OptionsController.set_theme("light")
|
OptionsController.set_theme("light")
|
||||||
OptionsController.save_options()
|
|
||||||
|
|
||||||
func _on_Dark_pressed():
|
func _on_Dark_pressed():
|
||||||
AudioBus.emit_signal("button_clicked")
|
AudioBus.emit_signal("button_clicked")
|
||||||
OptionsController.set_theme("dark")
|
OptionsController.set_theme("dark")
|
||||||
OptionsController.save_options()
|
|
||||||
|
@ -22,15 +22,28 @@ func set_theme(theme_name):
|
|||||||
theme = String(theme_name)
|
theme = String(theme_name)
|
||||||
save_options()
|
save_options()
|
||||||
emit_signal("change_theme", theme)
|
emit_signal("change_theme", theme)
|
||||||
func set_mas_vol(volume):
|
save_options()
|
||||||
mas_vol = volume
|
func set_vol(volume, type):
|
||||||
AudioServer.set_bus_volume_db(AudioServer.get_bus_index("Master"), mas_vol)
|
if type == "mas_vol":
|
||||||
func set_mus_vol(volume):
|
mas_vol = volume
|
||||||
mus_vol = volume
|
AudioServer.set_bus_volume_db(AudioServer.get_bus_index("Master"), mas_vol)
|
||||||
AudioServer.set_bus_volume_db(AudioServer.get_bus_index("BGM"), mus_vol)
|
elif type == "mus_vol":
|
||||||
func set_sfx_vol(volume):
|
mus_vol = volume
|
||||||
sfx_vol = volume
|
AudioServer.set_bus_volume_db(AudioServer.get_bus_index("BGM"), mus_vol)
|
||||||
AudioServer.set_bus_volume_db(AudioServer.get_bus_index("SFX"), sfx_vol)
|
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
|
#Option Save File
|
||||||
func save_options():
|
func save_options():
|
||||||
|
Loading…
Reference in New Issue
Block a user