|
|
@@ -40,6 +40,7 @@ func _ready() -> void:
|
|
|
$AudioSettings.hide()
|
|
|
$AudioDevicePopup.hide()
|
|
|
$SearchMenu.hide()
|
|
|
+ $Settings.hide()
|
|
|
|
|
|
$SaveDialog.access = FileDialog.ACCESS_FILESYSTEM
|
|
|
$SaveDialog.file_mode = FileDialog.FILE_MODE_SAVE_FILE
|
|
|
@@ -49,6 +50,7 @@ func _ready() -> void:
|
|
|
$LoadDialog.file_mode = FileDialog.FILE_MODE_OPEN_FILE
|
|
|
$LoadDialog.filters = ["*.thd"]
|
|
|
|
|
|
+
|
|
|
#Goes through all nodes in scene and checks for buttons in the make_node_buttons group
|
|
|
#Associates all buttons with the _on_button_pressed fuction and passes the button as an argument
|
|
|
for child in get_tree().get_nodes_in_group("make_node_buttons"):
|
|
|
@@ -58,6 +60,8 @@ func _ready() -> void:
|
|
|
get_node("SearchMenu").make_node.connect(_make_node_from_search_menu)
|
|
|
get_node("mainmenu").make_node.connect(_make_node_from_search_menu)
|
|
|
get_node("mainmenu").open_help.connect(show_help_for_node)
|
|
|
+ get_node("Settings").open_cdp_location.connect(show_cdp_location)
|
|
|
+ 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
|
|
|
@@ -156,15 +160,23 @@ func check_user_preferences():
|
|
|
var interface_settings = ConfigHandler.load_interface_settings()
|
|
|
var audio_settings = ConfigHandler.load_audio_settings()
|
|
|
var audio_devices = AudioServer.get_output_device_list()
|
|
|
- $MenuBar/SettingsButton.set_item_checked(1, interface_settings.disable_pvoc_warning)
|
|
|
- $MenuBar/SettingsButton.set_item_checked(2, interface_settings.auto_close_console)
|
|
|
- $MenuBar/SettingsButton.set_item_checked(3, interface_settings.console_on_top)
|
|
|
$Console.always_on_top = interface_settings.console_on_top
|
|
|
if audio_devices.has(audio_settings.device):
|
|
|
AudioServer.set_output_device(audio_settings.device)
|
|
|
else:
|
|
|
$AudioDevicePopup.popup_centered()
|
|
|
-
|
|
|
+
|
|
|
+ match interface_settings.theme:
|
|
|
+ 0:
|
|
|
+ RenderingServer.set_default_clear_color(Color("#2f4f4e"))
|
|
|
+ 1:
|
|
|
+ RenderingServer.set_default_clear_color(Color("#000807"))
|
|
|
+ 2:
|
|
|
+ RenderingServer.set_default_clear_color(Color("#98d4d2"))
|
|
|
+ 3:
|
|
|
+ RenderingServer.set_default_clear_color(Color(interface_settings.theme_custom_colour))
|
|
|
+func show_cdp_location():
|
|
|
+ $CdpLocationDialog.show()
|
|
|
|
|
|
func check_cdp_location_set():
|
|
|
#checks if the location has been set and prompts user to set it
|
|
|
@@ -1375,33 +1387,10 @@ func _on_settings_button_index_pressed(index: int) -> void:
|
|
|
|
|
|
match index:
|
|
|
0:
|
|
|
- $CdpLocationDialog.show()
|
|
|
+ $Settings.popup_centered()
|
|
|
1:
|
|
|
- if interface_settings.disable_pvoc_warning == false:
|
|
|
- $MenuBar/SettingsButton.set_item_checked(index, true)
|
|
|
- ConfigHandler.save_interface_settings("disable_pvoc_warning", true)
|
|
|
- else:
|
|
|
- $MenuBar/SettingsButton.set_item_checked(index, false)
|
|
|
- ConfigHandler.save_interface_settings("disable_pvoc_warning", false)
|
|
|
- 2:
|
|
|
- if interface_settings.auto_close_console == false:
|
|
|
- $MenuBar/SettingsButton.set_item_checked(index, true)
|
|
|
- ConfigHandler.save_interface_settings("auto_close_console", true)
|
|
|
- else:
|
|
|
- $MenuBar/SettingsButton.set_item_checked(index, false)
|
|
|
- ConfigHandler.save_interface_settings("auto_close_console", false)
|
|
|
- 3:
|
|
|
- if interface_settings.console_on_top == false:
|
|
|
- $MenuBar/SettingsButton.set_item_checked(index, true)
|
|
|
- ConfigHandler.save_interface_settings("console_on_top", true)
|
|
|
- $Console.always_on_top = true
|
|
|
- else:
|
|
|
- $MenuBar/SettingsButton.set_item_checked(index, false)
|
|
|
- ConfigHandler.save_interface_settings("console_on_top", false)
|
|
|
- $Console.always_on_top = false
|
|
|
- 4:
|
|
|
$AudioSettings.popup_centered()
|
|
|
- 5:
|
|
|
+ 2:
|
|
|
if $Console.is_visible():
|
|
|
$Console.hide()
|
|
|
await get_tree().process_frame # Wait a frame to allow hide to complete
|
|
|
@@ -1605,160 +1594,6 @@ func load_graph_edit(path: String):
|
|
|
print("Graph loaded.")
|
|
|
get_window().title = "SoundThread - " + path.get_file().trim_suffix(".thd")
|
|
|
|
|
|
-#func save_graph_edit(path: String):
|
|
|
- #var file = FileAccess.open(path, FileAccess.WRITE)
|
|
|
- #if file == null:
|
|
|
- #print("Failed to open file for saving")
|
|
|
- #return
|
|
|
-#
|
|
|
- #var node_data_list = []
|
|
|
- #var connection_data_list = []
|
|
|
-#
|
|
|
- #for node in graph_edit.get_children():
|
|
|
- #if node is GraphNode:
|
|
|
- #var offset = node.position_offset
|
|
|
- #var node_data = {
|
|
|
- #"name": node.name,
|
|
|
- #"command": node.get_meta("command"),
|
|
|
- #"offset": { "x": offset.x, "y": offset.y },
|
|
|
- #"slider_values": {},
|
|
|
- #"notes":{}
|
|
|
- #}
|
|
|
-#
|
|
|
- #for child in node.find_children("*", "Slider", true, false):
|
|
|
- #var relative_path = node.get_path_to(child)
|
|
|
- #var path_str = str(relative_path)
|
|
|
-#
|
|
|
- ## Save slider value
|
|
|
- #node_data["slider_values"][path_str] = {
|
|
|
- #"value": child.value,
|
|
|
- #"editable": child.editable,
|
|
|
- #"meta": {}
|
|
|
- #}
|
|
|
-#
|
|
|
- ## Save all metadata
|
|
|
- #for key in child.get_meta_list():
|
|
|
- #node_data["slider_values"][path_str]["meta"][str(key)] = child.get_meta(key)
|
|
|
- #
|
|
|
- #for child in node.find_children("*", "CodeEdit", true, false):
|
|
|
- #node_data["notes"][child.name] = child.text
|
|
|
-#
|
|
|
- #node_data_list.append(node_data)
|
|
|
-#
|
|
|
- #for conn in graph_edit.get_connection_list():
|
|
|
- #connection_data_list.append({
|
|
|
- #"from_node": conn["from_node"],
|
|
|
- #"from_port": conn["from_port"],
|
|
|
- #"to_node": conn["to_node"],
|
|
|
- #"to_port": conn["to_port"]
|
|
|
- #})
|
|
|
-#
|
|
|
- #var graph_data = {
|
|
|
- #"nodes": node_data_list,
|
|
|
- #"connections": connection_data_list
|
|
|
- #}
|
|
|
-#
|
|
|
- #var json = JSON.new()
|
|
|
- #var json_string = json.stringify(graph_data, "\t")
|
|
|
- #file.store_string(json_string)
|
|
|
- #file.close()
|
|
|
- #print("Graph saved.")
|
|
|
- #changesmade = false
|
|
|
- #get_window().title = "SoundThread - " + path.get_file().trim_suffix(".thd")
|
|
|
-#
|
|
|
-#
|
|
|
-#func load_graph_edit(path: String):
|
|
|
- #var file = FileAccess.open(path, FileAccess.READ)
|
|
|
- #if file == null:
|
|
|
- #print("Failed to open file for loading")
|
|
|
- #return
|
|
|
-#
|
|
|
- #var json_text = file.get_as_text()
|
|
|
- #file.close()
|
|
|
-#
|
|
|
- #var json = JSON.new()
|
|
|
- #if json.parse(json_text) != OK:
|
|
|
- #print("Error parsing JSON")
|
|
|
- #return
|
|
|
-#
|
|
|
- #var graph_data = json.get_data()
|
|
|
- #graph_edit.clear_connections()
|
|
|
-#
|
|
|
- #for node in graph_edit.get_children():
|
|
|
- #if node is GraphNode:
|
|
|
- #node.queue_free()
|
|
|
-#
|
|
|
- #await get_tree().process_frame # Ensure nodes are cleared
|
|
|
-#
|
|
|
- #for node_data in graph_data["nodes"]:
|
|
|
- #var command_name = node_data.get("command", "")
|
|
|
- #var template = Nodes.get_node_or_null(command_name)
|
|
|
- #if not template:
|
|
|
- #print("Template not found for command:", command_name)
|
|
|
- #continue
|
|
|
-#
|
|
|
- #var new_node: GraphNode = template.duplicate()
|
|
|
- #new_node.name = node_data["name"]
|
|
|
- #new_node.position_offset = Vector2(node_data["offset"]["x"], node_data["offset"]["y"])
|
|
|
- #new_node.set_meta("command", command_name)
|
|
|
- #graph_edit.add_child(new_node)
|
|
|
- #_register_node_movement() #link nodes for tracking position changes for changes tracking
|
|
|
-#
|
|
|
- ## Restore sliders
|
|
|
- #for slider_path_str in node_data["slider_values"]:
|
|
|
- #var slider = new_node.get_node_or_null(slider_path_str)
|
|
|
- #if slider and (slider is HSlider or slider is VSlider):
|
|
|
- #var slider_info = node_data["slider_values"][slider_path_str]
|
|
|
- #
|
|
|
- #if typeof(slider_info) == TYPE_DICTIONARY:
|
|
|
- #slider.value = slider_info.get("value", slider.value)
|
|
|
- #
|
|
|
- ## Restore enabled/disabled
|
|
|
- #if slider_info.has("editable"):
|
|
|
- #slider.editable = slider_info["editable"]
|
|
|
- #
|
|
|
- ## Restore metadata
|
|
|
- #if slider_info.has("meta"):
|
|
|
- #for key in slider_info["meta"]:
|
|
|
- #var value = slider_info["meta"][key]
|
|
|
-#
|
|
|
- ## Convert arrays of stringified Vector2s back to real Vector2s
|
|
|
- #if key == "brk_data" and typeof(value) == TYPE_ARRAY:
|
|
|
- #var new_array: Array = []
|
|
|
- #for item in value:
|
|
|
- #if typeof(item) == TYPE_STRING:
|
|
|
- ## Extract values from "(x, y)"
|
|
|
- #var numbers: PackedStringArray = item.strip_edges().trim_prefix("(").trim_suffix(")").split(",")
|
|
|
- #if numbers.size() == 2:
|
|
|
- #var x = float(numbers[0])
|
|
|
- #var y = float(numbers[1])
|
|
|
- #new_array.append(Vector2(x, y))
|
|
|
- #value = new_array
|
|
|
-#
|
|
|
- #slider.set_meta(key, value)
|
|
|
- #else:
|
|
|
- ## Legacy support: just value
|
|
|
- #slider.value = slider_info
|
|
|
- #
|
|
|
- #
|
|
|
- #
|
|
|
- ## Restore notes
|
|
|
- #for codeedit_name in node_data["notes"]:
|
|
|
- #var codeedit = new_node.find_child(codeedit_name, true, false)
|
|
|
- #if codeedit and (codeedit is CodeEdit):
|
|
|
- #codeedit.text = node_data["notes"][codeedit_name]
|
|
|
- #_register_inputs_in_node(new_node) #link sliders for changes tracking
|
|
|
- ## Restore connections
|
|
|
- #for conn in graph_data["connections"]:
|
|
|
- #graph_edit.connect_node(
|
|
|
- #conn["from_node"], conn["from_port"],
|
|
|
- #conn["to_node"], conn["to_port"]
|
|
|
- #)
|
|
|
- #link_output()
|
|
|
- #print("Graph loaded.")
|
|
|
- #get_window().title = "SoundThread - " + path.get_file().trim_suffix(".thd")
|
|
|
-
|
|
|
-
|
|
|
func _on_save_dialog_file_selected(path: String) -> void:
|
|
|
save_graph_edit(path) #save file
|
|
|
#check what the user was trying to do before save and do that action
|
|
|
@@ -1974,3 +1809,6 @@ func open_explore():
|
|
|
#position and show the menu
|
|
|
$mainmenu.position = Vector2(clamped_x, clamped_y)
|
|
|
$mainmenu.popup()
|
|
|
+
|
|
|
+func change_console_settings(toggled: bool):
|
|
|
+ $Console.always_on_top = toggled
|