fix: harden responsive HUD validation
This commit is contained in:
@@ -229,6 +229,147 @@ func test_compact_1280_layout_scales_header_text_and_keeps_it_inside_the_top_bar
|
||||
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,
|
||||
layout.get_node_or_null("HeaderOrnament") 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")
|
||||
|
||||
Reference in New Issue
Block a user