fix: harden responsive HUD validation

This commit is contained in:
goose
2026-10-08 23:13:51 -04:00
parent f6e93159c0
commit c779c796ec
5 changed files with 209 additions and 2 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ All binary art below is an unmodified 32×32 PNG copied from the local **Dungeon
## Dark fantasy UI kit — Task 1
Reusable UI components copied from the local prototype kit documented in `/home/hectelyon/Downloads/DungeonCrawlerWorld_UI_Assets/README.md`. Only transparent reusable components were imported, plus the two explicitly requested captures (`portrait_roger.png`, `illustration_equipement.png`). Import presets keep UI textures uncompressed, without mipmaps, and do not scale/recolor them with editor settings for pixel-stable UI rendering.
Reusable UI components copied from the local prototype kit documented by the portable pack identifier `DungeonCrawlerWorld_UI_Assets/README.md`. Only transparent reusable components were imported, plus the two explicitly requested captures (`portrait_roger.png`, `illustration_equipement.png`). Import presets keep UI textures uncompressed, without mipmaps, and do not scale/recolor them with editor settings for pixel-stable UI rendering.
| Imported path | Local source | Author / pack | License | Modification / intended use |
|---|---|---|---|---|
+32
View File
@@ -92,6 +92,14 @@ corner_radius_bottom_right = 6
corner_radius_bottom_left = 6
[sub_resource type="StyleBoxFlat" id="StyleBox_opaque_outside_artboard"]
bg_color = Color(0.012, 0.018, 0.028, 1)
border_width_left = 1
border_width_top = 1
border_width_right = 1
border_width_bottom = 1
border_color = Color(0.19, 0.15, 0.09, 1)
[sub_resource type="StyleBoxFlat" id="StyleBox_play_frame"]
bg_color = Color(0.008, 0.012, 0.018, 0.0)
border_width_left = 3
@@ -253,6 +261,30 @@ theme = ExtResource("36_hud_theme")
layout_mode = 0
mouse_filter = 2
[node name="Artboard" type="Control" parent="HUD/ResponsiveLayout"]
layout_mode = 0
mouse_filter = 2
[node name="LetterboxTop" type="Panel" parent="HUD/ResponsiveLayout"]
layout_mode = 0
mouse_filter = 2
theme_override_styles/panel = SubResource("StyleBox_opaque_outside_artboard")
[node name="LetterboxBottom" type="Panel" parent="HUD/ResponsiveLayout"]
layout_mode = 0
mouse_filter = 2
theme_override_styles/panel = SubResource("StyleBox_opaque_outside_artboard")
[node name="PillarboxLeft" type="Panel" parent="HUD/ResponsiveLayout"]
layout_mode = 0
mouse_filter = 2
theme_override_styles/panel = SubResource("StyleBox_opaque_outside_artboard")
[node name="PillarboxRight" type="Panel" parent="HUD/ResponsiveLayout"]
layout_mode = 0
mouse_filter = 2
theme_override_styles/panel = SubResource("StyleBox_opaque_outside_artboard")
[node name="TopBar" type="Panel" parent="HUD/ResponsiveLayout"]
layout_mode = 0
mouse_filter = 2
+15 -1
View File
@@ -60,9 +60,18 @@ func apply_viewport_layout(viewport_size: Vector2) -> void:
var artboard_size := REFERENCE_VIEWPORT * scale
var origin := (viewport_size - artboard_size) * 0.5
# Keep the authored HUD on one centered 16:9 artboard. The opaque dark-fantasy
# bands mask every pixel outside it, rather than allowing the world to show in
# letterbox or pillarbox space on non-16:9 displays.
_set_rect($ResponsiveLayout/DarkBackdrop, Vector2.ZERO, viewport_size)
_set_rect($ResponsiveLayout/Artboard, origin, artboard_size)
_set_rect($ResponsiveLayout/LetterboxTop, Vector2.ZERO, Vector2(viewport_size.x, origin.y))
_set_rect($ResponsiveLayout/LetterboxBottom, Vector2(0.0, origin.y + artboard_size.y), Vector2(viewport_size.x, origin.y))
_set_rect($ResponsiveLayout/PillarboxLeft, Vector2(0.0, origin.y), Vector2(origin.x, artboard_size.y))
_set_rect($ResponsiveLayout/PillarboxRight, Vector2(origin.x + artboard_size.x, origin.y), Vector2(origin.x, artboard_size.y))
# CanvasLayer controls paint over the world; the play frame is deliberately
# border-only so its center remains the unobscured gameplay viewport.
_set_rect($ResponsiveLayout/DarkBackdrop, Vector2.ZERO, viewport_size)
_set_rect($ResponsiveLayout/TopBar, origin + Vector2(20, 10) * scale, Vector2(1880, 100) * scale)
_set_rect($ResponsiveLayout/LeftRail, origin + Vector2(20, 122) * scale, Vector2(320, 826) * scale)
_set_rect($ResponsiveLayout/PlayAreaFrame, origin + Vector2(370, 125) * scale, Vector2(1180, 830) * scale)
@@ -76,6 +85,11 @@ func apply_viewport_layout(viewport_size: Vector2) -> void:
_set_rect($ResponsiveLayout/PromptPanel, origin + Vector2(525, 976) * scale, Vector2(600, 34) * scale)
_set_rect($ResponsiveLayout/HelpPanel, origin + Vector2(1125, 976) * scale, Vector2(775, 82) * scale)
_set_rect($ResponsiveLayout/QuickSlotStrip, origin + Vector2(20, 976) * scale, Vector2(490, 82) * scale)
# Minimap owns its compact/expanded sizing, but must consume the freshly sized
# rail before any frame is rendered at a new viewport size.
var minimap := get_node_or_null("Minimap") as Control
if minimap != null:
minimap.call("_layout_in_hud")
_apply_text_scale(scale)
_set_rect($AchievementToast, origin + Vector2(420, 16) * scale, Vector2(1080, 28) * scale)
+20
View File
@@ -0,0 +1,20 @@
# PR-4 — Responsive HUD validation hardening
## Scope
Final-review fixes for responsive HUD validation and non-16:9 presentation:
- Expanded the real 1280×720 layout test to require all major live HUD regions—rails, command bar, journal, prompt/help, gauges, quick slots, and minimap—to remain enclosed, readable, and outside the framed play area.
- Added 1024×768 and 2560×1080 unit coverage for a centered 16:9 artboard, explicit letterbox/pillarbox bands, opaque dark-fantasy outside margins, and shell containment.
- Added runtime `Artboard`, letterbox, and pillarbox nodes in `Game.tscn`; `hud.gd` sizes them from one centered reference artboard and synchronizes the minimap after rail relayout.
- Replaced the absolute UI-kit source path in `ASSET_REGISTRY.md` with the portable pack identifier `DungeonCrawlerWorld_UI_Assets/README.md`.
- Existing scene paths and gameplay behavior remain unchanged. The theme was not broadened to unrelated nodes because the current shell already owns the HUD theme and a CanvasLayer-wide theme would be unsafe for instantiated modal panels.
## Verification
- Targeted HUD layout: **10/10 tests passed**, 269 assertions.
- Full `scripts/verify.sh`: unit **223/223**, integration **19/19**, E2E **78/78**, 34,650 unit assertions plus 1,696,729 integration assertions; parity matrix **43 rows, 0 invalid**.
- Real visual runner passed 1920×1080, exit, and 1280×720 captures. Compact capture inspected at 1280×720; opaque dark-fantasy margins and contained controls are present.
- Capture measurements: reference `visible=82944`, `explored=18965`, `unknown=890112`; exit `visible=10368`, `explored=18965`, `unknown=976128`; compact `visible=36926`, `explored=8227`, `unknown=393984`.
Godot/GUT emitted only existing invalid-UID, cleanup/resource, and float/int comparison warnings. No push was performed.
+141
View File
@@ -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")