refactor(app): compose platform input and camera startup

This commit is contained in:
Erik 2026-07-22 15:13:04 +02:00
parent adb204560d
commit 1d51e35c14
4 changed files with 877 additions and 88 deletions

View file

@ -51,19 +51,9 @@ public sealed class GameWindowSlice8BoundaryTests
AssertAppearsInOrder(
body,
"_gl = GL.GetApi(_window!);",
"_input = _window!.CreateInput();",
"_kbSource = AcDream.App.Input.SilkKeyboardSource.CreateDetached(",
"_kbSource.Attach();",
"_mouseSource = AcDream.App.Input.SilkMouseSource.CreateDetached(",
"_mouseSource.Attach();",
"_inputDispatcher = AcDream.UI.Abstractions.Input.InputDispatcher.CreateDetached(",
"_inputDispatcher.Attach();",
"_movementInput.Bind(_inputDispatcher);",
"_cameraInput.Bind(_inputDispatcher);",
"_cameraController = new CameraController(orbit, fly);",
"_cameraPointerInput = AcDream.App.Input.CameraPointerInputController.Create(",
"_cameraPointerInput.AttachRaw();",
"GameWindowPlatformResult<GL, IInputContext> platform = AcquirePlatform();",
"new HostInputCameraCompositionPhase(",
"this).Compose(platform);",
"_dats = RuntimeDatCollectionFactory.OpenReadOnly(_datDir);",
"_runtimeSettings.ApplyStartup(",
"new RuntimeSettingsStartupTargets(",
@ -86,15 +76,24 @@ public sealed class GameWindowSlice8BoundaryTests
"_gameplayInputActions.Attach();",
"_liveSessionHost.Start(_options)");
Assert.Equal(1, CountOccurrences(body, "_liveSessionHost.Start(_options)"));
Assert.Contains("if (firstKb is not null)", body, StringComparison.Ordinal);
Assert.Contains("if (firstMouse is not null)", body, StringComparison.Ordinal);
string phaseOne = Slice(
File.ReadAllText(Path.Combine(
FindRepoRoot(),
"src",
"AcDream.App",
"Composition",
"HostInputCameraComposition.cs")),
"private HostInputCameraResult ComposeCore(",
"private void Fault(");
Assert.Contains("if (firstKeyboard is not null)", phaseOne, StringComparison.Ordinal);
Assert.Contains("if (firstMouse is not null)", phaseOne, StringComparison.Ordinal);
Assert.Contains(
"if (_kbSource is not null && _mouseSource is not null)",
body,
"if (keyboard is not null && mouse is not null)",
phaseOne,
StringComparison.Ordinal);
Assert.DoesNotContain(
"if (firstKb is not null && firstMouse is not null)",
body,
"if (firstKeyboard is not null && firstMouse is not null)",
phaseOne,
StringComparison.Ordinal);
int start = body.IndexOf("_liveSessionHost.Start(_options)", StringComparison.Ordinal);
string postStart = body[start..];
@ -199,11 +198,21 @@ public sealed class GameWindowSlice8BoundaryTests
Assert.DoesNotContain("Viewport(", body, StringComparison.Ordinal);
Assert.DoesNotContain("SetAspect(", body, StringComparison.Ordinal);
Assert.DoesNotContain("ResetLayout(", body, StringComparison.Ordinal);
string phaseOne = Slice(
File.ReadAllText(Path.Combine(
FindRepoRoot(),
"src",
"AcDream.App",
"Composition",
"HostInputCameraComposition.cs")),
"private HostInputCameraResult ComposeCore(",
"private void Fault(");
AssertAppearsInOrder(
load,
"_framebufferResize.BindViewport(",
"_framebufferResize.BindCamera(",
"_framebufferResize.Resize(_window!.FramebufferSize);");
phaseOne,
"_dependencies.FramebufferResize.BindViewport(",
"_publication.PublishCameraController(camera)",
"_dependencies.FramebufferResize.BindCamera(",
"_dependencies.FramebufferResize.Resize(");
Assert.DoesNotContain(
"_viewportAspect.Update(_window",
load,