2023-06-10 19:13:16 +02:00
|
|
|
extends PanelContainer
|
|
|
|
|
|
|
|
@onready var name_label: Label = %NameLabel
|
|
|
|
@onready var elements_container: VBoxContainer = %ElementsContainer
|
|
|
|
|
|
|
|
var node: DeckNode
|
|
|
|
const PortDrawer := preload("res://port_drawer.gd")
|
|
|
|
var port_drawer_scene := preload("res://port_drawer.tscn")
|
|
|
|
|
|
|
|
# THIS IS SUPER JANK AND A HACK FOR DEMONSTRATION PURPOSES
|
|
|
|
# PLEASE DO NOT ACTUALLY DO ANYTHING THIS CLASS DOES
|
|
|
|
# IN THE REAL PROJECT !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
|
|
|
|
func _ready() -> void:
|
|
|
|
name_label.text = node.name
|
2023-06-10 20:23:57 +02:00
|
|
|
for i in node.input_ports.size():
|
|
|
|
var input_port := node.input_ports[i]
|
2023-06-10 19:13:16 +02:00
|
|
|
var port_drawer: PortDrawer = port_drawer_scene.instantiate()
|
|
|
|
elements_container.add_child(port_drawer)
|
|
|
|
port_drawer.set_input_enabled(true)
|
|
|
|
match input_port.descriptor:
|
|
|
|
"field":
|
2023-06-10 20:23:57 +02:00
|
|
|
port_drawer.add_field(input_port.label)
|
|
|
|
input_port.value_callback = port_drawer.get_text
|
|
|
|
"button":
|
|
|
|
port_drawer.add_button(input_port.label)
|
|
|
|
port_drawer.button_pressed.connect(func():
|
|
|
|
node._receive(i, DeckType.DeckTypeString.new("memes"))
|
|
|
|
)
|
2023-06-10 19:13:16 +02:00
|
|
|
_:
|
|
|
|
port_drawer.add_label(input_port.label)
|
|
|
|
|
|
|
|
for i in node.output_ports.size():
|
|
|
|
if elements_container.get_child_count() - 1 < i:
|
|
|
|
var pd: PortDrawer = port_drawer_scene.instantiate()
|
|
|
|
elements_container.add_child(pd)
|
|
|
|
var port_drawer: PortDrawer = elements_container.get_child(i)
|
|
|
|
port_drawer.set_output_enabled(true)
|
|
|
|
var output_port := node.output_ports[i]
|
2023-06-10 20:23:57 +02:00
|
|
|
match output_port.descriptor:
|
|
|
|
"field":
|
|
|
|
port_drawer.add_field(output_port.label)
|
|
|
|
output_port.value_callback = port_drawer.get_text
|
|
|
|
"button":
|
|
|
|
port_drawer.add_button(output_port.label)
|
|
|
|
_:
|
|
|
|
port_drawer.add_label(output_port.label)
|
|
|
|
|
2023-06-10 19:13:16 +02:00
|
|
|
|
|
|
|
|