Browse Source

tidied up a bit more and refactored a few other bits

Jonathan Higgins 6 months ago
parent
commit
401b8a47cb

+ 1 - 1
scenes/main/audio_settings.tscn

@@ -1,6 +1,6 @@
 [gd_scene load_steps=2 format=3 uid="uid://dta7rfalv4uvd"]
 [gd_scene load_steps=2 format=3 uid="uid://dta7rfalv4uvd"]
 
 
-[ext_resource type="Script" uid="uid://c7krcoq5poxdn" path="res://scenes/main/audiosettings.gd" id="2_7qbns"]
+[ext_resource type="Script" uid="uid://c7krcoq5poxdn" path="res://scenes/main/scripts/audiosettings.gd" id="2_7qbns"]
 
 
 [node name="AudioSettings" type="Window"]
 [node name="AudioSettings" type="Window"]
 title = "Audio Settings"
 title = "Audio Settings"

+ 5 - 3
scenes/main/control.tscn

@@ -1,10 +1,11 @@
-[gd_scene load_steps=9 format=3 uid="uid://bcs87y7ptx3ke"]
+[gd_scene load_steps=10 format=3 uid="uid://bcs87y7ptx3ke"]
 
 
-[ext_resource type="Script" uid="uid://bdlfvuljckmu1" path="res://scenes/main/control.gd" id="1_2f0aq"]
-[ext_resource type="Script" uid="uid://l2yejnjysupr" path="res://scenes/main/graph_edit.gd" id="2_3ioqo"]
+[ext_resource type="Script" uid="uid://bdlfvuljckmu1" path="res://scenes/main/scripts/control.gd" id="1_2f0aq"]
+[ext_resource type="Script" uid="uid://l2yejnjysupr" path="res://scenes/main/scripts/graph_edit.gd" id="2_3ioqo"]
 [ext_resource type="PackedScene" uid="uid://b0wdj8v6o0wq0" path="res://scenes/menu/menu.tscn" id="3_dtf4o"]
 [ext_resource type="PackedScene" uid="uid://b0wdj8v6o0wq0" path="res://scenes/menu/menu.tscn" id="3_dtf4o"]
 [ext_resource type="Texture2D" uid="uid://cdwux1smquvpi" path="res://theme/images/logo.png" id="4_3ioqo"]
 [ext_resource type="Texture2D" uid="uid://cdwux1smquvpi" path="res://theme/images/logo.png" id="4_3ioqo"]
 [ext_resource type="PackedScene" uid="uid://dta7rfalv4uvd" path="res://scenes/main/audio_settings.tscn" id="5_dtf4o"]
 [ext_resource type="PackedScene" uid="uid://dta7rfalv4uvd" path="res://scenes/main/audio_settings.tscn" id="5_dtf4o"]
+[ext_resource type="Script" uid="uid://wja0lo4nobh1" path="res://scenes/main/scripts/about_menu.gd" id="5_yf4wl"]
 [ext_resource type="Script" uid="uid://dlcbmyu3s2phc" path="res://scenes/menu/search_menu.gd" id="6_fyarh"]
 [ext_resource type="Script" uid="uid://dlcbmyu3s2phc" path="res://scenes/menu/search_menu.gd" id="6_fyarh"]
 [ext_resource type="Script" uid="uid://b6r7k326k3vif" path="res://scenes/Nodes/check_for_updates.gd" id="7_1kc3g"]
 [ext_resource type="Script" uid="uid://b6r7k326k3vif" path="res://scenes/Nodes/check_for_updates.gd" id="7_1kc3g"]
 [ext_resource type="PackedScene" uid="uid://c1a6elrpk4eks" path="res://scenes/main/settings.tscn" id="8_16l5g"]
 [ext_resource type="PackedScene" uid="uid://c1a6elrpk4eks" path="res://scenes/main/settings.tscn" id="8_16l5g"]
@@ -296,6 +297,7 @@ item_12/id = 11
 item_count = 1
 item_count = 1
 item_0/id = 0
 item_0/id = 0
 item_0/disabled = true
 item_0/disabled = true
+script = ExtResource("5_yf4wl")
 
 
 [node name="SaveDialog" type="FileDialog" parent="."]
 [node name="SaveDialog" type="FileDialog" parent="."]
 use_native_dialog = true
 use_native_dialog = true

+ 1 - 1
scenes/main/help_window.tscn

@@ -1,6 +1,6 @@
 [gd_scene load_steps=2 format=3 uid="uid://cp5uwxjskqgr7"]
 [gd_scene load_steps=2 format=3 uid="uid://cp5uwxjskqgr7"]
 
 
-[ext_resource type="Script" uid="uid://bkte84glywsny" path="res://scenes/main/help_window.gd" id="1_ro77y"]
+[ext_resource type="Script" uid="uid://bkte84glywsny" path="res://scenes/main/scripts/help_window.gd" id="1_ro77y"]
 
 
 [node name="HelpWindow" type="Window"]
 [node name="HelpWindow" type="Window"]
 auto_translate_mode = 1
 auto_translate_mode = 1

+ 11 - 0
scenes/main/scripts/about_menu.gd

@@ -0,0 +1,11 @@
+extends PopupMenu
+
+
+# Called when the node enters the scene tree for the first time.
+func _ready() -> void:
+	#Check export config for version number and set about menu to current version
+	#Assumes version of mac + linux builds is the same as windows
+	#Requires manual update for alpha and beta builds but once the -beta is removed will be fully automatic so long as version is updated on export
+	var export_config = ConfigFile.new()
+	export_config.load("res://export_presets.cfg")
+	set_item_text(0, "SoundThread v" + export_config.get_value("preset.0.options", "application/product_version", "version unknown") + "-beta") 

+ 1 - 0
scenes/main/scripts/about_menu.gd.uid

@@ -0,0 +1 @@
+uid://wja0lo4nobh1

+ 0 - 0
scenes/main/audiosettings.gd → scenes/main/scripts/audiosettings.gd


+ 0 - 0
scenes/main/audiosettings.gd.uid → scenes/main/scripts/audiosettings.gd.uid


+ 15 - 31
scenes/main/control.gd → scenes/main/scripts/control.gd

@@ -29,9 +29,6 @@ var save_load
 func _ready() -> void:
 func _ready() -> void:
 	Nodes.hide()
 	Nodes.hide()
 	$mainmenu.hide()
 	$mainmenu.hide()
-	#$"mainmenu/select_effect/Time Domain".show()
-	#$"mainmenu/select_effect/Time Domain/Distort".show()
-	#$"mainmenu/select_effect/Frequency Domain/Convert".show()
 	$NoLocationPopup.hide()
 	$NoLocationPopup.hide()
 	$Console.hide()
 	$Console.hide()
 	$NoInputPopup.hide()
 	$NoInputPopup.hide()
@@ -50,10 +47,21 @@ func _ready() -> void:
 	$LoadDialog.file_mode = FileDialog.FILE_MODE_OPEN_FILE
 	$LoadDialog.file_mode = FileDialog.FILE_MODE_OPEN_FILE
 	$LoadDialog.filters = ["*.thd"]
 	$LoadDialog.filters = ["*.thd"]
 	
 	
-	#load scripts
+	get_tree().set_auto_accept_quit(false) #disable closing the app with the x and instead handle it internally
+	
+	load_scripts()
+	make_signal_connections()
+	check_user_preferences()
+	hidpi_adjustment()
+	new_patch()
+	check_cdp_location_set()
+	
+func load_scripts():
+	#load and initialise scripts
 	open_help = preload("res://scenes/main/scripts/open_help.gd").new()
 	open_help = preload("res://scenes/main/scripts/open_help.gd").new()
 	open_help.init(self)
 	open_help.init(self)
 	add_child(open_help)
 	add_child(open_help)
+	
 	run_thread = preload("res://scenes/main/scripts/run_thread.gd").new()
 	run_thread = preload("res://scenes/main/scripts/run_thread.gd").new()
 	run_thread.init(self, $ProgressWindow, $ProgressWindow/ProgressLabel, $ProgressWindow/ProgressBar, $GraphEdit, $Console, $Console/ConsoleOutput)
 	run_thread.init(self, $ProgressWindow, $ProgressWindow/ProgressLabel, $ProgressWindow/ProgressBar, $GraphEdit, $Console, $Console/ConsoleOutput)
 	add_child(run_thread)
 	add_child(run_thread)
@@ -64,23 +72,14 @@ func _ready() -> void:
 	save_load.init(self, $GraphEdit, Callable(open_help, "show_help_for_node"), Callable(graph_edit, "_register_node_movement"), Callable(graph_edit, "_register_inputs_in_node"), Callable(self, "link_output"))
 	save_load.init(self, $GraphEdit, Callable(open_help, "show_help_for_node"), Callable(graph_edit, "_register_node_movement"), Callable(graph_edit, "_register_inputs_in_node"), Callable(self, "link_output"))
 	add_child(save_load)
 	add_child(save_load)
 
 
-	
+func make_signal_connections():
 	get_node("SearchMenu").make_node.connect(graph_edit._make_node)
 	get_node("SearchMenu").make_node.connect(graph_edit._make_node)
 	get_node("mainmenu").make_node.connect(graph_edit._make_node)
 	get_node("mainmenu").make_node.connect(graph_edit._make_node)
 	get_node("mainmenu").open_help.connect(open_help.show_help_for_node)
 	get_node("mainmenu").open_help.connect(open_help.show_help_for_node)
 	get_node("Settings").open_cdp_location.connect(show_cdp_location)
 	get_node("Settings").open_cdp_location.connect(show_cdp_location)
 	get_node("Settings").console_on_top.connect(change_console_settings)
 	get_node("Settings").console_on_top.connect(change_console_settings)
 	
 	
