Browse Source

Added shortcuts help file and a few small ui tweaks

Jonathan Higgins 1 month ago
parent
commit
8138fbe5da

+ 8 - 6
scenes/main/control.tscn

@@ -375,7 +375,7 @@ item_2/id = 2
 [node name="HelpButton" type="PopupMenu" parent="MenuBar"]
 [node name="HelpButton" type="PopupMenu" parent="MenuBar"]
 auto_translate_mode = 1
 auto_translate_mode = 1
 title = "Help"
 title = "Help"
-item_count = 15
+item_count = 16
 item_0/text = "Tutorials"
 item_0/text = "Tutorials"
 item_0/id = 0
 item_0/id = 0
 item_0/separator = true
 item_0/separator = true
@@ -405,10 +405,12 @@ item_11/id = 12
 item_12/text = "Other Help"
 item_12/text = "Other Help"
 item_12/id = 9
 item_12/id = 9
 item_12/separator = true
 item_12/separator = true
-item_13/text = "CDP Documentation"
-item_13/id = 10
-item_14/text = "Report a Bug"
-item_14/id = 11
+item_13/text = "Keyboard/Mouse Shortcuts"
+item_13/id = 15
+item_14/text = "CDP Documentation"
+item_14/id = 10
+item_15/text = "Report a Bug"
+item_15/id = 11
 
 
 [node name="About" type="PopupMenu" parent="MenuBar"]
 [node name="About" type="PopupMenu" parent="MenuBar"]
 item_count = 1
 item_count = 1
@@ -652,7 +654,7 @@ offset_left = 668.0
 offset_top = 45.0
 offset_top = 45.0
 offset_right = 747.0
 offset_right = 747.0
 offset_bottom = 72.0
 offset_bottom = 72.0
-tooltip_text = "Adjusts the number of analysis points used by the frequency domain processes in this thread. More points give better frequency resolution but worse time resolution."
+tooltip_text = "Adjusts the amount of overlap between fft windows. Higher overlap values will provide better resolution but take longer to process."
 item_count = 4
 item_count = 4
 popup/item_0/text = "1"
 popup/item_0/text = "1"
 popup/item_0/id = 0
 popup/item_0/id = 0

+ 1 - 1
scenes/main/process_help.json

