mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
fix up the spinbox descriptor and switch delay node to use SceneTreeTimer (#99)
closes #76 Reviewed-on: https://codeberg.org/StreamGraph/StreamGraph/pulls/99 Co-authored-by: Lera Elvoé <yagich@poto.cafe> Co-committed-by: Lera Elvoé <yagich@poto.cafe>
This commit is contained in:
parent
677e7b36c5
commit
3886414374
2 changed files with 25 additions and 32 deletions
|
@ -10,36 +10,29 @@ func _init():
|
|||
node_type = name.to_snake_case()
|
||||
description = "A node that passes through its' input after the set time."
|
||||
|
||||
add_output_port(DeckType.Types.ANY, "Value")
|
||||
add_input_port(
|
||||
DeckType.Types.NUMERIC,
|
||||
"Delay Time",
|
||||
"spinbox:unbounded:0.01",
|
||||
Port.UsageType.VALUE_REQUEST,
|
||||
)
|
||||
|
||||
add_input_port(DeckType.Types.NUMERIC, "Delay Time", "field")
|
||||
add_input_port(DeckType.Types.ANY, "Value", "field")
|
||||
add_input_port(
|
||||
DeckType.Types.ANY,
|
||||
"Value",
|
||||
"",
|
||||
Port.UsageType.TRIGGER,
|
||||
)
|
||||
|
||||
add_output_port(
|
||||
DeckType.Types.ANY,
|
||||
"Value",
|
||||
"",
|
||||
Port.UsageType.TRIGGER,
|
||||
)
|
||||
|
||||
|
||||
func _receive(_to_input_port : int, data: Variant) -> void:
|
||||
|
||||
thread = Thread.new()
|
||||
thread.start(handle_delay.bind(data))
|
||||
|
||||
|
||||
func handle_delay(data):
|
||||
|
||||
var goal_time = Time.get_ticks_msec() + (int(get_input_ports()[0].value_callback.call()) * 1000)
|
||||
|
||||
while Time.get_ticks_msec() < goal_time:
|
||||
|
||||
pass
|
||||
|
||||
|
||||
#print("Delay over")
|
||||
send.call_deferred(0, data)
|
||||
|
||||
|
||||
func _notification(what):
|
||||
|
||||
if what == NOTIFICATION_PREDELETE and thread != null:
|
||||
|
||||
thread.wait_to_finish()
|
||||
|
||||
|
||||
var time: float = await resolve_input_port_value_async(0)
|
||||
await Engine.get_main_loop().create_timer(time).timeout
|
||||
send(0, data)
|
||||
|
|
|
@ -14,14 +14,14 @@ func _setup(port: Port, _node: DeckNode) -> void:
|
|||
spin_box.allow_greater = true
|
||||
spin_box.allow_lesser = true
|
||||
if descriptor.size() > 2:
|
||||
spin_box.step = float(descriptor[1])
|
||||
spin_box.step = float(descriptor[2])
|
||||
else:
|
||||
spin_box.step = 1.0
|
||||
else:
|
||||
spin_box.min_value = float(descriptor[1])
|
||||
spin_box.min_value = float(descriptor[2])
|
||||
if descriptor.size() > 2:
|
||||
spin_box.max_value = float(descriptor[2])
|
||||
spin_box.max_value = float(descriptor[3])
|
||||
if descriptor.size() > 3:
|
||||
spin_box.step = float(descriptor[3])
|
||||
spin_box.step = float(descriptor[4])
|
||||
port.value_callback = spin_box.get_value
|
||||
spin_box.value_changed.connect(port.set_value)
|
||||
|
|
Loading…
Reference in a new issue