-	check_user_preferences()
-	get_tree().set_auto_accept_quit(false) #disable closing the app with the x and instead handle it internally
-	
-	#Check export config for version number and set about menu to current version
-	#Assumes version of mac + linux builds is the same as windows
-	#Requires manual update for alpha and beta builds but once the -beta is removed will be fully automatic so long as version is updated on export
-	var export_config = ConfigFile.new()
-	export_config.load("res://export_presets.cfg")
-	$MenuBar/About.set_item_text(0, "SoundThread v" + export_config.get_value("preset.0.options", "application/product_version", "version unknown") + "-beta") 
-	
+func hidpi_adjustment():
 	#checks if display is hidpi and scales ui accordingly hidpi - 144
 	#checks if display is hidpi and scales ui accordingly hidpi - 144
 	if DisplayServer.screen_get_dpi(0) >= 144:
 	if DisplayServer.screen_get_dpi(0) >= 144:
 		uiscale = 2.0
 		uiscale = 2.0
@@ -97,11 +96,7 @@ func _ready() -> void:
 		if FileAccess.file_exists(path) and path.get_extension().to_lower() == "thd":
 		if FileAccess.file_exists(path) and path.get_extension().to_lower() == "thd":
 			save_load.load_graph_edit(path)
 			save_load.load_graph_edit(path)
 			break
 			break
-	
-	
-	new_patch()
-	check_cdp_location_set()
-	
+
 func new_patch():
 func new_patch():
 	#clear old patch
 	#clear old patch
 	graph_edit.clear_connections()
 	graph_edit.clear_connections()
@@ -134,7 +129,6 @@ func new_patch():
 	link_output()
 	link_output()
 	
 	
 	
 	
-
 func link_output():
 func link_output():
 	#links various buttons and function in the input nodes - this is called after they are created so that it still works on new and loading files
 	#links various buttons and function in the input nodes - this is called after they are created so that it still works on new and loading files
 	for control in get_tree().get_nodes_in_group("outputnode"): #check all items in outputnode group
 	for control in get_tree().get_nodes_in_group("outputnode"): #check all items in outputnode group
@@ -211,11 +205,6 @@ func _on_cdp_location_dialog_canceled() -> void:
 	#cycles around the set location prompt if user cancels the file dialog
 	#cycles around the set location prompt if user cancels the file dialog
 	check_cdp_location_set()
 	check_cdp_location_set()
 	
 	
-# Called every frame. 'delta' is the elapsed time since the previous frame.
-func _process(delta: float) -> void:
-	#showmenu()
-	pass
-	
 
 
 func _input(event):
 func _input(event):
 	if event.is_action_pressed("copy_node"):
 	if event.is_action_pressed("copy_node"):
@@ -242,8 +231,6 @@ func _input(event):
 	
 	
 
 
 
 
-
-
 func simulate_mouse_click():
 func simulate_mouse_click():
 	#simulates clicking the middle mouse button in order to hide any visible tooltips
 	#simulates clicking the middle mouse button in order to hide any visible tooltips
 	var click_pos = get_viewport().get_mouse_position()
 	var click_pos = get_viewport().get_mouse_position()
@@ -261,9 +248,6 @@ func simulate_mouse_click():
 	Input.parse_input_event(up_event)
 	Input.parse_input_event(up_event)
 
 
 
 
-	
-
-
 func _run_process() -> void:
 func _run_process() -> void:
 	if Global.infile == "no_file":
 	if Global.infile == "no_file":
 		$NoInputPopup.popup_centered()
 		$NoInputPopup.popup_centered()

+ 0 - 0
scenes/main/control.gd.uid → scenes/main/scripts/control.gd.uid


+ 0 - 0
scenes/main/graph_edit.gd → scenes/main/scripts/graph_edit.gd


+ 0 - 0
scenes/main/graph_edit.gd.uid → scenes/main/scripts/graph_edit.gd.uid


+ 0 - 0
scenes/main/help_window.gd → scenes/main/scripts/help_window.gd


+ 0 - 0
scenes/main/help_window.gd.uid → scenes/main/scripts/help_window.gd.uid


+ 0 - 0
scenes/main/settings.gd → scenes/main/scripts/settings.gd


+ 0 - 0
scenes/main/settings.gd.uid → scenes/main/scripts/settings.gd.uid


+ 1 - 1
scenes/main/settings.tscn

@@ -1,6 +1,6 @@
 [gd_scene load_steps=2 format=3 uid="uid://c1a6elrpk4eks"]
 [gd_scene load_steps=2 format=3 uid="uid://c1a6elrpk4eks"]
 
 
-[ext_resource type="Script" uid="uid://co12pspac25gq" path="res://scenes/main/settings.gd" id="1_uey6c"]
+[ext_resource type="Script" uid="uid://co12pspac25gq" path="res://scenes/main/scripts/settings.gd" id="1_uey6c"]
 
 
 [node name="Settings" type="Window"]
 [node name="Settings" type="Window"]
 auto_translate_mode = 1
 auto_translate_mode = 1