fix: refine character HUD and title presentation
This commit is contained in:
+29
-8
@@ -92,7 +92,9 @@ const QuestStateType = preload("res://scripts/domain/narrative/quest_state.gd")
|
||||
@onready var options_panel: OptionsPanel = $HUD/OptionsPanel
|
||||
@onready var help_panel: HelpPanel = $HUD/HelpPanel
|
||||
@onready var achievement_toast: Label = $HUD/AchievementToast
|
||||
@onready var title_label: Label = $HUD/TitleLabel
|
||||
@onready var achievement_toast_timer: Timer = $HUD/AchievementToastTimer
|
||||
@onready var title_notification_label: Label = $HUD/TitleNotificationLabel
|
||||
@onready var title_notification_timer: Timer = $HUD/TitleNotificationTimer
|
||||
@onready var companion_view: ActorView = $World/Companion
|
||||
@onready var party_views: Node2D = $World/Party
|
||||
const FACTION_WAR_MIN_FLOOR := 9
|
||||
@@ -132,6 +134,7 @@ var active_dialogue_npc: Dictionary = {}
|
||||
var active_event_index := -1
|
||||
var _turn_start_player_hit_points := -1
|
||||
var _turn_start_companion_hit_points := -1
|
||||
var _title_notifications_enabled := false
|
||||
|
||||
func configure_new_run(settings: RunSettings, player_name: String) -> void:
|
||||
pending_run_settings = settings
|
||||
@@ -158,6 +161,9 @@ func _ready() -> void:
|
||||
race_class_choice_panel.race_confirmed.connect(_choose_floor_three_race)
|
||||
race_class_choice_panel.class_confirmed.connect(_choose_floor_three_class)
|
||||
death_panel.navigation_requested.connect(func(action: StringName) -> void: death_navigation_requested.emit(action))
|
||||
title_notification_timer.timeout.connect(_hide_title_notification)
|
||||
achievement_toast_timer.timeout.connect(_hide_achievement_toast)
|
||||
_title_notifications_enabled = true
|
||||
map_renderer.set_map(game_state.map)
|
||||
_sync_map_renderer_visibility()
|
||||
_sync_minimap()
|
||||
@@ -1010,7 +1016,7 @@ func _toggle_character_panel() -> Array[GameEvent]:
|
||||
_close_character_panel(false)
|
||||
return _record_ranged_event(&"character_panel_closed", &"", {}, "Character panel closed.")
|
||||
_sync_dialogue_player_progression()
|
||||
character_panel.present(dialogue_player, game_state.player.progression)
|
||||
character_panel.present(dialogue_player, game_state.player.progression, run_state.player_name, _current_title())
|
||||
return _record_ranged_event(&"character_panel_opened", &"", {"level": game_state.player.progression.level}, "Character panel opened.")
|
||||
|
||||
func _spend_character_attribute(key: StringName) -> void:
|
||||
@@ -1812,6 +1818,8 @@ func _observe_achievements(events: Array[GameEvent]) -> void:
|
||||
var achievement_id := StringName(definition.get("id", ""))
|
||||
var message := "Succès débloqué : %s" % String(definition.get("name", achievement_id))
|
||||
achievement_toast.text = message
|
||||
achievement_toast.visible = true
|
||||
achievement_toast_timer.start()
|
||||
run_state.log.insert(insertion_index, GameEventType.new(
|
||||
event.turn,
|
||||
event.floor,
|
||||
@@ -1881,13 +1889,26 @@ func _current_title() -> Dictionary:
|
||||
return title_engine.refresh(_title_context()) if title_engine != null else {}
|
||||
|
||||
func _refresh_title() -> void:
|
||||
var title := _current_title()
|
||||
if title.is_empty():
|
||||
run_state.current_title_id = &""
|
||||
title_label.text = ""
|
||||
if run_state == null:
|
||||
return
|
||||
run_state.current_title_id = StringName(title.get("id", ""))
|
||||
title_label.text = "Titre : %s" % String(title.get("name", title.get("id", "")))
|
||||
var title := _current_title()
|
||||
var previous_title_id := run_state.current_title_id
|
||||
var current_title_id := StringName(title.get("id", ""))
|
||||
run_state.current_title_id = current_title_id
|
||||
# Boot and load establish the state silently. Only a real later transition
|
||||
# deserves the temporary overlay; the permanent top bar belongs to GameHud.
|
||||
if _title_notifications_enabled and current_title_id != previous_title_id and not title.is_empty():
|
||||
title_notification_label.text = String(title.get("name", current_title_id))
|
||||
title_notification_label.visible = true
|
||||
title_notification_timer.start()
|
||||
|
||||
func _hide_title_notification() -> void:
|
||||
title_notification_label.visible = false
|
||||
title_notification_label.text = ""
|
||||
|
||||
func _hide_achievement_toast() -> void:
|
||||
achievement_toast.visible = false
|
||||
achievement_toast.text = ""
|
||||
|
||||
func _append_level_up_events(events: Array[GameEvent]) -> void:
|
||||
var levels_gained := 0
|
||||
|
||||
Reference in New Issue
Block a user