main/ holds the main window and top bar, quiz/ the quiz and its parts, player/ the music player, popups/ every popup and what they share, data/ the songs, players, playlist and settings, server/ the MusicServer client, common/ the list row and GameLog, and themes/ the themes and style boxes.
25 lines
693 B
GDScript
25 lines
693 B
GDScript
class_name VolumeSlider
|
|
extends HSlider
|
|
## A slider that sets the volume of an audio bus.
|
|
|
|
## The audio bus whose volume the slider sets.
|
|
|
|
@export var audio_bus_name: String = "music"
|
|
|
|
var _bus: int
|
|
|
|
|
|
func _ready() -> void:
|
|
_bus = AudioServer.get_bus_index(audio_bus_name)
|
|
value_changed.connect(_on_value_changed)
|
|
value = db_to_linear(AudioServer.get_bus_volume_db(_bus))
|
|
|
|
|
|
## Sets the bus volume to [param changed_value], from 0 (silent) to 1 (full).
|
|
func change_volume(changed_value: float) -> void:
|
|
AudioServer.set_bus_volume_db(_bus, linear_to_db(changed_value))
|
|
|
|
|
|
func _on_value_changed(changed_value: float) -> void:
|
|
AudioServer.set_bus_volume_db(_bus, linear_to_db(changed_value))
|