2023-06-12 17:32:36 +02:00
|
|
|
extends GraphNode
|
|
|
|
class_name DeckNodeRendererGraphNode
|
|
|
|
|
|
|
|
var node: DeckNode
|
|
|
|
|
|
|
|
|
|
|
|
func _ready() -> void:
|
|
|
|
title = node.name
|
|
|
|
|
|
|
|
for port in node.get_all_ports():
|
|
|
|
var descriptor_split := port.descriptor.split(":")
|
|
|
|
match descriptor_split[0]:
|
|
|
|
"button":
|
|
|
|
var button := Button.new()
|
|
|
|
add_child(button)
|
|
|
|
button.text = port.label
|
|
|
|
if port.port_type == DeckNode.PortType.OUTPUT:
|
|
|
|
button.pressed.connect(
|
|
|
|
func():
|
2023-06-12 17:59:30 +02:00
|
|
|
node.send(port.index, DeckType.DeckTypeBool.new(true))
|
|
|
|
)
|
|
|
|
elif port.port_type == DeckNode.PortType.INPUT:
|
|
|
|
button.pressed.connect(
|
|
|
|
func():
|
|
|
|
node._receive(port.index, DeckType.DeckTypeBool.new(true))
|
2023-06-12 17:32:36 +02:00
|
|
|
)
|
|
|
|
"field":
|
|
|
|
var line_edit := LineEdit.new()
|
|
|
|
add_child(line_edit)
|
|
|
|
line_edit.placeholder_text = port.label
|
|
|
|
port.value_callback = line_edit.get_text
|
|
|
|
_:
|
|
|
|
var label := Label.new()
|
|
|
|
add_child(label)
|
|
|
|
label.text = port.label
|
|
|
|
|
|
|
|
set_slot(
|
|
|
|
port.index,
|
|
|
|
port.port_type == DeckNode.PortType.INPUT,
|
|
|
|
0,
|
|
|
|
Color.WHITE,
|
|
|
|
port.port_type == DeckNode.PortType.OUTPUT,
|
|
|
|
0,
|
|
|
|
Color.WHITE,
|
|
|
|
)
|
2023-06-24 05:39:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
func _on_position_offset_changed() -> void:
|
|
|
|
node.set_meta("position_offset", position_offset)
|