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
|
|
@ -79,6 +79,34 @@ internal sealed record RuntimeSettingsSnapshot(
|
|||
CharacterSettings Character,
|
||||
QualitySettings Quality);
|
||||
|
||||
/// <summary>
|
||||
/// Expected-owner lease for the optional developer settings view model.
|
||||
/// Failed optional composition can withdraw only the instance it installed.
|
||||
/// </summary>
|
||||
internal sealed class RuntimeSettingsViewModelBinding : IDisposable
|
||||
{
|
||||
private readonly RuntimeSettingsController _owner;
|
||||
private bool _disposed;
|
||||
|
||||
public RuntimeSettingsViewModelBinding(
|
||||
RuntimeSettingsController owner,
|
||||
SettingsVM viewModel)
|
||||
{
|
||||
_owner = owner ?? throw new ArgumentNullException(nameof(owner));
|
||||
ViewModel = viewModel ?? throw new ArgumentNullException(nameof(viewModel));
|
||||
}
|
||||
|
||||
public SettingsVM ViewModel { get; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_disposed)
|
||||
return;
|
||||
_owner.UnbindViewModel(ViewModel);
|
||||
_disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
internal interface IRuntimeSettingsStartupTarget
|
||||
{
|
||||
void ApplyDisplay(DisplaySettings display);
|
||||
|
|
@ -248,6 +276,14 @@ internal sealed class RuntimeSettingsController :
|
|||
return _viewModel;
|
||||
}
|
||||
|
||||
public RuntimeSettingsViewModelBinding CreateViewModelBinding(
|
||||
KeyBindings persistedBindings,
|
||||
InputDispatcher dispatcher,
|
||||
Action<KeyBindings> saveBindings) =>
|
||||
new(
|
||||
this,
|
||||
CreateViewModel(persistedBindings, dispatcher, saveBindings));
|
||||
|
||||
public void UnbindViewModel(SettingsVM? expected = null)
|
||||
{
|
||||
if (expected is null || ReferenceEquals(_viewModel, expected))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue