51 lines
1.6 KiB
GDScript
51 lines
1.6 KiB
GDScript
extends SceneTree
|
|
|
|
const CandidateLedger = preload("res://ui/m52/candidate_ledger.gd")
|
|
const SPEAR = preload("res://assets/entry/recruit_stickers/m52_q_company/spear_idle.png")
|
|
|
|
func _initialize() -> void:
|
|
call_deferred("capture")
|
|
|
|
func capture() -> void:
|
|
var output_root := OS.get_environment("ABG_EVIDENCE_DIR")
|
|
if output_root.is_empty():
|
|
output_root = "/tmp/abg-m52-candidate-ledger-capture"
|
|
DirAccess.make_dir_recursive_absolute(output_root)
|
|
var viewport := SubViewport.new()
|
|
viewport.size = Vector2i(420, 560)
|
|
viewport.render_target_update_mode = SubViewport.UPDATE_ALWAYS
|
|
root.add_child(viewport)
|
|
var background := ColorRect.new()
|
|
background.color = Color("#18303a")
|
|
background.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
|
viewport.add_child(background)
|
|
var ledger := CandidateLedger.new().configure({
|
|
"name": "Yori Valehook",
|
|
"profession": "长枪使",
|
|
"trait": "最后见证",
|
|
"availability": "可招募",
|
|
"cost": "14 金币",
|
|
"detail": "适合前排,攻击距离稳定",
|
|
"portrait": SPEAR,
|
|
"action_disabled": false,
|
|
})
|
|
ledger.position = Vector2(70, 16)
|
|
ledger.size = Vector2(280, 528)
|
|
viewport.add_child(ledger)
|
|
await process_frame
|
|
await process_frame
|
|
var image := viewport.get_texture().get_image()
|
|
if image == null:
|
|
push_error("capture texture unavailable")
|
|
quit(1)
|
|
return
|
|
var path := output_root.path_join("candidate-ledger-component-420x560.png")
|
|
var error := image.save_png(path)
|
|
viewport.queue_free()
|
|
if error == OK:
|
|
print("ABG_M52_CANDIDATE_LEDGER_COMPONENT_CAPTURE_OK path=%s size=420x560" % path)
|
|
quit(0)
|
|
else:
|
|
push_error("capture save failed: %s" % error)
|
|
quit(1)
|