@@ -5575,7 +5575,7 @@
 		"fftwindowsize": false
 		"fftwindowsize": false
 	  },
 	  },
 	  "param4": {
 	  "param4": {
-		"paramname": "Formant 3 Frequency",
+		"paramname": "Formant 4 Frequency",
 		"paramdescription": "The frequency to move formant 4 to in Hz",
 		"paramdescription": "The frequency to move formant 4 to in Hz",
 		"automatable": true,
 		"automatable": true,
 		"outputduration": false,
 		"outputduration": false,

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

@@ -608,8 +608,10 @@ func _on_help_button_index_pressed(index: int) -> void:
 		12:
 		12:
 			pass
 			pass
 		13:
 		13:
-			OS.shell_open("https://www.composersdesktop.com/docs/html/ccdpndex.htm")
+			open_help.open_keyboard_shortcuts_help()
 		14:
 		14:
+			OS.shell_open("https://www.composersdesktop.com/docs/html/ccdpndex.htm")
+		15:
 			OS.shell_open("https://github.com/j-p-higgins/SoundThread/issues")
 			OS.shell_open("https://github.com/j-p-higgins/SoundThread/issues")
 
 
 #func _recycle_outfile():
 #func _recycle_outfile():

+ 57 - 10
scenes/main/scripts/open_help.gd

@@ -1,28 +1,26 @@
 extends Node
 extends Node
 var control_script
 var control_script
 var help_data := {} #stores help data for each node to display in help popup
 var help_data := {} #stores help data for each node to display in help popup
+var shortcuts_data:= {}
 var HelpWindowScene = preload("res://scenes/main/help_window.tscn")
 var HelpWindowScene = preload("res://scenes/main/help_window.tscn")
 
 
 func _ready() -> void:
 func _ready() -> void:
 	var file = FileAccess.open("res://scenes/main/process_help.json", FileAccess.READ)
 	var file = FileAccess.open("res://scenes/main/process_help.json", FileAccess.READ)
 	if file:
 	if file:
 		help_data = JSON.parse_string(file.get_as_text())
 		help_data = JSON.parse_string(file.get_as_text())
+		
+	var shortcuts_file = FileAccess.open("res://scenes/main/shortcuts.json", FileAccess.READ)
+	if shortcuts_file:
+		shortcuts_data = JSON.parse_string(shortcuts_file.get_as_text())
 
 
 func init(main_node: Node) -> void:
 func init(main_node: Node) -> void:
 	control_script = main_node
 	control_script = main_node
 
 
 func show_help_for_node(node_name: String, node_title: String):
 func show_help_for_node(node_name: String, node_title: String):
 	#check if there is already a help window open for this node and pop it up instead of making a new one
 	#check if there is already a help window open for this node and pop it up instead of making a new one
-	for child in get_tree().current_scene.get_children():
-		if child is Window and child.title == "Help - " + node_title:
-			# Found existing window, bring it to front
-			if child.is_visible():
-				child.hide()
-				child.popup()
-			else:
-				child.popup()
-			return
-	
+	if is_help_open(node_title):
+		return
+		
 	if help_data.has(node_name):
 	if help_data.has(node_name):
 		#looks up the help data from the json and stores it in info
 		#looks up the help data from the json and stores it in info
 		var info = help_data[node_name]
 		var info = help_data[node_name]
@@ -75,3 +73,52 @@ func show_help_for_node(node_name: String, node_title: String):
 		help_window.get_node("HelpText").bbcode_text = "No help found."
 		help_window.get_node("HelpText").bbcode_text = "No help found."
 		get_tree().current_scene.add_child(help_window)
 		get_tree().current_scene.add_child(help_window)
 		help_window.popup()
 		help_window.popup()
+
+func open_keyboard_shortcuts_help():
+	var title = "Keyboard/Mouse Shortcuts"
+	#check if there is already a help window open for this node and pop it up instead of making a new one
+	if is_help_open(title):
+		return
+		
+	var help_window = HelpWindowScene.instantiate()
+	help_window.title = "Help - " + title
+	help_window.get_node("HelpTitle").text = title
+	
+	var help_text = "The main shortcuts available in SoundThread\n\n"
+	help_text += "[table=2]"
+		
+	for section in shortcuts_data.keys():
+		help_text += "[cell][b]" + section + "[/b][/cell][cell][/cell]"
+		var shortcuts = shortcuts_data.get(section, {})
+		for action in shortcuts.keys():
+			var shortcut = shortcuts[action]
+			help_text += "[cell]%s[/cell][cell]%s[/cell]" % [action, shortcut]
+		help_text += "[cell] [/cell][cell][/cell]"
+	help_text += "[/table]\n\n"
+	help_text += "Note: controls for navigating a thread can be swapped in the settings."
+	
+	if OS.get_name() == "macOS":
+		help_text = help_text.replace("Ctrl", "Cmd")
+	
+	help_window.get_node("HelpText").bbcode_text = help_text
+	help_window.get_node("HelpText").scroll_to_line(0) #scrolls to the first line of the help file just incase
+	
+	# Add to the current scene tree to show it
+	get_tree().current_scene.add_child(help_window)
+	if help_window.content_scale_factor < control_script.uiscale:
+		help_window.size = help_window.size * control_script.uiscale
+		help_window.content_scale_factor = control_script.uiscale
+	
+	help_window.popup() 
+	
+func is_help_open(node_title: String) -> bool:
+	for child in get_tree().current_scene.get_children():
+		if child is Window and child.title == "Help - " + node_title:
+			# Found existing window, bring it to front
+			if child.is_visible():
+				child.hide()
+				child.popup()
+			else:
+				child.popup()
+			return true
+	return false

+ 25 - 0
scenes/main/shortcuts.json

@@ -0,0 +1,25 @@
+{
+	"Thread Management":{
+		"Run Thread": "Ctrl + R",
+		"New Thread": "Ctrl + N",
+		"Save Thread": "Ctrl + S",
+		"Save Thread As": "Ctrl + Shift + S"
+	},
+	"Building a Thread":{
+		"Add Node (Open Search)": "Right click empty space or Ctrl + F",
+		"Browse Nodes (Open Explore)": "Ctrl + E",
+		"Replace Node": "Right click node",
+		"Add Node Connected to Node": "Shift + right click node",
+		"Insert Node into Connection": "Shift + drag node over cable",
+		"Reset Slider to Default": "Double click",
+		"Delete Node": "Backspace or Delete",
+		"Undo": "Ctrl + Z",
+		"Redo": "Ctrl + Y",
+		"Copy": "Ctrl + C",
+		"Paste": "Ctrl + V"
+	},
+	"Navigating a Thread":{
+		"Zoom": "Mouse wheel",
+		"Move": "Middle click + drag or Ctrl + Mouse wheel"
+	}
+}