fix: frame edge camera states inside play area

This commit is contained in:
goose
2026-10-09 01:20:29 -04:00
parent f8d4d932c3
commit 65d35b5102
4 changed files with 61 additions and 20 deletions
+5 -5
View File
@@ -20,9 +20,9 @@ EXPECTED_DIMENSIONS = {
"visual-check-exit.png": (REFERENCE_WIDTH, REFERENCE_HEIGHT),
"visual-check-compact.png": (1280, 720),
}
# Central dungeon measurement region in the reference 1920×1080 artboard.
# It excludes the anchored HUD panels and is scaled for the real 720p capture.
REFERENCE_VIEWPORT = (384, 60, 1536, 1017)
# The unmasked PlayAreaFrame in the reference 1920×1080 artboard.
# This is scaled for the real 720p capture.
PLAY_AREA_REFERENCE = (498, 125, 1422, 955)
UNKNOWN = (1, 2, 5)
# Captured explored tiles are texture modulated, so classify their blue-black
# pixels by palette range rather than expecting one flat overlay color.
@@ -170,13 +170,13 @@ def is_explored(pixel: tuple[int, int, int]) -> bool:
# 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
return 4 <= red <= 14 and 7 <= green <= 22 and 16 <= blue <= 32 and blue >= green + 4 and green >= red + 3
def viewport_for(width: int, height: int) -> tuple[int, int, int, int]:
scale_x = width / REFERENCE_WIDTH
scale_y = height / REFERENCE_HEIGHT
return tuple(round(coordinate * (scale_x if index % 2 == 0 else scale_y)) for index, coordinate in enumerate(REFERENCE_VIEWPORT))
return tuple(round(coordinate * (scale_x if index % 2 == 0 else scale_y)) for index, coordinate in enumerate(PLAY_AREA_REFERENCE))
def measure(path: Path) -> None:
+13 -4
View File
@@ -343,6 +343,7 @@ func _prepare_exit_capture_state() -> void:
_sync_map_renderer_visibility()
_sync_minimap()
player_view.refresh()
_configure_camera()
_sync_camera_to_player()
func _input(event: InputEvent) -> void:
@@ -1994,10 +1995,18 @@ func _create_initial_state() -> GameState:
func _configure_camera() -> void:
var map_size := game_state.map.size * TILE_SIZE
camera.limit_left = $World.position.x
camera.limit_top = $World.position.y
camera.limit_right = $World.position.x + map_size.x
camera.limit_bottom = $World.position.y + map_size.y
# Camera2D clamps against its full engine viewport, while opaque HUD masks
# expose only PlayAreaFrame. Extend each map edge by the difference between
# those half-extents so actors at a map edge remain inside the framed area
# instead of being pinned against its border.
var frame := hud.get_node_or_null("ResponsiveLayout/PlayAreaFrame") as Control
var viewport_half := get_viewport().get_visible_rect().size / camera.zoom * 0.5
var frame_half := frame.get_global_rect().size / camera.zoom * 0.5 if frame != null else viewport_half
var limit_padding := viewport_half - frame_half
camera.limit_left = floori($World.position.x - limit_padding.x)
camera.limit_top = floori($World.position.y - limit_padding.y)
camera.limit_right = ceili($World.position.x + map_size.x + limit_padding.x)
camera.limit_bottom = ceili($World.position.y + map_size.y + limit_padding.y)
_sync_camera_to_player()
func _sync_camera_to_player() -> void: