Browse Source

made deleting additional input nodes possible

Jonathan Higgins 6 months ago
parent
commit
be7d36c43e
3 changed files with 18 additions and 9 deletions
  1. 11 3
      scenes/main/scripts/graph_edit.gd
  2. 4 4
      scenes/menu/explore_menu.gd
  3. 3 2
      scenes/menu/search_menu.gd

+ 11 - 3
scenes/main/scripts/graph_edit.gd

@@ -83,12 +83,20 @@ func _unhandled_key_input(event: InputEvent) -> void:
 
 func _on_graph_edit_delete_nodes_request(nodes: Array[StringName]) -> void:
 	control_script.undo_redo.create_action("Delete Nodes (Undo only)")
-
+	
+	#get the number of inputs in the patch
+	var number_of_inputs = 0
+	for allnodes in get_children():
+		if allnodes.get_meta("command") == "inputfile":
+			number_of_inputs += 1
+			
 	for node in selected_nodes.keys():
 		if selected_nodes[node]:
-			if node.get_meta("command") == "inputfile" or node.get_meta("command") == "outputfile":
-				print("can't delete input or output")
+			#check if node is the output or the last input node and do nothing
+			if (number_of_inputs <= 1 and node.get_meta("command") == "inputfile") or node.get_meta("command") == "outputfile":
+				pass
 			else:
+				number_of_inputs -= 1
 				# Store duplicate and state for undo
 				var node_data = node.duplicate()
 				var position = node.position_offset

+ 4 - 4
scenes/menu/explore_menu.gd

@@ -26,8 +26,8 @@ func fill_menu():
 		var item = node_data[key]
 		var title = item.get("title", "")
 		
-		#filter out input and output nodes
-		if title == "Input File" or title == "Output File":
+		#filter out output nodes
+		if title == "Output File":
 			continue
 		
 		var category = item.get("category", "")
@@ -114,8 +114,8 @@ func fill_search(filter: String):
 		var item = node_data[key]
 		var title = item.get("title", "")
 		
-		#filter out input and output nodes
-		if title == "Input File" or title == "Output File":
+		#filter out output node
+		if title == "Output File":
 			continue
 		
 		var category = item.get("category", "")

+ 3 - 2
scenes/menu/search_menu.gd

@@ -37,8 +37,7 @@ func display_items(filter: String):
 		var item = node_data[key]
 		var title = item.get("title", "")
 		
-		#filter out input and output nodes
-		#if title == "Input File" or title == "Output File":
+		#filter out output node
 		if title == "Output File":
 			continue
 		
@@ -59,6 +58,8 @@ func display_items(filter: String):
 		btn.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS #and replace with ...
 		if category.to_lower() == "pvoc": #format node names correctly, only show the category for PVOC
 			btn.text = "%s %s: %s - %s" % [category.to_upper(), subcategory.to_pascal_case(), title, short_desc]
+		elif title.to_lower() == "input file":
+			btn.text = "%s - %s" % [title, short_desc]
 		else:
 			btn.text = "%s: %s - %s" % [subcategory.to_pascal_case(), title, short_desc]
 		btn.connect("pressed", Callable(self, "_on_item_selected").bind(key)) #pass key (process name) when button is pressed