Files
2026-10-10 16:35:28 +02:00

35 lines
1.1 KiB
GDScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
extends SceneTree
## Lädt eine Mockup-Szene oder ein Control-Skript, macht einen Screenshot und beendet.
## godot --path preview -s shot.gd -- mockup.gd out.png
## Braucht ein Fenster (kein --headless). Fenstergröße aus project.godot: 1280×800.
func _init() -> void:
var args := OS.get_cmdline_user_args()
if args.size() < 2:
printerr("Aufruf: -- szene.tscn|skript.gd out.png")
quit(1)
return
var node: Node
if args[0].ends_with(".tscn"):
node = (load(args[0]) as PackedScene).instantiate()
else:
node = (load(args[0]) as GDScript).new()
if node is Control:
node.size = Vector2(root.size) # vor _ready, damit Kinder die Größe kennen
root.add_child(node)
if node is Control:
node.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
_shot(args[1])
func _shot(out: String) -> void:
for i in 6:
await process_frame
await RenderingServer.frame_post_draw
var err := root.get_texture().get_image().save_png(out)
if err != OK:
printerr("PNG-Fehler %d" % err)
quit(1)
return
print("shot " + out)
quit(0)