Browse Source

fixed copy paste and updated valid thread checker

Jonathan Higgins 6 months ago
parent
commit
f5811a1ba1

+ 0 - 1
scenes/Nodes/audioplayer.gd

@@ -36,7 +36,6 @@ func _ready():
 	voice_preview_generator.texture_ready.connect(_on_texture_ready)
 	
 	#setup meta to say the player is empty and no trim points have been set
-	set_meta("inputfile", "none")
 	set_meta("trimfile", false)
 
 #func _on_files_dropped(files):

+ 1 - 1
scenes/main/scripts/control.gd

@@ -251,7 +251,7 @@ func simulate_mouse_click():
 func _run_process() -> void:
 	#check if any of the inputfile nodes don't have files loaded
 	for node in graph_edit.get_children():
-		if node.get_meta("command") == "inputfile" and node.get_node("AudioPlayer").get_meta("inputfile") == "none":
+		if node.get_meta("command") == "inputfile" and node.get_node("AudioPlayer").has_meta("inputfile") == false:
 			$NoInputPopup.popup_centered()
 			return
 	#check if the reuse folder toggle is set and a folder has been previously chosen

+ 1 - 1
scenes/main/scripts/graph_edit.gd

@@ -148,7 +148,7 @@ func copy_selected_nodes():
 	for node in get_children():
 		# Check if the node is selected and not an 'inputfile' or 'outputfile'
 		if node is GraphNode and selected_nodes.get(node, false):
-			if node.get_meta("command") == "inputfile" or node.get_meta("command") == "outputfile":
+			if node.get_meta("command") == "outputfile":
 				continue  # Skip these nodes
 
 			var node_data = {

+ 32 - 29
scenes/main/scripts/run_thread.gd

@@ -57,6 +57,10 @@ func run_thread_with_branches():
 		log_console("[color=#9c2828][b]Error: Valid Thread not found[/b][/color]", true)
 		log_console("Threads must contain at least one processing node and a valid path from the Input File to the Output File.", true)
 		await get_tree().process_frame  # Let UI update
+		if progress_window.visible:
+			progress_window.hide()
+		if !console_window.visible:
+			console_window.popup_centered()
 		return
 	else:
 		log_console("[color=#638382][b]Valid Thread found[/b][/color]", true)
@@ -190,18 +194,19 @@ func run_thread_with_branches():
 					return
 				else:
 					progress_label.text = "Trimming input audio"
-				await run_command(control_script.cdpprogs_location + "/sfedit", ["cut", "1", loadedfile, "%s_trimmed.wav" % Global.outfile, str(start), str(end)])
+				await run_command(control_script.cdpprogs_location + "/sfedit", ["cut", "1", loadedfile, "%s_%d_input_trim.wav" % [Global.outfile, process_count], str(start), str(end)])
 				
-				output_files[node_name] =  Global.outfile + "_trimmed.wav"
+				output_files[node_name] =  "%s_%d_input_trim.wav" % [Global.outfile, process_count]
 				
 				# Mark trimmed file for cleanup if needed
 				if control_script.delete_intermediate_outputs:
-					intermediate_files.append(Global.outfile + "_trimmed.wav")
+					intermediate_files.append("%s_%d_input_trim.wav" % [Global.outfile, process_count])
 				progress_bar.value += progress_step
 			else:
 				#if trim not enabled pass the loaded file
 				output_files[node_name] =  loadedfile
-			
+				
+			process_count += 1
 		else:
 			# Build the command for the current node's audio processing
 			var slider_data = _get_slider_values_ordered(node)
@@ -665,10 +670,11 @@ func _on_kill_process_button_down() -> void:
 
 	
 func path_exists_through_all_nodes() -> bool:
+	print("checking path")
 	var all_nodes = {}
 	var graph = {}
 
-	var input_node_name = ""
+	var input_node_names = []
 	var output_node_name = ""
 
 	# Gather all relevant nodes
@@ -679,19 +685,15 @@ func path_exists_through_all_nodes() -> bool:
 
 			var command = child.get_meta("command")
 			if command == "inputfile":
-				input_node_name = name
+				input_node_names.append(name)
 			elif command == "outputfile":
 				output_node_name = name
 
 			# Skip utility nodes, include others
 			if command in ["inputfile", "outputfile"] or not child.has_meta("utility"):
 				graph[name] = []
-
-	# Ensure both input and output were found
-	if input_node_name == "" or output_node_name == "":
-		print("Input or output node not found!")
-		return false
-
+	print(input_node_names)
+	print(output_node_name)
 	# Add edges to graph from the connection list
 	var connection_list = graph_edit.get_connection_list()
 	for conn in connection_list:
@@ -700,28 +702,29 @@ func path_exists_through_all_nodes() -> bool:
 		if graph.has(from):
 			graph[from].append(to)
 
-	# BFS traversal to check path and depth
-	var visited = {}
-	var queue = [ { "node": input_node_name, "depth": 0 } ]
-	var has_intermediate = false
+	# BFS from each input node
+	for input_node_name in input_node_names:
+		var visited = {}
+		var queue = [{ "node": input_node_name, "depth": 0 }]
 
-	while queue.size() > 0:
-		var current = queue.pop_front()
-		var current_node = current["node"]
-		var depth = current["depth"]
+		while queue.size() > 0:
+			var current = queue.pop_front()
+			var current_node = current["node"]
+			var depth = current["depth"]
 
-		if current_node in visited:
-			continue
-		visited[current_node] = true
+			if current_node in visited:
+				continue
+			visited[current_node] = true
 
-		if current_node == output_node_name and depth >= 2:
-			has_intermediate = true
+			if current_node == output_node_name and depth >= 2:
+				return true  # Found a valid path from this input node
 
-		if graph.has(current_node):
-			for neighbor in graph[current_node]:
-				queue.append({ "node": neighbor, "depth": depth + 1 })
+			if graph.has(current_node):
+				for neighbor in graph[current_node]:
+					queue.append({ "node": neighbor, "depth": depth + 1 })
 
-	return has_intermediate
+	# If no path from any input node to output node was found
+	return false
 	
 func log_console(text: String, update: bool) -> void:
 	console_output.append_text(text + "\n \n")