asingcrow/godot/Components/MultiVolumeSlider.gd

48 lines
1.3 KiB
GDScript3
Raw Permalink Normal View History

extends Control
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
signal volume_changed(slider,value)
var count = 0
var sliders = []
var values = []
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
func set_count(value):
for slice in $HBoxContainer.get_children():
slice.remove_and_skip()
sliders = []
for i in range(0,value):
if len(values) < value+1:
2020-10-09 10:19:56 +00:00
values.append(100)
var slice = VBoxContainer.new()
var slider = VSlider.new()
slider.hint_tooltip = "Vocal mix "+String(i+1)
slider.size_flags_vertical = SIZE_EXPAND_FILL
slider.value = values[i]
slider.connect("value_changed",self,"on_value_changed")
slice.add_child(slider)
sliders.append(slider)
var label = Label.new()
label.text = String(i+1)
label.hint_tooltip = "Vocal mix "+String(i+1)
label.mouse_filter = Control.MOUSE_FILTER_STOP
2020-09-26 12:59:15 +00:00
label.align = Label.ALIGN_CENTER
slice.add_child(label)
$HBoxContainer.add_child(slice)
func on_value_changed(value):
for i in range(0,len(sliders)):
if values[i] != sliders[i].value:
values[i] = sliders[i].value
2020-09-26 12:59:15 +00:00
emit_signal("volume_changed",i,sliders[i].value)
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass