33 lines
1015 B
GDScript
33 lines
1015 B
GDScript
extends BaseUI
|
|
|
|
|
|
func _ready():
|
|
$VBoxContainer/GridContainer/MasterVolume.value = db2linear(get_bus_volume("Master"))
|
|
$VBoxContainer/GridContainer/MusicVolume.value = db2linear(get_bus_volume("Music"))
|
|
$VBoxContainer/GridContainer/SoundsVolume.value = db2linear(get_bus_volume("Sounds"))
|
|
$VBoxContainer/GridContainer/AmbiantsVolume.value = db2linear(get_bus_volume("Ambiants"))
|
|
|
|
|
|
func get_bus_volume(bus: String):
|
|
var idx = AudioServer.get_bus_index(bus)
|
|
return AudioServer.get_bus_volume_db(idx)
|
|
|
|
func set_bus_volume(bus: String, volume_percent: float):
|
|
var idx = AudioServer.get_bus_index(bus)
|
|
AudioServer.set_bus_volume_db(idx, linear2db(volume_percent))
|
|
|
|
func _on_MasterVolume_value_changed(value):
|
|
set_bus_volume("Master", value)
|
|
|
|
func _on_MusicVolume_value_changed(value):
|
|
set_bus_volume("Music", value)
|
|
|
|
func _on_SoundsVolume_value_changed(value):
|
|
set_bus_volume("Sounds", value)
|
|
|
|
func _on_AmbiantsVolume_value_changed(value):
|
|
set_bus_volume("Ambiants", value)
|
|
|
|
func _on_Save_pressed():
|
|
close()
|