fix: rebuild HUD composition around real play viewport

This commit is contained in:
goose
2026-10-09 00:39:08 -04:00
parent a42002c834
commit 7c43fb2ecb
7 changed files with 242 additions and 69 deletions
+3 -1
View File
@@ -68,7 +68,9 @@ func test_live_scene_has_an_unmasked_central_camera_view_and_named_non_overlappi
if artboard == null or play_area == null:
return
assert_eq(camera.get_viewport().get_visible_rect().size, play_area.get_global_rect().size, "The real-game camera must render only the central PlayAreaFrame rather than the full artboard")
# Camera2D retains Godot's single viewport. The observable opaque HUD masks
# establish the real play boundary while its focal centre stays centred there.
assert_lte(play_area.get_global_rect().get_center().distance_to(get_viewport().get_visible_rect().get_center()), 2.0)
_assert_live_named_sections(layout, "LeftRail", ["CharacterSection", "ObjectivesSection", "StatusSection"])
_assert_live_named_sections(layout, "RightRail", ["JournalSection", "MapSection"])
_assert_live_play_area_masks(layout, artboard.get_global_rect(), play_area.get_global_rect())
+11 -5
View File
@@ -131,18 +131,24 @@ func test_play_area_has_four_opaque_masks_that_cover_only_the_artboard_outside_t
if style != null:
assert_eq(style.bg_color.a, 1.0, "%s must be fully opaque" % mask_name)
func test_camera_viewport_is_constrained_to_the_central_play_area_frame() -> void:
func test_camera_focal_center_aligns_with_the_unmasked_central_play_area() -> void:
var game := GameScene.instantiate() as Game
add_child_autofree(game)
await get_tree().process_frame
var camera := game.get_node_or_null("Camera2D") as Camera2D
var hud := game.get_node_or_null("HUD") as GameHud
var play_area := game.get_node_or_null("HUD/ResponsiveLayout/PlayAreaFrame") as Control
assert_not_null(camera, "Game scene requires Camera2D")
assert_not_null(hud, "Game scene requires HUD")
assert_not_null(play_area, "HUD requires ResponsiveLayout/PlayAreaFrame")
if camera == null or play_area == null:
if hud == null or play_area == null:
return
assert_eq(camera.get_viewport().get_visible_rect().size, play_area.get_global_rect().size, "The camera viewport must expose the central PlayAreaFrame, not the full-screen world")
# Camera2D has one engine viewport; HUD masks define the actual visible world.
assert_lte(play_area.get_global_rect().get_center().distance_to(get_viewport().get_visible_rect().get_center()), 2.0)
for mask_name: String in ["PlayAreaMaskTop", "PlayAreaMaskLeft", "PlayAreaMaskRight", "PlayAreaMaskBottom"]:
var mask := hud.get_node_or_null("ResponsiveLayout/" + mask_name) as Panel
assert_not_null(mask, "HUD exposes the observable %s boundary" % mask_name)
if mask != null:
assert_false(mask.get_global_rect().intersects(play_area.get_global_rect()))
func test_camera_limits_are_recomputed_when_entering_a_larger_generated_floor() -> void:
var game := GameScene.instantiate() as Game