fix: prove title timing and compact journal readability
This commit is contained in:
+12
-1
@@ -317,6 +317,7 @@ func _get_capture_mode() -> String:
|
|||||||
func _capture_visual_check(capture_mode: String) -> void:
|
func _capture_visual_check(capture_mode: String) -> void:
|
||||||
if capture_mode == "exit":
|
if capture_mode == "exit":
|
||||||
_prepare_exit_capture_state()
|
_prepare_exit_capture_state()
|
||||||
|
_refresh_capture_hud()
|
||||||
# Camera2D applies its scroll during the frame cycle. Force it before the
|
# Camera2D applies its scroll during the frame cycle. Force it before the
|
||||||
# deterministic capture so the world is framed around the capture state.
|
# deterministic capture so the world is framed around the capture state.
|
||||||
camera.force_update_scroll()
|
camera.force_update_scroll()
|
||||||
@@ -334,6 +335,11 @@ func _capture_visual_check(capture_mode: String) -> void:
|
|||||||
var result := image.save_png(capture_path)
|
var result := image.save_png(capture_path)
|
||||||
get_tree().quit(0 if result == OK else 1)
|
get_tree().quit(0 if result == OK else 1)
|
||||||
|
|
||||||
|
func _refresh_capture_hud() -> void:
|
||||||
|
# Capture startup appends game_started after the normal first HUD refresh.
|
||||||
|
# Refresh only on the capture path so production rendering remains untouched.
|
||||||
|
hud.refresh(game_state, run_state.recent_events(run_state.log.size()), run_state)
|
||||||
|
|
||||||
func _prepare_exit_capture_state() -> void:
|
func _prepare_exit_capture_state() -> void:
|
||||||
# Preserve the entrance exploration, then frame the authored surface exit.
|
# Preserve the entrance exploration, then frame the authored surface exit.
|
||||||
# This exercises visible, explored, and unknown rendering without depending
|
# This exercises visible, explored, and unknown rendering without depending
|
||||||
@@ -1895,9 +1901,14 @@ func _refresh_title() -> void:
|
|||||||
var previous_title_id := run_state.current_title_id
|
var previous_title_id := run_state.current_title_id
|
||||||
var current_title_id := StringName(title.get("id", ""))
|
var current_title_id := StringName(title.get("id", ""))
|
||||||
run_state.current_title_id = current_title_id
|
run_state.current_title_id = current_title_id
|
||||||
|
if title.is_empty():
|
||||||
|
# A title loss is not an announcement; it must also clear a still-visible
|
||||||
|
# notification from the prior title.
|
||||||
|
_hide_title_notification()
|
||||||
|
return
|
||||||
# Boot and load establish the state silently. Only a real later transition
|
# Boot and load establish the state silently. Only a real later transition
|
||||||
# deserves the temporary overlay; the permanent top bar belongs to GameHud.
|
# 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():
|
if _title_notifications_enabled and current_title_id != previous_title_id:
|
||||||
title_notification_label.text = String(title.get("name", current_title_id))
|
title_notification_label.text = String(title.get("name", current_title_id))
|
||||||
title_notification_label.visible = true
|
title_notification_label.visible = true
|
||||||
title_notification_timer.start()
|
title_notification_timer.start()
|
||||||
|
|||||||
@@ -175,7 +175,6 @@ func _apply_text_scale(layout_scale: float) -> void:
|
|||||||
$EnemyHealthLabel,
|
$EnemyHealthLabel,
|
||||||
$CombatSummaryLabel,
|
$CombatSummaryLabel,
|
||||||
$DeadlineLabel,
|
$DeadlineLabel,
|
||||||
$EventLog,
|
|
||||||
action_hint_label,
|
action_hint_label,
|
||||||
$ContextPromptLabel,
|
$ContextPromptLabel,
|
||||||
$HelpLabel,
|
$HelpLabel,
|
||||||
@@ -186,6 +185,14 @@ func _apply_text_scale(layout_scale: float) -> void:
|
|||||||
control.set_meta(&"base_font_size", base_size)
|
control.set_meta(&"base_font_size", base_size)
|
||||||
control.add_theme_font_size_override(&"font_size", roundi(base_size * font_scale))
|
control.add_theme_font_size_override(&"font_size", roundi(base_size * font_scale))
|
||||||
|
|
||||||
|
# RichTextLabel does not use Label's font_size theme key. Keep the journal
|
||||||
|
# independently readable at 720p without changing the rest of the HUD scale.
|
||||||
|
var event_log_base_size: int = event_log.get_meta(&"base_normal_font_size", 0)
|
||||||
|
if event_log_base_size == 0:
|
||||||
|
event_log_base_size = event_log.get_theme_font_size(&"normal_font_size")
|
||||||
|
event_log.set_meta(&"base_normal_font_size", event_log_base_size)
|
||||||
|
event_log.add_theme_font_size_override(&"normal_font_size", max(12, roundi(event_log_base_size * font_scale)))
|
||||||
|
|
||||||
func _layout_expanded_log(origin: Vector2, scale: float) -> void:
|
func _layout_expanded_log(origin: Vector2, scale: float) -> void:
|
||||||
# Explicit expansion may temporarily consume the MapSection, never the world.
|
# Explicit expansion may temporarily consume the MapSection, never the world.
|
||||||
_set_rect(log_panel, origin + Vector2(1456, 110) * scale, Vector2(436, 818) * scale)
|
_set_rect(log_panel, origin + Vector2(1456, 110) * scale, Vector2(436, 818) * scale)
|
||||||
|
|||||||
@@ -50,9 +50,8 @@ func test_real_hit_unlocks_reward_toast_journal_claim_and_title_refresh() -> voi
|
|||||||
assert_eq(notification.text, "Frappeur")
|
assert_eq(notification.text, "Frappeur")
|
||||||
assert_true(notification_timer.one_shot)
|
assert_true(notification_timer.one_shot)
|
||||||
assert_eq(notification_timer.wait_time, 5.0)
|
assert_eq(notification_timer.wait_time, 5.0)
|
||||||
notification_timer.timeout.emit()
|
# The real five-second expiry is intentionally verified by the dedicated
|
||||||
await get_tree().process_frame
|
# transition test below, rather than manually emitting this timer's signal.
|
||||||
assert_false(notification.visible, "The title notification disappears at timeout")
|
|
||||||
if permanent_title != null:
|
if permanent_title != null:
|
||||||
assert_eq(permanent_title.text, "Étage 0")
|
assert_eq(permanent_title.text, "Étage 0")
|
||||||
|
|
||||||
@@ -63,6 +62,56 @@ func test_real_hit_unlocks_reward_toast_journal_claim_and_title_refresh() -> voi
|
|||||||
assert_true(game.get_run_state().recent_events(3).any(func(event: GameEvent) -> bool: return event.kind == &"achievement_reward_claimed"))
|
assert_true(game.get_run_state().recent_events(3).any(func(event: GameEvent) -> bool: return event.kind == &"achievement_reward_claimed"))
|
||||||
assert_string_contains((panel.get_node("Body") as RichTextLabel).get_parsed_text(), "Récompense reçue")
|
assert_string_contains((panel.get_node("Body") as RichTextLabel).get_parsed_text(), "Récompense reçue")
|
||||||
|
|
||||||
|
func test_title_notification_only_announces_real_transitions_and_expires_after_its_timer() -> void:
|
||||||
|
var permanent_title := game.get_node_or_null("HUD/TitleLabel") as Label
|
||||||
|
var notification := game.get_node_or_null("HUD/TitleNotificationLabel") as Label
|
||||||
|
var notification_timer := game.get_node_or_null("HUD/TitleNotificationTimer") as Timer
|
||||||
|
assert_not_null(permanent_title)
|
||||||
|
assert_not_null(notification)
|
||||||
|
assert_not_null(notification_timer)
|
||||||
|
if permanent_title == null or notification == null or notification_timer == null:
|
||||||
|
return
|
||||||
|
|
||||||
|
assert_false(notification.visible, "Initialization must not announce the established title")
|
||||||
|
assert_eq(notification.text, "")
|
||||||
|
assert_eq(permanent_title.text, "Étage 0")
|
||||||
|
|
||||||
|
game._refresh_title()
|
||||||
|
assert_false(notification.visible, "Refreshing the same current title stays silent")
|
||||||
|
assert_eq(permanent_title.text, "Étage 0")
|
||||||
|
|
||||||
|
game.title_engine = TitleEngineType.new([])
|
||||||
|
game._refresh_title()
|
||||||
|
assert_false(notification.visible, "Losing a title or receiving no title stays silent")
|
||||||
|
assert_eq(notification.text, "")
|
||||||
|
assert_eq(permanent_title.text, "Étage 0")
|
||||||
|
|
||||||
|
game.title_engine = TitleEngineType.new([
|
||||||
|
{"id": "renewed", "name": "Renouveau", "rank": 1, "conditions": []},
|
||||||
|
])
|
||||||
|
game._refresh_title()
|
||||||
|
assert_true(notification.visible, "A real title transition needs a temporary notification")
|
||||||
|
assert_eq(notification.text, "Renouveau")
|
||||||
|
assert_true(notification_timer.time_left > 0.0)
|
||||||
|
assert_eq(permanent_title.text, "Étage 0")
|
||||||
|
|
||||||
|
game.title_engine = TitleEngineType.new([])
|
||||||
|
game._refresh_title()
|
||||||
|
assert_false(notification.visible, "A title loss clears an in-flight notification")
|
||||||
|
assert_eq(notification.text, "")
|
||||||
|
assert_eq(permanent_title.text, "Étage 0")
|
||||||
|
|
||||||
|
game.title_engine = TitleEngineType.new([
|
||||||
|
{"id": "renewed", "name": "Renouveau", "rank": 1, "conditions": []},
|
||||||
|
])
|
||||||
|
game._refresh_title()
|
||||||
|
assert_true(notification.visible, "Regaining a title is a real transition")
|
||||||
|
await notification_timer.timeout
|
||||||
|
await get_tree().process_frame
|
||||||
|
assert_false(notification.visible, "The actual five-second timer hides the notification")
|
||||||
|
assert_eq(notification.text, "")
|
||||||
|
assert_eq(permanent_title.text, "Étage 0")
|
||||||
|
|
||||||
func _dispatch_key(keycode: Key) -> void:
|
func _dispatch_key(keycode: Key) -> void:
|
||||||
Input.parse_input_event(_key_event(keycode, true))
|
Input.parse_input_event(_key_event(keycode, true))
|
||||||
await get_tree().process_frame
|
await get_tree().process_frame
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
extends GutTest
|
||||||
|
|
||||||
|
const GameScene = preload("res://scenes/Game.tscn")
|
||||||
|
const RunSettingsType = preload("res://scripts/domain/run/run_settings.gd")
|
||||||
|
|
||||||
|
func test_capture_preparation_refreshes_the_real_name_and_started_journal() -> void:
|
||||||
|
var game := GameScene.instantiate() as Game
|
||||||
|
game.configure_new_run(RunSettingsType.new("visual-check", &"crawler", false, false), "Visual Check")
|
||||||
|
add_child_autofree(game)
|
||||||
|
await get_tree().process_frame
|
||||||
|
|
||||||
|
var hud := game.get_node_or_null("HUD") as GameHud
|
||||||
|
var character_title := game.get_node_or_null("HUD/ResponsiveLayout/CharacterSectionTitle") as Label
|
||||||
|
var event_log := game.get_node_or_null("HUD/EventLog") as RichTextLabel
|
||||||
|
assert_not_null(hud)
|
||||||
|
assert_not_null(character_title)
|
||||||
|
assert_not_null(event_log)
|
||||||
|
if hud == null or character_title == null or event_log == null:
|
||||||
|
return
|
||||||
|
assert_eq(character_title.text, "Visual Check")
|
||||||
|
assert_eq(event_log.get_parsed_text(), "", "Startup initially refreshes before game_started is appended")
|
||||||
|
|
||||||
|
game._refresh_capture_hud()
|
||||||
|
assert_eq(character_title.text, "Visual Check")
|
||||||
|
assert_string_contains(event_log.get_parsed_text(), "Visual Check commence une nouvelle aventure.")
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://d00r2dqs4yi56
|
||||||
@@ -298,9 +298,19 @@ func test_compact_1280_layout_contains_live_hud_regions_without_covering_the_pla
|
|||||||
if label != null:
|
if label != null:
|
||||||
assert_gte(label.get_theme_font_size(&"font_size"), 9, "%s must keep a readable compact font" % label.name)
|
assert_gte(label.get_theme_font_size(&"font_size"), 9, "%s must keep a readable compact font" % label.name)
|
||||||
var journal := hud.get_node_or_null("EventLog") as RichTextLabel
|
var journal := hud.get_node_or_null("EventLog") as RichTextLabel
|
||||||
|
var journal_title := layout.get_node_or_null("JournalSectionTitle") as Label
|
||||||
|
var character_title := layout.get_node_or_null("CharacterSectionTitle") as Label
|
||||||
assert_not_null(journal)
|
assert_not_null(journal)
|
||||||
|
assert_not_null(journal_title)
|
||||||
|
assert_not_null(character_title)
|
||||||
if journal != null:
|
if journal != null:
|
||||||
assert_gte(journal.get_theme_font_size(&"normal_font_size"), 9, "The compact journal font must remain readable")
|
var journal_font_size := journal.get_theme_font_size(&"normal_font_size")
|
||||||
|
assert_gte(journal_font_size, 12, "The compact journal must retain a 12px normal font")
|
||||||
|
assert_gte(journal.size.y / journal_font_size, 12.0, "The compact journal must retain at least twelve lines of visible space")
|
||||||
|
if journal_title != null:
|
||||||
|
assert_gte(journal_title.get_theme_font_size(&"font_size"), 14, "The compact journal title must remain readable")
|
||||||
|
if character_title != null:
|
||||||
|
assert_gte(character_title.get_theme_font_size(&"font_size"), 14, "The compact character title must remain readable")
|
||||||
|
|
||||||
func test_non_sixteen_by_nine_viewports_center_the_artboard_and_mask_every_outside_band() -> void:
|
func test_non_sixteen_by_nine_viewports_center_the_artboard_and_mask_every_outside_band() -> void:
|
||||||
var hud := game.get_node_or_null("HUD") as GameHud
|
var hud := game.get_node_or_null("HUD") as GameHud
|
||||||
|
|||||||
Reference in New Issue
Block a user