extends Node const INTRO := preload("res://scenes/main/intro_comic.tscn") var failures: Array[String] = [] func _ready() -> void: GameState.save_locked = true call_deferred("_run") func _check(condition: bool, message: String) -> void: if not condition: failures.append(message) push_error("INTRO CHECK: " + message) func _run() -> void: _check(DataCatalog.loaded_from_master, DataCatalog.last_load_error) if not DataCatalog.loaded_from_master: get_tree().quit(1) return var initial_payload: Dictionary = GameState.call("_build_save_payload").duplicate(true) initial_payload.erase("saved_at_unix") var original_language := Loc.language Loc.set_language("fr") var preview := INTRO.instantiate() add_child(preview) await get_tree().process_frame await get_tree().process_frame var story: Node2D = preview.get("story") _check(bool(story.get("running")), "Preview does not start") _check((story.get("_text_label") as Label).text.contains("œuf"), "French caption is missing or damaged") var seen := {} var captions := {} for step: int in 20: if bool(preview.get("finished")): break var chapter: int = int(preview.get("chapter_index")) captions[str(story.get("current_event_id"))] = true var backdrop := story.get_node("BackdropVisuals") as VisualHolder _check(backdrop.is_visible_in_tree() and backdrop.is_showing(), "Comic art is hidden in 3D mode") _check(backdrop.get_child_count() > 0, "Comic texture did not load") _check(backdrop.z_index >= 0, "Comic art is behind the opaque backdrop") if not seen.has(chapter) and OS.get_cmdline_user_args().has("--capture"): await RenderingServer.frame_post_draw get_viewport().get_texture().get_image().save_png("user://intro_preview_%d.png" % chapter) seen[chapter] = true if step == 0: var click := InputEventMouseButton.new() click.button_index = MOUSE_BUTTON_LEFT click.position = Vector2(960, 900) click.pressed = true Input.parse_input_event(click) else: var advance := InputEventAction.new() advance.action = "action" advance.pressed = true Input.parse_input_event(advance) await get_tree().process_frame var event := InputEventAction.new() event.action = "action" event.pressed = false Input.parse_input_event(event) await get_tree().process_frame _check(seen.size() == 3, "The three authored chapters were not reached") _check(captions.size() == 13, "A caption was skipped or the first mouse click was swallowed") _check(bool(preview.get("finished")), "The intro did not finish") preview.call("_press", "language") await get_tree().process_frame _check(Loc.language == "en", "Language replay did not switch to English") _check((story.get("_text_label") as Label).text.contains("egg"), "English caption is missing") var skip_event := InputEventAction.new() skip_event.action = "pause" skip_event.pressed = true Input.parse_input_event(skip_event) await get_tree().process_frame _check(bool(preview.get("finished")) and int(preview.get("chapter_index")) == 0, "Skip must leave the entire intro") var final_payload: Dictionary = GameState.call("_build_save_payload").duplicate(true) final_payload.erase("saved_at_unix") _check(initial_payload == final_payload, "Preview changed persistent gameplay state") preview.queue_free() await get_tree().process_frame _check(Loc.language == "fr", "Preview did not restore its entry language") Loc.set_language(original_language) print("INTRO CHECK: ", "OK" if failures.is_empty() else failures) get_tree().quit(0 if failures.is_empty() else 1)