Files
DungeonCrawlerWorld/scripts/presentation/help_panel.gd

27 lines
940 B
GDScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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("\nCiblage : flèches, Entrée pour confirmer, Échap pour annuler")
lines.append("Sauvegarde : V (éditeur) ou Ctrl+S (jeu autonome), puis choix d’un emplacement")
lines.append("F1 / Échap — fermer")
body.text = "\n".join(lines)