Files
DungeonCrawlerWorld/scripts/presentation/help_panel.gd

25 lines
755 B
GDScript

class_name HelpPanel
extends PanelContainer
const InputBindingsType = preload("res://scripts/game/input_bindings.gd")
@onready var body: RichTextLabel = $Body
func present() -> void:
visible = true
refresh()
func dismiss() -> void:
visible = false
func refresh() -> void:
var lines: PackedStringArray = ["Commandes", ""]
for action: StringName in InputBindingsType.input_actions():
var events := InputMap.action_get_events(action)
var binding := "—"
if not events.is_empty() and events[0] is InputEventKey:
binding = OS.get_keycode_string((events[0] as InputEventKey).physical_keycode)
lines.append("%s — %s" % [binding, InputBindingsType.help_name_for(action)])
lines.append("\nF1 / ? — fermer")
body.text = "\n".join(lines)