From 590f40e8314a1c3a4c3a4eba18adc7d2a8b3257f Mon Sep 17 00:00:00 2001 From: WallK Date: Wed, 20 Dec 2023 10:00:55 +0200 Subject: [PATCH] Implemented Rekku help text from element description --- tools/configurator/helper_text.gd | 21 ++++++++------------- tools/configurator/main.tscn | 2 ++ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/tools/configurator/helper_text.gd b/tools/configurator/helper_text.gd index c948472d..d94060ef 100755 --- a/tools/configurator/helper_text.gd +++ b/tools/configurator/helper_text.gd @@ -1,18 +1,13 @@ extends RichTextLabel -var selected_element +@onready var helper_text_node = self -# Called when the node enters the scene tree for the first time. func _ready(): - # Get a reference to the helper_text node - var helper_text_node = $bubble/helper_text - - # Ensure that the helper_text node exists before trying to access it - if helper_text_node != null: - # Set the text of the helper_text node only if the element is selected and has the 'description' variable - if selected_element != null and selected_element.has("description"): - helper_text_node.text = selected_element.description - else: - helper_text_node.text = "" + # Connect the signal that gets fired on every focus change + get_viewport().connect("gui_focus_changed", _on_focus_changed) + +func _on_focus_changed(selected_element:Control) -> void: + if selected_element != null and selected_element.has_meta("description"): + helper_text_node.text = selected_element.get_meta("description") else: - print("Error: helper_text node not found!") + helper_text_node.text = "Hey, there's no description" diff --git a/tools/configurator/main.tscn b/tools/configurator/main.tscn index f62f87eb..d06426e0 100755 --- a/tools/configurator/main.tscn +++ b/tools/configurator/main.tscn @@ -130,6 +130,7 @@ layout_mode = 2 theme_override_constants/h_separation = 128 button_pressed = true text = "Quick Resume" +metadata/description = "This is a test description set to this element" [node name="Button" type="Button" parent="MarginContainer/TabContainer/System/ScrollContainer/VBoxContainer/game_control_container/GridContainer"] layout_mode = 2 @@ -140,6 +141,7 @@ text = "Advanced" layout_mode = 2 theme_override_constants/h_separation = 256 text = "Rewind" +metadata/description = "This is another description. Very long text anyone? Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." [node name="Button2" type="Button" parent="MarginContainer/TabContainer/System/ScrollContainer/VBoxContainer/game_control_container/GridContainer"] layout_mode = 2