saumwacht-godot/tools/screenshot.gd
Martin Stickelbroeck c2b447610c Baseline: Saumwacht 0.15.0 (Phase 20A) vor dem Umbau zu Champions of Luneraria
Unveränderter Ausgangsstand inklusive Masterprompt und Konzeptbildern
unter assets/. .godot/ und docs/screenshots/ bleiben laut .gitignore
unversioniert; letztere sind unter ../backups gesichert.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 20:00:36 +02:00

94 lines
3.3 KiB
GDScript

extends Node
## UI smoke check with the real main scene and ordinary economic commands.
## Run: godot --path . res://tools/screenshot.tscn
const OUT_DIR := "res://docs/screenshots"
func _ready() -> void:
get_tree().create_timer(25.0).timeout.connect(func():
printerr("FAIL: graphical smoke check did not finish.")
get_tree().quit(1))
DirAccess.make_dir_recursive_absolute(OUT_DIR)
var main: Node3D = load("res://scenes/main.tscn").instantiate()
add_child(main)
await _wait(1.2)
_capture("menu-overlay.png")
main.hud._overlay_action.pressed.emit()
main.hud._starter_button.pressed.emit()
await _wait(0.5)
assert(GameState.phase == GameState.Phase.BUILD)
assert(EconomyManager.get_team(0).gold == 40)
assert(EconomyManager.get_team(0).roster.size() == 3)
main.selected_uid = EconomyManager.get_team(0).roster[0].uid
main.hud.selected_uid = main.selected_uid
main._update_selection_visuals()
await _wait(0.3)
_capture("build-phase.png")
main.hud._pause_button.grab_focus()
_key(KEY_SPACE)
await _wait(3.0)
assert(GameState.phase == GameState.Phase.COMBAT)
_capture("combat-phase.png")
main.hud._pause_button.pressed.emit()
var paused_time: float = main.battle.elapsed
await _wait(0.25)
assert(is_equal_approx(main.battle.elapsed, paused_time))
main.hud._pause_button.pressed.emit()
_key(KEY_TAB)
assert(main.viewed_team == 1)
# Finish using real fixed combat steps; no balance values are modified.
WaveManager.set_physics_process(false)
for _step in range(5400):
if GameState.phase != GameState.Phase.COMBAT:
break
WaveManager.advance(1.0 / 60.0)
assert(GameState.phase == GameState.Phase.RESULTS)
main.hud._ready_button.pressed.emit()
assert(GameState.wave == 2 and GameState.phase == GameState.Phase.BUILD)
main.hud._front_button.pressed.emit()
await _wait(0.2)
var cell_point: Vector2 = main.camera.unproject_position(Vector3(-14, 0, 7))
main.hud._shop_buttons["g01"].pressed.emit()
# Route through Godot's real input path, including plane picking and grid snap.
var motion := InputEventMouseMotion.new()
motion.position = cell_point
get_viewport().push_input(motion, true)
await get_tree().process_frame
var click := InputEventMouseButton.new()
click.position = cell_point
click.button_index = MOUSE_BUTTON_LEFT
click.pressed = true
get_viewport().push_input(click, true)
await get_tree().process_frame
click = click.duplicate()
click.pressed = false
get_viewport().push_input(click, true)
await get_tree().process_frame
assert(EconomyManager.get_team(0).roster.size() == 4)
assert(EconomyManager.get_team(0).roster[3].cell == Vector2i(0, 7))
main.hud._undo.pressed.emit()
assert(EconomyManager.get_team(0).roster.size() == 3)
print("PASS: HUD start, formation, keyboard shortcuts with button focus, combat, pause, front switch, next wave, mouse placement and undo.")
await Soundscape.quit_game(0)
func _wait(seconds: float) -> void:
await get_tree().create_timer(seconds).timeout
func _key(keycode: int) -> void:
var event := InputEventKey.new()
event.keycode = keycode
event.pressed = true
get_viewport().push_input(event, true)
event = event.duplicate()
event.pressed = false
get_viewport().push_input(event, true)
func _capture(file_name: String) -> void:
var image: Image = get_viewport().get_texture().get_image()
var path: String = OUT_DIR + "/" + file_name
image.save_png(path)
print("Saved ", path)