Files
Bullosseum/tests/screenshot_test.gd
T
richard 7b6a141767 Reorganize the codebase into role-based folders (snake_case)
Move the 40-odd root-level scripts and scenes into a tree that groups by role,
per the approved roadmap (WS2/WS3): actors/{player,matador,bear}, systems/{combat,
fx,input,debug,render,crowd,config}, ui/, props/ (was tscn_s/). Rename the shell
scene.tscn -> levels/game_shell.tscn and every PascalCase scene to snake_case
(Player.tscn -> player.tscn, MainMenu.tscn -> main_menu.tscn, etc.) so the
case-insensitive web/macOS filesystems can't alias two files together.

Done as a scripted move: each file travels with its .uid; every quoted res:// path
across scenes, scripts, .tres, and project.godot's 9 autoloads is rewritten; the
.godot uid/class cache is rebuilt from scratch. Scenes still resolve by uid, so the
rewrite is belt-and-suspenders. Lint globs (run_tests.sh + both CI workflows) now
walk the new dirs; an orphan animation_tree.gd.uid and 7 pre-existing trailing-
whitespace lints (barrel/torch, never covered by the old root-only glob) are cleaned.

Full suite green on both sides. Asset consolidation (Assets/Animations/fonts ->
art/) is deferred — moving imported .glb/.png/.ttf is safer done in the editor.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017KoYBYQgRyY1zDHXMsXY3V
2026-09-06 00:04:41 +03:00

49 lines
1.3 KiB
GDScript

extends SceneTree
## Headless screenshot test — captures a viewport frame after the scene loads.
## Run: godot --headless --script tests/screenshot_test.gd
##
## Outputs: tests/output/screenshot.png
## Exit code 0 = success, 1 = failure.
const OUTPUT_DIR := "res://tests/output"
const SETTLE_TIME := 2.0 # seconds to let physics/animations settle
func _init() -> void:
_run.call_deferred()
func _run() -> void:
# Ensure output directory exists
DirAccess.make_dir_recursive_absolute(OUTPUT_DIR)
# Load and switch to the main scene
var scene_res := load("res://levels/game_shell.tscn")
if scene_res == null:
push_error("screenshot_test: Failed to load scene.tscn")
quit(1)
return
var scene_instance: Node = scene_res.instantiate()
root.add_child(scene_instance)
# Wait for the scene to settle (physics, spawning, animations)
await create_timer(SETTLE_TIME).timeout
# Capture viewport
var img: Image = root.get_viewport().get_texture().get_image()
if img == null:
push_error("screenshot_test: Failed to capture viewport image")
quit(1)
return
var path := OUTPUT_DIR + "/screenshot.png"
var err := img.save_png(path)
if err != OK:
push_error("screenshot_test: Failed to save PNG (error %d)" % err)
quit(1)
return
print("screenshot_test: Saved %s (%dx%d)" % [path, img.get_width(), img.get_height()])
quit(0)