mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
fix node connections not being empty on copy/paste (#142)
Reviewed-on: https://codeberg.org/StreamGraph/StreamGraph/pulls/142 Co-authored-by: Lera Elvoé <yagich@poto.cafe> Co-committed-by: Lera Elvoé <yagich@poto.cafe>
This commit is contained in:
parent
82edd774a0
commit
2ac9db8350
2 changed files with 15 additions and 16 deletions
|
@ -357,14 +357,13 @@ func copy_nodes(nodes_to_copy: Array[String]) -> Dictionary:
|
|||
if to_node not in nodes_to_copy:
|
||||
(d.nodes[node].outgoing_connections[from_port] as Dictionary).erase(to_node)
|
||||
|
||||
var outgoing_is_empty: bool = true
|
||||
var keys_to_erase := []
|
||||
for from_port: int in d.nodes[node].outgoing_connections:
|
||||
if not (d.nodes[node].outgoing_connections[from_port] as Dictionary).is_empty():
|
||||
outgoing_is_empty = false
|
||||
break
|
||||
if (d.nodes[node].outgoing_connections[from_port] as Dictionary).is_empty():
|
||||
keys_to_erase.append(from_port)
|
||||
|
||||
if outgoing_is_empty:
|
||||
d.nodes[node].outgoing_connections = {}
|
||||
for key in keys_to_erase:
|
||||
(d.nodes[node].outgoing_connections as Dictionary).erase(key)
|
||||
|
||||
var incoming_connections: Dictionary = d.nodes[node].incoming_connections.duplicate(true)
|
||||
|
||||
|
@ -373,14 +372,14 @@ func copy_nodes(nodes_to_copy: Array[String]) -> Dictionary:
|
|||
if from_node not in nodes_to_copy:
|
||||
(d.nodes[node].incoming_connections[to_port] as Dictionary).erase(from_node)
|
||||
|
||||
var incoming_is_empty: bool = true
|
||||
keys_to_erase.clear()
|
||||
for to_port: int in d.nodes[node].incoming_connections:
|
||||
if not (d.nodes[node].incoming_connections[to_port] as Dictionary).is_empty():
|
||||
incoming_is_empty = false
|
||||
break
|
||||
if (d.nodes[node].incoming_connections[to_port] as Dictionary).is_empty():
|
||||
keys_to_erase.append(to_port)
|
||||
|
||||
if incoming_is_empty:
|
||||
d.nodes[node].incoming_connections = {}
|
||||
for key in keys_to_erase:
|
||||
(d.nodes[node].incoming_connections as Dictionary).erase(key)
|
||||
keys_to_erase.clear()
|
||||
|
||||
for node: Dictionary in d.nodes.values().slice(1):
|
||||
node.position.x = node.position.x - d.nodes.values()[0].position.x
|
||||
|
|
|
@ -14,7 +14,7 @@ var name: String
|
|||
## [code]Dictionary[int -> output port, Dictionary[String -> DeckNode#_id, Array[int -> input port]]][/code]
|
||||
var outgoing_connections: Dictionary
|
||||
## A map of incoming connections to this node, in the format[br]
|
||||
## [code]Dictionary[int -> input port, [Dictionary[String -> DeckNode#_id, int -> output port]][/code]
|
||||
## [code]Dictionary[int -> input port, Dictionary[String -> DeckNode#_id, int -> output port][/code]
|
||||
var incoming_connections: Dictionary
|
||||
|
||||
## A list of [Port]s on this node.
|
||||
|
|
Loading…
Reference in a new issue