disallow grouping and removing group i/o nodes

This commit is contained in:
Lera Elvoé 2023-12-14 19:08:02 +03:00
parent 16c6cfb4f9
commit 73422418ba
No known key found for this signature in database
4 changed files with 17 additions and 2 deletions

View file

@ -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

View file

@ -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).

View file

@ -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,

View file

@ -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,