From e912d6738809012dc13b552fc703867aa3a6ec36 Mon Sep 17 00:00:00 2001 From: Natalie Date: Sun, 7 Jun 2026 22:49:57 -0700 Subject: [PATCH] =?UTF-8?q?feat(@projects/@magic-civilization):=20?= =?UTF-8?q?=E2=9C=A8=20add=20fog-regression=20test=20for=20lens=20overlays?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- src/game/engine/scenes/tests/auto_play.gd | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/game/engine/scenes/tests/auto_play.gd b/src/game/engine/scenes/tests/auto_play.gd index 51474679..4edbded4 100644 --- a/src/game/engine/scenes/tests/auto_play.gd +++ b/src/game/engine/scenes/tests/auto_play.gd @@ -655,6 +655,10 @@ func _process(_delta: float) -> void: _play_turn() if _turn_count % _screenshot_interval == 1 or _turn_count <= 3: _screenshot("turn_%03d" % _turn_count) + # Self-test the living-world overlay under REAL fog each interval — + # the god-view turn shots above cannot catch fog-render regressions + # in lens overlays (e.g. the fauna fog-leak fixed in p2-80). + _screenshot_lens("fauna_%03d" % _turn_count, "wildlife_habitat") if _frame == 20: _end_turn() @@ -2391,6 +2395,26 @@ func _screenshot(name: String) -> void: print(" -> %s (%dx%d)" % [path, img.get_width(), img.get_height()]) +## Capture the map with an observation lens toggled on, then restore it. Lets +## autoplay self-test lens overlays (the wildlife_habitat fauna overlay) under +## the player's REAL fog — the god-view turn shots cannot expose fog-render +## regressions in overlays. Only `fauna_overlay_renderer` listens to +## `map_overlay_changed`, so toggling back to "none" is side-effect-free. +## +## Async (fire-and-forget from `_process`): the overlay's `_draw` runs on the +## frame AFTER its `queue_redraw`, so a same-frame capture would show the +## pre-toggle map. Yield two frames (one to dispatch the redraw, one for the +## world_map background SubViewport to recomposite) before capturing. +func _screenshot_lens(name: String, lens_id: String) -> void: + if DisplayServer.get_name() == "headless": + return + EventBus.map_overlay_changed.emit(lens_id) + await get_tree().process_frame + await get_tree().process_frame + _screenshot(name) + EventBus.map_overlay_changed.emit("none") + + func _find_button(text: String) -> Button: return _find_button_in(get_tree().root, text)