diff --git a/classes/deck/deck.gd b/classes/deck/deck.gd index 00455f1..fa554b1 100644 --- a/classes/deck/deck.gd +++ b/classes/deck/deck.gd @@ -143,11 +143,14 @@ func is_empty() -> bool: ## Remove a node from this deck. -func remove_node(uuid: String, remove_connections: bool = false, keep_group_instances: bool = false) -> void: +func remove_node(uuid: String, remove_connections: bool = false, force: bool = false, keep_group_instances: bool = false) -> void: var node := get_node(uuid) if node == null: return + if !node.user_can_delete && !force: + return + if node.node_type == "group_node" && !keep_group_instances: DeckHolder.close_group_instance(node.group_id, node.group_instance_id) @@ -179,7 +182,13 @@ func remove_node(uuid: String, remove_connections: bool = false, keep_group_inst func group_nodes(nodes_to_group: Array) -> Deck: if nodes_to_group.is_empty(): return null - + + # don't include nodes that can't be grouped/deleted + nodes_to_group = nodes_to_group.filter( + func(x: DeckNode): + return x.user_can_delete + ) + var node_ids_to_keep := nodes_to_group.map( func(x: DeckNode): return x._id diff --git a/classes/deck/deck_node.gd b/classes/deck/deck_node.gd index 333df3a..76d745e 100644 --- a/classes/deck/deck_node.gd +++ b/classes/deck/deck_node.gd @@ -41,6 +41,10 @@ var props_to_serialize: Array[StringName] ## Only used by renderers. var position: Dictionary = {"x": 0.0, "y": 0.0} +## If [code]true[/code], the user can delete this node by normal means. +## The parent [Deck] can still delete the node by other means. +var user_can_delete: bool = true + enum PortType{ INPUT, ## Input port type (slot on the left). OUTPUT, ## Output port type (slot on the right). diff --git a/classes/deck/nodes/group_input_node.gd b/classes/deck/nodes/group_input_node.gd index 52022dc..1230b6e 100644 --- a/classes/deck/nodes/group_input_node.gd +++ b/classes/deck/nodes/group_input_node.gd @@ -12,6 +12,7 @@ func _init() -> void: node_type = "group_input" props_to_serialize = [&"output_count"] appears_in_search = false + user_can_delete = false add_output_port( DeckType.Types.ANY, diff --git a/classes/deck/nodes/group_output_node.gd b/classes/deck/nodes/group_output_node.gd index baeb7b4..5643b09 100644 --- a/classes/deck/nodes/group_output_node.gd +++ b/classes/deck/nodes/group_output_node.gd @@ -12,6 +12,7 @@ func _init() -> void: node_type = "group_output" props_to_serialize = [&"input_count"] appears_in_search = false + user_can_delete = false add_input_port( DeckType.Types.ANY,