Tales-of-PKMN/game/ui/hints/hints_hud.gd
2026-10-13 08:55:12 +02:00

34 lines
899 B
GDScript

extends MarginContainer
@onready var rows : HBoxContainer = $HBoxContainer
func _ready() -> void:
Hints.changed.connect(refresh)
refresh()
func refresh() -> void:
for c in rows.get_children():
rows.remove_child(c)
c.queue_free()
for h in Hints.get_visible():
rows.add_child(make_row(h.action, h.text))
func make_row(action : StringName, text : String) -> HBoxContainer:
var row := HBoxContainer.new()
var tex := ControllerIconTexture.new()
tex.path = String(action) #même chose que le champ "path" dans ta scène
var icon := TextureRect.new()
icon.texture = tex
icon.custom_minimum_size = Vector2(40, 40)
icon.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
icon.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
row.add_child(icon)
var label := Label.new()
label.text = text
label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
row.add_child(label)
return row