fix recursive grouping

This commit is contained in:
Lera Elvoé 2023-12-08 12:25:08 +03:00
parent 802749704f
commit 330906460e
No known key found for this signature in database

View file

@ -140,12 +140,12 @@ func is_empty() -> bool:
## Remove a node from this deck.
func remove_node(uuid: String, remove_connections: bool = false) -> void:
func remove_node(uuid: String, remove_connections: bool = false, keep_group_instances: bool = false) -> void:
var node := get_node(uuid)
if node == null:
return
if node.node_type == "group_node":
if node.node_type == "group_node" && !keep_group_instances:
DeckHolder.close_group_instance(node.group_id, node.group_instance_id)
if remove_connections:
@ -185,8 +185,9 @@ func group_nodes(nodes_to_group: Array) -> Deck:
var group := DeckHolder.add_empty_group()
var midpoint := Vector2()
var temp := []
for node: DeckNode in nodes_to_group:
#if node.node_type == "group_node": # for recursive grouping
#if node.node_type == "group_node":
#var _group_id: String = node.group_id
#var _group: Deck = groups[_group_id]
#groups.erase(_group)
@ -209,7 +210,7 @@ func group_nodes(nodes_to_group: Array) -> Deck:
disconnect_nodes(from_node, node._id, incoming_connections[to_port][from_node], to_port)
midpoint += node.position_as_vector2()
remove_node(node._id)
remove_node(node._id, false, true)
group.add_node_inst(node, node._id)
midpoint /= nodes_to_group.size()