feat(@projects/@magic-civilization): add fog-regression test for lens overlays

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
Natalie 2026-06-07 22:49:57 -07:00
parent 74e8117f88
commit e912d67388

View file

@ -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)