147 lines
5.2 KiB
GDScript
147 lines
5.2 KiB
GDScript
extends SceneTree
|
|
|
|
## App Store screenshot capture at native 3x device resolution.
|
|
##
|
|
## Renders the real GameRoot states at 430x932 logical points with the window
|
|
## at 1290x2796, so Godot scales canvas items 3x: pixel art stays crisp and
|
|
## engine text stays smooth. Output is separate from the ui_captures matrix.
|
|
|
|
const OUTPUT_DIR := "res://artifacts/store_screenshots/"
|
|
const LOGICAL := Vector2i(430, 932)
|
|
const SCALE := 3
|
|
|
|
const SHOTS := [
|
|
{"name": "01_skyport_zh", "page": "skyport", "locale": "zh_CN"},
|
|
{"name": "02_map_zh", "page": "map", "locale": "zh_CN"},
|
|
{"name": "03_battle_zh", "attack_hero": "H02", "locale": "zh_CN"},
|
|
{"name": "04_victory_zh", "victory": "R1-C01-N02", "locale": "zh_CN"},
|
|
{"name": "05_event_zh", "event": "R1-C01-N04", "locale": "zh_CN"},
|
|
{"name": "06_skyport_en", "page": "skyport", "locale": "en_US"},
|
|
{"name": "07_map_en", "page": "map", "locale": "en_US"},
|
|
{"name": "08_battle_en", "attack_hero": "H02", "locale": "en_US"},
|
|
# Full-game content (L0-L6): 600-node world, side systems, gear, prestige.
|
|
{"name": "09_world_zh", "page": "world", "locale": "zh_CN"},
|
|
{"name": "10_world_en", "page": "world", "locale": "en_US"},
|
|
{"name": "11_interactions_zh", "page": "side", "tab": "interactions", "locale": "zh_CN"},
|
|
{"name": "12_loadout_en", "page": "loadout", "locale": "en_US"},
|
|
{"name": "13_prestige_zh", "prestige": true, "locale": "zh_CN"},
|
|
{"name": "14_prestige_en", "prestige": true, "locale": "en_US"},
|
|
{"name": "15_edict_shop_zh", "edict_shop": true, "locale": "zh_CN"},
|
|
{"name": "16_edict_shop_en", "edict_shop": true, "locale": "en_US"},
|
|
]
|
|
|
|
|
|
func _init() -> void:
|
|
_run.call_deferred()
|
|
|
|
|
|
func _wait_frames(count: int) -> void:
|
|
for _i in range(count):
|
|
await process_frame
|
|
await RenderingServer.frame_post_draw
|
|
|
|
|
|
func _run() -> void:
|
|
DirAccess.make_dir_recursive_absolute(ProjectSettings.globalize_path(OUTPUT_DIR))
|
|
# Warm up the window: the first resize after launch can settle one pixel off.
|
|
var warmup_root := get_root()
|
|
warmup_root.content_scale_mode = Window.CONTENT_SCALE_MODE_CANVAS_ITEMS
|
|
warmup_root.content_scale_size = LOGICAL
|
|
warmup_root.size = LOGICAL * SCALE
|
|
await _wait_frames(4)
|
|
var manifest: Array = []
|
|
for shot in SHOTS:
|
|
var entry := await _capture(shot)
|
|
manifest.append(entry)
|
|
print("STORE_SHOT %s %s %s" % [entry["name"], str(entry["size"]), entry["status"]])
|
|
var file := FileAccess.open(OUTPUT_DIR.path_join("store_manifest.json"), FileAccess.WRITE)
|
|
if file != null:
|
|
file.store_string(JSON.stringify({"schema": 1, "scale": SCALE, "shots": manifest}, "\t", true))
|
|
file.close()
|
|
var bad := 0
|
|
for e in manifest:
|
|
if str(e["status"]) != "ok":
|
|
bad += 1
|
|
if bad == 0:
|
|
print("STORE_CAPTURE_PASS %d shots" % manifest.size())
|
|
quit(0)
|
|
else:
|
|
print("STORE_CAPTURE_FAIL %d" % bad)
|
|
quit(1)
|
|
|
|
|
|
func _capture(shot: Dictionary) -> Dictionary:
|
|
var root := get_root()
|
|
await _wait_frames(2)
|
|
root.content_scale_mode = Window.CONTENT_SCALE_MODE_CANVAS_ITEMS
|
|
root.content_scale_size = LOGICAL
|
|
root.size = LOGICAL * SCALE
|
|
await _wait_frames(3)
|
|
|
|
var shell := load("res://scenes/game_root.tscn").instantiate() as GameRoot
|
|
root.add_child(shell)
|
|
shell.set_locale(str(shot["locale"]))
|
|
if str(shot.get("page", "skyport")) == "map":
|
|
shell.show_page("map")
|
|
if str(shot.get("page", "")) == "world":
|
|
shell.show_page("world")
|
|
shell.select_world_region_for_test("R3")
|
|
shell.select_world_chapter_for_test("R3-C05")
|
|
if str(shot.get("page", "")) == "side":
|
|
shell.show_page("side")
|
|
shell.set_side_tab_for_test(str(shot.get("tab", "partners")))
|
|
if str(shot.get("page", "")) == "loadout":
|
|
shell.show_page("loadout")
|
|
var sp := shell.get_profile()
|
|
for n in range(1, 8):
|
|
shell.grant_gear_drop_for_test("R1-C01-N%02d" % n)
|
|
sp = shell.get_profile()
|
|
sp["battle_wins"] = 12
|
|
ProfileStore.save_profile(sp)
|
|
shell.show_page("loadout")
|
|
if bool(shot.get("edict_shop", false)):
|
|
var ep := shell.get_profile()
|
|
ep["sky_marks"] = 60
|
|
ep["edicts"] = {"D01": true}
|
|
ProfileStore.save_profile(ep)
|
|
shell.open_edict_shop_for_test()
|
|
if bool(shot.get("prestige", false)):
|
|
var pp := shell.get_profile()
|
|
pp["completed_nodes"] = ["R1-C01-N10"]
|
|
pp["highest_node"] = 300
|
|
pp["completed_chapters"] = 30
|
|
pp["region_boss_first_clears"] = 5
|
|
pp["total_essence_earned"] = 120
|
|
pp["completed_regions"] = 3
|
|
pp["final_boss_first_clears"] = 1
|
|
ProfileStore.save_profile(pp)
|
|
shell.on_prestige_preview_for_test()
|
|
if shot.has("victory"):
|
|
shell.reset_profile_for_test()
|
|
shell.force_victory_for_test(str(shot["victory"]))
|
|
await _wait_frames(50)
|
|
elif shot.has("attack_hero"):
|
|
shell.reset_profile_for_test()
|
|
shell.start_node("R1-C01-N02")
|
|
await _wait_frames(6)
|
|
if shell.get_battle() != null and shell.get_battle().hud != null:
|
|
shell.get_battle().hud.force_hero_attack_frame_for_test(str(shot["attack_hero"]), 2)
|
|
await _wait_frames(3)
|
|
elif shot.has("event"):
|
|
shell.start_node(str(shot["event"]))
|
|
await _wait_frames(6)
|
|
else:
|
|
await _wait_frames(6)
|
|
|
|
var img := root.get_texture().get_image()
|
|
var path := OUTPUT_DIR.path_join("%s.png" % shot["name"])
|
|
var saved := img.save_png(ProjectSettings.globalize_path(path))
|
|
root.remove_child(shell)
|
|
shell.queue_free()
|
|
return {
|
|
"name": str(shot["name"]),
|
|
"locale": str(shot["locale"]),
|
|
"size": [img.get_width(), img.get_height()],
|
|
"status": "ok" if saved == OK else "save_failed:%d" % saved,
|
|
}
|