fix: refine character HUD and title presentation

This commit is contained in:
goose
2026-10-09 12:44:09 -04:00
parent c410f830e3
commit bc67e5ed88
8 changed files with 181 additions and 103 deletions
+34 -10
View File
@@ -3,16 +3,26 @@ extends PanelContainer
const SkillTreeType = preload("res://scripts/domain/progression/skill_tree.gd")
const ATTRIBUTE_LABELS := {
&"str_": "Force", &"agi": "Agilité", &"end": "Endurance", &"per": "Perception",
&"int_": "Intelligence", &"wil": "Volonté", &"cha": "Charisme", &"luc": "Chance",
}
const FEATURED_SKILLS := {&"melee": "Corps à corps", &"ranged": "Distance", &"dodge": "Esquive"}
@onready var title: Label = $Title
@onready var body: RichTextLabel = $Body
var _player: PlayerState
var _experience: Experience
var _skill_tree: SkillTree
var _player_name := "Sans-Nom"
var _title_definition: Dictionary = {}
func present(player: PlayerState, experience: Experience) -> void:
func present(player: PlayerState, experience: Experience, player_name: String = "Sans-Nom", title_definition: Dictionary = {}) -> void:
_player = player
_experience = experience
_player_name = player_name
_title_definition = title_definition.duplicate(true)
_skill_tree = SkillTreeType.new(experience, player.attributes, player.skills)
visible = true
refresh()
@@ -22,6 +32,7 @@ func dismiss() -> void:
_player = null
_experience = null
_skill_tree = null
_title_definition.clear()
func spend_attribute(key: StringName) -> Dictionary:
if _skill_tree == null:
@@ -42,13 +53,26 @@ func spend_skill(key: StringName) -> Dictionary:
func refresh() -> void:
if _player == null or _experience == null:
return
title.text = "Character"
body.text = "Level %d — XP %d/%d\nAttribute points: %d\nSkill points: %d\n\n[A] Strength: %d\n[S] Melee: %d\n\nA / S Allocate Esc Close" % [
_experience.level,
_experience.total_xp,
_experience.next_level_xp(),
_experience.attribute_points,
_experience.skill_points,
_player.attributes.get_attribute(&"str_"),
_player.effective_skill(&"melee"),
var title_name := String(_title_definition.get("name", "Sans titre"))
var flavor := String(_title_definition.get("flavor", "Aucune légende n’est encore écrite."))
title.text = "FICHE DE PERSONNAGE"
var lines := [
"Nom : %s" % _player_name,
"Titre : %s" % title_name,
flavor,
"",
"Niveau %d — XP %d/%d" % [_experience.level, _experience.total_xp, _experience.next_level_xp()],
"Points d’attribut : %d" % _experience.attribute_points,
"Points de compétence : %d" % _experience.skill_points,
"",
"Caractéristiques :",
]
for key: StringName in ATTRIBUTE_LABELS:
lines.append("%s : %d" % [ATTRIBUTE_LABELS[key], _player.attributes.get_attribute(key)])
lines.append("")
lines.append("Compétences principales :")
for key: StringName in FEATURED_SKILLS:
lines.append("%s : %d" % [FEATURED_SKILLS[key], _player.effective_skill(key)])
lines.append("")
lines.append("A / S Allouer (Force / Corps à corps) Échap Fermer")
body.text = "\n".join(lines)