|
|
@@ -1,28 +1,26 @@
|
|
|
extends Node
|
|
|
var control_script
|
|
|
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")
|
|
|
|
|
|
func _ready() -> void:
|
|
|
var file = FileAccess.open("res://scenes/main/process_help.json", FileAccess.READ)
|
|
|
if file:
|
|
|
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:
|
|
|
control_script = main_node
|
|
|
|
|
|
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
|
|
|
- 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):
|
|
|
#looks up the help data from the json and stores it in info
|
|
|
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."
|
|
|
get_tree().current_scene.add_child(help_window)
|
|
|
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
|