mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
Merge branch 'main' into poc/godot-showreel-demo
This commit is contained in:
commit
1326b3bfad
5 changed files with 94 additions and 3 deletions
43
classes/deck/nodes/delay.gd
Normal file
43
classes/deck/nodes/delay.gd
Normal file
|
@ -0,0 +1,43 @@
|
|||
extends DeckNode
|
||||
|
||||
var thread : Thread
|
||||
|
||||
func _init():
|
||||
name = "Delay"
|
||||
node_type = name.to_snake_case()
|
||||
description = "A Node that passes through the input after the set time."
|
||||
category = "general"
|
||||
|
||||
add_output_port(DeckType.Types.STRING, "Value", "")
|
||||
|
||||
add_input_port(DeckType.Types.NUMERIC, "Delay Time", "field")
|
||||
add_input_port(DeckType.Types.NUMERIC, "Value", "field")
|
||||
|
||||
|
||||
|
||||
func _receive(to_input_port : int, data: Variant, extra_data: Array = []) -> 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(0, data)
|
||||
|
||||
|
||||
func _notification(what):
|
||||
|
||||
if what == NOTIFICATION_PREDELETE and thread != null:
|
||||
|
||||
thread.wait_to_finish()
|
||||
|
||||
|
36
classes/deck/nodes/expression_node.gd
Normal file
36
classes/deck/nodes/expression_node.gd
Normal file
|
@ -0,0 +1,36 @@
|
|||
extends DeckNode
|
||||
|
||||
var expr = Expression.new()
|
||||
|
||||
func _init():
|
||||
name = "Expression"
|
||||
node_type = name.to_snake_case()
|
||||
description = "A Node holding a block of executable GDScript code."
|
||||
category = "general"
|
||||
|
||||
props_to_serialize = []
|
||||
|
||||
add_output_port(DeckType.Types.ANY, "Expression Text", "codeblock")
|
||||
|
||||
|
||||
|
||||
func _value_request(from_port : int) -> Variant:
|
||||
|
||||
var text = get_output_ports()[0].value_callback.call()
|
||||
|
||||
var err = expr.parse(text)
|
||||
if err != OK:
|
||||
|
||||
printerr(err)
|
||||
return null
|
||||
|
||||
|
||||
var res = expr.execute()
|
||||
if expr.has_execute_failed():
|
||||
|
||||
printerr("Expression Execution Failed: ", text)
|
||||
return null
|
||||
|
||||
|
||||
return res
|
||||
|
|
@ -101,7 +101,16 @@ func update_port(port: Port) -> void:
|
|||
func(id: int):
|
||||
port.set_value.call(box.get_item_text(box.get_selected_id()))
|
||||
)
|
||||
|
||||
"codeblock":
|
||||
var code_edit = CodeEdit.new()
|
||||
add_child(code_edit)
|
||||
if port.value:
|
||||
code_edit.text = str(port.value)
|
||||
code_edit.placeholder_text = port.label
|
||||
port.value_callback = code_edit.get_text
|
||||
code_edit.text_changed.connect(port.set_value.bind(code_edit.get_text))
|
||||
code_edit.custom_minimum_size = Vector2(200, 100)
|
||||
code_edit.size_flags_vertical = SIZE_EXPAND_FILL
|
||||
_:
|
||||
var label := Label.new()
|
||||
add_child(label)
|
||||
|
|
|
@ -3,8 +3,10 @@
|
|||
[ext_resource type="Script" path="res://graph_node_renderer/deck_node_renderer_graph_node.gd" id="1_pos0w"]
|
||||
|
||||
[node name="DeckNodeRendererGraphNode" type="GraphNode"]
|
||||
offset_right = 280.0
|
||||
offset_bottom = 217.0
|
||||
custom_minimum_size = Vector2(200, 0)
|
||||
offset_right = 200.0
|
||||
offset_bottom = 55.0
|
||||
resizable = true
|
||||
title = "Deck Node"
|
||||
script = ExtResource("1_pos0w")
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ anchor_bottom = 1.0
|
|||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
right_disconnects = true
|
||||
show_arrange_button = false
|
||||
script = ExtResource("1_pojfs")
|
||||
|
||||
[connection signal="popup_request" from="." to="." method="_on_popup_request"]
|
||||
|
|
Loading…
Reference in a new issue