From 32bda994f636a181ddd112d84f7007312408ec0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lera=20Elvo=C3=A9?= Date: Fri, 24 May 2024 16:17:07 +0300 Subject: [PATCH] followup to db590ac: improve group node renderer UX --- .../deck_node_renderer_graph_node.gd | 13 ++++++++++++- .../shortcuts/renderer_shortcuts.gd | 17 +++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/graph_node_renderer/deck_node_renderer_graph_node.gd b/graph_node_renderer/deck_node_renderer_graph_node.gd index ee80fc2..f2cc685 100644 --- a/graph_node_renderer/deck_node_renderer_graph_node.gd +++ b/graph_node_renderer/deck_node_renderer_graph_node.gd @@ -51,6 +51,8 @@ func _ready() -> void: node.renamed.connect(_on_node_renamed) if node.node_type == "group_node": get_titlebar_hbox().tooltip_text = "Group %s" % node.group_id.left(8) + if get_child_count() == 0: + create_group_help_text() size = node.get_meta("size", Vector2()) @@ -112,8 +114,11 @@ func _on_node_ports_updated() -> void: for port in node.get_all_ports(): update_port(port) - + + if get_child_count() == 0: + create_group_help_text() await get_tree().process_frame + size = Vector2() @@ -121,6 +126,12 @@ func _on_node_renamed(new_name: String) -> void: title = new_name +func create_group_help_text() -> void: + var l := Label.new() + l.text = RendererShortcuts.interpolate_string("This group node has no used ports.\nPress {enter_group} to enter and edit it to see changes reflected.") + add_child(l) + + func update_port(port: Port) -> void: var descriptor_split := port.descriptor.split(":") var d: DescriptorContainer diff --git a/graph_node_renderer/shortcuts/renderer_shortcuts.gd b/graph_node_renderer/shortcuts/renderer_shortcuts.gd index da605b9..bbb12ca 100644 --- a/graph_node_renderer/shortcuts/renderer_shortcuts.gd +++ b/graph_node_renderer/shortcuts/renderer_shortcuts.gd @@ -100,6 +100,17 @@ static func get_full_map() -> Dictionary: return defaults_copy +static func get_full_map_string() -> Dictionary: + var full_map := get_full_map() + var res := {} + for key: String in full_map: + if key.begins_with("_"): + continue + res[key] = (full_map[key] as Shortcut).get_as_text() + return res + + + ## Returns the default [Shortcut] for the given [param action]. static func get_default(action: String) -> Shortcut: return defaults.get(action) @@ -173,3 +184,9 @@ static func map_from_dict(d: Dictionary) -> void: static func commit_overrides() -> void: RendererPersistence.set_value(PERSISTENCE_NAMESPACE, PERSISTENCE_CHANNEL, PERSISTENCE_KEY, map_to_dict()) RendererPersistence.commit(PERSISTENCE_NAMESPACE, PERSISTENCE_CHANNEL) + + +## Replaces shortcut names with their keybinds in [param s].[br] +## Example usage: [code]interpolate_string("Press {new_deck} to open a new deck.")[/code] +static func interpolate_string(s: String) -> String: + return s.format(get_full_map_string())