fix connections but 2

This commit is contained in:
Lera Elvoé 2023-06-12 18:59:30 +03:00
parent 318efb9c34
commit a5acd3a1c3
No known key found for this signature in database
6 changed files with 25 additions and 5 deletions

View file

@ -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)

View file

@ -3,7 +3,7 @@ extends DeckNode
func _init() -> void:
add_output_port(
Deck.Types.STRING,
Deck.Types.BOOL,
"Press me",
"button"
)

View file

@ -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))

View file

@ -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()

View file

@ -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)

View file

@ -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"