fix: complete Task 5 visual HUD validation
This commit is contained in:
@@ -240,6 +240,7 @@ text = "Sans-Nom • Étage 0 • Salle inconnue • 0 cases explorées"
|
||||
|
||||
[node name="ResponsiveLayout" type="Control" parent="HUD"]
|
||||
layout_mode = 3
|
||||
z_index = -1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
|
||||
@@ -154,10 +154,12 @@ def is_visible(pixel: tuple[int, int, int]) -> bool:
|
||||
|
||||
|
||||
def is_explored(pixel: tuple[int, int, int]) -> bool:
|
||||
# Tile texture remains visible under a blue-black fog overlay. This is the
|
||||
# dominant fog-modulated floor texel; keeping the detector exact avoids HUD
|
||||
# colors and visible terrain satisfying it.
|
||||
return pixel == (19, 29, 39)
|
||||
# Texture-preserving explored terrain is rendered under a blue-black fog
|
||||
# overlay. GPU blend rounding and the authored floor texture produce a
|
||||
# palette rather than one portable exact RGB value; accept only its dark,
|
||||
# blue-shifted range so HUD chrome and visible brown terrain cannot match.
|
||||
red, green, blue = pixel
|
||||
return 4 <= red <= 14 and 8 <= green <= 22 and 17 <= blue <= 32 and blue >= green + 4 and green >= red + 3
|
||||
|
||||
|
||||
def measure(path: Path) -> None:
|
||||
|
||||
@@ -309,6 +309,9 @@ func _get_capture_mode() -> String:
|
||||
func _capture_visual_check(capture_mode: String) -> void:
|
||||
if capture_mode == "exit":
|
||||
_prepare_exit_capture_state()
|
||||
# Camera2D applies its scroll during the frame cycle. Force it before the
|
||||
# deterministic capture so the world is framed around the capture state.
|
||||
camera.force_update_scroll()
|
||||
await get_tree().process_frame
|
||||
await get_tree().process_frame
|
||||
await RenderingServer.frame_post_draw
|
||||
@@ -326,6 +329,11 @@ func _prepare_exit_capture_state() -> void:
|
||||
game_state.map.set_cell(Vector2i(36, 7), GridMapStateType.CellKind.FLOOR)
|
||||
game_state.player.cell = game_state.floor_state.exit
|
||||
game_state.update_exploration()
|
||||
# Keep a nearby floor tile as remembered terrain. The entrance is outside
|
||||
# the exit camera crop, so it cannot prove the explored-fog render contract.
|
||||
var remembered_cell := game_state.floor_state.exit + Vector2i(-2, 0)
|
||||
game_state.explored_cells[remembered_cell] = true
|
||||
game_state.visible_cells.erase(remembered_cell)
|
||||
_sync_map_renderer_visibility()
|
||||
_sync_minimap()
|
||||
player_view.refresh()
|
||||
|
||||
@@ -13,6 +13,7 @@ const QUEST_BOARD_PROMPT := "Espace — Lire le tableau des quêtes"
|
||||
|
||||
const REFERENCE_VIEWPORT := Vector2(1920.0, 1080.0)
|
||||
const MIN_LAYOUT_SCALE := 0.66
|
||||
const MIN_FONT_SCALE := 0.66
|
||||
|
||||
@onready var player_health_label: Label = $PlayerHealthLabel
|
||||
@onready var player_focus_label: Label = $PlayerFocusLabel
|
||||
@@ -75,10 +76,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)
|
||||
_apply_text_scale(scale)
|
||||
|
||||
_set_rect($AchievementToast, origin + Vector2(420, 16) * scale, Vector2(1080, 28) * scale)
|
||||
_set_rect($TitleLabel, origin + Vector2(420, 47) * scale, Vector2(1080, 30) * scale)
|
||||
_set_rect($HeaderValuesLabel, origin + Vector2(420, 78) * scale, Vector2(1080, 24) * scale)
|
||||
_set_rect($HeaderValuesLabel, origin + Vector2(420, 75) * scale, Vector2(1080, 24) * scale)
|
||||
_set_rect($ResponsiveLayout/HeaderOrnament, origin + Vector2(560, 12) * scale, Vector2(800, 54) * scale)
|
||||
|
||||
_set_rect($ResponsiveLayout/PortraitIllustration, origin + Vector2(45, 145) * scale, Vector2(127, 140) * scale)
|
||||
@@ -108,6 +110,33 @@ func _set_rect(control: Control, position: Vector2, control_size: Vector2) -> vo
|
||||
control.position = position
|
||||
control.size = control_size
|
||||
|
||||
func _apply_text_scale(layout_scale: float) -> void:
|
||||
var font_scale := clampf(layout_scale, MIN_FONT_SCALE, 1.0)
|
||||
for control: Control in [
|
||||
$AchievementToast,
|
||||
$TitleLabel,
|
||||
$HeaderValuesLabel,
|
||||
$ResponsiveLayout/QuickSlotHint,
|
||||
$PlayerHealthLabel,
|
||||
$PlayerFocusLabel,
|
||||
$ExperienceLabel,
|
||||
$CharacterStatusLabel,
|
||||
$GoldLabel,
|
||||
$QuestTrackerLabel,
|
||||
$SpellLabel,
|
||||
$EnemyHealthLabel,
|
||||
$CombatSummaryLabel,
|
||||
$DeadlineLabel,
|
||||
$EventLog,
|
||||
$ContextPromptLabel,
|
||||
$HelpLabel,
|
||||
]:
|
||||
var base_size: int = control.get_meta(&"base_font_size", 0)
|
||||
if base_size == 0:
|
||||
base_size = control.get_theme_font_size(&"font_size")
|
||||
control.set_meta(&"base_font_size", base_size)
|
||||
control.add_theme_font_size_override(&"font_size", roundi(base_size * font_scale))
|
||||
|
||||
func _layout_expanded_log(origin: Vector2, scale: float) -> void:
|
||||
_set_rect(log_panel, origin + Vector2(1580, 122) * scale, Vector2(320, 826) * scale)
|
||||
_set_rect(event_log, origin + Vector2(1600, 145) * scale, Vector2(280, 775) * scale)
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
# Task 5 — Visual validation and responsive HUD completion
|
||||
|
||||
## Scope completed
|
||||
|
||||
Task 5 closes the visual-capture and responsive-HUD issues without changing gameplay, map generation, combat, or input behavior.
|
||||
|
||||
### Root-cause audit of inherited changes
|
||||
|
||||
The three pre-existing working-tree edits were retained because they address actual capture-contract causes:
|
||||
|
||||
1. **Explored-fog validator (`scripts/check-visual-capture.py`)**
|
||||
- The old detector required the single RGB value `(19, 29, 39)`.
|
||||
- Actual texture-preserving fog is a range of dark blue-shifted pixels: floor texture and GPU blend rounding make a renderer-independent exact RGB assertion invalid.
|
||||
- The replacement accepts only a bounded, blue-shifted palette (`R 4–14`, `G 8–22`, `B 17–32`, with channel-separation guards), excluding HUD chrome and unmodulated brown terrain.
|
||||
- `tests/scripts/test_godot_import_runners.sh` now emits a representative accepted palette pixel `(9, 14, 23)`, covering the updated contract rather than encoding an obsolete exact renderer sample.
|
||||
|
||||
2. **Deterministic exit capture (`scripts/game/game.gd`)**
|
||||
- `Camera2D` scroll is applied during the frame cycle. Capturing immediately after moving the player to the exit could retain the previous camera framing.
|
||||
- The capture now calls `camera.force_update_scroll()` before its frame waits.
|
||||
- The entry cell is outside the exit crop, so it could not prove the remembered/explored rendering contract. The deterministic exit state explicitly retains a neighboring exit floor tile as explored while removing it from visible cells.
|
||||
- The visual runner then verifies both visible terrain and remembered texture-preserving fog in the actual exit image.
|
||||
|
||||
### Responsive 1280×720 correction
|
||||
|
||||
Manual inspection of the original 1280×720 capture showed the three header text rows were too tightly stacked: the dynamic header values intruded into the lower edge of the top bar and were visibly clipped/overlapped by the header ornament. The underlying issue was that the rectangles scaled to 2/3 but all label font overrides remained at their desktop sizes; also, the `ResponsiveLayout` chrome painted after the direct HUD labels.
|
||||
|
||||
The repair:
|
||||
|
||||
- places the decorative `ResponsiveLayout` chrome behind direct live HUD values via `z_index = -1` in `Game.tscn`;
|
||||
- scales the HUD’s text overrides with the existing artboard scale (bounded by the same 0.66 compact minimum);
|
||||
- moves the dynamic header value baseline from reference y=78 to y=75, giving the 1280 layout sufficient top-bar height;
|
||||
- adds `test_compact_1280_layout_scales_header_text_and_keeps_it_inside_the_top_bar`, which asserts the compact 11px header font, top-bar containment, and adequate label height.
|
||||
|
||||
No gameplay logic changed.
|
||||
|
||||
## Manual capture inspection
|
||||
|
||||
### 1920×1080
|
||||
|
||||
- Captured the initial state and deterministic exit state.
|
||||
- The full shell is legible and the live header text remains clear of the ornament; no material clipping or overlap observed.
|
||||
- The rails, command band, and centered map frame are distinct. The header deliberately uses three compact rows, but they have visible separation at this resolution.
|
||||
- The exit capture shows visible terrain, unknown fog, and a dark blue remembered-terrain patch as required by the visual contract.
|
||||
|
||||
### 1280×720
|
||||
|
||||
- Before the repair, the header text was visibly crowded and partly clipped/overdrawn at the lower header edge; command/rail texts were correspondingly cramped.
|
||||
- After the repair, header rows are contained in the top bar and no longer overdraw the ornament. Rail and command text are smaller but readable for a compact 720p presentation.
|
||||
- The visual density remains necessarily high because this is the complete 1920×1080 artboard at two-thirds scale; however, no material header clipping/overlap remains.
|
||||
|
||||
Temporary comparison captures were removed after inspection; no capture PNG, `.import`, or other artifact is included in the commit.
|
||||
|
||||
## Cleanup
|
||||
|
||||
- Terminated the lingering `godot4 --headless --script res://tests/tmp_inspect_hud.gd` process.
|
||||
- Removed `tests/tmp_inspect_hud.gd` and its UID if present.
|
||||
- Removed the one-off HUD diagnostic script after use.
|
||||
- Emptied generated `artifacts/` before commit. Existing Godot-generated `.import` files remain ignored and untracked.
|
||||
|
||||
## Verification
|
||||
|
||||
All commands completed successfully:
|
||||
|
||||
| Command | Result |
|
||||
| --- | --- |
|
||||
| `./scripts/test-unit.sh` | **221 / 221** tests passed, **34,509** assertions |
|
||||
| `./scripts/run-visual-check.sh` | Passed initial + exit capture measurements |
|
||||
| `./tests/scripts/test_godot_import_runners.sh` | Passed |
|
||||
| `./scripts/verify.sh` | Passed unit, integration, E2E, visual, and strict parity gates |
|
||||
|
||||
`./scripts/verify.sh` results:
|
||||
|
||||
| Suite | Passing | Tests | Assertions |
|
||||
| --- | ---: | ---: | ---: |
|
||||
| Unit | 221 | 221 | 34,509 |
|
||||
| Integration | 19 | 19 | 1,696,729 |
|
||||
| E2E | 78 | 78 | 676 |
|
||||
|
||||
Visual measurements reported by the final verifier:
|
||||
|
||||
- `visual-check.png`: `dungeon_non_black_pixels=1102464`, `visible_pixels=82944`, `explored_pixels=18965`, `explored_luminance=0.004`, `unknown_pixels=890112`, `unknown_luminance=0.001`.
|
||||
- `visual-check-exit.png`: `dungeon_non_black_pixels=1102464`, `visible_pixels=10368`, `explored_pixels=18965`, `explored_luminance=0.004`, `unknown_pixels=976128`, `unknown_luminance=0.001`.
|
||||
- Strict parity: `matrix gate passed (rows=43 invalid=0)`.
|
||||
|
||||
Godot emitted pre-existing GUT invalid-UID and resource-cleanup warnings; none were script/parse/test failures, and all verifier commands exited 0.
|
||||
|
||||
## Git
|
||||
|
||||
The Task 5 implementation, regression coverage, and this report are committed locally. No push was performed.
|
||||
@@ -33,7 +33,9 @@ os.makedirs("artifacts", exist_ok=True)
|
||||
width, height = 1920, 1080
|
||||
unknown = (1, 2, 5)
|
||||
visible = (176, 176, 176)
|
||||
explored = (19, 29, 39)
|
||||
# Match the blue-black explored tile palette accepted by the real capture
|
||||
# validator; do not model it as a single renderer-specific RGB tuple.
|
||||
explored = (9, 14, 23)
|
||||
def pixel_for_x(x):
|
||||
if x < width // 3:
|
||||
return unknown
|
||||
|
||||
@@ -211,6 +211,24 @@ func test_dynamic_hud_groups_refresh_from_live_game_values() -> void:
|
||||
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_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