Implemented Rekku help text from element description

This commit is contained in:
WallK 2023-12-20 10:00:55 +02:00
parent 1212c2cd7a
commit 590f40e831
2 changed files with 10 additions and 13 deletions

View file

@ -1,18 +1,13 @@
extends RichTextLabel 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(): func _ready():
# Get a reference to the helper_text node # Connect the signal that gets fired on every focus change
var helper_text_node = $bubble/helper_text get_viewport().connect("gui_focus_changed", _on_focus_changed)
# Ensure that the helper_text node exists before trying to access it func _on_focus_changed(selected_element:Control) -> void:
if helper_text_node != null: if selected_element != null and selected_element.has_meta("description"):
# Set the text of the helper_text node only if the element is selected and has the 'description' variable helper_text_node.text = selected_element.get_meta("description")
if selected_element != null and selected_element.has("description"):
helper_text_node.text = selected_element.description
else:
helper_text_node.text = ""
else: else:
print("Error: helper_text node not found!") helper_text_node.text = "Hey, there's no description"

View file

@ -130,6 +130,7 @@ layout_mode = 2
theme_override_constants/h_separation = 128 theme_override_constants/h_separation = 128
button_pressed = true button_pressed = true
text = "Quick Resume" 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"] [node name="Button" type="Button" parent="MarginContainer/TabContainer/System/ScrollContainer/VBoxContainer/game_control_container/GridContainer"]
layout_mode = 2 layout_mode = 2
@ -140,6 +141,7 @@ text = "Advanced"
layout_mode = 2 layout_mode = 2
theme_override_constants/h_separation = 256 theme_override_constants/h_separation = 256
text = "Rewind" 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"] [node name="Button2" type="Button" parent="MarginContainer/TabContainer/System/ScrollContainer/VBoxContainer/game_control_container/GridContainer"]
layout_mode = 2 layout_mode = 2