refactor(ui): own retained controller lifetimes

This commit is contained in:
Erik 2026-07-10 23:35:26 +02:00
parent 921c388e2c
commit 5d9e98c118
21 changed files with 373 additions and 35 deletions

View file

@ -11,7 +11,7 @@ namespace AcDream.App.UI.Layout;
/// LayoutDesc <c>0x21000074</c> tree. Like the other gm* controllers, this class only
/// finds children by retail id and attaches live providers; it does not recreate DAT chrome.
/// </summary>
public sealed class RadarController
public sealed class RadarController : IRetainedPanelController
{
public const uint LayoutId = 0x21000074u;
/// <summary>Production layout property 0x1000002D, recovered directly from the retail DAT.</summary>
@ -39,6 +39,7 @@ public sealed class RadarController
private string? _lastCoordinates;
private bool _coordinatesInitialized;
private bool? _lastUiLocked;
private bool _disposed;
private RadarController(
ImportedLayout layout,
@ -235,6 +236,17 @@ public sealed class RadarController
? Array.Empty<UiText.Line>()
: new[] { new UiText.Line(_lastCoordinates, CoordinateColor) };
public void Dispose()
{
if (_disposed) return;
_disposed = true;
_radar.SnapshotProvider = null;
_radar.SelectObject = null;
_radar.HoveredObjectChanged = null;
if (_lockButton is not null)
_lockButton.OnClick = null;
}
private readonly record struct CompassToken(
UiElement? Element,
float Magnitude,