diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 908ba02c7..db877b5c0 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -4292,6 +4292,9 @@ static void RequireRuntimeInputScreenUsesEveSurface(string root) "new AetheriaRuntimeInputSettingsSurfaceState(", "new AetheriaRuntimeInputBindingSurfaceState(", "new AetheriaRuntimeActionBarInputSurfaceState(", + "public sealed class AetheriaRuntimeInputSettingsSurfaceState", + "public sealed class AetheriaRuntimeInputBindingSurfaceState", + "public sealed class AetheriaRuntimeActionBarInputSurfaceState", "AetheriaRuntimeInputSettingsSurfaceBuilder.ProjectActionBarInputs(", "AetheriaRuntimeInputSettingsSurfaceBuilder.ProjectActionBarCandidates(", "new SortedDictionary(StringComparer.Ordinal)", @@ -4322,19 +4325,18 @@ static void RequireRuntimeInputScreenUsesEveSurface(string root) var requiredBuilderSymbols = new[] { - "public sealed class AetheriaRuntimeInputSettingsSurfaceState", - "public sealed class AetheriaRuntimeInputBindingSurfaceState", - "public sealed class AetheriaRuntimeActionBarInputSurfaceState", "public sealed class AetheriaRuntimeInputPathSurfaceLabel", "public sealed class AetheriaRuntimeObservedInputBinding", "public static readonly IReadOnlyList DefaultActionBarCandidatePaths", "public static readonly IReadOnlyList DefaultActionBarCandidateInputPaths", "public static bool IsSupportedCapturePath(string path)", "public static AetheriaRuntimeSurfaceDocument Build(", - "private static AetheriaRuntimeInputSettingsSurfaceState ComposeState(", - "private static IReadOnlyList ComposeBindingInputs(", + "private static AetheriaRuntimeSurfaceDocument Build(", + "private static IReadOnlyList ComposeBindingInputs(", "private static IReadOnlyList ComposeActionBarCandidates(", - "private static IReadOnlyList ComposeActionBarInputs(", + "private static IReadOnlyList ComposeActionBarInputs(", + "private sealed class InputBindingRow", + "private sealed class ActionBarInputRow", "new SortedDictionary(StringComparer.Ordinal)", "public enum AetheriaRuntimeInputSettingsCommandKind", "public readonly struct AetheriaRuntimeInputSettingsSurfaceCommand", @@ -4360,13 +4362,17 @@ static void RequireRuntimeInputScreenUsesEveSurface(string root) string.Join(", ", missingBuilderSymbols)); } - if (builder.Contains("public static AetheriaRuntimeInputSettingsSurfaceState Project(", StringComparison.Ordinal) || + if (builder.Contains("AetheriaRuntimeInputSettingsSurfaceState", StringComparison.Ordinal) || + builder.Contains("AetheriaRuntimeInputBindingSurfaceState", StringComparison.Ordinal) || + builder.Contains("AetheriaRuntimeActionBarInputSurfaceState", StringComparison.Ordinal) || + builder.Contains("ComposeState(", StringComparison.Ordinal) || + builder.Contains("public static AetheriaRuntimeInputSettingsSurfaceState Project(", StringComparison.Ordinal) || builder.Contains("public static IReadOnlyList ProjectBindingInputs(", StringComparison.Ordinal) || builder.Contains("public static IReadOnlyList ProjectActionBarCandidates(", StringComparison.Ordinal) || builder.Contains("public static IReadOnlyList ProjectActionBarInputs(", StringComparison.Ordinal)) { throw new InvalidOperationException( - "Input-settings surface composition must stay behind Build(...); do not re-expose projection helpers as the public ergonomic path."); + "Input-settings surface builder must emit the typed surface document directly; do not rebuild a shadow SurfaceState projection layer."); } var actionGameManagerPath = Path.Combine(root, "Assets", "Scripts", "Gameplay", "ActionGameManager.cs"); diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeInputSettingsSurfaceBuilder.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeInputSettingsSurfaceBuilder.cs index 4c0877695..2611ceca7 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeInputSettingsSurfaceBuilder.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeInputSettingsSurfaceBuilder.cs @@ -6,72 +6,6 @@ using GameCult.Eve.Surface; namespace GameCult.Aetheria.State.Verse { - public sealed class AetheriaRuntimeInputSettingsSurfaceState - { - public AetheriaRuntimeInputSettingsSurfaceState( - IReadOnlyList bindings, - IReadOnlyList actionBarInputs, - bool capturePending, - string capturePrompt, - string updatedAtUtc) - { - Bindings = bindings ?? Array.Empty(); - ActionBarInputs = actionBarInputs ?? Array.Empty(); - CapturePending = capturePending; - CapturePrompt = capturePrompt ?? ""; - UpdatedAtUtc = updatedAtUtc ?? ""; - } - - public IReadOnlyList Bindings { get; } - - public IReadOnlyList ActionBarInputs { get; } - - public bool CapturePending { get; } - - public string CapturePrompt { get; } - - public string UpdatedAtUtc { get; } - } - - public sealed class AetheriaRuntimeInputBindingSurfaceState - { - public AetheriaRuntimeInputBindingSurfaceState( - string actionName, - int bindingIndex, - string bindingLabel, - string currentInputLabel) - { - ActionName = actionName ?? ""; - BindingIndex = bindingIndex; - BindingLabel = bindingLabel ?? ""; - CurrentInputLabel = currentInputLabel ?? ""; - } - - public string ActionName { get; } - - public int BindingIndex { get; } - - public string BindingLabel { get; } - - public string CurrentInputLabel { get; } - } - - public sealed class AetheriaRuntimeActionBarInputSurfaceState - { - public AetheriaRuntimeActionBarInputSurfaceState(string inputPath, string label, bool enabled) - { - InputPath = inputPath ?? ""; - Label = label ?? ""; - Enabled = enabled; - } - - public string InputPath { get; } - - public string Label { get; } - - public bool Enabled { get; } - } - public sealed class AetheriaRuntimeInputPathSurfaceLabel { public AetheriaRuntimeInputPathSurfaceLabel(string inputPath, string label) @@ -162,35 +96,20 @@ namespace GameCult.Aetheria.State.Verse var observed = (observedBindings ?? Array.Empty()) .Where(binding => binding != null) .ToArray(); + var actionBarCandidates = ComposeActionBarCandidates(observed, enabledActionBarInputPaths); + var bindings = ComposeBindingInputs(observed); + var actionBarInputs = ComposeActionBarInputs(enabledActionBarInputPaths, actionBarCandidates); return Build( - ComposeState( - observed, - enabledActionBarInputPaths, - ComposeActionBarCandidates(observed, enabledActionBarInputPaths), - capturePending, - capturePrompt, - updatedAtUtc), + bindings, + actionBarInputs, + capturePending, + capturePrompt, + updatedAtUtc, version); } - private static AetheriaRuntimeInputSettingsSurfaceState ComposeState( - IEnumerable observedBindings, - IEnumerable enabledActionBarInputPaths, - IEnumerable actionBarCandidateInputPaths, - bool capturePending, - string capturePrompt, - string updatedAtUtc) - { - return new AetheriaRuntimeInputSettingsSurfaceState( - ComposeBindingInputs(observedBindings), - ComposeActionBarInputs(enabledActionBarInputPaths, actionBarCandidateInputPaths), - capturePending, - capturePrompt, - updatedAtUtc); - } - - private static IReadOnlyList ComposeBindingInputs( + private static IReadOnlyList ComposeBindingInputs( IEnumerable observedBindings) { return (observedBindings ?? Array.Empty()) @@ -198,7 +117,7 @@ namespace GameCult.Aetheria.State.Verse binding.Include && !string.IsNullOrWhiteSpace(binding.InputPath) && IsSupportedCapturePath(binding.InputPath)) - .Select(binding => new AetheriaRuntimeInputBindingSurfaceState( + .Select(binding => new InputBindingRow( binding.ActionName, binding.BindingIndex, binding.BindingLabel, @@ -244,7 +163,7 @@ namespace GameCult.Aetheria.State.Verse return candidates; } - private static IReadOnlyList ComposeActionBarInputs( + private static IReadOnlyList ComposeActionBarInputs( IEnumerable enabledInputPaths, IEnumerable candidateInputPaths) { @@ -274,7 +193,7 @@ namespace GameCult.Aetheria.State.Verse } return candidates - .Select(entry => new AetheriaRuntimeActionBarInputSurfaceState( + .Select(entry => new ActionBarInputRow( entry.Key, entry.Value, enabledPaths.Contains(entry.Key))) @@ -300,23 +219,22 @@ namespace GameCult.Aetheria.State.Verse return inputPath; } - public static AetheriaRuntimeSurfaceDocument Build( - AetheriaRuntimeInputSettingsSurfaceState settings, - long version = 1) + private static AetheriaRuntimeSurfaceDocument Build( + IReadOnlyList bindings, + IReadOnlyList actionBarInputs, + bool capturePending, + string capturePrompt, + string updatedAtUtc, + long version) { - settings ??= new AetheriaRuntimeInputSettingsSurfaceState( - Array.Empty(), - Array.Empty(), - capturePending: false, - capturePrompt: "", - updatedAtUtc: ""); - + bindings ??= Array.Empty(); + actionBarInputs ??= Array.Empty(); return new AetheriaRuntimeSurfaceDocument( providerId: "aetheria", providerKind: "game.runtime", title: "Aetheria Input Settings", version: version, - updatedAtUtc: settings.UpdatedAtUtc, + updatedAtUtc: updatedAtUtc ?? "", surface: new AetheriaRuntimeSurfaceTree( AetheriaRuntimeInputSettingsCommands.SurfaceId, Node( @@ -330,11 +248,11 @@ namespace GameCult.Aetheria.State.Verse Metric( "aetheria.inputSettings.summary.bindings", "Rebindable Inputs", - settings.Bindings.Count.ToString()), + bindings.Count.ToString()), Metric( "aetheria.inputSettings.summary.actionBar", "Action-Bar Inputs", - settings.ActionBarInputs.Count(entry => entry.Enabled).ToString()), + actionBarInputs.Count(entry => entry.Enabled).ToString()), Text( "aetheria.inputSettings.summary.note", "Low-level InputSystem edits flow through this Eve surface as typed input-setting requests.")), @@ -344,12 +262,12 @@ namespace GameCult.Aetheria.State.Verse new[] { ("title", "Capture") }, Text( "aetheria.inputSettings.capture.note", - settings.CapturePending - ? settings.CapturePrompt + capturePending + ? capturePrompt ?? "" : "Choose a binding row, then press a keyboard or mouse input to capture it."), ButtonRow( "aetheria.inputSettings.capture.actions", - settings.CapturePending + capturePending ? Button( "aetheria.inputSettings.capture.cancel", "Cancel Capture", @@ -366,7 +284,7 @@ namespace GameCult.Aetheria.State.Verse "aetheria.inputSettings.bindings.grid", "grid", Array.Empty<(string Key, string Value)>(), - settings.Bindings.Select(BuildBindingCard).ToArray())), + bindings.Select(BuildBindingCard).ToArray())), Node( "aetheria.inputSettings.actionBarInputs", "card", @@ -375,7 +293,7 @@ namespace GameCult.Aetheria.State.Verse "aetheria.inputSettings.actionBarInputs.grid", "grid", Array.Empty<(string Key, string Value)>(), - settings.ActionBarInputs.Select(BuildActionBarCard).ToArray()))), + actionBarInputs.Select(BuildActionBarCard).ToArray()))), Array.Empty()), commands: new[] { @@ -399,7 +317,7 @@ namespace GameCult.Aetheria.State.Verse } private static AetheriaRuntimeSurfaceComponent BuildBindingCard( - AetheriaRuntimeInputBindingSurfaceState binding) + InputBindingRow binding) { return Node( $"aetheria.inputSettings.binding.{binding.ActionName}.{binding.BindingIndex}", @@ -419,7 +337,7 @@ namespace GameCult.Aetheria.State.Verse } private static AetheriaRuntimeSurfaceComponent BuildActionBarCard( - AetheriaRuntimeActionBarInputSurfaceState input) + ActionBarInputRow input) { return Node( $"aetheria.inputSettings.actionBar.{input.Label}", @@ -486,6 +404,45 @@ namespace GameCult.Aetheria.State.Verse props.ToDictionary(prop => prop.Key, prop => prop.Value, StringComparer.Ordinal), children ?? Array.Empty()); } + + private sealed class InputBindingRow + { + public InputBindingRow( + string actionName, + int bindingIndex, + string bindingLabel, + string currentInputLabel) + { + ActionName = actionName ?? ""; + BindingIndex = bindingIndex; + BindingLabel = bindingLabel ?? ""; + CurrentInputLabel = currentInputLabel ?? ""; + } + + public string ActionName { get; } + + public int BindingIndex { get; } + + public string BindingLabel { get; } + + public string CurrentInputLabel { get; } + } + + private sealed class ActionBarInputRow + { + public ActionBarInputRow(string inputPath, string label, bool enabled) + { + InputPath = inputPath ?? ""; + Label = label ?? ""; + Enabled = enabled; + } + + public string InputPath { get; } + + public string Label { get; } + + public bool Enabled { get; } + } } public enum AetheriaRuntimeInputSettingsCommandKind