using System.Collections.Generic; using UnityEngine; namespace Ashwild.Player { /// /// One rebindable entry: the action it targets, the binding index within that action, and the /// human label shown in the row. Composite parts (Move up/down/left/right) are four separate /// entries, each pointing at its own part-binding index. /// [System.Serializable] public struct RebindableEntry { [SerializeField] private string actionName; [SerializeField] private int bindingIndex; [SerializeField] private string displayLabel; public string ActionName => actionName; public int BindingIndex => bindingIndex; public string DisplayLabel => displayLabel; } /// /// One glyph: the layout-aware display name it matches (case-insensitive) and its sprite. /// [System.Serializable] public struct KeyIcon { [SerializeField] private string displayName; [SerializeField] private Sprite icon; public string DisplayName => displayName; public Sprite Icon => icon; } /// /// One authored binding override: which binding of which action to re-path, and to what control /// path. Used only for deliberate letter-mnemonic exceptions per layout. /// [System.Serializable] public struct LayoutOverride { [SerializeField] private string actionName; [SerializeField] private int bindingIndex; [SerializeField] private string overridePath; public string ActionName => actionName; public int BindingIndex => bindingIndex; public string OverridePath => overridePath; } /// /// Single authored asset for everything the input UI needs: which bindings are rebindable (and /// their labels), the key glyphs to show instead of text, and the optional first-launch layout /// overrides per keyboard layout. One asset keeps all input configuration in one place — the /// settings panel reads the bindings/icons, the SettingsManager reads the layout overrides. /// Look is intentionally absent (mouse-only) and gamepad bindings are absent (keyboard only). /// [CreateAssetMenu(fileName = "InputConfig", menuName = "Input/Input Config")] public class InputConfig : ScriptableObject { #region Serialized Fields [Header("Rebindable bindings (shown in the panel, in order)")] [SerializeField] private List bindings = new List(); [Header("Key glyphs (display name → sprite; missing falls back to text)")] [SerializeField] private List icons = new List(); [Header("First-launch layout overrides (usually empty — physical paths already fit)")] [SerializeField] private List qwertyOverrides = new List(); [SerializeField] private List azertyOverrides = new List(); #endregion #region Public API public IReadOnlyList Bindings => bindings; /// /// Returns the glyph for a display name, or null when none is authored (caller shows text). /// public Sprite GetIcon(string displayName) { if (string.IsNullOrEmpty(displayName)) return null; foreach (KeyIcon entry in icons) if (string.Equals(entry.DisplayName, displayName, System.StringComparison.OrdinalIgnoreCase)) return entry.Icon; return null; } /// /// The first-launch overrides authored for a detected layout (usually empty). /// public IReadOnlyList OverridesFor(KeyboardLayout layout) => layout == KeyboardLayout.Azerty ? azertyOverrides : qwertyOverrides; #endregion } }