diff --git a/graph_node_renderer/deck_renderer_graph_edit.gd b/graph_node_renderer/deck_renderer_graph_edit.gd index 27f751d..5197116 100644 --- a/graph_node_renderer/deck_renderer_graph_edit.gd +++ b/graph_node_renderer/deck_renderer_graph_edit.gd @@ -124,12 +124,18 @@ func attempt_disconnect(from_node_name: StringName, from_port: int, to_node_name dirty = true -## Returns the associated [DeckNodeRendererGraphNode] for the supplied [DeckNode]. -## Or [code]null[/code] if none is found. +## Returns the associated [DeckNodeRendererGraphNode] for the supplied [DeckNode], +## or [code]null[/code] if none is found. func get_node_renderer(node: DeckNode) -> DeckNodeRendererGraphNode: return get_node_or_null(NodePath(node._id)) +## Returns the associated [DeckNodeRendererGraphNode] for the supplied [DeckNode] [member DeckNode._id], +## or [code]null[/code] if none is found. +func get_node_id_renderer(id: String) -> DeckNodeRendererGraphNode: + return get_node_or_null(NodePath(id)) + + func focus_node(node: DeckNodeRendererGraphNode) -> void: set_selected(node) var t := create_tween() @@ -349,14 +355,12 @@ func _on_add_node_menu_node_selected(type: String) -> void: func _on_deck_nodes_disconnected(from_node_id: String, to_node_id: String, from_output_port: int, to_input_port: int) -> void: - var from_node: DeckNodeRendererGraphNode = get_children().filter( - func(x: DeckNodeRendererGraphNode): - return x.node._id == from_node_id - )[0] - var to_node: DeckNodeRendererGraphNode = get_children().filter( - func(x: DeckNodeRendererGraphNode): - return x.node._id == to_node_id - )[0] + var from_node := get_node_id_renderer(from_node_id) + if from_node == null: + return + var to_node := get_node_id_renderer(to_node_id) + if to_node == null: + return disconnect_node(from_node.name, from_output_port, to_node.name, to_input_port)