808 lines
43 KiB
GDScript
808 lines
43 KiB
GDScript
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 : ZQSD / Flèches")
|
|
assert_string_contains(help_label.text, "nord-est : pavé num. 9")
|
|
assert_string_contains(help_label.text, "Interagir : Espace ou E")
|
|
|
|
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_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_from_live_game_values() -> 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 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(command_bar, "ResponsiveLayout requires a CommandBar")
|
|
if top_bar == null or left_rail == null or command_bar == 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 header_values := _labels_in_group(hud, HEADER_VALUES_GROUP)
|
|
var character_values := _labels_in_group(hud, CHARACTER_VALUES_GROUP)
|
|
var command_hints := _labels_in_group(hud, COMMAND_HINTS_GROUP)
|
|
assert_gte(header_values.size(), 1, "TopBar exposes dynamic header values through the hud_header_values 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")
|
|
if header_values.is_empty() or character_values.is_empty() or command_hints.is_empty():
|
|
return
|
|
|
|
var header_text := _combined_label_text(header_values)
|
|
var character_text := _combined_label_text(character_values)
|
|
var expected_room_id := ""
|
|
for room: RoomState in state.floor_state.rooms:
|
|
if room.bounds.has_point(state.player.cell):
|
|
expected_room_id = String(room.id)
|
|
break
|
|
assert_ne(expected_room_id, "", "The player's authored room must be discoverable from its bounds")
|
|
assert_string_contains(header_text, run.player_name)
|
|
assert_string_contains(header_text, str(state.floor_state.floor_number))
|
|
assert_string_contains(header_text, expected_room_id)
|
|
assert_string_contains(header_text, str(state.explored_cells.size()))
|
|
assert_string_contains(character_text, str(state.player.hit_points))
|
|
_assert_controls_enclosed(top_bar, header_values, "TopBar")
|
|
_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_scales_header_text_and_keeps_it_inside_the_top_bar() -> 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 top_bar := hud.get_node_or_null("ResponsiveLayout/TopBar") as Control
|
|
var header := hud.get_node_or_null("HeaderValuesLabel") as Label
|
|
assert_not_null(top_bar, "ResponsiveLayout requires a TopBar")
|
|
assert_not_null(header, "HUD requires HeaderValuesLabel")
|
|
if top_bar == null or header == null:
|
|
return
|
|
|
|
assert_eq(header.get_theme_font_size(&"font_size"), 11, "The compact shell scales the 16px header value font to the 1280x720 artboard")
|
|
assert_true(top_bar.get_global_rect().encloses(header.get_global_rect()), "The compact header remains inside its TopBar")
|
|
assert_lte(header.get_minimum_size().y, header.size.y, "The compact header has enough height for its scaled 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
|
|
assert_not_null(journal)
|
|
if journal != null:
|
|
assert_gte(journal.get_theme_font_size(&"normal_font_size"), 9, "The compact journal font 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_long_deadline_text_wraps_and_stays_inside_the_left_rail() -> 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.current_floor = 1
|
|
run.ensure_floor_deadline(1)
|
|
hud.refresh(state, [], run)
|
|
await get_tree().process_frame
|
|
|
|
var left_rail := hud.get_node_or_null("ResponsiveLayout/LeftRail") as Control
|
|
var deadline := hud.get_node_or_null("DeadlineLabel") as Label
|
|
assert_not_null(left_rail, "ResponsiveLayout requires a LeftRail")
|
|
assert_not_null(deadline, "HUD requires DeadlineLabel")
|
|
if left_rail == null or deadline == null:
|
|
return
|
|
assert_true(left_rail.get_global_rect().encloses(deadline.get_global_rect()))
|
|
assert_lte(deadline.get_minimum_size().x, deadline.size.x)
|
|
assert_gt(deadline.size.y, deadline.get_line_height())
|
|
|
|
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_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_exposes_live_name_and_level_labels() -> 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 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(name_label, "CharacterSection requires CharacterNameLabel")
|
|
assert_not_null(level_label, "CharacterSection requires CharacterLevelLabel")
|
|
if layout == null or character_section == null or name_label == 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(name_label.visible, "CharacterNameLabel must be visible")
|
|
assert_true(level_label.visible, "CharacterLevelLabel must be visible")
|
|
assert_true(character_section.get_global_rect().encloses(name_label.get_global_rect()), "CharacterSection must contain CharacterNameLabel")
|
|
assert_true(character_section.get_global_rect().encloses(level_label.get_global_rect()), "CharacterSection must contain CharacterLevelLabel")
|
|
assert_string_contains(name_label.text, run.player_name, "CharacterNameLabel must show the real player name")
|
|
assert_string_contains(level_label.text, str(state.player.progression.level), "CharacterLevelLabel must show the real player 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_contains_readable_non_overlapping_title_and_header_values() -> 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
|
|
assert_not_null(top_bar, "ResponsiveLayout requires TopBar")
|
|
assert_not_null(title, "TopBar requires TitleLabel")
|
|
assert_not_null(header_values, "TopBar requires HeaderValuesLabel")
|
|
if top_bar == null or title == null or header_values == null:
|
|
return
|
|
assert_true(top_bar.get_global_rect().encloses(title.get_global_rect()), "TopBar must contain TitleLabel")
|
|
assert_true(top_bar.get_global_rect().encloses(header_values.get_global_rect()), "TopBar must contain HeaderValuesLabel")
|
|
assert_false(title.get_global_rect().intersects(header_values.get_global_rect()), "TitleLabel and HeaderValuesLabel must not intersect")
|
|
assert_gte(title.get_theme_font_size(&"font_size"), 20, "TitleLabel must use at least a 20px font at 1920x1080")
|
|
assert_gte(header_values.get_theme_font_size(&"font_size"), 15, "HeaderValuesLabel must use at least a 15px font at 1920x1080")
|
|
|
|
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, "The required dungeon background asset must exist")
|
|
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_the_requested_vertical_breathing_room() -> 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 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 status_title := layout.get_node_or_null("StatusSectionTitle") as Label if layout != null else null
|
|
assert_not_null(objectives)
|
|
assert_not_null(status)
|
|
assert_not_null(status_title)
|
|
if objectives == null or status == null or status_title == null:
|
|
return
|
|
assert_gte(status.get_global_rect().position.y - objectives.get_global_rect().end.y, 24.0, "Objectives and Status need at least 24px of vertical separation at 1920x1080")
|
|
assert_gte(status_title.get_global_rect().position.y - status.get_global_rect().position.y, 14.0, "ÉTAT title needs at least 14px top inset")
|
|
|
|
func test_character_and_journal_titles_are_outlined_light_and_readable() -> 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 title_name: String in ["CharacterSectionTitle", "JournalSectionTitle"]:
|
|
var title := layout.get_node_or_null(title_name) as Label
|
|
assert_not_null(title, "ResponsiveLayout requires %s" % title_name)
|
|
if title == null:
|
|
continue
|
|
assert_gte(title.get_theme_font_size(&"font_size"), 16, "%s needs at least a 16px font at 1920x1080" % title_name)
|
|
assert_gte(title.get_theme_constant(&"outline_size"), 2, "%s needs a >=2px contour" % title_name)
|
|
assert_gte(title.get_theme_color(&"font_color").get_luminance(), 0.60, "%s needs a light font color" % 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 := hud.get_node_or_null("ContextPromptLabel") as Label
|
|
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_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
|