asingcrow/godot/Components/MultiDelaySlider.gd

56 lines
1.6 KiB
GDScript3
Raw Permalink Normal View History

2020-09-26 12:59:15 +00:00
extends Control
signal delay_changed(slider,value)
var count = 0
var sliders = []
var values = []
var deets = []
func set_count(value):
for slice in $VBoxContainer.get_children():
slice.remove_and_skip()
sliders = []
deets = []
for i in range(0,value):
if len(values) < value+1:
values.append(Globals.audio_delay_seconds * 1000)
var slice = HBoxContainer.new()
var label = Label.new()
label.text = String(i+1)
label.hint_tooltip = "Vocal delay track "+String(i+1)
label.mouse_filter = Control.MOUSE_FILTER_STOP
slice.add_child(label)
var slider = HSlider.new()
slider.hint_tooltip = "Vocal delay track "+String(i+1)
slider.size_flags_horizontal = SIZE_EXPAND_FILL
print("Set track "+String(i)+" to "+String(values[i]))
slider.value = values[i]
slider.max_value = 1000
slider.connect("value_changed",self,"on_value_changed")
slice.add_child(slider)
sliders.append(slider)
var deet = Label.new()
deet.text = String(values[i]/1000) + "s"
deet.rect_min_size = Vector2(50,0)
deet.hint_tooltip = "Vocal delay track "+String(i+1)
deet.mouse_filter = Control.MOUSE_FILTER_STOP
deets.append(deet)
slice.add_child(deet)
$VBoxContainer.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
deets[i].text = String(values[i]/1000) + "s"
emit_signal("delay_changed",i,sliders[i].value)
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass