diff --git a/StarterNG.Tests/SettingsStoreTests.cs b/StarterNG.Tests/SettingsStoreTests.cs index 78b0d1b..aa063be 100644 --- a/StarterNG.Tests/SettingsStoreTests.cs +++ b/StarterNG.Tests/SettingsStoreTests.cs @@ -1246,6 +1246,28 @@ public class SettingsStoreTests Assert.Equal(60, store.Settings.FieldOfView); } + // The move to the standard mode puts back the keys of the rows it hides: the row of the + // render scale has the frame buffer's two, and the percent it is worked out from is the starter's own. + [Theory] + [InlineData("width 1920\nheight 1080\nstarter.bufferscale 50\ngfx.framebuffer.width 960\ngfx.framebuffer.height 540\n")] + [InlineData("width 1920\nheight 1080\ngfx.framebuffer.width 960\ngfx.framebuffer.height 540\n")] + public void The_frame_buffer_put_back_takes_the_render_scale_with_it(string ini) + { + var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, ini)); + var store = installation.SettingsStore; + store.Load(); + Assert.Equal(50, store.Settings.BufferScalePercent); + + var reset = store.WithDefaults(store.Settings, new[] { "gfx.framebuffer.width", "gfx.framebuffer.height" }); + + Assert.Equal(100, reset.BufferScalePercent); + Assert.Equal(1920, reset.Width); + var written = store.Render(reset); + Assert.Equal("100", written["starter.bufferscale"]); + Assert.Equal("1920", written["gfx.framebuffer.width"]); + Assert.Equal("1080", written["gfx.framebuffer.height"]); + } + // ── What the screen shows otherwise ────────────────────────────────────── [Fact] diff --git a/StarterNG/Application/SettingsStore.cs b/StarterNG/Application/SettingsStore.cs index feb7937..d68bc54 100644 --- a/StarterNG/Application/SettingsStore.cs +++ b/StarterNG/Application/SettingsStore.cs @@ -529,6 +529,7 @@ public sealed class SettingsStore /// A copy of with as has them. public SimulatorSettings WithKeysOf(SimulatorSettings settings, SimulatorSettings source, IReadOnlyCollection keys) { + keys = SettingsSerializer.WithCompanions(keys); var taken = Render(source); var config = new ConfigFile(); diff --git a/StarterNG/Infrastructure/Settings/SettingsSerializer.cs b/StarterNG/Infrastructure/Settings/SettingsSerializer.cs index ad932d0..f70654b 100644 --- a/StarterNG/Infrastructure/Settings/SettingsSerializer.cs +++ b/StarterNG/Infrastructure/Settings/SettingsSerializer.cs @@ -379,6 +379,23 @@ public sealed class SettingsSerializer c.Set(key.Key, value.Trim()); } + /// The keys of the frame buffer's size. + public static readonly string[] FramebufferKeys = { "gfx.framebuffer.width", "gfx.framebuffer.height" }; + + /// + /// with the keys that say the same setting along with them: the + /// starter's own percent goes wherever the frame buffer's size does, or it would stand + /// when the size is put back. + /// + public static IReadOnlyCollection WithCompanions(IReadOnlyCollection keys) + { + if (!keys.Intersect(FramebufferKeys, StringComparer.OrdinalIgnoreCase).Any()) + return keys; + var all = new HashSet(keys, StringComparer.OrdinalIgnoreCase) { "starter.bufferscale" }; + all.UnionWith(FramebufferKeys); + return all; + } + private static int ReadBufferScale(ConfigFile c) => Clamp(BufferScaleIn(c), 25, GraphicsRules.MaxBufferScale);