mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-23 00:24:41 +01:00
fix(settings): a borderless screen draws into a buffer of the monitor's size, not the resolution row's
With fullscreenwindowed the simulator takes the window's size from the monitor and leaves width and height unread (application.cpp), but its full renderer still draws into gfx.framebuffer.width and height (opengl33renderer.cpp). Those were written from the resolution row, greyed out in that mode: 1280x720 stretched over a larger monitor. Borderless, they are now -1, the simulator's own word for a buffer of the window's size, or with a smaller render scale that part of the chosen monitor's size, the primary one's when none is chosen. A size left in a borderless file goes on the next save.
This commit is contained in:
@@ -172,6 +172,84 @@ public class GraphicsSettingsTests
|
||||
Assert.Null(Line(text, "gfx.buffer.percent"));
|
||||
}
|
||||
|
||||
// Borderless, the simulator takes the window's size from the monitor (application.cpp) and
|
||||
// leaves width and height unread; -1 is its own word for a buffer of the window's size
|
||||
// (opengl33renderer.cpp).
|
||||
[Fact]
|
||||
public void A_borderless_screen_draws_into_a_buffer_of_the_windows_own_size()
|
||||
{
|
||||
var s = Read("fullscreenwindowed yes\nwidth 1280\nheight 720\n");
|
||||
|
||||
string text = Write(s);
|
||||
|
||||
Assert.Equal("gfx.framebuffer.width -1", Line(text, "gfx.framebuffer.width"));
|
||||
Assert.Equal("gfx.framebuffer.height -1", Line(text, "gfx.framebuffer.height"));
|
||||
Assert.Equal("width 1280", Line(text, "width"));
|
||||
Assert.Equal(100, Read(text).BufferScalePercent);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_borderless_screen_with_a_smaller_buffer_takes_its_part_of_the_monitor()
|
||||
{
|
||||
var s = Read("fullscreenwindowed yes\nfullscreenmonitor HDMI-1:1920,0\nwidth 1280\nheight 720\nstarter.bufferscale 50\n");
|
||||
var asked = new List<string>();
|
||||
var serializer = new SettingsSerializer(id =>
|
||||
{
|
||||
asked.Add(id);
|
||||
return (2560, 1440);
|
||||
});
|
||||
var c = new ConfigFile();
|
||||
|
||||
serializer.Write(s, c);
|
||||
|
||||
Assert.Equal("1280", c.GetRaw("gfx.framebuffer.width"));
|
||||
Assert.Equal("720", c.GetRaw("gfx.framebuffer.height"));
|
||||
Assert.Equal("50", c.GetRaw("starter.bufferscale"));
|
||||
Assert.Equal(new[] { "HDMI-1:1920,0" }, asked.Distinct());
|
||||
var read = new SimulatorSettings();
|
||||
serializer.Read(read, c);
|
||||
Assert.Equal(50, read.BufferScalePercent);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_borderless_screen_on_a_monitor_of_unknown_size_keeps_the_windows_own_buffer()
|
||||
{
|
||||
var s = Read("fullscreenwindowed yes\nwidth 1280\nheight 720\nstarter.bufferscale 50\n");
|
||||
var c = new ConfigFile();
|
||||
|
||||
new SettingsSerializer(_ => null).Write(s, c);
|
||||
|
||||
Assert.Equal("-1", c.GetRaw("gfx.framebuffer.width"));
|
||||
Assert.Equal("-1", c.GetRaw("gfx.framebuffer.height"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_buffer_of_the_window_left_in_a_borderless_file_goes_on_a_save()
|
||||
{
|
||||
// As this starter wrote it before: the size of the resolution row, which borderless does not use.
|
||||
var installation = WithIni("fullscreenwindowed yes\nwidth 1280\nheight 720\nstarter.bufferscale 100\n" +
|
||||
"gfx.framebuffer.width 1280\ngfx.framebuffer.height 720\n");
|
||||
|
||||
installation.SettingsStore.Save();
|
||||
|
||||
string saved = installation.Files.ReadAllText(UserIni);
|
||||
Assert.Equal("gfx.framebuffer.width -1", Line(saved, "gfx.framebuffer.width"));
|
||||
Assert.Equal("gfx.framebuffer.height -1", Line(saved, "gfx.framebuffer.height"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_buffer_the_file_has_for_a_window_or_a_full_screen_stays_until_changed()
|
||||
{
|
||||
var installation = WithIni("fullscreenwindowed no\nwidth 1280\nheight 720\nstarter.bufferscale 100\n" +
|
||||
"gfx.framebuffer.width 1280\ngfx.framebuffer.height 720\n");
|
||||
|
||||
installation.SettingsStore.Save();
|
||||
|
||||
string saved = installation.Files.ReadAllText(UserIni);
|
||||
Assert.Equal("gfx.framebuffer.width 1280", Line(saved, "gfx.framebuffer.width"));
|
||||
Assert.Equal("gfx.framebuffer.height 720", Line(saved, "gfx.framebuffer.height"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_level_is_recognised_after_it_is_applied_and_survives_a_save()
|
||||
{
|
||||
|
||||
@@ -59,6 +59,22 @@ public class MonitorsTests
|
||||
Assert.Equal("HDMI-1:1920,0", c.GetRaw("fullscreenmonitor"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_size_is_of_the_monitor_named_or_of_the_primary_one()
|
||||
{
|
||||
var monitors = new[]
|
||||
{
|
||||
new DisplayMonitor("eDP-1:0,360", "eDP-1", 1920, 1080, true),
|
||||
new DisplayMonitor("HDMI-1:1920,0", "HDMI-1", 2560, 1440, false)
|
||||
};
|
||||
|
||||
Assert.Equal((2560, 1440), Monitors.SizeOf(monitors, "HDMI-1:1920,0"));
|
||||
Assert.Equal((1920, 1080), Monitors.SizeOf(monitors, ""));
|
||||
// Not connected: the simulator goes to the primary one.
|
||||
Assert.Equal((1920, 1080), Monitors.SizeOf(monitors, "DP-3:4480,0"));
|
||||
Assert.Null(Monitors.SizeOf(Array.Empty<DisplayMonitor>(), "HDMI-1:1920,0"));
|
||||
}
|
||||
|
||||
// ── A name outside ASCII: the simulator compares the file's bytes with GLFW's UTF-8 name ──
|
||||
|
||||
private static readonly string UserIni = Path.Combine("/home/kolejarz", ".config", "MaSzyna", "eu07.ini");
|
||||
|
||||
Reference in New Issue
Block a user