diff --git a/classes/deck/deck.gd b/classes/deck/deck.gd index 09887f8..c466be3 100644 --- a/classes/deck/deck.gd +++ b/classes/deck/deck.gd @@ -43,8 +43,8 @@ func get_node(uuid: String) -> DeckNode: func connect_nodes(from_node: DeckNode, to_node: DeckNode, from_port: int, to_port: int) -> bool: # first, check that we can do the type conversion. - var type_a: Types = from_node.output_ports[from_port].type - var type_b: Types = to_node.input_ports[to_port].type + var type_a: Types = from_node.ports[from_port].type + var type_b: Types = to_node.ports[to_port].type var err: DeckType = (type_assoc[type_b]).from(type_assoc[type_a].new()) if err is DeckType.DeckTypeError: print(err.error_message) diff --git a/classes/deck/nodes/button.gd b/classes/deck/nodes/button.gd index 8b6bd03..f983540 100644 --- a/classes/deck/nodes/button.gd +++ b/classes/deck/nodes/button.gd @@ -3,7 +3,7 @@ extends DeckNode func _init() -> void: add_output_port( - Deck.Types.STRING, + Deck.Types.BOOL, "Press me", "button" ) diff --git a/classes/deck/nodes/print.gd b/classes/deck/nodes/print.gd index 9bd45d5..e042156 100644 --- a/classes/deck/nodes/print.gd +++ b/classes/deck/nodes/print.gd @@ -27,7 +27,8 @@ func _receive(to_port: int, data: DeckType, extra_data: Array = []) -> void: if to_port != 1: return - var data_to_print = data.get_value() + var data_to_print = ports[0].value_callback.call() if ports[0].value_callback.call() != "" else data.get_value() # var data_to_print = input_ports[0].value_callback.call() print(data_to_print) print("extra data: ", extra_data) + send(2, DeckType.DeckTypeBool.new(true)) diff --git a/graph_node_renderer/deck_node_renderer_graph_node.gd b/graph_node_renderer/deck_node_renderer_graph_node.gd index 9a553c3..4854c7d 100644 --- a/graph_node_renderer/deck_node_renderer_graph_node.gd +++ b/graph_node_renderer/deck_node_renderer_graph_node.gd @@ -17,7 +17,12 @@ func _ready() -> void: if port.port_type == DeckNode.PortType.OUTPUT: button.pressed.connect( func(): - node.send(port.index, DeckType.DeckTypeString.new("Button Pressed")) + 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)) ) "field": var line_edit := LineEdit.new() diff --git a/graph_node_renderer/deck_renderer_graph_edit.gd b/graph_node_renderer/deck_renderer_graph_edit.gd index 929be2b..473cb18 100644 --- a/graph_node_renderer/deck_renderer_graph_edit.gd +++ b/graph_node_renderer/deck_renderer_graph_edit.gd @@ -30,3 +30,16 @@ func _ready() -> void: node_renderer.node = node add_child(node_renderer) ) + + connection_request.connect(attempt_connection) + + +func attempt_connection(from_node_name: StringName, from_port: int, to_node_name: StringName, to_port: int) -> void: + var from_node: DeckNode = get_node(NodePath(from_node_name)).node + var to_node: DeckNode = get_node(NodePath(to_node_name)).node + + var from_output := from_node.get_global_port_idx_from_output(from_port) + var to_input := to_node.get_global_port_idx_from_input(to_port) + + if deck.connect_nodes(from_node, to_node, from_output, to_input): + connect_node(from_node_name, from_port, to_node_name, to_port) diff --git a/project.godot b/project.godot index 80a16fb..a0a95f3 100644 --- a/project.godot +++ b/project.godot @@ -14,4 +14,5 @@ config/name="Re-DotDeck" config/tags=PackedStringArray("dot_deck") run/main_scene="res://graph_node_renderer/deck_renderer_graph_edit.tscn" config/features=PackedStringArray("4.1", "Forward Plus") +run/low_processor_mode=true config/icon="res://icon.svg"