mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
fa5e9997ef
here we go Reviewed-on: https://codeberg.org/Eroax/Re-DotDeck/pulls/2 Co-authored-by: Lera Elvoé <yagich@poto.cafe> Co-committed-by: Lera Elvoé <yagich@poto.cafe>
68 lines
1.6 KiB
GDScript
68 lines
1.6 KiB
GDScript
extends DeckNode
|
|
|
|
var group_id: String
|
|
var input_node: DeckNode
|
|
var output_node: DeckNode
|
|
|
|
var extra_ports: Array
|
|
|
|
|
|
func _init() -> void:
|
|
name = "Group"
|
|
node_type = "group_node"
|
|
props_to_serialize = [&"group_id", &"extra_ports"]
|
|
|
|
|
|
func _pre_connection() -> void:
|
|
for port_type: PortType in extra_ports:
|
|
var index_of_type: int
|
|
match port_type:
|
|
PortType.OUTPUT:
|
|
add_output_port(Deck.Types.STRING, "Output %s" % get_output_ports().size())
|
|
PortType.INPUT:
|
|
add_input_port(Deck.Types.STRING, "Input %s" % get_input_ports().size())
|
|
|
|
|
|
func init_io() -> void:
|
|
var group: Deck = _belonging_to.groups.get(group_id) as Deck
|
|
if !group:
|
|
return
|
|
|
|
input_node = group.get_node(group.group_input_node)
|
|
output_node = group.get_node(group.group_output_node)
|
|
|
|
recalculate_ports()
|
|
setup_connections()
|
|
|
|
|
|
func setup_connections() -> void:
|
|
input_node.ports_updated.connect(recalculate_ports)
|
|
output_node.ports_updated.connect(recalculate_ports)
|
|
|
|
|
|
func recalculate_ports() -> void:
|
|
ports.clear()
|
|
|
|
for output_port: Port in output_node.get_input_ports():
|
|
add_output_port(
|
|
Deck.Types.STRING,
|
|
"Output %s" % output_port.index
|
|
)
|
|
|
|
for input_port: Port in input_node.get_output_ports():
|
|
add_input_port(
|
|
Deck.Types.STRING,
|
|
"Input %s" % input_port.index
|
|
)
|
|
|
|
extra_ports.clear()
|
|
for port in ports:
|
|
extra_ports.append(port.port_type)
|
|
|
|
|
|
func _receive(to_input_port: int, data: DeckType, extra_data: Array = []):
|
|
input_node.send(get_input_ports()[to_input_port].index_of_type, data, extra_data)
|
|
|
|
|
|
func _value_request(from_port: int) -> Variant:
|
|
return output_node.request_value(from_port)
|