extends GutTest const GameScene = preload("res://scenes/Game.tscn") const HEADER_VALUES_GROUP := &"hud_header_values" const CHARACTER_VALUES_GROUP := &"hud_character_values" const COMMAND_HINTS_GROUP := &"hud_command_hints" var game: Game func before_each() -> void: game = GameScene.instantiate() add_child_autofree(game) await get_tree().process_frame func test_help_band_displays_the_exact_control_labels() -> void: var help_label := game.get_node_or_null("HUD/HelpLabel") as Label assert_not_null(help_label) if help_label == null: return assert_string_contains(help_label.text, "Déplacer") assert_string_contains(help_label.text, "Interagir") assert_string_contains(help_label.text, "Inventaire") assert_string_contains(help_label.text, "Sauvegarde") assert_string_contains(help_label.text, "Aide") func test_xp_bar_shows_progress_inside_the_current_level_and_refreshes_after_xp_gain() -> void: var hud := game.get_node_or_null("HUD") as GameHud assert_not_null(hud, "Game scene requires HUD") if hud == null: return var state := game.get_game_state() var xp_bar := hud.get_node_or_null("ExperienceBar") as ProgressBar var xp_label := hud.get_node_or_null("ExperienceLabel") as Label assert_not_null(xp_bar) assert_not_null(xp_label) if xp_bar == null or xp_label == null: return assert_eq(xp_bar.min_value, 0.0) assert_eq(xp_bar.max_value, 100.0) assert_eq(xp_bar.value, 0.0) assert_eq(xp_label.text, "Niveau 1 — XP 0/100") state.player.progression.set_total_xp(125) hud.refresh(state, [], game.get_run_state()) assert_eq(xp_bar.max_value, 200.0) assert_eq(xp_bar.value, 25.0) assert_eq(xp_label.text, "Niveau 2 — XP 25/200") func test_hud_preserves_legacy_responsive_panel_paths() -> void: var hud := game.get_node_or_null("HUD") as GameHud assert_not_null(hud, "Game scene requires HUD") if hud == null: return var layout := hud.get_node_or_null("ResponsiveLayout") as Control assert_not_null(layout, "HUD requires ResponsiveLayout") if layout == null: return var stats_panel := layout.get_node_or_null("StatsPanel") as PanelContainer var log_panel := layout.get_node_or_null("LogPanel") as PanelContainer var prompt_panel := layout.get_node_or_null("PromptPanel") as PanelContainer var help_panel := layout.get_node_or_null("HelpPanel") as PanelContainer assert_not_null(stats_panel, "HUD must preserve ResponsiveLayout/StatsPanel") assert_not_null(log_panel, "HUD must preserve ResponsiveLayout/LogPanel because GameHud uses that path") assert_not_null(prompt_panel, "HUD must preserve ResponsiveLayout/PromptPanel") assert_not_null(help_panel, "HUD must preserve ResponsiveLayout/HelpPanel") if stats_panel == null or log_panel == null or prompt_panel == null or help_panel == null: return var player_health := hud.get_node_or_null("PlayerHealthLabel") as Control var event_log := hud.get_node_or_null("EventLog") as Control var prompt := hud.get_node_or_null("ContextPromptLabel") as Control var help := hud.get_node_or_null("HelpLabel") as Control assert_not_null(player_health, "StatsPanel requires the existing health control") assert_not_null(event_log, "LogPanel requires the existing event log") assert_not_null(prompt, "PromptPanel requires the existing context prompt") assert_not_null(help, "HelpPanel requires the existing help label") if player_health == null or event_log == null or prompt == null or help == null: return assert_true(stats_panel.get_global_rect().encloses(player_health.get_global_rect())) assert_true(log_panel.get_global_rect().encloses(event_log.get_global_rect())) _assert_legacy_panel_is_transparent_and_behind(stats_panel) _assert_legacy_panel_is_transparent_and_behind(log_panel) assert_true(prompt_panel.get_global_rect().encloses(prompt.get_global_rect())) assert_true(help_panel.get_global_rect().encloses(help.get_global_rect())) func test_hud_defines_a_full_frame_shell_with_a_significant_centered_play_area() -> void: var hud := game.get_node_or_null("HUD") as GameHud assert_not_null(hud, "Game scene requires HUD") if hud == null: return var layout := hud.get_node_or_null("ResponsiveLayout") as Control assert_not_null(layout, "HUD requires ResponsiveLayout") if layout == null: return var top_bar := layout.get_node_or_null("TopBar") as Control var left_rail := layout.get_node_or_null("LeftRail") as Control var play_area_frame := layout.get_node_or_null("PlayAreaFrame") as Control var right_rail := layout.get_node_or_null("RightRail") as Control var command_bar := layout.get_node_or_null("CommandBar") as Control assert_not_null(top_bar, "ResponsiveLayout requires a TopBar") assert_not_null(left_rail, "ResponsiveLayout requires a LeftRail") assert_not_null(play_area_frame, "ResponsiveLayout requires a PlayAreaFrame") assert_not_null(right_rail, "ResponsiveLayout requires a RightRail") assert_not_null(command_bar, "ResponsiveLayout requires a CommandBar") if top_bar == null or left_rail == null or play_area_frame == null or right_rail == null or command_bar == null: return assert_eq(layout.anchor_right, 1.0) assert_eq(layout.anchor_bottom, 1.0) _assert_play_area_is_centered_and_inside_effective_viewport(play_area_frame) var play_rect := play_area_frame.get_global_rect() assert_false(left_rail.get_global_rect().intersects(play_rect), "LeftRail must not cover the framed play area") assert_false(right_rail.get_global_rect().intersects(play_rect), "RightRail must not cover the framed play area") assert_false(top_bar.get_global_rect().intersects(play_rect), "TopBar must not cover the framed play area") assert_false(command_bar.get_global_rect().intersects(play_rect), "CommandBar must not cover the framed play area") assert_false(left_rail.get_global_rect().intersects(right_rail.get_global_rect()), "the two rails must be distinct") assert_false(top_bar.get_global_rect().intersects(command_bar.get_global_rect()), "the top and command bars must be distinct") func test_live_hud_content_is_enclosed_by_its_intended_shell_region() -> void: var hud := game.get_node_or_null("HUD") as GameHud assert_not_null(hud, "Game scene requires HUD") if hud == null: return var layout := hud.get_node_or_null("ResponsiveLayout") as Control assert_not_null(layout, "HUD requires ResponsiveLayout") if layout == null: return var top_bar := layout.get_node_or_null("TopBar") as Control var left_rail := layout.get_node_or_null("LeftRail") as Control var right_rail := layout.get_node_or_null("RightRail") as Control var command_bar := layout.get_node_or_null("CommandBar") as Control assert_not_null(top_bar, "ResponsiveLayout requires a TopBar") assert_not_null(left_rail, "ResponsiveLayout requires a LeftRail") assert_not_null(right_rail, "ResponsiveLayout requires a RightRail") assert_not_null(command_bar, "ResponsiveLayout requires a CommandBar") if top_bar == null or left_rail == null or right_rail == null or command_bar == null: return _assert_controls_enclosed(top_bar, [ hud.get_node_or_null("AchievementToast") as Control, hud.get_node_or_null("TitleLabel") as Control, ] + _controls_in_group(hud, HEADER_VALUES_GROUP), "TopBar") _assert_controls_enclosed(left_rail, [ hud.get_node_or_null("PlayerHealthLabel") as Control, hud.get_node_or_null("PlayerFocusLabel") as Control, hud.get_node_or_null("ExperienceBar") as Control, hud.get_node_or_null("ExperienceLabel") as Control, hud.get_node_or_null("GoldLabel") as Control, hud.get_node_or_null("QuestTrackerLabel") as Control, hud.get_node_or_null("SpellLabel") as Control, hud.get_node_or_null("EnemyHealthLabel") as Control, hud.get_node_or_null("CombatSummaryLabel") as Control, hud.get_node_or_null("DeadlineLabel") as Control, ] + _controls_in_group(hud, CHARACTER_VALUES_GROUP), "LeftRail") _assert_controls_enclosed(right_rail, [hud.get_node_or_null("EventLog") as Control], "RightRail") _assert_controls_enclosed(command_bar, _controls_in_group(hud, COMMAND_HINTS_GROUP), "CommandBar") func test_dynamic_hud_groups_refresh_live_character_and_command_values_without_a_redundant_header() -> void: var hud := game.get_node_or_null("HUD") as GameHud assert_not_null(hud, "Game scene requires HUD") if hud == null: return var layout := hud.get_node_or_null("ResponsiveLayout") as Control assert_not_null(layout, "HUD requires ResponsiveLayout") if layout == null: return var left_rail := layout.get_node_or_null("LeftRail") as Control var command_bar := layout.get_node_or_null("CommandBar") as Control var header_values := hud.get_node_or_null("HeaderValuesLabel") as Label assert_not_null(left_rail) assert_not_null(command_bar) assert_not_null(header_values, "Legacy HeaderValuesLabel remains an explicitly hidden empty compatibility control") if left_rail == null or command_bar == null or header_values == null: return var state := game.get_game_state() var run := game.get_run_state() run.player_name = "Dame Ysabel" state.player.hit_points = state.player.max_hit_points - 1 state.player.cell = state.floor_state.entrance hud.refresh(state, [], run) var character_values := _labels_in_group(hud, CHARACTER_VALUES_GROUP) var command_hints := _labels_in_group(hud, COMMAND_HINTS_GROUP) assert_gte(character_values.size(), 1, "LeftRail exposes dynamic character values through the hud_character_values group") assert_gte(command_hints.size(), 1, "CommandBar exposes dynamic hints through the hud_command_hints group") assert_false(header_values.visible, "HeaderValuesLabel must not duplicate top-bar information") assert_eq(header_values.text, "", "HeaderValuesLabel must be empty when hidden") if character_values.is_empty() or command_hints.is_empty(): return assert_string_contains(_combined_label_text(character_values), str(state.player.hit_points)) _assert_controls_enclosed(left_rail, character_values, "LeftRail") state.player.cell = Vector2i(35, 7) hud.refresh(state, [], run) assert_string_contains(_combined_label_text(command_hints), hud.get_context_prompt()) assert_string_contains(_combined_label_text(command_hints), "Ouvrir la porte") _assert_controls_enclosed(command_bar, command_hints, "CommandBar") func test_compact_1280_layout_keeps_the_hidden_legacy_header_out_of_the_top_bar_content() -> void: var hud := game.get_node_or_null("HUD") as GameHud assert_not_null(hud, "Game scene requires HUD") if hud == null: return hud.apply_viewport_layout(Vector2(1280, 720)) var header := hud.get_node_or_null("HeaderValuesLabel") as Label assert_not_null(header, "HUD retains HeaderValuesLabel as a compatibility node") if header == null: return assert_false(header.visible, "The compact TopBar must not revive the removed header values") assert_eq(header.text, "") func test_compact_1280_layout_contains_live_hud_regions_without_covering_the_play_area() -> void: var hud := game.get_node_or_null("HUD") as GameHud assert_not_null(hud, "Game scene requires HUD") if hud == null: return hud.apply_viewport_layout(Vector2(1280, 720)) await get_tree().process_frame var layout := hud.get_node_or_null("ResponsiveLayout") as Control var minimap := hud.get_node_or_null("Minimap") as Minimap assert_not_null(layout, "HUD requires ResponsiveLayout") assert_not_null(minimap, "HUD requires its live minimap") if layout == null or minimap == null: return var top_bar := layout.get_node_or_null("TopBar") as Control var left_rail := layout.get_node_or_null("LeftRail") as Control var play_area := layout.get_node_or_null("PlayAreaFrame") as Control var right_rail := layout.get_node_or_null("RightRail") as Control var command_bar := layout.get_node_or_null("CommandBar") as Control var stats_panel := layout.get_node_or_null("StatsPanel") as Control var log_panel := layout.get_node_or_null("LogPanel") as Control var prompt_panel := layout.get_node_or_null("PromptPanel") as Control var help_panel := layout.get_node_or_null("HelpPanel") as Control var quick_slots := layout.get_node_or_null("QuickSlotStrip") as Control assert_not_null(top_bar) assert_not_null(left_rail) assert_not_null(play_area) assert_not_null(right_rail) assert_not_null(command_bar) assert_not_null(stats_panel) assert_not_null(log_panel) assert_not_null(prompt_panel) assert_not_null(help_panel) assert_not_null(quick_slots) if top_bar == null or left_rail == null or play_area == null or right_rail == null or command_bar == null or stats_panel == null or log_panel == null or prompt_panel == null or help_panel == null or quick_slots == null: return _assert_controls_enclosed(top_bar, [ hud.get_node_or_null("AchievementToast") as Control, hud.get_node_or_null("TitleLabel") as Control, hud.get_node_or_null("HeaderValuesLabel") as Control, ], "compact TopBar") _assert_controls_enclosed(left_rail, [ stats_panel, hud.get_node_or_null("PlayerHealthLabel") as Control, hud.get_node_or_null("HealthBar") as Control, hud.get_node_or_null("PlayerFocusLabel") as Control, hud.get_node_or_null("FocusBar") as Control, hud.get_node_or_null("ExperienceBar") as Control, hud.get_node_or_null("ExperienceLabel") as Control, hud.get_node_or_null("CharacterStatusLabel") as Control, hud.get_node_or_null("GoldLabel") as Control, hud.get_node_or_null("QuestTrackerLabel") as Control, hud.get_node_or_null("SpellLabel") as Control, hud.get_node_or_null("EnemyHealthLabel") as Control, hud.get_node_or_null("CombatSummaryLabel") as Control, hud.get_node_or_null("DeadlineLabel") as Control, ], "compact LeftRail") _assert_controls_enclosed(right_rail, [ log_panel, hud.get_node_or_null("EventLog") as Control, minimap, ], "compact RightRail") _assert_controls_enclosed(command_bar, [prompt_panel, help_panel, quick_slots, hud.get_node_or_null("ContextPromptLabel") as Control, hud.get_node_or_null("HelpLabel") as Control, layout.get_node_or_null("QuickSlotHint") as Control, ], "compact CommandBar") for shell: Control in [top_bar, left_rail, right_rail, command_bar]: assert_false(shell.get_global_rect().intersects(play_area.get_global_rect()), "%s must not cover the compact PlayAreaFrame" % shell.name) assert_false(minimap.get_global_rect().intersects(play_area.get_global_rect()), "The compact minimap must remain off the PlayAreaFrame") for label: Label in [ hud.get_node_or_null("HeaderValuesLabel") as Label, hud.get_node_or_null("PlayerHealthLabel") as Label, hud.get_node_or_null("PlayerFocusLabel") as Label, hud.get_node_or_null("ExperienceLabel") as Label, hud.get_node_or_null("ContextPromptLabel") as Label, hud.get_node_or_null("HelpLabel") as Label, ]: assert_not_null(label) if label != null: 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_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_title) assert_not_null(character_title) if journal != null: 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: var hud := game.get_node_or_null("HUD") as GameHud assert_not_null(hud, "Game scene requires HUD") if hud == null: return for viewport_size: Vector2 in [Vector2(1024, 768), Vector2(2560, 1080)]: hud.apply_viewport_layout(viewport_size) var layout := hud.get_node_or_null("ResponsiveLayout") as Control var artboard := layout.get_node_or_null("Artboard") as Control if layout != null else null assert_not_null(artboard, "ResponsiveLayout requires its centered 16:9 Artboard") if layout == null or artboard == null: return var scale := minf(viewport_size.x / GameHud.REFERENCE_VIEWPORT.x, viewport_size.y / GameHud.REFERENCE_VIEWPORT.y) var expected_size := GameHud.REFERENCE_VIEWPORT * scale var expected_origin := (viewport_size - expected_size) * 0.5 assert_eq(artboard.position, expected_origin, "The artboard must be centered at %s" % viewport_size) assert_eq(artboard.size, expected_size, "The artboard must preserve a 16:9 size at %s" % viewport_size) var artboard_rect := artboard.get_global_rect() for shell_name: String in ["TopBar", "LeftRail", "PlayAreaFrame", "RightRail", "CommandBar"]: var shell := layout.get_node_or_null(shell_name) as Control assert_not_null(shell) if shell != null: assert_true(artboard_rect.encloses(shell.get_global_rect()), "%s must remain inside the 16:9 artboard" % shell_name) for band_name: String in ["LetterboxTop", "LetterboxBottom", "PillarboxLeft", "PillarboxRight"]: var band := layout.get_node_or_null(band_name) as Panel assert_not_null(band, "ResponsiveLayout requires %s" % band_name) if band != null and band.size.x > 0.0 and band.size.y > 0.0: var style := band.get_theme_stylebox(&"panel") as StyleBoxFlat assert_not_null(style, "%s needs an explicit opaque panel style" % band_name) if style != null: assert_eq(style.bg_color.a, 1.0, "%s must be opaque so the world cannot show through" % band_name) assert_false(band.get_global_rect().intersects(artboard_rect), "%s must cover only the outside band" % band_name) var top := layout.get_node_or_null("LetterboxTop") as Control var bottom := layout.get_node_or_null("LetterboxBottom") as Control var left := layout.get_node_or_null("PillarboxLeft") as Control var right := layout.get_node_or_null("PillarboxRight") as Control if viewport_size == Vector2(1024, 768): assert_eq(top.size, Vector2(1024, 96), "1024x768 needs a fully covered top letterbox") assert_eq(bottom.size, Vector2(1024, 96), "1024x768 needs a fully covered bottom letterbox") assert_eq(left.size.x, 0.0) assert_eq(right.size.x, 0.0) else: assert_eq(left.size, Vector2(320, 1080), "ultrawide needs a fully covered left pillarbox") assert_eq(right.size, Vector2(320, 1080), "ultrawide needs a fully covered right pillarbox") assert_eq(top.size.y, 0.0) assert_eq(bottom.size.y, 0.0) func test_deadline_label_is_hidden_on_floor_zero_and_uses_only_the_live_collapse_countdown_afterward() -> void: var hud := game.get_node_or_null("HUD") as GameHud assert_not_null(hud, "Game scene requires HUD") if hud == null: return var state := game.get_game_state() var run := game.get_run_state() var deadline := hud.get_node_or_null("DeadlineLabel") as Label assert_not_null(deadline, "HUD requires DeadlineLabel") if deadline == null: return run.current_floor = 0 hud.refresh(state, [], run) assert_eq(deadline.text, "", "Floor zero has no collapse deadline") assert_false(deadline.visible, "Floor zero must not show an empty deadline slot") run.current_floor = 1 var floor_deadline := run.ensure_floor_deadline(1) floor_deadline.turns_remaining = 15 * floor_deadline.TURNS_PER_DAY hud.refresh(state, [], run) assert_true(deadline.visible) assert_eq(deadline.text, "Effondrement du niveau dans 15 jours") assert_eq(deadline.text.findn("escalier"), -1, "DeadlineLabel must not mention stairs") assert_eq(deadline.text.findn("Étage"), -1, "DeadlineLabel must not repeat the floor") floor_deadline.rest() hud.refresh(state, [], run) assert_eq(deadline.text, "Effondrement du niveau dans 14 jours", "The displayed count must follow the live deadline") func test_event_log_and_log_panel_never_intersect_the_hud_minimap_at_reference_and_compact_sizes() -> void: var hud := game.get_node_or_null("HUD") as GameHud assert_not_null(hud, "Game scene requires HUD") if hud == null: return for viewport_size: Vector2 in [Vector2(1920, 1080), Vector2(1280, 720)]: hud.apply_viewport_layout(viewport_size) await get_tree().process_frame var layout := hud.get_node_or_null("ResponsiveLayout") as Control var event_log := hud.get_node_or_null("EventLog") as Control var minimap := hud.get_node_or_null("Minimap") as Control assert_not_null(layout, "HUD requires ResponsiveLayout at %s" % viewport_size) assert_not_null(event_log, "HUD requires EventLog at %s" % viewport_size) assert_not_null(minimap, "HUD requires Minimap at %s" % viewport_size) if layout == null or event_log == null or minimap == null: return var log_panel := layout.get_node_or_null("LogPanel") as Control assert_not_null(log_panel, "HUD requires ResponsiveLayout/LogPanel at %s" % viewport_size) if log_panel == null: return assert_false(event_log.get_global_rect().intersects(minimap.get_global_rect()), "EventLog must not intersect HUD/Minimap at %s" % viewport_size) assert_false(log_panel.get_global_rect().intersects(minimap.get_global_rect()), "LogPanel must not intersect HUD/Minimap at %s" % viewport_size) func test_artboard_rails_and_center_follow_the_mockup_width_proportions() -> void: var hud := game.get_node_or_null("HUD") as GameHud assert_not_null(hud, "Game scene requires HUD") if hud == null: return for viewport_size: Vector2 in [Vector2(1920, 1080), Vector2(1280, 720)]: hud.apply_viewport_layout(viewport_size) await get_tree().process_frame var layout := hud.get_node_or_null("ResponsiveLayout") as Control assert_not_null(layout, "HUD requires ResponsiveLayout at %s" % viewport_size) if layout == null: return var artboard := layout.get_node_or_null("Artboard") as Control var left_rail := layout.get_node_or_null("LeftRail") as Control var play_area := layout.get_node_or_null("PlayAreaFrame") as Control var right_rail := layout.get_node_or_null("RightRail") as Control assert_not_null(artboard, "ResponsiveLayout requires Artboard at %s" % viewport_size) assert_not_null(left_rail, "ResponsiveLayout requires LeftRail at %s" % viewport_size) assert_not_null(play_area, "ResponsiveLayout requires PlayAreaFrame at %s" % viewport_size) assert_not_null(right_rail, "ResponsiveLayout requires RightRail at %s" % viewport_size) if artboard == null or left_rail == null or play_area == null or right_rail == null: return var left_ratio := left_rail.size.x / artboard.size.x var center_ratio := play_area.size.x / artboard.size.x var right_ratio := right_rail.size.x / artboard.size.x assert_gte(left_ratio, 0.22, "LeftRail must use at least 22%% of the artboard width at %s" % viewport_size) assert_lte(left_ratio, 0.26, "LeftRail must use at most 26%% of the artboard width at %s" % viewport_size) assert_gte(center_ratio, 0.48, "PlayAreaFrame must use at least 48%% of the artboard width at %s" % viewport_size) assert_lte(center_ratio, 0.56, "PlayAreaFrame must use at most 56%% of the artboard width at %s" % viewport_size) assert_gte(right_ratio, 0.22, "RightRail must use at least 22%% of the artboard width at %s" % viewport_size) assert_lte(right_ratio, 0.26, "RightRail must use at most 26%% of the artboard width at %s" % viewport_size) func test_named_left_and_right_rail_sections_are_visible_enclosed_and_non_overlapping() -> void: var hud := game.get_node_or_null("HUD") as GameHud assert_not_null(hud, "Game scene requires HUD") if hud == null: return var layout := hud.get_node_or_null("ResponsiveLayout") as Control assert_not_null(layout, "HUD requires ResponsiveLayout") if layout == null: return _assert_named_non_overlapping_sections(layout, "LeftRail", ["CharacterSection", "ObjectivesSection", "StatusSection"]) _assert_named_non_overlapping_sections(layout, "RightRail", ["JournalSection", "MapSection"]) func _assert_legacy_panel_is_transparent_and_behind(panel: PanelContainer) -> void: assert_true(panel.has_theme_stylebox_override(&"panel"), "%s requires an explicit local panel style rather than an inherited theme style" % panel.name) var style := panel.get_theme_stylebox(&"panel") assert_not_null(style, "%s requires an explicit local transparent panel style" % panel.name) assert_true(style is StyleBoxEmpty or (style is StyleBoxFlat and (style as StyleBoxFlat).bg_color.a == 0.0), "%s must not repaint over section headings" % panel.name) assert_true(panel.show_behind_parent, "%s must draw behind its parent and section titles" % panel.name) func _assert_named_non_overlapping_sections(layout: Control, rail_name: String, section_names: Array[String]) -> void: var rail := layout.get_node_or_null(rail_name) as Control assert_not_null(rail, "ResponsiveLayout requires %s" % rail_name) if rail == null: return var sections: Array[Control] = [] for section_name in section_names: var section := layout.get_node_or_null(section_name) as Control assert_not_null(section, "%s requires a visible %s" % [rail_name, section_name]) if section == null: continue assert_true(section.visible, "%s must be visible" % section_name) assert_true(rail.get_global_rect().encloses(section.get_global_rect()), "%s must be enclosed by %s" % [section_name, rail_name]) sections.append(section) for index in sections.size(): for other_index in range(index + 1, sections.size()): assert_false(sections[index].get_global_rect().intersects(sections[other_index].get_global_rect()), "%s must not overlap %s" % [sections[index].name, sections[other_index].name]) func test_character_section_title_shows_the_real_run_name_without_a_redundant_name_label() -> void: var hud := game.get_node_or_null("HUD") as GameHud assert_not_null(hud, "Game scene requires HUD") if hud == null: return var layout := hud.get_node_or_null("ResponsiveLayout") as Control var character_section := layout.get_node_or_null("CharacterSection") as Control if layout != null else null var section_title := layout.get_node_or_null("CharacterSectionTitle") as Label if layout != null else null var name_label := layout.get_node_or_null("CharacterNameLabel") as Label if layout != null else null var level_label := layout.get_node_or_null("CharacterLevelLabel") as Label if layout != null else null assert_not_null(layout, "HUD requires ResponsiveLayout") assert_not_null(character_section, "ResponsiveLayout requires CharacterSection") assert_not_null(section_title, "CharacterSection requires CharacterSectionTitle") assert_not_null(level_label, "CharacterSection requires CharacterLevelLabel") if layout == null or character_section == null or section_title == null or level_label == null: return var state := game.get_game_state() var run := game.get_run_state() run.player_name = "Dame Ysabel" state.player.progression.set_total_xp(125) hud.refresh(state, [], run) assert_true(section_title.visible) assert_eq(section_title.text, run.player_name, "The card heading is the run's real name, not PERSONNAGE") assert_ne(section_title.text, "PERSONNAGE") assert_true(name_label == null or not name_label.visible, "CharacterNameLabel must be absent or invisible because the title already names the run") if name_label != null: assert_eq(name_label.text, "", "The hidden duplicate must not retain a second visible identity") assert_true(level_label.visible) assert_true(character_section.get_global_rect().encloses(section_title.get_global_rect())) assert_true(character_section.get_global_rect().encloses(level_label.get_global_rect())) assert_string_contains(level_label.text, str(state.player.progression.level)) func test_character_portrait_uses_mockup_width_and_preserves_its_aspect_ratio_at_reference_size() -> void: var hud := game.get_node_or_null("HUD") as GameHud assert_not_null(hud, "Game scene requires HUD") if hud == null: return hud.apply_viewport_layout(Vector2(1920, 1080)) await get_tree().process_frame var layout := hud.get_node_or_null("ResponsiveLayout") as Control var character_section := layout.get_node_or_null("CharacterSection") as Control if layout != null else null var portrait := layout.get_node_or_null("PortraitIllustration") as TextureRect if layout != null else null assert_not_null(character_section, "ResponsiveLayout requires CharacterSection") assert_not_null(portrait, "CharacterSection requires PortraitIllustration") if character_section == null or portrait == null: return assert_true(portrait.visible, "PortraitIllustration must be visible") assert_gte(portrait.size.x / character_section.size.x, 0.28, "Portrait must use at least 28%% of CharacterSection width") assert_lte(portrait.size.x / character_section.size.x, 0.38, "Portrait must use at most 38%% of CharacterSection width") var texture := portrait.texture as Texture2D assert_not_null(texture, "PortraitIllustration requires a portrait texture") if texture != null: assert_almost_eq(portrait.size.x / portrait.size.y, texture.get_width() as float / texture.get_height() as float, 0.01, "PortraitIllustration must preserve the portrait aspect ratio") func test_section_titles_are_visible_contained_and_readable_at_reference_size() -> void: var hud := game.get_node_or_null("HUD") as GameHud assert_not_null(hud, "Game scene requires HUD") if hud == null: return hud.apply_viewport_layout(Vector2(1920, 1080)) await get_tree().process_frame var layout := hud.get_node_or_null("ResponsiveLayout") as Control assert_not_null(layout, "HUD requires ResponsiveLayout") if layout == null: return var section_names := ["CharacterSection", "ObjectivesSection", "StatusSection", "JournalSection", "MapSection"] var title_names := ["CharacterSectionTitle", "ObjectivesSectionTitle", "StatusSectionTitle", "JournalSectionTitle", "MapSectionTitle"] for index in section_names.size(): var section := layout.get_node_or_null(section_names[index]) as Control var title := layout.get_node_or_null(title_names[index]) as Label assert_not_null(section, "ResponsiveLayout requires %s" % section_names[index]) assert_not_null(title, "ResponsiveLayout requires %s" % title_names[index]) if section == null or title == null: continue assert_true(title.visible, "%s must be visible" % title_names[index]) assert_true(section.get_global_rect().encloses(title.get_global_rect()), "%s must contain %s" % [section_names[index], title_names[index]]) assert_gte(title.get_theme_font_size(&"font_size"), 16, "%s must use at least a 16px font at 1920x1080" % title_names[index]) func test_top_bar_defaults_to_a_single_floor_title_without_legacy_values_or_notifications() -> void: var hud := game.get_node_or_null("HUD") as GameHud assert_not_null(hud, "Game scene requires HUD") if hud == null: return hud.apply_viewport_layout(Vector2(1920, 1080)) await get_tree().process_frame var layout := hud.get_node_or_null("ResponsiveLayout") as Control var top_bar := layout.get_node_or_null("TopBar") as Control if layout != null else null var title := hud.get_node_or_null("TitleLabel") as Label var header_values := hud.get_node_or_null("HeaderValuesLabel") as Label var achievement_toast := hud.get_node_or_null("AchievementToast") as Label var title_notification := hud.get_node_or_null("TitleNotificationLabel") as Label assert_not_null(top_bar, "ResponsiveLayout requires TopBar") assert_not_null(title, "TopBar requires TitleLabel") assert_not_null(header_values, "Legacy HeaderValuesLabel must be explicitly hidden") assert_not_null(achievement_toast, "HUD retains AchievementToast") assert_not_null(title_notification, "HUD requires a separate temporary TitleNotificationLabel") if top_bar == null or title == null or header_values == null or achievement_toast == null or title_notification == null: return assert_true(title.visible, "TitleLabel is the sole default visible TopBar value") assert_eq(title.text, "Étage 0") assert_false(header_values.visible) assert_eq(header_values.text, "") assert_false(achievement_toast.visible) assert_false(title_notification.visible) assert_true(top_bar.get_global_rect().encloses(title.get_global_rect())) assert_gte(title.get_theme_font_size(&"font_size"), 20) func test_command_bar_subzones_are_distinct_and_contain_their_text() -> void: var hud := game.get_node_or_null("HUD") as GameHud assert_not_null(hud, "Game scene requires HUD") if hud == null: return hud.apply_viewport_layout(Vector2(1920, 1080)) await get_tree().process_frame var layout := hud.get_node_or_null("ResponsiveLayout") as Control var command_bar := layout.get_node_or_null("CommandBar") as Control if layout != null else null assert_not_null(command_bar, "ResponsiveLayout requires CommandBar") if layout == null or command_bar == null: return var quick_slots := layout.get_node_or_null("QuickSlotStrip") as Control var prompt_panel := layout.get_node_or_null("PromptPanel") as Control var help_panel := layout.get_node_or_null("HelpPanel") as Control var quick_text := layout.get_node_or_null("QuickSlotHint") as Control var prompt_text := hud.get_node_or_null("ContextPromptLabel") as Control var help_text := hud.get_node_or_null("HelpLabel") as Control for zone: Control in [quick_slots, prompt_panel, help_panel]: assert_not_null(zone, "CommandBar requires its three text sub-zones") if zone != null: assert_true(zone.visible, "%s must be visible" % zone.name) assert_true(command_bar.get_global_rect().encloses(zone.get_global_rect()), "%s must be contained by CommandBar" % zone.name) for index in 3: for other_index in range(index + 1, 3): var zones: Array[Control] = [quick_slots, prompt_panel, help_panel] if zones[index] != null and zones[other_index] != null: assert_false(zones[index].get_global_rect().intersects(zones[other_index].get_global_rect()), "%s must not overlap %s" % [zones[index].name, zones[other_index].name]) assert_not_null(quick_text, "QuickSlotStrip requires QuickSlotHint") assert_not_null(prompt_text, "PromptPanel requires ContextPromptLabel") assert_not_null(help_text, "HelpPanel requires HelpLabel") for text_control: Control in [quick_text, prompt_text, help_text]: if text_control != null: assert_true(text_control.visible, "%s text must be visible" % text_control.name) if quick_slots != null and quick_text != null: assert_true(quick_slots.get_global_rect().encloses(quick_text.get_global_rect()), "QuickSlotStrip must contain its text") if prompt_panel != null and prompt_text != null: assert_true(prompt_panel.get_global_rect().encloses(prompt_text.get_global_rect()), "PromptPanel must contain its text") if help_panel != null and help_text != null: assert_true(help_panel.get_global_rect().encloses(help_text.get_global_rect()), "HelpPanel must contain its text") func _assert_play_area_is_centered_and_inside_effective_viewport(play_area_frame: Control) -> void: var viewport_rect := get_viewport().get_visible_rect() var expected_viewport := Vector2(Game.REFERENCE_VIEWPORT) var play_rect := play_area_frame.get_global_rect() assert_eq(viewport_rect.size, expected_viewport, "HUD layout is evaluated in the effective 1920x1080 viewport") assert_gte(play_rect.position.x, viewport_rect.position.x, "PlayAreaFrame must stay inside the viewport on the left") assert_gte(play_rect.position.y, viewport_rect.position.y, "PlayAreaFrame must stay inside the viewport at the top") assert_lte(play_rect.end.x, viewport_rect.end.x, "PlayAreaFrame must stay inside the viewport on the right") assert_lte(play_rect.end.y, viewport_rect.end.y, "PlayAreaFrame must stay inside the viewport at the bottom") assert_gte(play_rect.size.x, viewport_rect.size.x * 0.40, "PlayAreaFrame must have meaningful viewport width") assert_gte(play_rect.size.y, viewport_rect.size.y * 0.40, "PlayAreaFrame must have meaningful viewport height") assert_gte(play_rect.get_area(), viewport_rect.get_area() * 0.25, "PlayAreaFrame must occupy a meaningful part of the viewport") assert_lte(play_rect.get_center().distance_to(viewport_rect.get_center()), 2.0, "PlayAreaFrame must be centered in the effective viewport") func _assert_controls_enclosed(region: Control, controls: Array, region_name: String) -> void: for live_control: Control in controls: assert_not_null(live_control, "%s must retain its live HUD control" % region_name) if live_control != null: assert_true(region.get_global_rect().encloses(live_control.get_global_rect()), "%s must enclose %s" % [region_name, live_control.get_path()]) func _controls_in_group(hud: GameHud, group_name: StringName) -> Array[Control]: var controls: Array[Control] = [] for node in get_tree().get_nodes_in_group(group_name): if node is Control and hud.is_ancestor_of(node): controls.append(node as Control) return controls func _labels_in_group(hud: GameHud, group_name: StringName) -> Array[Label]: var labels: Array[Label] = [] for node in _controls_in_group(hud, group_name): if node is Label: labels.append(node as Label) return labels func _combined_label_text(labels: Array[Label]) -> String: var text := "" for label in labels: text += label.text + "\n" return text func test_hud_shell_frames_use_the_dark_fantasy_nine_patch_texture() -> void: var hud := game.get_node_or_null("HUD") as GameHud assert_not_null(hud, "Game scene requires HUD") if hud == null: return var layout := hud.get_node_or_null("ResponsiveLayout") as Control assert_not_null(layout, "HUD requires ResponsiveLayout") if layout == null: return for frame_name: String in [ "TopBar", "LeftRail", "RightRail", "CommandBar", "CharacterSection", "ObjectivesSection", "StatusSection", "JournalSection", "MapSection", ]: var frame := layout.get_node_or_null(frame_name) as Panel assert_not_null(frame, "ResponsiveLayout requires %s" % frame_name) if frame == null: continue var style := frame.get_theme_stylebox(&"panel") assert_true(style is StyleBoxTexture, "%s must use StyleBoxTexture rather than StyleBoxFlat" % frame_name) var texture_style := style as StyleBoxTexture if texture_style != null: assert_true(_texture_uses_path(texture_style.texture, "res://assets/ui/dark_fantasy/panel_64x64_nine_patch_source.png"), "%s must use panel_64x64_nine_patch_source.png" % frame_name) func test_play_area_masks_use_the_dungeon_background_texture() -> void: var hud := game.get_node_or_null("HUD") as GameHud assert_not_null(hud, "Game scene requires HUD") if hud == null: return var layout := hud.get_node_or_null("ResponsiveLayout") as Control assert_not_null(layout, "HUD requires ResponsiveLayout") if layout == null: return const DUNGEON_BACKGROUND := "res://assets/ui/dark_fantasy/dungeon_ui_background.png" assert_file_exists(DUNGEON_BACKGROUND) for mask_name: String in ["PlayAreaMaskTop", "PlayAreaMaskLeft", "PlayAreaMaskRight", "PlayAreaMaskBottom"]: var mask := layout.get_node_or_null(mask_name) as Panel assert_not_null(mask, "ResponsiveLayout requires %s" % mask_name) if mask == null: continue var style := mask.get_theme_stylebox(&"panel") assert_true(style is StyleBoxTexture, "%s must use a StyleBoxTexture/AtlasTexture dungeon background" % mask_name) var texture_style := style as StyleBoxTexture if texture_style != null: assert_true(_texture_uses_path(texture_style.texture, DUNGEON_BACKGROUND), "%s must use the new dungeon_ui_background.png asset" % mask_name) func test_decorative_equipment_and_header_art_are_absent_or_hidden() -> void: var hud := game.get_node_or_null("HUD") as GameHud assert_not_null(hud, "Game scene requires HUD") if hud == null: return var layout := hud.get_node_or_null("ResponsiveLayout") as Control assert_not_null(layout, "HUD requires ResponsiveLayout") if layout == null: return for decorative_name: String in ["EquipmentIllustration", "HeaderOrnament"]: var decorative := layout.get_node_or_null(decorative_name) as Control assert_true(decorative == null or not decorative.visible, "%s must be absent or invisible rather than adding decorative visual noise" % decorative_name) func test_objectives_and_status_keep_separate_titles_and_content_at_reference_and_compact_sizes() -> void: var hud := game.get_node_or_null("HUD") as GameHud assert_not_null(hud, "Game scene requires HUD") if hud == null: return for viewport_size: Vector2 in [Vector2(1920, 1080), Vector2(1280, 720)]: hud.apply_viewport_layout(viewport_size) await get_tree().process_frame var layout := hud.get_node_or_null("ResponsiveLayout") as Control var objectives := layout.get_node_or_null("ObjectivesSection") as Control if layout != null else null var status := layout.get_node_or_null("StatusSection") as Control if layout != null else null var objectives_title := layout.get_node_or_null("ObjectivesSectionTitle") as Label if layout != null else null var status_title := layout.get_node_or_null("StatusSectionTitle") as Label if layout != null else null var quest_content := hud.get_node_or_null("QuestTrackerLabel") as Control var status_content := hud.get_node_or_null("CharacterStatusLabel") as Control assert_not_null(objectives, "ObjectivesSection is required at %s" % viewport_size) assert_not_null(status, "StatusSection is required at %s" % viewport_size) assert_not_null(objectives_title) assert_not_null(status_title) assert_not_null(quest_content) assert_not_null(status_content) if objectives == null or status == null or objectives_title == null or status_title == null or quest_content == null or status_content == null: continue assert_true(status.get_global_rect().encloses(status_content.get_global_rect()), "CharacterStatusLabel belongs inside StatusSection at %s" % viewport_size) assert_true(objectives.get_global_rect().encloses(objectives_title.get_global_rect())) assert_true(objectives.get_global_rect().encloses(quest_content.get_global_rect())) assert_true(status.get_global_rect().encloses(status_title.get_global_rect())) assert_false(status_content.get_global_rect().intersects(objectives.get_global_rect()), "CharacterStatusLabel must not touch ObjectivesSection at %s" % viewport_size) assert_false(objectives_title.get_global_rect().intersects(quest_content.get_global_rect()), "Objectives title and content must be distinct at %s" % viewport_size) assert_false(status_title.get_global_rect().intersects(status_content.get_global_rect()), "Status title and content must be distinct at %s" % viewport_size) assert_false(objectives.get_global_rect().intersects(status.get_global_rect()), "Objectives and status frames must remain separate at %s" % viewport_size) if viewport_size == Vector2(1920, 1080): assert_gte(status.get_global_rect().position.y - objectives.get_global_rect().end.y, 24.0) assert_gte(status_title.get_global_rect().position.y - status.get_global_rect().position.y, 14.0) func test_player_health_and_gold_use_the_final_compact_character_section_contract() -> void: var hud := game.get_node_or_null("HUD") as GameHud assert_not_null(hud, "Game scene requires HUD") if hud == null: return var state := game.get_game_state() var run := game.get_run_state() run.gold = 15 hud.refresh(state, [], run) var layout := hud.get_node_or_null("ResponsiveLayout") as Control var character_section := layout.get_node_or_null("CharacterSection") as Control if layout != null else null var health := hud.get_node_or_null("PlayerHealthLabel") as Label var gold_icon := hud.get_node_or_null("GoldIcon") as TextureRect var gold_label := hud.get_node_or_null("GoldLabel") as Label assert_not_null(character_section) assert_not_null(health) assert_not_null(gold_icon, "CharacterSection requires GoldIcon") assert_not_null(gold_label) if character_section == null or health == null or gold_icon == null or gold_label == null: return assert_eq(health.text, "PV : %d/%d" % [state.player.hit_points, state.player.max_hit_points]) assert_true(gold_icon.visible) assert_not_null(gold_icon.texture) if gold_icon.texture != null: assert_true(_texture_has_gold_coin_path(gold_icon.texture), "GoldIcon must use the gold_coin SVG or PNG asset") assert_eq(gold_label.text, "15", "GoldLabel contains the numeric value only") assert_true(character_section.get_global_rect().encloses(gold_icon.get_global_rect())) assert_true(character_section.get_global_rect().encloses(gold_label.get_global_rect())) var currency_bottom := maxf(gold_icon.get_global_rect().end.y, gold_label.get_global_rect().end.y) assert_gte(character_section.get_global_rect().end.y - currency_bottom, 16.0, "The currency icon/value union needs a >=16px bottom margin") func test_character_and_journal_titles_use_the_final_large_outlined_light_style() -> void: var hud := game.get_node_or_null("HUD") as GameHud assert_not_null(hud, "Game scene requires HUD") if hud == null: return hud.apply_viewport_layout(Vector2(1920, 1080)) await get_tree().process_frame var layout := hud.get_node_or_null("ResponsiveLayout") as Control assert_not_null(layout) if layout == null: return for specification: Dictionary in [ {"section": "CharacterSection", "title": "CharacterSectionTitle"}, {"section": "JournalSection", "title": "JournalSectionTitle"}, ]: var section := layout.get_node_or_null(String(specification.section)) as Control var title := layout.get_node_or_null(String(specification.title)) as Label assert_not_null(section) assert_not_null(title, "ResponsiveLayout requires %s" % specification.title) if section == null or title == null: continue assert_gte(title.get_theme_font_size(&"font_size"), 20, "%s needs a >=20px font at 1920x1080" % title.name) assert_gte(title.get_theme_constant(&"outline_size"), 3, "%s needs a >=3px contour" % title.name) var font_color := title.get_theme_color(&"font_color") assert_gte(font_color.r, 0.95, "%s must use an explicit gold/yellow red channel" % title.name) assert_gte(font_color.g, 0.70, "%s must use an explicit gold/yellow green channel" % title.name) assert_lte(font_color.g, 0.90, "%s must use an explicit gold/yellow green channel" % title.name) assert_lte(font_color.b, 0.55, "%s must use an explicit gold/yellow blue channel" % title.name) assert_eq(font_color.a, 1.0, "%s must be fully opaque" % title.name) assert_gte(title.get_global_rect().position.y - section.get_global_rect().position.y, 16.0, "%s needs a >=16px vertical inset" % title.name) func test_command_bar_keeps_all_three_zones_readable_at_reference_and_compact_sizes() -> void: var hud := game.get_node_or_null("HUD") as GameHud assert_not_null(hud, "Game scene requires HUD") if hud == null: return for viewport_size: Vector2 in [Vector2(1920, 1080), Vector2(1280, 720)]: hud.apply_viewport_layout(viewport_size) await get_tree().process_frame var layout := hud.get_node_or_null("ResponsiveLayout") as Control var command_bar := layout.get_node_or_null("CommandBar") as Control if layout != null else null var quick_slots := layout.get_node_or_null("QuickSlotStrip") as Control if layout != null else null var prompt_panel := layout.get_node_or_null("PromptPanel") as Control if layout != null else null var help_panel := layout.get_node_or_null("HelpPanel") as Control if layout != null else null var quick_hint := layout.get_node_or_null("QuickSlotHint") as Label if layout != null else null var prompt := layout.get_node_or_null("PromptPanel/ActionHintLabel") as Label if layout != null else null var help := hud.get_node_or_null("HelpLabel") as Label assert_not_null(command_bar, "CommandBar is required at %s" % viewport_size) assert_not_null(quick_slots) assert_not_null(prompt_panel) assert_not_null(help_panel) assert_not_null(quick_hint) assert_not_null(prompt) assert_not_null(help) if command_bar == null or quick_slots == null or prompt_panel == null or help_panel == null or quick_hint == null or prompt == null or help == null: continue for zone: Control in [quick_slots, prompt_panel, help_panel]: assert_true(command_bar.get_global_rect().encloses(zone.get_global_rect()), "%s must remain contained at %s" % [zone.name, viewport_size]) for index in 3: var zones: Array[Control] = [quick_slots, prompt_panel, help_panel] for other_index in range(index + 1, 3): assert_false(zones[index].get_global_rect().intersects(zones[other_index].get_global_rect()), "%s and %s must not overlap at %s" % [zones[index].name, zones[other_index].name, viewport_size]) assert_true(quick_slots.get_global_rect().encloses(quick_hint.get_global_rect())) assert_true(prompt_panel.get_global_rect().encloses(prompt.get_global_rect())) assert_true(help_panel.get_global_rect().encloses(help.get_global_rect())) assert_false(help.clip_text, "HelpLabel must not be truncated at %s" % viewport_size) assert_lte(help.get_minimum_size().x, help.size.x, "The right help zone must fit its complete label at %s" % viewport_size) assert_eq(prompt.text, "F : Distance • X : Magie • K : Familier", "The center zone must contain exactly the three requested command notions") func _texture_has_gold_coin_path(texture: Texture2D) -> bool: return _texture_uses_path(texture, "res://assets/ui/dark_fantasy/gold_coin.svg") or _texture_uses_path(texture, "res://assets/ui/dark_fantasy/gold_coin.png") func _texture_uses_path(texture: Texture2D, expected_path: String) -> bool: if texture == null: return false if texture.resource_path == expected_path: return true if texture is AtlasTexture: var atlas_texture := texture as AtlasTexture return atlas_texture.atlas != null and atlas_texture.atlas.resource_path == expected_path return false