using System.Linq; using Cthangover.Core.Mods; using Cthangover.Core.Utils; using Godot; namespace Cthangover.Tools.CharactersEditor.Tests { /// Adds the editor test driver when --itest=characters_editor_edit is given. public class CharacterEditorTestInitializer : IModInitializer { private static bool driverQueued; /// Nothing per mod. public void OnModLoaded(string modId) { } /// Queues the driver once. public void OnModResourcesReady() { var args = OS.GetCmdlineUserArgs(); if (driverQueued || !args.Any(a => a == "--itest=characters_editor_edit")) return; driverQueued = true; var shots = args.Where(a => a.StartsWith("--shots=", System.StringComparison.Ordinal)) .Select(a => a.Substring("--shots=".Length)) .FirstOrDefault(); GameLogger.Log("TEST", $"CharacterEditorTestInitializer: activating characters_editor_edit, shots={shots ?? "off"}"); ModRoot.AddDeferred(new CharacterEditorTestDriver(shots)); } } }