This commit is contained in:
Lera Elvoé 2023-11-27 00:39:53 +03:00
parent a3ac776907
commit 14ecc1087a
No known key found for this signature in database

View file

@ -80,7 +80,7 @@ func attempt_disconnect(from_node_name: StringName, from_port: int, to_node_name
## Returns the associated [DeckNodeRendererGraphNode] for the supplied [DeckNode]. ## Returns the associated [DeckNodeRendererGraphNode] for the supplied [DeckNode].
## Or [code]null[/code] if none is found. ## Or [code]null[/code] if none is found.
func get_node_renderer(node: DeckNode) -> DeckNodeRendererGraphNode: func get_node_renderer(node: DeckNode) -> DeckNodeRendererGraphNode:
for i: DeckNodeRendererGraphNode in get_children().slice(1): for i: DeckNodeRendererGraphNode in get_children():
if i.node == node: if i.node == node:
return i return i
@ -92,9 +92,7 @@ func _on_scroll_offset_changed(offset: Vector2) -> void:
## Setups all the data from the set [member deck] in this [DeckRendererGraphEdit] ## Setups all the data from the set [member deck] in this [DeckRendererGraphEdit]
func initialize_from_deck() -> void: func initialize_from_deck() -> void:
# TODO: wait for https://github.com/godotengine/godot/issues/85005 to get merged for i in get_children():
# until it is, all calls to GraphEdit#get_children will need to slice off the first element
for i in get_children().slice(1):
i.queue_free() i.queue_free()
scroll_offset = deck.get_meta("offset", Vector2()) scroll_offset = deck.get_meta("offset", Vector2())
@ -107,7 +105,7 @@ func initialize_from_deck() -> void:
for node_id in deck.nodes: for node_id in deck.nodes:
var node: DeckNode = deck.nodes[node_id] var node: DeckNode = deck.nodes[node_id]
var from_node = get_children().slice(1).filter( var from_node = get_children().filter(
func(c: DeckNodeRendererGraphNode): func(c: DeckNodeRendererGraphNode):
return c.node._id == node_id return c.node._id == node_id
)[0] )[0]
@ -119,7 +117,7 @@ func initialize_from_deck() -> void:
func refresh_connections() -> void: func refresh_connections() -> void:
for node_id in deck.nodes: for node_id in deck.nodes:
var node: DeckNode = deck.nodes[node_id] var node: DeckNode = deck.nodes[node_id]
var from_node: DeckNodeRendererGraphNode = get_children().slice(1).filter( var from_node: DeckNodeRendererGraphNode = get_children().filter(
func(c: DeckNodeRendererGraphNode): func(c: DeckNodeRendererGraphNode):
return c.node._id == node_id return c.node._id == node_id
)[0] )[0]
@ -128,7 +126,7 @@ func refresh_connections() -> void:
for connection in node.outgoing_connections[from_port]: for connection in node.outgoing_connections[from_port]:
var to_node_id = connection.keys()[0] var to_node_id = connection.keys()[0]
var to_node_port = connection.values()[0] var to_node_port = connection.values()[0]
var to_node: DeckNodeRendererGraphNode = get_children().slice(1).filter( var to_node: DeckNodeRendererGraphNode = get_children().filter(
func(c: DeckNodeRendererGraphNode): func(c: DeckNodeRendererGraphNode):
return c.node._id == to_node_id return c.node._id == to_node_id
)[0] )[0]
@ -157,7 +155,7 @@ func _on_deck_node_added(node: DeckNode) -> void:
## Connected to [signal Deck.node_added], used to remove the specified ## Connected to [signal Deck.node_added], used to remove the specified
## [DeckNodeRendererGraphNode] and queue_free it. ## [DeckNodeRendererGraphNode] and queue_free it.
func _on_deck_node_removed(node: DeckNode) -> void: func _on_deck_node_removed(node: DeckNode) -> void:
for renderer: DeckNodeRendererGraphNode in get_children().slice(1): for renderer: DeckNodeRendererGraphNode in get_children():
if renderer.node != node: if renderer.node != node:
continue continue
@ -167,7 +165,7 @@ func _on_deck_node_removed(node: DeckNode) -> void:
## Utility function that gets all [DeckNodeRenderGraphNode]s that are selected ## Utility function that gets all [DeckNodeRenderGraphNode]s that are selected
## See [member GraphNode.selected] ## See [member GraphNode.selected]
func get_selected_nodes() -> Array: func get_selected_nodes() -> Array:
return get_children().slice(1).filter( return get_children().filter(
func(x: DeckNodeRendererGraphNode): func(x: DeckNodeRendererGraphNode):
return x.selected return x.selected
) )