refactor(app): compose settings and developer tools
This commit is contained in:
parent
60a1698ce7
commit
cd7b519f78
24 changed files with 2073 additions and 333 deletions
|
|
@ -32,7 +32,7 @@ internal interface IDevToolsFrameLifecycle : IRenderFrameFailureRecovery
|
|||
void Render(double deltaSeconds, int viewportWidth, int viewportHeight);
|
||||
}
|
||||
|
||||
internal interface IDevToolsFrameBackend
|
||||
internal interface IDevToolsFrameBackend : IDisposable
|
||||
{
|
||||
void BeginFrame(float deltaSeconds);
|
||||
|
||||
|
|
@ -93,12 +93,12 @@ internal interface IDevToolsPanelSet
|
|||
/// <summary>Concrete ImGui backend for the developer presentation owner.</summary>
|
||||
internal sealed class ImGuiDevToolsFrameBackend : IDevToolsFrameBackend, IDisposable
|
||||
{
|
||||
private readonly ImGuiBootstrapper _bootstrap;
|
||||
private readonly IImGuiBootstrapper _bootstrap;
|
||||
private readonly ImGuiPanelHost _panels;
|
||||
private bool _disposed;
|
||||
|
||||
public ImGuiDevToolsFrameBackend(
|
||||
ImGuiBootstrapper bootstrap,
|
||||
IImGuiBootstrapper bootstrap,
|
||||
ImGuiPanelHost panels)
|
||||
{
|
||||
_bootstrap = bootstrap ?? throw new ArgumentNullException(nameof(bootstrap));
|
||||
|
|
@ -157,11 +157,14 @@ internal sealed class ImGuiDevToolsFrameBackend : IDevToolsFrameBackend, IDispos
|
|||
internal sealed class DevToolsCameraMenuOperations : IDevToolsCameraMenuOperations
|
||||
{
|
||||
private readonly CameraController _camera;
|
||||
private PlayerModeController? _playerMode;
|
||||
private readonly IDevToolsPlayerModeCommands _playerMode;
|
||||
|
||||
public DevToolsCameraMenuOperations(CameraController camera)
|
||||
public DevToolsCameraMenuOperations(
|
||||
CameraController camera,
|
||||
IDevToolsPlayerModeCommands playerMode)
|
||||
{
|
||||
_camera = camera ?? throw new ArgumentNullException(nameof(camera));
|
||||
_playerMode = playerMode ?? throw new ArgumentNullException(nameof(playerMode));
|
||||
}
|
||||
|
||||
public bool IsFlyMode => _camera.IsFlyMode;
|
||||
|
|
@ -172,25 +175,41 @@ internal sealed class DevToolsCameraMenuOperations : IDevToolsCameraMenuOperatio
|
|||
set => AcDream.Core.Rendering.CameraDiagnostics.CollideCamera = value;
|
||||
}
|
||||
|
||||
public void Bind(PlayerModeController playerMode)
|
||||
{
|
||||
_playerMode = playerMode ?? throw new ArgumentNullException(nameof(playerMode));
|
||||
}
|
||||
|
||||
public void ToggleFlyOrChase() => _playerMode?.ToggleFlyOrChase();
|
||||
public void ToggleFlyOrChase() => _playerMode.ToggleFlyOrChase();
|
||||
}
|
||||
|
||||
/// <summary>Resolves the reconnect-safe command bus at draw time.</summary>
|
||||
internal sealed class DevToolsCommandBusSource : IDevToolsCommandBusSource
|
||||
{
|
||||
private LiveSessionController? _session;
|
||||
private bool _deactivated;
|
||||
|
||||
public ICommandBus Current =>
|
||||
_session?.Commands ?? NullCommandBus.Instance;
|
||||
!_deactivated && _session is { } session
|
||||
? session.Commands
|
||||
: NullCommandBus.Instance;
|
||||
|
||||
public void Bind(LiveSessionController session)
|
||||
{
|
||||
_session = session ?? throw new ArgumentNullException(nameof(session));
|
||||
ArgumentNullException.ThrowIfNull(session);
|
||||
ObjectDisposedException.ThrowIf(_deactivated, this);
|
||||
if (_session is not null && !ReferenceEquals(_session, session))
|
||||
throw new InvalidOperationException(
|
||||
"Developer command-bus authority is already bound.");
|
||||
_session = session;
|
||||
}
|
||||
|
||||
public void Unbind(LiveSessionController session)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(session);
|
||||
if (ReferenceEquals(_session, session))
|
||||
_session = null;
|
||||
}
|
||||
|
||||
public void Deactivate()
|
||||
{
|
||||
_deactivated = true;
|
||||
_session = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue