From f7a58e8431b9b9442acf45e3c40a9ca05141fdc4 Mon Sep 17 00:00:00 2001 From: maj00r Date: Sun, 22 Nov 2026 14:51:59 +0100 Subject: [PATCH] fix(settings): the move to the standard mode puts the render scale back with the frame buffer The row of the render scale, which only the advanced mode shows, has the keys of the frame buffer's size, while the scale itself is read from starter.bufferscale: put back without it, the two came out as they were, and a player moved to the standard mode kept a blurred picture with no setting for it on the screen. The percent now goes wherever the buffer's size does, on the move, on leaving the advanced mode and on a section put back. --- StarterNG.Tests/SettingsStoreTests.cs | 22 +++++++++++++++++++ StarterNG/Application/SettingsStore.cs | 1 + .../Settings/SettingsSerializer.cs | 17 ++++++++++++++ 3 files changed, 40 insertions(+) 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);