Move input surface projection into runtime
This commit is contained in:
parent
f049b329b5
commit
5fc21cd6b1
3 changed files with 85 additions and 15 deletions
|
|
@ -3571,7 +3571,8 @@ static void RequireRuntimeInputScreenUsesEveSurface(string root)
|
|||
"new InputAction(\"Aetheria Input Capture\")",
|
||||
"AetheriaRuntimeInputSettingsSurfaceBuilder.DefaultActionBarCandidatePaths",
|
||||
"AetheriaRuntimeInputSettingsSurfaceBuilder.IsSupportedCapturePath(",
|
||||
"AetheriaRuntimeInputSettingsSurfaceBuilder.ProjectActionBarInputs(",
|
||||
"AetheriaRuntimeInputSettingsSurfaceBuilder.Project(",
|
||||
"new AetheriaRuntimeObservedInputBinding(",
|
||||
"new AetheriaRuntimeInputPathSurfaceLabel(",
|
||||
"HideLegacyChildren()"
|
||||
};
|
||||
|
|
@ -3610,6 +3611,10 @@ static void RequireRuntimeInputScreenUsesEveSurface(string root)
|
|||
"request.Payload",
|
||||
"private static readonly string[] DefaultActionBarCandidatePaths",
|
||||
"private static bool IsSupportedCapturePath(string path)",
|
||||
"new AetheriaRuntimeInputSettingsSurfaceState(",
|
||||
"new AetheriaRuntimeInputBindingSurfaceState(",
|
||||
"new AetheriaRuntimeActionBarInputSurfaceState(",
|
||||
"AetheriaRuntimeInputSettingsSurfaceBuilder.ProjectActionBarInputs(",
|
||||
"new SortedDictionary<string, string>(StringComparer.Ordinal)"
|
||||
};
|
||||
|
||||
|
|
@ -3641,8 +3646,11 @@ static void RequireRuntimeInputScreenUsesEveSurface(string root)
|
|||
"public sealed class AetheriaRuntimeInputBindingSurfaceState",
|
||||
"public sealed class AetheriaRuntimeActionBarInputSurfaceState",
|
||||
"public sealed class AetheriaRuntimeInputPathSurfaceLabel",
|
||||
"public sealed class AetheriaRuntimeObservedInputBinding",
|
||||
"public static readonly IReadOnlyList<string> DefaultActionBarCandidatePaths",
|
||||
"public static bool IsSupportedCapturePath(string path)",
|
||||
"public static AetheriaRuntimeInputSettingsSurfaceState Project(",
|
||||
"public static IReadOnlyList<AetheriaRuntimeInputBindingSurfaceState> ProjectBindingInputs(",
|
||||
"public static IReadOnlyList<AetheriaRuntimeActionBarInputSurfaceState> ProjectActionBarInputs(",
|
||||
"new SortedDictionary<string, string>(StringComparer.Ordinal)",
|
||||
"public enum AetheriaRuntimeInputSettingsCommandKind",
|
||||
|
|
|
|||
|
|
@ -164,19 +164,21 @@ public class InputDisplayLayout : MonoBehaviour
|
|||
|
||||
private AetheriaRuntimeInputSettingsSurfaceState ProjectSurfaceState()
|
||||
{
|
||||
return new AetheriaRuntimeInputSettingsSurfaceState(
|
||||
ProjectBindingRows(),
|
||||
ProjectActionBarRows(),
|
||||
var runtimeSettings = ActionGameManager.RuntimePlayerSettings.InputSettings;
|
||||
return AetheriaRuntimeInputSettingsSurfaceBuilder.Project(
|
||||
ProjectObservedBindings(),
|
||||
runtimeSettings.ActionBarInputs,
|
||||
ProjectActionBarCandidates(runtimeSettings.ActionBarInputs),
|
||||
capturePending: _captureBindingIndex >= 0 && !string.IsNullOrWhiteSpace(_captureActionName),
|
||||
capturePrompt: BuildCapturePrompt(),
|
||||
updatedAtUtc: DateTime.UtcNow.ToString("O"));
|
||||
}
|
||||
|
||||
private IReadOnlyList<AetheriaRuntimeInputBindingSurfaceState> ProjectBindingRows()
|
||||
private IReadOnlyList<AetheriaRuntimeObservedInputBinding> ProjectObservedBindings()
|
||||
{
|
||||
if (Input == null)
|
||||
{
|
||||
return Array.Empty<AetheriaRuntimeInputBindingSurfaceState>();
|
||||
return Array.Empty<AetheriaRuntimeObservedInputBinding>();
|
||||
}
|
||||
|
||||
return Input
|
||||
|
|
@ -188,18 +190,19 @@ public class InputDisplayLayout : MonoBehaviour
|
|||
!entry.binding.isComposite &&
|
||||
!string.IsNullOrWhiteSpace(entry.binding.effectivePath) &&
|
||||
AetheriaRuntimeInputSettingsSurfaceBuilder.IsSupportedCapturePath(entry.binding.effectivePath))
|
||||
.Select(entry => new AetheriaRuntimeInputBindingSurfaceState(
|
||||
.Select(entry => new AetheriaRuntimeObservedInputBinding(
|
||||
entry.action.name,
|
||||
entry.bindingIndex,
|
||||
DescribeBinding(entry.action.name, entry.binding),
|
||||
DescribeInputPath(entry.binding.effectivePath)))
|
||||
.OrderBy(entry => entry.BindingLabel, StringComparer.Ordinal)
|
||||
entry.binding.effectivePath,
|
||||
DescribeInputPath(entry.binding.effectivePath),
|
||||
include: true))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
private IReadOnlyList<AetheriaRuntimeActionBarInputSurfaceState> ProjectActionBarRows()
|
||||
private IReadOnlyList<AetheriaRuntimeInputPathSurfaceLabel> ProjectActionBarCandidates(
|
||||
IEnumerable<string> enabledActionBarInputPaths)
|
||||
{
|
||||
var runtimeSettings = ActionGameManager.RuntimePlayerSettings.InputSettings;
|
||||
var candidates = new List<AetheriaRuntimeInputPathSurfaceLabel>();
|
||||
|
||||
foreach (var defaultPath in AetheriaRuntimeInputSettingsSurfaceBuilder.DefaultActionBarCandidatePaths)
|
||||
|
|
@ -209,7 +212,7 @@ public class InputDisplayLayout : MonoBehaviour
|
|||
DescribeInputPath(defaultPath)));
|
||||
}
|
||||
|
||||
foreach (var inputPath in runtimeSettings.ActionBarInputs)
|
||||
foreach (var inputPath in enabledActionBarInputPaths ?? Array.Empty<string>())
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(inputPath))
|
||||
{
|
||||
|
|
@ -239,9 +242,7 @@ public class InputDisplayLayout : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
return AetheriaRuntimeInputSettingsSurfaceBuilder.ProjectActionBarInputs(
|
||||
runtimeSettings.ActionBarInputs,
|
||||
candidates);
|
||||
return candidates;
|
||||
}
|
||||
|
||||
private static string DescribeBinding(string actionName, InputBinding binding)
|
||||
|
|
|
|||
|
|
@ -85,6 +85,32 @@ namespace GameCult.Aetheria.State.Verse
|
|||
public string Label { get; }
|
||||
}
|
||||
|
||||
public sealed class AetheriaRuntimeObservedInputBinding
|
||||
{
|
||||
public AetheriaRuntimeObservedInputBinding(
|
||||
string actionName,
|
||||
int bindingIndex,
|
||||
string bindingLabel,
|
||||
string inputPath,
|
||||
string inputLabel,
|
||||
bool include)
|
||||
{
|
||||
ActionName = actionName ?? "";
|
||||
BindingIndex = bindingIndex;
|
||||
BindingLabel = bindingLabel ?? "";
|
||||
InputPath = inputPath ?? "";
|
||||
InputLabel = inputLabel ?? "";
|
||||
Include = include;
|
||||
}
|
||||
|
||||
public string ActionName { get; }
|
||||
public int BindingIndex { get; }
|
||||
public string BindingLabel { get; }
|
||||
public string InputPath { get; }
|
||||
public string InputLabel { get; }
|
||||
public bool Include { get; }
|
||||
}
|
||||
|
||||
public static class AetheriaRuntimeInputSettingsSurfaceBuilder
|
||||
{
|
||||
public static readonly IReadOnlyList<string> DefaultActionBarCandidatePaths = new[]
|
||||
|
|
@ -109,6 +135,41 @@ namespace GameCult.Aetheria.State.Verse
|
|||
path.StartsWith("<Mouse>/", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
public static AetheriaRuntimeInputSettingsSurfaceState Project(
|
||||
IEnumerable<AetheriaRuntimeObservedInputBinding> observedBindings,
|
||||
IEnumerable<string> enabledActionBarInputPaths,
|
||||
IEnumerable<AetheriaRuntimeInputPathSurfaceLabel> actionBarCandidateInputPaths,
|
||||
bool capturePending,
|
||||
string capturePrompt,
|
||||
string updatedAtUtc)
|
||||
{
|
||||
return new AetheriaRuntimeInputSettingsSurfaceState(
|
||||
ProjectBindingInputs(observedBindings),
|
||||
ProjectActionBarInputs(enabledActionBarInputPaths, actionBarCandidateInputPaths),
|
||||
capturePending,
|
||||
capturePrompt,
|
||||
updatedAtUtc);
|
||||
}
|
||||
|
||||
public static IReadOnlyList<AetheriaRuntimeInputBindingSurfaceState> ProjectBindingInputs(
|
||||
IEnumerable<AetheriaRuntimeObservedInputBinding> observedBindings)
|
||||
{
|
||||
return (observedBindings ?? Array.Empty<AetheriaRuntimeObservedInputBinding>())
|
||||
.Where(binding => binding != null &&
|
||||
binding.Include &&
|
||||
!string.IsNullOrWhiteSpace(binding.InputPath) &&
|
||||
IsSupportedCapturePath(binding.InputPath))
|
||||
.Select(binding => new AetheriaRuntimeInputBindingSurfaceState(
|
||||
binding.ActionName,
|
||||
binding.BindingIndex,
|
||||
binding.BindingLabel,
|
||||
string.IsNullOrWhiteSpace(binding.InputLabel) ? binding.InputPath : binding.InputLabel))
|
||||
.OrderBy(binding => binding.BindingLabel, StringComparer.Ordinal)
|
||||
.ThenBy(binding => binding.ActionName, StringComparer.Ordinal)
|
||||
.ThenBy(binding => binding.BindingIndex)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
public static IReadOnlyList<AetheriaRuntimeActionBarInputSurfaceState> ProjectActionBarInputs(
|
||||
IEnumerable<string> enabledInputPaths,
|
||||
IEnumerable<AetheriaRuntimeInputPathSurfaceLabel> candidateInputPaths)
|
||||
|
|
|
|||
Loading…
Reference in a new issue