fix(ui): restore retail vitals and window interactions
All checks were successful
CI / linux-portable (push) Successful in 3m16s
CI / windows-gate (push) Successful in 5m41s
CI / release (push) Successful in 2m5s

This commit is contained in:
Erik 2026-08-20 13:26:35 +02:00
parent 4d84456c21
commit 1bd2b30291
36 changed files with 1462 additions and 86 deletions

View file

@ -334,7 +334,7 @@ public sealed class RetailWindowLayoutPersistenceTests : IDisposable
}
[Fact]
public void RestoreAll_WithoutSaveBack_WritesNothingToTheStore()
public void RestoreAfterDisplayChange_WritesNothingToTheStore()
{
// The live display-change reload (#390) must not persist — retail
// saves layouts only via @saveui/@saveautoui, and a mid-drag reload
@ -346,19 +346,70 @@ public sealed class RetailWindowLayoutPersistenceTests : IDisposable
using var persistence = new RetailWindowLayoutPersistence(
root.WindowManager, store, () => "Alice", () => (800, 600));
persistence.RestoreAll(saveBack: false);
persistence.RestoreAfterDisplayChange();
Assert.Null(store.LoadWindowLayout(
"Alice", "800x600", WindowNames.Examination, default));
}
[Fact]
public void RestoreAfterDisplayChange_RestoresGeometryButPreservesLiveVisibility()
{
// Retail's global-message-0xE auto-layout file contains only X/Y/W/H.
// Our richer ambient settings schema also remembers visibility and
// collapsed/maximized state, but replaying visibility during a
// resolution change used to hide an open Options panel. Config's OnHidden reset
// then restored the previous resolution, creating the user-observed
// resize-out/resize-back blip.
var store = new SettingsStore(PathName);
store.SaveWindowLayout(
"Alice",
"1280x720",
WindowNames.Options,
new UiWindowLayout(
X: 700f,
Y: 200f,
Width: 310f,
Height: 400f,
Visible: false,
Collapsed: true,
Maximized: true));
var root = new UiRoot { Width = 1280, Height = 720 };
var state = new FakeWindowState();
var lifecycle = new FakePanelController();
RetailWindowHandle handle = Mount(
root,
WindowNames.Options,
state,
controller: lifecycle,
width: 300f,
height: 300f);
using var persistence = new RetailWindowLayoutPersistence(
root.WindowManager,
store,
() => "Alice",
() => (1280, 720));
persistence.RestoreAfterDisplayChange();
Assert.Equal((700f, 200f, 310f, 400f),
(handle.Left, handle.Top, handle.Width, handle.Height));
Assert.True(handle.IsVisible);
Assert.Equal(0, lifecycle.HiddenCount);
Assert.Equal(1, state.RestoreCount);
Assert.True(state.Restored.Collapsed);
Assert.True(state.Restored.Maximized);
}
private static RetailWindowHandle Mount(
UiRoot root,
string name,
IRetainedWindowStateController? state = null,
int authoredGeometryRevision = 0,
float width = 200f,
float height = 100f)
float height = 100f,
IRetainedPanelController? controller = null)
{
var frame = new UiPanel
{
@ -377,6 +428,7 @@ public sealed class RetailWindowLayoutPersistenceTests : IDisposable
return root.RegisterWindow(
name,
frame,
controller: controller,
stateController: state,
authoredGeometryRevision: authoredGeometryRevision);
}
@ -389,7 +441,23 @@ public sealed class RetailWindowLayoutPersistenceTests : IDisposable
private sealed class FakeWindowState : IRetainedWindowStateController
{
public RetainedWindowState Restored { get; private set; }
public int RestoreCount { get; private set; }
public RetainedWindowState CaptureWindowState() => Restored;
public void RestoreWindowState(RetainedWindowState state) => Restored = state;
public void RestoreWindowState(RetainedWindowState state)
{
Restored = state;
RestoreCount++;
}
}
private sealed class FakePanelController : IRetainedPanelController
{
public int HiddenCount { get; private set; }
public void OnShown() { }
public void OnHidden() => HiddenCount++;
public void Dispose() { }
}
}