namespace Cthangover.Mods.ScenarioStudio.Tests.Live { using System.Linq; using Cthangover.Core.Mods; using Cthangover.Core.Utils; using Godot; /// /// Entry point of the studio live test, active only with /// --itest=studio_live; --shots=<dir> also saves a /// screenshot per checked state (needs a real display, e.g. xvfb). The /// test expects --studio-write=layer and its own /// --studio-layer= so it never writes into a mod. The driver is added /// deferred because resources-ready fires before the shell scene exists. /// public class StudioLiveTestInitializer : IModInitializer { private static bool driverQueued; public void OnModLoaded(string modId) { } public void OnModResourcesReady() { if (driverQueued) return; var args = OS.GetCmdlineUserArgs(); if (!args.Any(a => a == "--itest=studio_live")) return; var shots = args .Where(a => a.StartsWith("--shots=", System.StringComparison.Ordinal)) .Select(a => a.Substring("--shots=".Length)) .FirstOrDefault(); driverQueued = true; GameLogger.Log("TEST", $"StudioLiveTestInitializer: activating studio live test, shots='{shots ?? ""}'"); ModRoot.AddDeferred(new StudioLiveDriverNode(shots)); } } }