feat(ui): persist retained window layouts
This commit is contained in:
parent
a8e9503d2e
commit
921c388e2c
22 changed files with 705 additions and 141 deletions
|
|
@ -384,4 +384,54 @@ public sealed class SettingsStoreTests : System.IDisposable
|
|||
Assert.Null(store.LoadWindowPosition("Alice", "inventory"));
|
||||
Assert.True(store.LoadGameplay().LockUI);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WindowLayouts_RoundTripPerCharacterResolutionAndPreserveSettings()
|
||||
{
|
||||
var store = new SettingsStore(_tempPath);
|
||||
store.SaveGameplay(GameplaySettings.Default with { LockUI = true });
|
||||
var alice1080 = new UiWindowLayout(10f, 20f, 500f, 300f, true, false, true);
|
||||
var alice1440 = new UiWindowLayout(30f, 40f, 650f, 420f, false, true, false);
|
||||
var bob1080 = new UiWindowLayout(50f, 60f, 310f, 132f, true, false, false);
|
||||
|
||||
store.SaveWindowLayout("Alice", "1920x1080", "chat", alice1080);
|
||||
store.SaveWindowLayout("Alice", "2560x1440", "chat", alice1440);
|
||||
store.SaveWindowLayout("Bob", "1920x1080", "toolbar", bob1080);
|
||||
|
||||
Assert.Equal(alice1080, store.LoadWindowLayout("Alice", "1920x1080", "chat", default));
|
||||
Assert.Equal(alice1440, store.LoadWindowLayout("Alice", "2560x1440", "chat", default));
|
||||
Assert.Equal(bob1080, store.LoadWindowLayout("Bob", "1920x1080", "toolbar", default));
|
||||
Assert.Null(store.LoadWindowLayout("Alice", "1920x1080", "inventory", default));
|
||||
Assert.True(store.LoadGameplay().LockUI);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WindowLayouts_MigrateLegacyRadarPositionOverCurrentDefaults()
|
||||
{
|
||||
var store = new SettingsStore(_tempPath);
|
||||
store.SaveWindowPosition("Alice", "radar", new UiWindowPosition(321.5f, 18f));
|
||||
var current = new UiWindowLayout(10f, 10f, 160f, 180f, true, false, false);
|
||||
|
||||
UiWindowLayout migrated = Assert.IsType<UiWindowLayout>(
|
||||
store.LoadWindowLayout("Alice", "1920x1080", "radar", current));
|
||||
|
||||
Assert.Equal(321.5f, migrated.X);
|
||||
Assert.Equal(18f, migrated.Y);
|
||||
Assert.Equal(current.Width, migrated.Width);
|
||||
Assert.Equal(current.Height, migrated.Height);
|
||||
Assert.Equal(current.Visible, migrated.Visible);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WindowLayouts_FallBackToNearestSavedResolution()
|
||||
{
|
||||
var store = new SettingsStore(_tempPath);
|
||||
var hd = new UiWindowLayout(100f, 110f, 400f, 250f, true, false, false);
|
||||
var uhd = new UiWindowLayout(300f, 310f, 600f, 450f, true, false, false);
|
||||
store.SaveWindowLayout("Alice", "1280x720", "chat", hd);
|
||||
store.SaveWindowLayout("Alice", "3840x2160", "chat", uhd);
|
||||
|
||||
Assert.Equal(hd, store.LoadWindowLayout("Alice", "1600x900", "chat", default));
|
||||
Assert.Equal(uhd, store.LoadWindowLayout("Alice", "3200x1800", "chat", default));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue