Added audio settings
This commit is contained in:
21
client/ui/settings/audio/AudioBusVolume.gd
Normal file
21
client/ui/settings/audio/AudioBusVolume.gd
Normal file
@ -0,0 +1,21 @@
|
||||
@tool
|
||||
extends Slider
|
||||
|
||||
var bus := -1
|
||||
|
||||
func _ready():
|
||||
bus = AudioServer.get_bus_index(get_parent().name)
|
||||
var db := AudioServer.get_bus_volume_db(bus)
|
||||
var linear := db_to_linear(db)
|
||||
set_value_no_signal(linear)
|
||||
|
||||
func on_value_changed(new_value: float):
|
||||
AudioServer.set_bus_volume_db(bus, linear_to_db(new_value))
|
||||
|
||||
func _get_configuration_warnings() -> PackedStringArray:
|
||||
var warnings := []
|
||||
|
||||
if AudioServer.get_bus_index(get_parent().name) == -1:
|
||||
warnings.append("Invalid audio bus name: %s" % get_parent().name)
|
||||
|
||||
return warnings
|
23
client/ui/settings/audio/AudioBusVolume.tscn
Normal file
23
client/ui/settings/audio/AudioBusVolume.tscn
Normal file
@ -0,0 +1,23 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://meal8j3ft58r"]
|
||||
|
||||
[ext_resource type="Script" path="res://ui/label/ParentNameLabel.gd" id="1_hrs80"]
|
||||
[ext_resource type="Script" path="res://ui/settings/audio/AudioBusVolume.gd" id="2_3ihfm"]
|
||||
|
||||
[node name="Master" type="HBoxContainer"]
|
||||
custom_minimum_size = Vector2(0, 32)
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Master:"
|
||||
script = ExtResource("1_hrs80")
|
||||
|
||||
[node name="HSlider" type="HSlider" parent="."]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
max_value = 1.0
|
||||
step = 0.01
|
||||
value = 1.0
|
||||
script = ExtResource("2_3ihfm")
|
||||
|
||||
[connection signal="value_changed" from="HSlider" to="HSlider" method="on_value_changed"]
|
Reference in New Issue
Block a user