The popups, the volume slider, the player name field and the main window get a class_name, so the main window and the quiz hold them by their real type instead of Control. The classes already use the names the files will get.
20 lines
509 B
GDScript
20 lines
509 B
GDScript
class_name VolumeSlider
|
|
extends HSlider
|
|
|
|
@export
|
|
var audio_bus_name := "music"
|
|
|
|
@onready
|
|
var _bus: int
|
|
|
|
func _ready():
|
|
_bus = AudioServer.get_bus_index(audio_bus_name)
|
|
value_changed.connect(_on_value_changed)
|
|
value = db_to_linear(AudioServer.get_bus_volume_db(_bus))
|
|
|
|
func _on_value_changed(changed_value: float) -> void:
|
|
AudioServer.set_bus_volume_db(_bus, linear_to_db(changed_value))
|
|
|
|
func change_volume(changed_value: float) -> void:
|
|
AudioServer.set_bus_volume_db(_bus, linear_to_db(changed_value))
|