mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-22 00:04:57 +01:00
feat(settings): a standard mode as the old starter's panel, the rest behind a warning
The settings keep only the keys master reads, Vulkan left out. The standard mode is the old starter's panel; the advanced mode opens behind a warning whose yes takes a click only after 20 seconds in front of the player. - Sliders go by fixed steps (SliderRanges), held to the standard ranges there: fpslimit up to 240, sleeperdistance up to 1000 m. - On the first start everyone is moved to the standard mode once: what is outside it goes back to its default, the sliders' values to their ranges, and a copy of eu07.ini is kept as eu07.ini.before-standard. - "Restore defaults" puts every setting back, the language, the simulator, the UART port and the control keys kept. - Monitors and renderers are found anew (Monitors, Renderers), Displays and SettingReach gone. - mousescale writes its second number as the old starter did, 0.5 or -0.5 for an inverted vertical axis; an axis that would not move gets the default. - Depot, in the standard mode: no AI or drivable-only filters, empty consists not listed, the crew shown but not changed. - Randomizing the textures of a whole scenery no longer rebuilds the view per consist, and finds its candidates by mini, so the window keeps answering. - A long operator in the vehicle list is cut short instead of over the name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,100 +0,0 @@
|
||||
using StarterNG.Infrastructure;
|
||||
using StarterNG.Tests.Fakes;
|
||||
|
||||
namespace StarterNG.Tests;
|
||||
|
||||
public class DisplaysTests
|
||||
{
|
||||
/// <summary>A 128-byte block with an 18-byte timing at 54, as a panel's base EDID has it.</summary>
|
||||
private static byte[] BaseBlock(int pixelClock10KHz, int hActive, int hBlank, int vActive, int vBlank,
|
||||
int extensions = 0)
|
||||
{
|
||||
var edid = new byte[128];
|
||||
new byte[] { 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0 }.CopyTo(edid, 0);
|
||||
edid[126] = (byte)extensions;
|
||||
int at = 54;
|
||||
edid[at] = (byte)pixelClock10KHz;
|
||||
edid[at + 1] = (byte)(pixelClock10KHz >> 8);
|
||||
edid[at + 2] = (byte)hActive;
|
||||
edid[at + 3] = (byte)hBlank;
|
||||
edid[at + 4] = (byte)((hActive >> 8) << 4 | hBlank >> 8);
|
||||
edid[at + 5] = (byte)vActive;
|
||||
edid[at + 6] = (byte)vBlank;
|
||||
edid[at + 7] = (byte)((vActive >> 8) << 4 | vBlank >> 8);
|
||||
return edid;
|
||||
}
|
||||
|
||||
/// <summary>A DisplayID 2.0 block with one type VII timing (kHz, sizes less one).</summary>
|
||||
private static byte[] DisplayIdBlock(int pixelClockKHz, int hActive, int hBlank, int vActive, int vBlank)
|
||||
{
|
||||
var block = new byte[128];
|
||||
block[0] = 0x70;
|
||||
block[1] = 0x20;
|
||||
block[2] = 23; // one data block: 3 bytes of header, 20 of timing
|
||||
block[3] = 2;
|
||||
int at = 5;
|
||||
block[at] = 0x22;
|
||||
block[at + 2] = 20;
|
||||
int t = at + 3, clock = pixelClockKHz - 1;
|
||||
block[t] = (byte)clock;
|
||||
block[t + 1] = (byte)(clock >> 8);
|
||||
block[t + 2] = (byte)(clock >> 16);
|
||||
void Put(int offset, int value)
|
||||
{
|
||||
block[t + offset] = (byte)(value - 1);
|
||||
block[t + offset + 1] = (byte)((value - 1) >> 8);
|
||||
}
|
||||
Put(4, hActive);
|
||||
Put(6, hBlank);
|
||||
Put(12, vActive);
|
||||
Put(14, vBlank);
|
||||
return block;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_plain_monitor_gives_its_preferred_timing()
|
||||
{
|
||||
// 1920x1080 at 148.5 MHz: the usual 60 Hz.
|
||||
Assert.Equal(60, Edid.HighestRefreshRate(BaseBlock(14850, 1920, 280, 1080, 45)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_fast_panel_found_only_in_displayid_is_read_there()
|
||||
{
|
||||
// As the eDP panel of a gaming laptop: 60 Hz in the base block, 165 Hz in DisplayID.
|
||||
var edid = BaseBlock(15394, 1920, 160, 1200, 35, extensions: 1)
|
||||
.Concat(DisplayIdBlock(423250, 1920, 160, 1200, 33)).ToArray();
|
||||
|
||||
Assert.Equal(165, Edid.HighestRefreshRate(edid));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Something_too_short_for_an_edid_has_no_rate()
|
||||
{
|
||||
Assert.Equal(0, Edid.HighestRefreshRate(new byte[] { 0, 0xFF }));
|
||||
Assert.Equal(0, Edid.HighestRefreshRate(new byte[128]));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Only_connected_screens_are_listed_by_their_connector()
|
||||
{
|
||||
var files = new InMemoryFileSystem(caseSensitive: true)
|
||||
.WithFile("/sys/class/drm/card1-eDP-1/status", "connected\n")
|
||||
.WithFile("/sys/class/drm/card1-HDMI-A-1/status", "disconnected\n")
|
||||
.WithFile("/sys/class/drm/card1/device/uevent", "DRIVER=amdgpu\n");
|
||||
files.WriteAllBytes("/sys/class/drm/card1-eDP-1/edid", BaseBlock(14850, 1920, 280, 1080, 45));
|
||||
files.WriteAllBytes("/sys/class/drm/card1-HDMI-A-1/edid", BaseBlock(14850, 1920, 280, 1080, 45));
|
||||
|
||||
var displays = new Displays(files, new FakeEnvironment()).List();
|
||||
|
||||
Assert.Equal(new[] { new Display("eDP-1", 60) }, displays);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Off_linux_without_windows_nothing_is_read()
|
||||
{
|
||||
var environment = new FakeEnvironment { IsLinux = false, IsMacOS = true };
|
||||
|
||||
Assert.Empty(new Displays(new InMemoryFileSystem(), environment).List());
|
||||
}
|
||||
}
|
||||
158
StarterNG.Tests/ExternalIniTests.cs
Normal file
158
StarterNG.Tests/ExternalIniTests.cs
Normal file
@@ -0,0 +1,158 @@
|
||||
using StarterNG.Classes;
|
||||
using StarterNG.Domain.Settings;
|
||||
using StarterNG.Infrastructure.Settings;
|
||||
using StarterNG.Tests.Fakes;
|
||||
|
||||
namespace StarterNG.Tests;
|
||||
|
||||
/// <summary>eu07.ini as other hands leave it: edited while the starter runs, and with lines the starter does not know.</summary>
|
||||
public class ExternalIniTests
|
||||
{
|
||||
private static readonly string UserIni = Path.Combine("/home/kolejarz", ".config", "MaSzyna", "eu07.ini");
|
||||
|
||||
private static TestInstallation WithIni(string text)
|
||||
{
|
||||
var installation = new TestInstallation(new InMemoryFileSystem().WithFile(UserIni, text));
|
||||
installation.Environment.With("HOME", "/home/kolejarz");
|
||||
installation.SettingsStore.Load();
|
||||
return installation;
|
||||
}
|
||||
|
||||
private static SimulatorSettings Read(string text)
|
||||
{
|
||||
var s = new SimulatorSettings();
|
||||
new SettingsSerializer().Read(s, ConfigFile.Parse(text));
|
||||
return s;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_key_inside_a_block_comment_is_not_read()
|
||||
{
|
||||
Assert.False(Read("/*\nfullscreen yes\n*/\n").Fullscreen);
|
||||
Assert.False(Read("/* fullscreen yes */\n").Fullscreen);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_comment_glued_to_a_value_is_not_part_of_it()
|
||||
{
|
||||
Assert.True(Read("fullscreen yes//na pelnym ekranie\n").Fullscreen);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_save_keeps_what_was_changed_on_disk_meanwhile()
|
||||
{
|
||||
var installation = WithIni("fieldofview 45\n");
|
||||
Edited(installation, "fieldofview 45\nvsync yes\ncalibratein 1 2 3 4\n");
|
||||
|
||||
installation.SettingsStore.Settings.FieldOfView = 60;
|
||||
installation.SettingsStore.Save();
|
||||
|
||||
string saved = installation.Files.ReadAllText(UserIni);
|
||||
Assert.Contains("fieldofview 60", saved);
|
||||
Assert.Contains("calibratein 1 2 3 4", saved);
|
||||
Assert.Contains("vsync yes", saved);
|
||||
// What is held is the file again: a later save does not take the other change back.
|
||||
Assert.True(installation.SettingsStore.Settings.VSync);
|
||||
Assert.True(installation.SettingsStore.LastSaveMerged);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_key_changed_both_here_and_on_disk_takes_the_players_value()
|
||||
{
|
||||
var installation = WithIni("fieldofview 45\n");
|
||||
Edited(installation, "fieldofview 70\n");
|
||||
|
||||
installation.SettingsStore.Settings.FieldOfView = 60;
|
||||
installation.SettingsStore.Save();
|
||||
|
||||
Assert.Contains("fieldofview 60", installation.Files.ReadAllText(UserIni));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_file_nobody_else_touched_saves_as_before()
|
||||
{
|
||||
var installation = WithIni("fieldofview 45\n");
|
||||
|
||||
installation.SettingsStore.Settings.FieldOfView = 60;
|
||||
installation.SettingsStore.Save();
|
||||
|
||||
Assert.False(installation.SettingsStore.LastSaveMerged);
|
||||
Assert.Contains("fieldofview 60", installation.Files.ReadAllText(UserIni));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_known_key_with_a_value_the_starter_cannot_read_is_named_with_that_value()
|
||||
{
|
||||
var installation = WithIni("fieldofview abc\nfullscreen moze\nui.scale duzo\nvsync tak\nwidth 1920.0\n" +
|
||||
"gfxrenderer legacy\nwidth 1920\ngfx.framebuffer.width 960\ncalibratein 1 2\n");
|
||||
|
||||
var unreadable = installation.SettingsStore.UnreadableValues();
|
||||
|
||||
Assert.Equal("abc", unreadable["fieldofview"]);
|
||||
Assert.Equal("moze", unreadable["fullscreen"]);
|
||||
Assert.Equal("duzo", unreadable["ui.scale"]);
|
||||
// Read another way, derived from other keys, or not the starter's: none of them unknown.
|
||||
Assert.False(unreadable.ContainsKey("vsync"));
|
||||
Assert.False(unreadable.ContainsKey("width"));
|
||||
Assert.False(unreadable.ContainsKey("gfxrenderer"));
|
||||
Assert.False(unreadable.ContainsKey("gfx.framebuffer.width"));
|
||||
Assert.False(unreadable.ContainsKey("calibratein"));
|
||||
// The file keeps what it says until the setting is changed.
|
||||
installation.SettingsStore.Save();
|
||||
Assert.Contains("fieldofview abc", installation.Files.ReadAllText(UserIni));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Values_above_what_the_old_starter_gave_are_brought_down_on_the_next_save()
|
||||
{
|
||||
var installation = WithIni("maxcabtexturesize 8192\nshadowtune 4096 250 600 300\n" +
|
||||
"width 1920\nheight 1080\ngfx.framebuffer.width 2880\ngfx.framebuffer.height 1620\n" +
|
||||
"fieldofview 50\n");
|
||||
var store = installation.SettingsStore;
|
||||
|
||||
Assert.Equal(GraphicsRules.MaxCabTextureSize, store.Settings.MaxCabTextureSize);
|
||||
Assert.Equal(GraphicsRules.MaxShadowRange, store.Settings.ShadowProjectionRange);
|
||||
Assert.Equal(GraphicsRules.MaxBufferScale, store.Settings.BufferScalePercent);
|
||||
// Read, only brought down: not a value the starter cannot read.
|
||||
Assert.Empty(store.UnreadableValues());
|
||||
|
||||
store.Save();
|
||||
|
||||
string saved = installation.Files.ReadAllText(UserIni);
|
||||
Assert.Contains("maxcabtexturesize 4096", saved);
|
||||
Assert.Contains("shadowtune 4096 250 400 300", saved);
|
||||
Assert.Contains("gfx.framebuffer.width 1920", saved);
|
||||
Assert.Contains("gfx.framebuffer.height 1080", saved);
|
||||
Assert.Contains("fieldofview 50", saved);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Values_within_the_caps_are_left_as_the_file_has_them()
|
||||
{
|
||||
var installation = WithIni("maxcabtexturesize 2048\nshadowtune 2048 250 300 300\n");
|
||||
|
||||
installation.SettingsStore.Save();
|
||||
|
||||
string saved = installation.Files.ReadAllText(UserIni);
|
||||
Assert.Contains("maxcabtexturesize 2048", saved);
|
||||
Assert.Contains("shadowtune 2048 250 300 300", saved);
|
||||
}
|
||||
|
||||
// Another program writes the file a minute after the starter read it.
|
||||
private static void Edited(TestInstallation installation, string text) =>
|
||||
installation.Files.WithFile(UserIni, text)
|
||||
.WrittenAt(UserIni, installation.Files.GetLastWriteTimeUtc(UserIni).AddMinutes(1));
|
||||
|
||||
[Fact]
|
||||
public void Lines_the_starter_does_not_know_survive_a_save_in_place()
|
||||
{
|
||||
const string ini = "// moj komentarz\nfoo bar baz\n\nfullscreen no\nzmq.address tcp://*:5555\n";
|
||||
var installation = WithIni(ini);
|
||||
installation.SettingsStore.Settings.Fullscreen = true;
|
||||
|
||||
installation.SettingsStore.Save();
|
||||
|
||||
string saved = installation.Files.ReadAllText(UserIni).Replace("\r\n", "\n");
|
||||
Assert.StartsWith("// moj komentarz\nfoo bar baz\n\nfullscreen yes\nzmq.address tcp://*:5555\n", saved);
|
||||
}
|
||||
}
|
||||
@@ -26,16 +26,13 @@ public class GraphicsPresetTests
|
||||
var store = new TestInstallation().SettingsStore;
|
||||
var low = Defaults().Copy();
|
||||
var top = Defaults().Copy();
|
||||
// Ray tracing is one of them, and only Vulkan has it.
|
||||
low.RenderEngine = top.RenderEngine = SimulatorSettings.VulkanEngine;
|
||||
(GraphicsPreset.Minimal with { Extras = null }).ApplyTo(low);
|
||||
(GraphicsPreset.Ultra with { Extras = null, Top = null }).ApplyTo(top);
|
||||
|
||||
var lowKeys = store.Render(low);
|
||||
var topKeys = store.Render(top);
|
||||
var differing = lowKeys.Keys.Union(topKeys.Keys)
|
||||
.Where(key => lowKeys.GetValueOrDefault(key) != topKeys.GetValueOrDefault(key))
|
||||
.Where(key => !key.StartsWith("gfx.framebuffer", StringComparison.Ordinal));
|
||||
.Where(key => lowKeys.GetValueOrDefault(key) != topKeys.GetValueOrDefault(key));
|
||||
|
||||
Assert.Equal(GraphicsPreset.Keys.OrderBy(k => k), differing.OrderBy(k => k));
|
||||
}
|
||||
@@ -55,7 +52,7 @@ public class GraphicsPresetTests
|
||||
{
|
||||
// Sizes and filtering run out of steps above High.
|
||||
Climbs(p => p.TextureSize, 1);
|
||||
Climbs(p => p.CabTextureSize, 1);
|
||||
Climbs(p => p.CabTextureSize, 2);
|
||||
Climbs(p => p.Anisotropy, 1);
|
||||
|
||||
// Four steps or three for six levels.
|
||||
@@ -65,28 +62,23 @@ public class GraphicsPresetTests
|
||||
Climbs(p => p.ReflectionsFidelity, 3);
|
||||
Climbs(p => p.ShadowRank, 3);
|
||||
|
||||
// The simulator takes no more than its own 7 lights, and draws no less than 2 km.
|
||||
// The simulator takes no more than its own 7 lights.
|
||||
Climbs(p => p.DynamicLights, 2);
|
||||
Climbs(p => p.DrawRange, 1);
|
||||
Climbs(p => p.DrawRangeFactor, 2);
|
||||
Climbs(p => p.DrawRangeFactor, 3);
|
||||
Climbs(p => p.CabShadowsRange, 1);
|
||||
|
||||
Climbs(p => p.ShadowMap, 1);
|
||||
Climbs(p => p.ShadowRange, 0);
|
||||
Climbs(p => p.ReflectionsRate, 0);
|
||||
Climbs(p => p.DistanceFactor, 0);
|
||||
Climbs(p => p.BufferScale, 0);
|
||||
Climbs(p => p.SleeperDistance, 0);
|
||||
Climbs(p => p.ReflectedInstances, 0);
|
||||
Climbs(p => p.ReflectedVehicles, 0);
|
||||
Climbs(p => p.ShadowMap, 2);
|
||||
Climbs(p => p.ShadowRange, 1);
|
||||
// The old starter's steps begin at once a second: the lower levels share it.
|
||||
Climbs(p => p.ReflectionsRate, 2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void No_step_up_a_scale_is_more_than_a_few_steps_of_its_slider()
|
||||
{
|
||||
// In steps of what the screen offers, so Ultra does not jump to the top from far below.
|
||||
var rates = GraphicsPreset.All.Select(p => Steps.IndexOf(Steps.ReflectionUpdates, p.ReflectionsRate)).ToList();
|
||||
Assert.All(rates.Zip(rates.Skip(1)), step => Assert.InRange(step.Second - step.First, 1, 4));
|
||||
var rates = GraphicsPreset.All.Select(p => Steps.IndexOf(SliderRanges.ReflectionUpdates, p.ReflectionsRate)).ToList();
|
||||
Assert.All(rates.Zip(rates.Skip(1)), step => Assert.InRange(step.Second - step.First, 0, 2));
|
||||
|
||||
foreach (Func<GraphicsPreset, int> fidelity in new Func<GraphicsPreset, int>[] { p => p.SmokeFidelity, p => p.SplineFidelity })
|
||||
{
|
||||
@@ -103,9 +95,7 @@ public class GraphicsPresetTests
|
||||
var high = store.Render(AtHigh());
|
||||
|
||||
var differing = own.Keys.Union(high.Keys)
|
||||
.Where(key => own.GetValueOrDefault(key) != high.GetValueOrDefault(key))
|
||||
.Where(key => !GraphicsPreset.RowKeys.Contains(key))
|
||||
.Where(key => !key.StartsWith("gfx.framebuffer", StringComparison.Ordinal) && key != "gfx.buffer.percent");
|
||||
.Where(key => own.GetValueOrDefault(key) != high.GetValueOrDefault(key));
|
||||
|
||||
Assert.Equal(new[] { "gfx.reflections.fidelity", "gfx.reflections.framerate", "gfx.shadows.cab.range",
|
||||
"gfx.smoke.fidelity", "splinefidelity" }, differing.OrderBy(k => k));
|
||||
@@ -128,6 +118,8 @@ public class GraphicsPresetTests
|
||||
var again = new TestInstallation(installation.Files).SettingsStore;
|
||||
again.Load();
|
||||
Assert.Same(GraphicsPreset.High, GraphicsPreset.Matching(again.Settings));
|
||||
// Nothing of an older starter to bring into the standard mode.
|
||||
Assert.True(again.Settings.MovedToStandard);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -144,158 +136,102 @@ public class GraphicsPresetTests
|
||||
again.StartAtHighWithoutOwnSettings();
|
||||
|
||||
Assert.Same(GraphicsPreset.Low, GraphicsPreset.Matching(again.Settings));
|
||||
Assert.False(again.Settings.MovedToStandard);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void High_is_what_the_new_simulator_does_with_nothing_set()
|
||||
public void A_copy_of_the_file_is_kept_once_and_not_written_over()
|
||||
{
|
||||
Assert.Equal(GraphicsPreset.High.NewRenderer, GraphicsNewRenderer.Of(Defaults()));
|
||||
var installation = new TestInstallation();
|
||||
var store = installation.SettingsStore;
|
||||
store.Load();
|
||||
store.Settings.FieldOfView = 50;
|
||||
store.Save();
|
||||
string copy = store.SavePath + ".before-standard";
|
||||
|
||||
store.KeepCopy(".before-standard");
|
||||
string first = installation.Files.ReadAllText(copy);
|
||||
Assert.Equal(installation.Files.ReadAllText(store.SavePath), first);
|
||||
|
||||
store.Settings.FieldOfView = 60;
|
||||
store.Save();
|
||||
store.KeepCopy(".before-standard");
|
||||
Assert.Equal(first, installation.Files.ReadAllText(copy));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_new_renderers_scales_never_go_down()
|
||||
{
|
||||
void NeverDown(Func<GraphicsNewRenderer, double> value) => Climbs(p => value(p.NewRenderer), 5);
|
||||
|
||||
void TurnsOn(Func<GraphicsNewRenderer, bool> on)
|
||||
{
|
||||
var values = GraphicsPreset.All.Select(p => on(p.NewRenderer)).ToList();
|
||||
Assert.Equal(values.OrderBy(value => value), values);
|
||||
}
|
||||
|
||||
NeverDown(r => r.LampShadows);
|
||||
NeverDown(r => r.ContactShadows);
|
||||
NeverDown(r => r.Occlusion);
|
||||
NeverDown(r => r.OcclusionSlices);
|
||||
NeverDown(r => r.OcclusionSteps);
|
||||
NeverDown(r => r.CabProbe);
|
||||
NeverDown(r => r.ScreenReflections);
|
||||
NeverDown(r => r.FogQuality);
|
||||
NeverDown(r => r.Clouds);
|
||||
|
||||
TurnsOn(r => r.OcclusionLighting);
|
||||
TurnsOn(r => r.CabProbeReflections);
|
||||
TurnsOn(r => r.RayTracing);
|
||||
TurnsOn(r => r.VolumetricFog);
|
||||
TurnsOn(r => r.CloudShadows);
|
||||
TurnsOn(r => r.Grass);
|
||||
TurnsOn(r => r.Bloom);
|
||||
|
||||
Climbs(p => p.NewRenderer.GrassDistance, 0);
|
||||
Climbs(p => p.NewRenderer.GrassDensity, 0);
|
||||
Climbs(p => p.NewRenderer.Precipitation, 1);
|
||||
// Frames between refreshes, so the dearer the fewer.
|
||||
Climbs(p => -p.NewRenderer.CabProbeInterval, 2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Ultra_is_the_top_of_the_new_renderers_scales()
|
||||
{
|
||||
var ultra = GraphicsPreset.Ultra.NewRenderer;
|
||||
|
||||
Assert.Equal(3, ultra.LampShadows);
|
||||
Assert.Equal(3, ultra.ContactShadows);
|
||||
Assert.Equal(2, ultra.Occlusion);
|
||||
Assert.Equal((6, 8), (ultra.OcclusionSlices, ultra.OcclusionSteps));
|
||||
Assert.Equal(3, ultra.CabProbe);
|
||||
Assert.Equal(3, ultra.ScreenReflections);
|
||||
Assert.True(ultra.RayTracing && ultra.VolumetricFog);
|
||||
Assert.Equal(4, ultra.FogQuality);
|
||||
Assert.Equal(4, ultra.Clouds);
|
||||
Assert.Equal(300, ultra.GrassDistance);
|
||||
Assert.Equal(2.0, ultra.GrassDensity);
|
||||
Assert.Equal(262144, ultra.Precipitation);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Grass_fades_out_beyond_where_it_is_drawn_in_full()
|
||||
{
|
||||
var store = new TestInstallation().SettingsStore;
|
||||
foreach (var preset in GraphicsPreset.All)
|
||||
{
|
||||
var settings = Defaults().Copy();
|
||||
preset.ApplyTo(settings);
|
||||
|
||||
Assert.True(int.Parse(store.Render(settings)["gfx.grass.fadedistance"]) > preset.NewRenderer.GrassDistance, preset.NameKey);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_level_set_in_the_new_renderers_rows_is_told_from_the_others()
|
||||
{
|
||||
var settings = Defaults().Copy();
|
||||
GraphicsPreset.Medium.ApplyTo(settings);
|
||||
Assert.Same(GraphicsPreset.Medium, GraphicsPreset.Matching(settings));
|
||||
|
||||
settings.FogQuality = 4;
|
||||
|
||||
Assert.Null(GraphicsPreset.Matching(settings));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void What_is_left_to_the_player_stays_through_a_level()
|
||||
{
|
||||
var settings = Defaults().Copy();
|
||||
settings.RenderEngine = SimulatorSettings.VulkanEngine;
|
||||
settings.AntiAliasing = AntiAliasingMode.Dlss;
|
||||
settings.FrameGeneration = 2;
|
||||
settings.VulkanDevice = "RTX";
|
||||
|
||||
foreach (var preset in GraphicsPreset.All)
|
||||
{
|
||||
preset.ApplyTo(settings);
|
||||
|
||||
Assert.Same(preset, GraphicsPreset.Matching(settings));
|
||||
Assert.Equal(AntiAliasingMode.Dlss, settings.AntiAliasing);
|
||||
Assert.Equal(2, settings.FrameGeneration);
|
||||
Assert.Equal("RTX", settings.VulkanDevice);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Ultra_is_the_top_of_everything_the_screen_offers()
|
||||
public void Ultra_is_the_top_of_what_the_old_starter_offered()
|
||||
{
|
||||
var ultra = GraphicsPreset.Ultra;
|
||||
double Top(string key) => SimulatorKeys.Named(key).Maximum;
|
||||
|
||||
Assert.Equal(8192, ultra.TextureSize);
|
||||
Assert.Equal(8192, ultra.CabTextureSize);
|
||||
Assert.Equal(GraphicsRules.MaxCabTextureSize, ultra.CabTextureSize);
|
||||
Assert.Equal(8192, ultra.ShadowMap);
|
||||
Assert.Equal(600, ultra.ShadowRange);
|
||||
Assert.Equal(GraphicsRules.MaxShadowRange, ultra.ShadowRange);
|
||||
Assert.Equal(Steps.Anisotropy.Max(), ultra.Anisotropy);
|
||||
Assert.Equal(AntiAliasingMode.Msaa8, ultra.AntiAliasing);
|
||||
Assert.Equal(Steps.ReflectionUpdates.Max(), ultra.ReflectionsRate);
|
||||
Assert.Equal(SliderRanges.ReflectionUpdates.Max(), ultra.ReflectionsRate);
|
||||
Assert.Equal(4, ultra.SmokeFidelity);
|
||||
Assert.Equal(4, ultra.SplineFidelity);
|
||||
Assert.Equal(200, ultra.BufferScale);
|
||||
Assert.Equal(Top(GraphicsPreset.DrawRangeKey), ultra.DrawRange);
|
||||
Assert.Equal(Top(GraphicsPreset.DistanceFactorKey), ultra.DistanceFactor);
|
||||
Assert.Equal(Top(GraphicsPreset.SleeperKey), ultra.SleeperDistance);
|
||||
Assert.Equal(Steps.DrawRangeFactors.Max(), ultra.DrawRangeFactor);
|
||||
Assert.Equal(Top(GraphicsPreset.ReflectedInstancesKey), ultra.ReflectedInstances);
|
||||
Assert.Equal(Top(GraphicsPreset.ReflectedVehiclesKey), ultra.ReflectedVehicles);
|
||||
Assert.Equal(SliderRanges.DrawRangeFactors.Max(), ultra.DrawRangeFactor);
|
||||
Assert.Equal(100, ultra.CabShadowsRange);
|
||||
|
||||
var extras = ultra.Extras!;
|
||||
Assert.Equal(200, extras.PythonUpdateMs);
|
||||
Assert.True(extras.MotionBlur && extras.ChromaticAberration && extras.Smoke);
|
||||
|
||||
var top = ultra.Top!;
|
||||
Assert.Equal(Top(GraphicsTop.ScreenWindowFpsKey), top.ScreenWindowFps);
|
||||
Assert.True(top.Screens && top.ScreenMipmaps && top.Sky && top.Cab && top.AirCouplers && top.SmoothTraction);
|
||||
Assert.True(ultra.Top!.Screens);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void At_ultra_what_would_only_take_away_is_off()
|
||||
public void No_level_goes_past_what_the_old_starter_gave()
|
||||
{
|
||||
var top = GraphicsPreset.Ultra.Top!;
|
||||
foreach (var preset in GraphicsPreset.All)
|
||||
{
|
||||
Assert.True(preset.ShadowRange <= GraphicsRules.MaxShadowRange, preset.NameKey);
|
||||
Assert.True(preset.CabTextureSize <= GraphicsRules.MaxCabTextureSize, preset.NameKey);
|
||||
}
|
||||
}
|
||||
|
||||
// The longest shadows, the bottom of that scale.
|
||||
Assert.Equal(0.2, top.ShadowAngleLimit);
|
||||
Assert.Equal(0, top.TargetFps);
|
||||
Assert.Equal(0, top.TextureRelease);
|
||||
Assert.False(top.CompressTextures);
|
||||
Assert.False(top.SkipDecor);
|
||||
[Fact]
|
||||
public void No_level_sets_what_only_the_advanced_mode_shows()
|
||||
{
|
||||
var set = GraphicsPreset.Keys.Concat(GraphicsExtras.Keys).Concat(GraphicsTop.Keys).ToList();
|
||||
|
||||
// The rows of keys by name, the buffer and the resources are all the advanced mode's.
|
||||
Assert.Empty(set.Intersect(SimulatorKeys.All.Select(key => key.Key)));
|
||||
Assert.Empty(set.Intersect(new[] { "starter.bufferscale", "gfx.framebuffer.width", "gfx.framebuffer.height",
|
||||
"compresstex", "python.mipmaps", "gfx.skippipeline" }));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_level_leaves_what_only_the_advanced_mode_shows_as_it_is()
|
||||
{
|
||||
foreach (var preset in GraphicsPreset.All)
|
||||
{
|
||||
var settings = Defaults().Copy();
|
||||
settings.BufferScalePercent = 80;
|
||||
settings.CompressTextures = false;
|
||||
settings.ScreenMipmaps = false;
|
||||
settings.Extra["basedrawrange"] = "3000";
|
||||
settings.Extra["targetfps"] = "60";
|
||||
|
||||
preset.ApplyTo(settings);
|
||||
|
||||
Assert.Equal(80, settings.BufferScalePercent);
|
||||
Assert.False(settings.CompressTextures);
|
||||
Assert.False(settings.ScreenMipmaps);
|
||||
Assert.Equal("3000", settings.Extra["basedrawrange"]);
|
||||
Assert.Equal("60", settings.Extra["targetfps"]);
|
||||
Assert.Same(preset, GraphicsPreset.Matching(settings));
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void At_ultra_the_shadows_are_longest()
|
||||
{
|
||||
// The bottom of that scale.
|
||||
Assert.Equal(0.2, GraphicsPreset.Ultra.Top!.ShadowAngleLimit);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -304,16 +240,14 @@ public class GraphicsPresetTests
|
||||
var settings = Defaults().Copy();
|
||||
settings.ShadowAngleLimit = 0.8;
|
||||
settings.IgnoreIrrelevantTrains = true;
|
||||
settings.Extra[GraphicsTop.TargetFpsKey] = "60";
|
||||
settings.Extra[GraphicsTop.TextureReleaseKey] = "2";
|
||||
settings.PythonScreens = false;
|
||||
|
||||
GraphicsPreset.Ultra.ApplyTo(settings);
|
||||
|
||||
Assert.Same(GraphicsPreset.Ultra, GraphicsPreset.Matching(settings));
|
||||
Assert.Equal(0.2, settings.ShadowAngleLimit);
|
||||
Assert.False(settings.IgnoreIrrelevantTrains);
|
||||
Assert.Equal("0", settings.Extra[GraphicsTop.TargetFpsKey]);
|
||||
Assert.Equal("0", settings.Extra[GraphicsTop.TextureReleaseKey]);
|
||||
Assert.True(settings.PythonScreens);
|
||||
Assert.True(settings.IgnoreIrrelevantTrains);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -335,12 +269,12 @@ public class GraphicsPresetTests
|
||||
{
|
||||
var settings = Defaults().Copy();
|
||||
settings.IgnoreIrrelevantTrains = true;
|
||||
settings.Extra[GraphicsTop.TargetFpsKey] = "60";
|
||||
settings.ShadowAngleLimit = 0.8;
|
||||
|
||||
preset.ApplyTo(settings);
|
||||
|
||||
Assert.True(settings.IgnoreIrrelevantTrains, preset.NameKey);
|
||||
Assert.Equal("60", settings.Extra[GraphicsTop.TargetFpsKey]);
|
||||
Assert.Equal(0.8, settings.ShadowAngleLimit);
|
||||
Assert.Same(preset, GraphicsPreset.Matching(settings));
|
||||
}
|
||||
}
|
||||
@@ -352,26 +286,11 @@ public class GraphicsPresetTests
|
||||
GraphicsPreset.Ultra.ApplyTo(settings);
|
||||
Assert.Same(GraphicsPreset.Ultra, GraphicsPreset.Matching(settings));
|
||||
|
||||
settings.Extra[GraphicsPreset.ReflectedVehiclesKey] = "250";
|
||||
settings.ReflectionsFramerate = 25;
|
||||
|
||||
Assert.Null(GraphicsPreset.Matching(settings));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void No_level_asks_for_a_range_the_renderer_would_raise_anyway()
|
||||
{
|
||||
Assert.All(GraphicsPreset.All, preset => Assert.True(preset.DrawRange >= 2000, preset.NameKey));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_view_only_shortens_going_down_the_levels()
|
||||
{
|
||||
var factors = GraphicsPreset.All.Select(preset => preset.DistanceFactor).ToList();
|
||||
|
||||
Assert.Equal(factors.OrderBy(factor => factor), factors);
|
||||
Assert.Equal(1, GraphicsPreset.High.DistanceFactor);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Shadows_reach_further_with_every_level_that_has_them()
|
||||
{
|
||||
@@ -405,29 +324,17 @@ public class GraphicsPresetTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Every_level_sets_the_buffer_and_is_not_recognised_with_another()
|
||||
public void Every_level_is_within_what_the_sliders_offer()
|
||||
{
|
||||
foreach (var preset in GraphicsPreset.All)
|
||||
{
|
||||
var settings = Defaults().Copy();
|
||||
settings.BufferScalePercent = 120;
|
||||
|
||||
preset.ApplyTo(settings);
|
||||
Assert.Equal(preset.BufferScale, settings.BufferScalePercent);
|
||||
|
||||
settings.BufferScalePercent = 120;
|
||||
Assert.Null(GraphicsPreset.Matching(settings));
|
||||
Assert.True(preset.TextureSize >= SliderRanges.MinTextureSize, preset.NameKey);
|
||||
Assert.True(preset.ShadowMap >= SliderRanges.MinShadowMap, preset.NameKey);
|
||||
Assert.True(preset.DynamicLights >= SliderRanges.MinDynamicLights, preset.NameKey);
|
||||
Assert.Contains(preset.ReflectionsRate, SliderRanges.ReflectionUpdates);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_buffer_is_the_screen_at_high_and_climbs_through_it()
|
||||
{
|
||||
Assert.Equal(100, GraphicsPreset.High.BufferScale);
|
||||
Assert.Equal(200, GraphicsPreset.Ultra.BufferScale);
|
||||
Assert.InRange(GraphicsPreset.Minimal.BufferScale, 50, 100);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_lowest_level_is_not_recognised_with_one_of_its_extras_undone()
|
||||
{
|
||||
@@ -453,14 +360,13 @@ public class GraphicsPresetTests
|
||||
{
|
||||
var settings = Defaults().Copy();
|
||||
settings.MotionBlur = false;
|
||||
settings.Extra[GraphicsTop.TargetFpsKey] = "60";
|
||||
settings.ShadowAngleLimit = 0.8;
|
||||
|
||||
var applied = new GraphicsPresetMemory().Apply(GraphicsPreset.Medium, settings);
|
||||
|
||||
Assert.Same(GraphicsPreset.Medium, GraphicsPreset.Matching(settings));
|
||||
Assert.False(settings.MotionBlur);
|
||||
Assert.Equal("60", settings.Extra[GraphicsTop.TargetFpsKey]);
|
||||
Assert.Equal(GraphicsPreset.RowKeys, applied.RowKeys);
|
||||
Assert.Equal(0.8, settings.ShadowAngleLimit);
|
||||
Assert.Equal(GraphicsPreset.Keys, applied.ChosenKeys);
|
||||
}
|
||||
|
||||
@@ -474,14 +380,12 @@ public class GraphicsPresetTests
|
||||
|
||||
var entering = memory.Apply(GraphicsPreset.Minimal, settings);
|
||||
Assert.Equal(GraphicsPreset.Minimal.Extras, GraphicsExtras.Of(settings));
|
||||
Assert.Equal(GraphicsPreset.RowKeys, entering.RowKeys);
|
||||
Assert.Equal(GraphicsPreset.Keys.Concat(GraphicsExtras.Keys), entering.ChosenKeys);
|
||||
|
||||
var leaving = memory.Apply(GraphicsPreset.Medium, settings);
|
||||
|
||||
Assert.Equal(before, GraphicsExtras.Of(settings));
|
||||
Assert.Same(GraphicsPreset.Medium, GraphicsPreset.Matching(settings));
|
||||
Assert.Equal(GraphicsPreset.RowKeys, leaving.RowKeys);
|
||||
Assert.Equal(GraphicsPreset.Keys.Concat(GraphicsExtras.Keys), leaving.ChosenKeys);
|
||||
}
|
||||
|
||||
@@ -492,7 +396,6 @@ public class GraphicsPresetTests
|
||||
var settings = Defaults().Copy();
|
||||
settings.MotionBlur = false;
|
||||
settings.ShadowAngleLimit = 0.8;
|
||||
settings.Extra[GraphicsTop.TargetFpsKey] = "60";
|
||||
var extras = GraphicsExtras.Of(settings);
|
||||
var top = GraphicsTop.Of(settings);
|
||||
|
||||
@@ -502,7 +405,6 @@ public class GraphicsPresetTests
|
||||
Assert.Equal(extras, GraphicsExtras.Of(settings));
|
||||
Assert.Equal(top, GraphicsTop.Of(settings));
|
||||
Assert.Same(GraphicsPreset.VeryHigh, GraphicsPreset.Matching(settings));
|
||||
Assert.Equal(GraphicsPreset.RowKeys.Concat(GraphicsTop.RowKeys), applied.RowKeys);
|
||||
Assert.Equal(GraphicsPreset.Keys.Concat(GraphicsExtras.Keys).Concat(GraphicsTop.Keys), applied.ChosenKeys);
|
||||
}
|
||||
|
||||
@@ -512,12 +414,11 @@ public class GraphicsPresetTests
|
||||
var settings = Defaults().Copy();
|
||||
GraphicsPreset.Ultra.ApplyTo(settings);
|
||||
|
||||
var applied = new GraphicsPresetMemory().Apply(GraphicsPreset.Low, settings);
|
||||
new GraphicsPresetMemory().Apply(GraphicsPreset.Low, settings);
|
||||
|
||||
Assert.Equal(GraphicsExtras.None, GraphicsExtras.Of(settings));
|
||||
Assert.Equal(GraphicsTop.None, GraphicsTop.Of(settings));
|
||||
Assert.Same(GraphicsPreset.Low, GraphicsPreset.Matching(settings));
|
||||
Assert.Equal(GraphicsPreset.RowKeys.Concat(GraphicsTop.RowKeys), applied.RowKeys);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -526,19 +427,18 @@ public class GraphicsPresetTests
|
||||
var memory = new GraphicsPresetMemory();
|
||||
var settings = Defaults().Copy();
|
||||
settings.MotionBlur = false;
|
||||
settings.ShadowAngleLimit = 0.8;
|
||||
var extras = GraphicsExtras.Of(settings);
|
||||
var top = GraphicsTop.Of(settings);
|
||||
|
||||
memory.Apply(GraphicsPreset.Minimal, settings);
|
||||
var toUltra = memory.Apply(GraphicsPreset.Ultra, settings);
|
||||
memory.Apply(GraphicsPreset.Ultra, settings);
|
||||
Assert.Same(GraphicsPreset.Ultra, GraphicsPreset.Matching(settings));
|
||||
Assert.Equal(GraphicsPreset.RowKeys.Concat(GraphicsTop.RowKeys), toUltra.RowKeys);
|
||||
|
||||
var toMinimal = memory.Apply(GraphicsPreset.Minimal, settings);
|
||||
memory.Apply(GraphicsPreset.Minimal, settings);
|
||||
Assert.Same(GraphicsPreset.Minimal, GraphicsPreset.Matching(settings));
|
||||
// Ultra's own values go, Minimal has no say over them.
|
||||
Assert.Equal(top, GraphicsTop.Of(settings));
|
||||
Assert.Equal(GraphicsPreset.RowKeys.Concat(GraphicsTop.RowKeys), toMinimal.RowKeys);
|
||||
|
||||
memory.Apply(GraphicsPreset.Medium, settings);
|
||||
Assert.Equal(extras, GraphicsExtras.Of(settings));
|
||||
@@ -560,7 +460,6 @@ public class GraphicsPresetTests
|
||||
var applied = memory.Apply(GraphicsPreset.High, settings);
|
||||
|
||||
Assert.True(settings.MotionBlur);
|
||||
Assert.Equal(GraphicsPreset.RowKeys, applied.RowKeys);
|
||||
Assert.Equal(GraphicsPreset.Keys, applied.ChosenKeys);
|
||||
}
|
||||
|
||||
@@ -596,33 +495,15 @@ public class GraphicsPresetTests
|
||||
[Fact]
|
||||
public void Every_level_sits_on_the_steps_the_screen_offers()
|
||||
{
|
||||
void OnSteps(double value, string name)
|
||||
{
|
||||
var key = SimulatorKeys.Named(name);
|
||||
Assert.InRange(value, key.Minimum, key.Maximum);
|
||||
double steps = value / key.Step;
|
||||
Assert.Equal(Math.Round(steps), steps, 6);
|
||||
}
|
||||
|
||||
foreach (var preset in GraphicsPreset.All)
|
||||
{
|
||||
OnSteps(preset.DistanceFactor, GraphicsPreset.DistanceFactorKey);
|
||||
OnSteps(preset.DrawRange, GraphicsPreset.DrawRangeKey);
|
||||
OnSteps(preset.SleeperDistance, GraphicsPreset.SleeperKey);
|
||||
OnSteps(preset.ReflectedInstances, GraphicsPreset.ReflectedInstancesKey);
|
||||
OnSteps(preset.ReflectedVehicles, GraphicsPreset.ReflectedVehiclesKey);
|
||||
Assert.InRange(preset.NewRenderer.CabProbeInterval, 1, 120);
|
||||
Assert.InRange(preset.NewRenderer.GrassDistance, 20, 300);
|
||||
Assert.Equal(0, preset.NewRenderer.GrassDistance % 10);
|
||||
Assert.Equal(0, preset.NewRenderer.GrassDensity % 0.25);
|
||||
Assert.Contains(preset.NewRenderer.Precipitation, new[] { 16384, 32768, 65536, 131072, 262144 });
|
||||
Assert.True(Steps.IndexOf(Steps.Anisotropy, preset.Anisotropy) >= 0, preset.NameKey);
|
||||
Assert.True(Steps.IndexOf(Steps.ReflectionUpdates, preset.ReflectionsRate) >= 0, preset.NameKey);
|
||||
Assert.True(Steps.IndexOf(Steps.DrawRangeFactors, preset.DrawRangeFactor) >= 0, preset.NameKey);
|
||||
Assert.True(Steps.IndexOf(SliderRanges.ReflectionUpdates, preset.ReflectionsRate) >= 0, preset.NameKey);
|
||||
Assert.True(Steps.IndexOf(SliderRanges.DrawRangeFactors, preset.DrawRangeFactor) >= 0, preset.NameKey);
|
||||
foreach (int size in new[] { preset.TextureSize, preset.CabTextureSize, preset.ShadowMap })
|
||||
Assert.True(size is >= 512 and <= 8192 && (size & (size - 1)) == 0, preset.NameKey);
|
||||
Assert.True(preset.ShadowRange >= SimulatorSettings.ShadowRangeFloor(preset.ShadowMap), preset.NameKey);
|
||||
Assert.Equal(0, preset.CabShadowsRange % 10);
|
||||
Assert.True(Steps.IndexOf(SliderRanges.CabShadowRanges, preset.CabShadowsRange) >= 0, preset.NameKey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -637,7 +518,7 @@ public class GraphicsPresetTests
|
||||
|
||||
Assert.Equal(inGroups.Distinct(), inGroups);
|
||||
Assert.Empty(inGroups.Except(GraphicsPreset.Keys).Except(GraphicsExtras.Keys).Except(GraphicsTop.Keys));
|
||||
Assert.Equal(new[] { "gfx.antialiasing", "gfx.buffer.percent", "gfx.extraeffects", "gfx.postfx.bloom", "multisampling", "starter.bufferscale" },
|
||||
Assert.Equal(new[] { "dynamiclights", "gfx.extraeffects", "gfx.smoke.fidelity", "multisampling" },
|
||||
GraphicsPreset.Keys.Except(inGroups).OrderBy(key => key, StringComparer.Ordinal));
|
||||
}
|
||||
|
||||
@@ -669,27 +550,22 @@ public class GraphicsPresetTests
|
||||
GraphicsPreset.Ultra.ApplyTo(settings);
|
||||
|
||||
Assert.All(Groups().LevelsOf(settings).Values, level => Assert.Same(GraphicsPreset.Ultra, level));
|
||||
|
||||
// The row of a key at the simulator's own value leaves it out of the file.
|
||||
settings.Extra.Remove(GraphicsTop.TextureReleaseKey);
|
||||
|
||||
Assert.Same(GraphicsPreset.Ultra, Groups().LevelsOf(settings)[GraphicsGroup.Textures]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_part_moved_by_hand_is_at_no_level_and_the_others_keep_theirs()
|
||||
{
|
||||
var settings = AtHigh();
|
||||
settings.DynamicLights = 6;
|
||||
settings.ReflectionsFidelity = 0;
|
||||
|
||||
var levels = Groups().LevelsOf(settings);
|
||||
|
||||
Assert.Null(levels[GraphicsGroup.Lights]);
|
||||
Assert.Null(levels[GraphicsGroup.Reflections]);
|
||||
Assert.Same(GraphicsPreset.High, levels[GraphicsGroup.Shadows]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Every_part_at_a_level_and_the_buffer_with_it_is_that_level()
|
||||
public void Every_part_at_a_level_and_the_rest_with_it_is_that_level()
|
||||
{
|
||||
var groups = Groups();
|
||||
foreach (var level in GraphicsPreset.All.Where(level => level.Extras is null))
|
||||
@@ -697,8 +573,9 @@ public class GraphicsPresetTests
|
||||
var settings = Defaults().Copy();
|
||||
foreach (var group in GraphicsGroup.All)
|
||||
settings = groups.Apply(group, level, settings);
|
||||
settings.BufferScalePercent = level.BufferScale;
|
||||
settings.AntiAliasing = level.AntiAliasing;
|
||||
settings.DynamicLights = level.DynamicLights;
|
||||
settings.SmokeFidelity = level.SmokeFidelity;
|
||||
|
||||
Assert.Same(level, GraphicsPreset.Matching(settings));
|
||||
}
|
||||
@@ -718,14 +595,15 @@ public class GraphicsPresetTests
|
||||
{
|
||||
var groups = Groups();
|
||||
var settings = AtHigh();
|
||||
settings.ShadowAngleLimit = 0.8;
|
||||
|
||||
var ultra = groups.Apply(GraphicsGroup.Textures, GraphicsPreset.Ultra, settings);
|
||||
Assert.False(ultra.CompressTextures);
|
||||
Assert.Same(GraphicsPreset.Ultra, groups.LevelsOf(ultra)[GraphicsGroup.Textures]);
|
||||
var ultra = groups.Apply(GraphicsGroup.Shadows, GraphicsPreset.Ultra, settings);
|
||||
Assert.Equal(0.2, ultra.ShadowAngleLimit);
|
||||
Assert.Same(GraphicsPreset.Ultra, groups.LevelsOf(ultra)[GraphicsGroup.Shadows]);
|
||||
|
||||
var back = groups.Apply(GraphicsGroup.Textures, GraphicsPreset.High, ultra);
|
||||
Assert.Equal(GraphicsTop.None.CompressTextures, back.CompressTextures);
|
||||
Assert.Same(GraphicsPreset.High, groups.LevelsOf(back)[GraphicsGroup.Textures]);
|
||||
var back = groups.Apply(GraphicsGroup.Shadows, GraphicsPreset.High, ultra);
|
||||
Assert.Equal(GraphicsTop.None.ShadowAngleLimit, back.ShadowAngleLimit);
|
||||
Assert.Same(GraphicsPreset.High, groups.LevelsOf(back)[GraphicsGroup.Shadows]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -736,8 +614,9 @@ public class GraphicsPresetTests
|
||||
|
||||
settings.Smoke = false;
|
||||
|
||||
var nature = Groups().Apply(GraphicsGroup.Nature, GraphicsPreset.VeryHigh, settings);
|
||||
Assert.False(nature.Smoke);
|
||||
Assert.Equal(GraphicsPreset.VeryHigh.SmokeFidelity, nature.SmokeFidelity);
|
||||
var shadows = Groups().Apply(GraphicsGroup.Shadows, GraphicsPreset.VeryHigh, settings);
|
||||
Assert.False(shadows.Smoke);
|
||||
Assert.False(shadows.MotionBlur);
|
||||
Assert.Equal(GraphicsPreset.VeryHigh.ShadowMap, shadows.ShadowMapResolution);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,17 +17,17 @@ public class GraphicsSettingsTests
|
||||
return installation;
|
||||
}
|
||||
|
||||
private static SimulatorSettings Read(string text, bool dlssPlatform = true)
|
||||
private static SimulatorSettings Read(string text)
|
||||
{
|
||||
var s = new SimulatorSettings();
|
||||
new SettingsSerializer(dlssPlatform).Read(s, ConfigFile.Parse(text));
|
||||
new SettingsSerializer().Read(s, ConfigFile.Parse(text));
|
||||
return s;
|
||||
}
|
||||
|
||||
private static string Write(SimulatorSettings s, string text = "", bool dlssPlatform = true)
|
||||
private static string Write(SimulatorSettings s, string text = "")
|
||||
{
|
||||
var c = ConfigFile.Parse(text);
|
||||
new SettingsSerializer(dlssPlatform).Write(s, c);
|
||||
new SettingsSerializer().Write(s, c);
|
||||
return c.ToText();
|
||||
}
|
||||
|
||||
@@ -37,63 +37,54 @@ public class GraphicsSettingsTests
|
||||
private static string? Line(string text, string key) =>
|
||||
Lines(text).FirstOrDefault(l => l == key || l.StartsWith(key + " ", StringComparison.Ordinal));
|
||||
|
||||
// As application.cpp on master has them: a word it does not know gets the full renderer.
|
||||
[Theory]
|
||||
[InlineData("full", GraphicsBackend.OpenGL)]
|
||||
[InlineData("default", GraphicsBackend.OpenGL)]
|
||||
[InlineData("gl46", GraphicsBackend.OpenGL)]
|
||||
[InlineData("legacy", GraphicsBackend.OpenGL)]
|
||||
[InlineData("experimental", GraphicsBackend.OpenGL)]
|
||||
[InlineData("vulkan", GraphicsBackend.Vulkan)]
|
||||
[InlineData("vulkan14", GraphicsBackend.Vulkan)]
|
||||
public void The_renderer_is_read_with_the_aliases_the_simulator_takes(string value, GraphicsBackend expected)
|
||||
{
|
||||
Assert.Equal(expected, Read($"gfxrenderer {value}\n").Backend);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("full", "full")]
|
||||
[InlineData("gl46", "full")]
|
||||
[InlineData("default", "default")]
|
||||
[InlineData("full", "default")]
|
||||
[InlineData("gl46", "default")]
|
||||
[InlineData("vulkan", "default")]
|
||||
[InlineData("vulkan14", "default")]
|
||||
[InlineData("legacy", "legacy")]
|
||||
[InlineData("simpleshader", "legacy")]
|
||||
[InlineData("off", "legacy")]
|
||||
[InlineData("simple", "simple")]
|
||||
[InlineData("experimental", "experimental")]
|
||||
[InlineData("vulkan14", "vulkan")]
|
||||
public void A_renderer_is_written_by_its_name(string read, string written)
|
||||
[InlineData("experimental", "default")]
|
||||
public void A_renderer_is_written_by_the_name_master_knows(string read, string written)
|
||||
{
|
||||
Assert.Equal($"gfxrenderer {written}", Line(Write(Read($"gfxrenderer {read}\n")), "gfxrenderer"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Without_a_renderer_in_the_file_the_full_one_is_chosen()
|
||||
{
|
||||
Assert.Equal(0, Read("").RenderEngine);
|
||||
Assert.Equal("gfxrenderer default", Line(Write(Read("")), "gfxrenderer"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void An_older_renderer_stays_chosen_and_can_be_chosen_again()
|
||||
{
|
||||
var installation = WithIni("gfxrenderer legacy\n");
|
||||
var store = installation.SettingsStore;
|
||||
|
||||
store.Settings.Clouds = 3;
|
||||
store.Settings.FieldOfView = 50;
|
||||
store.Save();
|
||||
Assert.Contains("gfxrenderer legacy", installation.Files.ReadAllText(UserIni));
|
||||
|
||||
store.Settings.RenderEngine = SimulatorSettings.VulkanEngine;
|
||||
store.Save();
|
||||
Assert.Contains("gfxrenderer vulkan", installation.Files.ReadAllText(UserIni));
|
||||
Assert.Equal(GraphicsBackend.Vulkan, store.Settings.Backend);
|
||||
|
||||
store.Settings.RenderEngine = SimulatorSettings.RenderEngineOf("simple");
|
||||
store.Save();
|
||||
Assert.Contains("gfxrenderer simple", installation.Files.ReadAllText(UserIni));
|
||||
Assert.Equal(GraphicsBackend.OpenGL, store.Settings.Backend);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Keys_only_an_older_simulator_reads_stay_in_the_file()
|
||||
public void Keys_only_the_legacy_renderer_or_windows_read_stay_in_the_file()
|
||||
{
|
||||
string[] old =
|
||||
{
|
||||
"usevbo no", "gfx.angleplatform vulkan", "gfx.usegles yes",
|
||||
"gfx.framebuffer.width 1920", "gfx.framebuffer.height 1080", "gfx.shadows.cab.range 20"
|
||||
"usevbo no", "gfx.angleplatform vulkan", "gfx.usegles yes", "gfx.shadows.cab.range 20"
|
||||
};
|
||||
var installation = WithIni(string.Join("\n", old) + "\n");
|
||||
installation.SettingsStore.Settings.Clouds = 3;
|
||||
installation.SettingsStore.Settings.FieldOfView = 50;
|
||||
|
||||
installation.SettingsStore.Save();
|
||||
|
||||
@@ -101,6 +92,24 @@ public class GraphicsSettingsTests
|
||||
Assert.All(old, line => Assert.Contains(line, saved));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Keys_of_the_vulkan_renderer_master_does_not_have_go_on_a_save()
|
||||
{
|
||||
string[] vulkan =
|
||||
{
|
||||
"gfx.antialiasing dlss", "gfx.dlss.preset k", "gfx.framegeneration x2", "gfx.reflex on",
|
||||
"gfx.raytracing yes", "gfx.ssr high", "gfx.postfx.ao gtao", "gfx.clouds ultra", "gfx.grass yes",
|
||||
"gfx.buffer.percent 0.67", "gfx.vulkan.device RTX", "gfx.fog yes", "gfx.cabprobe medium"
|
||||
};
|
||||
var installation = WithIni("calibratein 0 0 0 0\n" + string.Join("\n", vulkan) + "\n");
|
||||
|
||||
installation.SettingsStore.Save();
|
||||
|
||||
string saved = installation.Files.ReadAllText(UserIni);
|
||||
Assert.Contains("calibratein 0 0 0 0", saved);
|
||||
Assert.All(vulkan, line => Assert.Null(Line(saved, line.Split(' ')[0])));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Levels_leave_the_switches_only_an_older_simulator_reads()
|
||||
{
|
||||
@@ -111,160 +120,26 @@ public class GraphicsSettingsTests
|
||||
Assert.Equal((false, true, true), (s.UseVbo, s.UseGLES, s.RenderAngleVulkan));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_new_graphics_keys_are_read()
|
||||
[Theory]
|
||||
[InlineData("multisampling 0\n", AntiAliasingMode.Off)]
|
||||
[InlineData("multisampling 1\n", AntiAliasingMode.Msaa2)]
|
||||
[InlineData("multisampling 2\n", AntiAliasingMode.Msaa4)]
|
||||
[InlineData("multisampling 3\n", AntiAliasingMode.Msaa8)]
|
||||
[InlineData("", AntiAliasingMode.Msaa4)]
|
||||
public void Multisampling_is_read_as_master_reads_it(string text, AntiAliasingMode expected)
|
||||
{
|
||||
var s = Read("gfxrenderer vulkan\n" +
|
||||
"gfx.antialiasing dlss\ngfx.dlss.preset K\ngfx.framegeneration x3\ngfx.reflex boost\n" +
|
||||
"gfx.raytracing yes\ngfx.raytracing.range 800\ngfx.ssr high\ngfx.postfx.ao ssao\ngfx.postfx.ao.quality 4 6\n" +
|
||||
"gfx.lights.shadows low\ngfx.contactshadows 3\ngfx.fog analytic\ngfx.fog.quality ultra\n" +
|
||||
"gfx.clouds ultra\ngfx.clouds.shadows no\ngfx.grass no\ngfx.grass.distance 120\ngfx.grass.density 1.5\n" +
|
||||
"gfx.buffer.percent 0.67\ngfx.vulkan.device RTX\n");
|
||||
|
||||
Assert.Equal(GraphicsBackend.Vulkan, s.Backend);
|
||||
Assert.Equal(AntiAliasingMode.Dlss, s.AntiAliasing);
|
||||
Assert.Equal("k", s.DlssPreset);
|
||||
Assert.Equal(3, s.FrameGeneration);
|
||||
Assert.Equal(2, s.Reflex);
|
||||
Assert.True(s.RayTracing);
|
||||
Assert.Equal(800, s.RayTracingRange);
|
||||
Assert.Equal(3, s.Ssr);
|
||||
Assert.Equal(1, s.AmbientOcclusion);
|
||||
Assert.Equal((4, 6), (s.AoSlices, s.AoSteps));
|
||||
Assert.Equal(1, s.LightShadows);
|
||||
Assert.Equal(3, s.ContactShadows);
|
||||
Assert.False(s.VolumetricFog);
|
||||
Assert.Equal(4, s.FogQuality);
|
||||
Assert.Equal(4, s.Clouds);
|
||||
Assert.False(s.CloudShadows);
|
||||
Assert.False(s.Grass);
|
||||
Assert.Equal(120, s.GrassDistance);
|
||||
Assert.Equal(1.5, s.GrassDensity);
|
||||
Assert.Equal(67, s.BufferScalePercent);
|
||||
Assert.Equal("RTX", s.VulkanDevice);
|
||||
Assert.Equal(expected, Read(text).AntiAliasing);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Missing_keys_take_the_simulators_defaults()
|
||||
{
|
||||
var s = Read("");
|
||||
|
||||
Assert.Equal(GraphicsBackend.OpenGL, s.Backend);
|
||||
Assert.Equal(AntiAliasingMode.Msaa4, s.AntiAliasing);
|
||||
Assert.Equal(2, s.Ssr);
|
||||
Assert.Equal(2, s.AmbientOcclusion);
|
||||
Assert.Equal(2, s.LightShadows);
|
||||
Assert.Equal(0, s.ContactShadows);
|
||||
Assert.True(s.VolumetricFog);
|
||||
Assert.Equal(2, s.FogQuality);
|
||||
Assert.Equal(2, s.Clouds);
|
||||
Assert.False(s.RayTracing);
|
||||
Assert.Equal(1, s.FrameGeneration);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_tokens_written_are_the_ones_the_simulator_parses()
|
||||
{
|
||||
var s = Read("gfxrenderer vulkan\n");
|
||||
s.AntiAliasing = AntiAliasingMode.Dlaa;
|
||||
s.FrameGeneration = 4;
|
||||
s.Reflex = 1;
|
||||
s.LightShadows = 3;
|
||||
s.ContactShadows = 0;
|
||||
s.Clouds = 4;
|
||||
s.VolumetricFog = false;
|
||||
s.FogQuality = 1;
|
||||
s.AmbientOcclusion = 1;
|
||||
s.Ssr = 2;
|
||||
s.RayTracing = true;
|
||||
|
||||
string text = Write(s);
|
||||
|
||||
Assert.Equal("gfx.antialiasing dlaa", Line(text, "gfx.antialiasing"));
|
||||
Assert.Equal("multisampling 0", Line(text, "multisampling"));
|
||||
Assert.Equal("gfx.framegeneration x4", Line(text, "gfx.framegeneration"));
|
||||
Assert.Equal("gfx.reflex on", Line(text, "gfx.reflex"));
|
||||
Assert.Equal("gfx.lights.shadows high", Line(text, "gfx.lights.shadows"));
|
||||
Assert.Equal("gfx.contactshadows no", Line(text, "gfx.contactshadows"));
|
||||
Assert.Equal("gfx.clouds ultra", Line(text, "gfx.clouds"));
|
||||
Assert.Equal("gfx.fog analytic", Line(text, "gfx.fog"));
|
||||
Assert.Equal("gfx.fog.quality low", Line(text, "gfx.fog.quality"));
|
||||
Assert.Equal("gfx.postfx.ao ssao", Line(text, "gfx.postfx.ao"));
|
||||
Assert.Equal("gfx.ssr medium", Line(text, "gfx.ssr"));
|
||||
Assert.Equal("gfx.raytracing yes", Line(text, "gfx.raytracing"));
|
||||
Assert.Equal("gfx.buffer.percent 100", Line(text, "gfx.buffer.percent"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Msaa_is_written_to_both_keys_for_older_simulators()
|
||||
public void Multisampling_is_written_to_its_own_key_only()
|
||||
{
|
||||
var s = Read("multisampling 1\n");
|
||||
Assert.Equal(AntiAliasingMode.Msaa2, s.AntiAliasing);
|
||||
|
||||
string text = Write(s);
|
||||
|
||||
Assert.Equal("multisampling 1", Line(text, "multisampling"));
|
||||
Assert.Equal("gfx.antialiasing msaax2", Line(text, "gfx.antialiasing"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Of_the_two_anti_aliasing_keys_the_later_one_wins_as_in_the_simulator()
|
||||
{
|
||||
Assert.Equal(AntiAliasingMode.Taa, Read("multisampling 2\ngfx.antialiasing taa\n").AntiAliasing);
|
||||
Assert.Equal(AntiAliasingMode.Msaa4, Read("gfx.antialiasing taa\nmultisampling 2\n").AntiAliasing);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void On_opengl_the_vulkan_only_features_are_written_off()
|
||||
{
|
||||
var s = Read("gfxrenderer full\ngfx.antialiasing dlss\ngfx.framegeneration x2\ngfx.reflex on\ngfx.raytracing yes\n");
|
||||
|
||||
Assert.Equal(AntiAliasingMode.Taa, s.AntiAliasing);
|
||||
Assert.Equal(1, s.FrameGeneration);
|
||||
Assert.Equal(0, s.Reflex);
|
||||
Assert.False(s.RayTracing);
|
||||
|
||||
string text = Write(s);
|
||||
Assert.Equal("gfx.antialiasing taa", Line(text, "gfx.antialiasing"));
|
||||
Assert.Equal("gfx.framegeneration off", Line(text, "gfx.framegeneration"));
|
||||
Assert.Equal("gfx.reflex off", Line(text, "gfx.reflex"));
|
||||
Assert.Equal("gfx.raytracing no", Line(text, "gfx.raytracing"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Frame_generation_needs_dlss_even_on_vulkan()
|
||||
{
|
||||
var s = Read("gfxrenderer vulkan\ngfx.antialiasing taa\ngfx.framegeneration x2\ngfx.reflex on\n");
|
||||
|
||||
Assert.Equal(1, s.FrameGeneration);
|
||||
Assert.Equal(1, s.Reflex);
|
||||
Assert.False(GraphicsRules.ReflexForced(s, true));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Frame_generation_turns_reflex_on()
|
||||
{
|
||||
var s = Read("gfxrenderer vulkan\ngfx.antialiasing dlss\ngfx.framegeneration x2\n");
|
||||
|
||||
Assert.True(GraphicsRules.ReflexForced(s, true));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Without_a_dlss_platform_dlss_falls_back_to_taa()
|
||||
{
|
||||
var s = Read("gfxrenderer vulkan\ngfx.antialiasing dlss\n", dlssPlatform: false);
|
||||
|
||||
Assert.Equal(AntiAliasingMode.Taa, s.AntiAliasing);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Dlaa_ignores_the_render_scale()
|
||||
{
|
||||
var s = Read("gfxrenderer vulkan\ngfx.antialiasing dlaa\n");
|
||||
Assert.False(GraphicsRules.BufferScaleUsed(s, true));
|
||||
|
||||
s.AntiAliasing = AntiAliasingMode.Dlss;
|
||||
Assert.True(GraphicsRules.BufferScaleUsed(s, true));
|
||||
Assert.Null(Line(text, "gfx.antialiasing"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -278,10 +153,23 @@ public class GraphicsSettingsTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_render_scale_reads_the_old_starter_key_when_the_new_one_is_missing()
|
||||
public void The_render_scale_is_the_starters_own_key_or_the_framebuffer_against_the_window()
|
||||
{
|
||||
Assert.Equal(75, Read("starter.bufferscale 75\n").BufferScalePercent);
|
||||
Assert.Equal(50, Read("starter.bufferscale 75\ngfx.buffer.percent 50\n").BufferScalePercent);
|
||||
Assert.Equal(50, Read("width 1920\ngfx.framebuffer.width 960\n").BufferScalePercent);
|
||||
Assert.Equal(100, Read("").BufferScalePercent);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_render_scale_is_written_as_the_framebuffer_master_reads()
|
||||
{
|
||||
var s = Read("width 1920\nheight 1080\nstarter.bufferscale 50\n");
|
||||
|
||||
string text = Write(s);
|
||||
|
||||
Assert.Equal("gfx.framebuffer.width 960", Line(text, "gfx.framebuffer.width"));
|
||||
Assert.Equal("gfx.framebuffer.height 540", Line(text, "gfx.framebuffer.height"));
|
||||
Assert.Null(Line(text, "gfx.buffer.percent"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -312,7 +200,7 @@ public class GraphicsSettingsTests
|
||||
{
|
||||
var s = new SimulatorSettings();
|
||||
GraphicsPreset.High.ApplyTo(s);
|
||||
s.Clouds = 4;
|
||||
s.DynamicLights = 2;
|
||||
|
||||
Assert.Null(GraphicsPreset.Matching(s));
|
||||
}
|
||||
@@ -328,82 +216,62 @@ public class GraphicsSettingsTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Ray_tracing_comes_with_ultra_on_vulkan_only()
|
||||
public void No_level_leaves_decorative_consists_out()
|
||||
{
|
||||
var vulkan = new SimulatorSettings { RenderEngine = SimulatorSettings.VulkanEngine };
|
||||
var opengl = new SimulatorSettings();
|
||||
foreach (var level in GraphicsPreset.All)
|
||||
{
|
||||
var s = new SimulatorSettings { IgnoreIrrelevantTrains = false };
|
||||
level.ApplyTo(s);
|
||||
Assert.False(s.IgnoreIrrelevantTrains, level.NameKey);
|
||||
|
||||
GraphicsPreset.Ultra.ApplyTo(vulkan);
|
||||
GraphicsPreset.Ultra.ApplyTo(opengl);
|
||||
|
||||
Assert.True(vulkan.RayTracing);
|
||||
Assert.False(opengl.RayTracing);
|
||||
Assert.Same(GraphicsPreset.Ultra, GraphicsPreset.Matching(opengl));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_level_keeps_dlss_on_vulkan()
|
||||
{
|
||||
var s = new SimulatorSettings { RenderEngine = SimulatorSettings.VulkanEngine, AntiAliasing = AntiAliasingMode.Dlss };
|
||||
|
||||
GraphicsPreset.Ultra.ApplyTo(s);
|
||||
|
||||
Assert.Equal(AntiAliasingMode.Dlss, s.AntiAliasing);
|
||||
Assert.Same(GraphicsPreset.Ultra, GraphicsPreset.Matching(s));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_level_replaces_taa_with_its_own_multisampling()
|
||||
{
|
||||
var s = new SimulatorSettings { AntiAliasing = AntiAliasingMode.Taa };
|
||||
|
||||
GraphicsPreset.Medium.ApplyTo(s);
|
||||
|
||||
Assert.Equal(AntiAliasingMode.Msaa2, s.AntiAliasing);
|
||||
s.IgnoreIrrelevantTrains = true;
|
||||
level.ApplyTo(s);
|
||||
Assert.True(s.IgnoreIrrelevantTrains, level.NameKey);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void An_import_takes_the_settings_but_keeps_this_installations_simulator_and_the_unmanaged_lines()
|
||||
{
|
||||
var installation = WithIni("starter.exe.auto no\nstarter.exe.path eu07_local.exe\ncalibratein 0 0 0 0\ngfx.clouds low\n");
|
||||
installation.Files.WithFile("/backup/eu07.ini", "starter.exe.auto no\nstarter.exe.path eu07_other.exe\ngfx.clouds ultra\ngfxrenderer vulkan\n");
|
||||
var installation = WithIni("starter.exe.auto no\nstarter.exe.path eu07_local.exe\ncalibratein 0 0 0 0\nfieldofview 45\n");
|
||||
installation.Files.WithFile("/backup/eu07.ini", "starter.exe.auto no\nstarter.exe.path eu07_other.exe\nfieldofview 60\ngfxrenderer legacy\n");
|
||||
|
||||
Assert.True(installation.SettingsStore.ImportFrom("/backup/eu07.ini"));
|
||||
var s = installation.SettingsStore.Settings;
|
||||
Assert.Equal(4, s.Clouds);
|
||||
Assert.Equal(GraphicsBackend.Vulkan, s.Backend);
|
||||
Assert.Equal(60, s.FieldOfView);
|
||||
Assert.Equal(SimulatorSettings.RenderEngineOf("legacy"), s.RenderEngine);
|
||||
Assert.Equal("eu07_local.exe", s.ExecutablePath);
|
||||
|
||||
// Nothing is written until saved, and the save keeps the user's own lines.
|
||||
Assert.Contains("gfx.clouds low", installation.Files.ReadAllText(UserIni));
|
||||
Assert.Contains("fieldofview 45", installation.Files.ReadAllText(UserIni));
|
||||
installation.SettingsStore.Save();
|
||||
string saved = installation.Files.ReadAllText(UserIni);
|
||||
Assert.Contains("calibratein 0 0 0 0", saved);
|
||||
Assert.Contains("gfx.clouds ultra", saved);
|
||||
Assert.Contains("fieldofview 60", saved);
|
||||
Assert.Contains("starter.exe.path eu07_local.exe", saved);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void An_import_of_a_missing_file_changes_nothing()
|
||||
{
|
||||
var installation = WithIni("gfx.clouds low\n");
|
||||
var installation = WithIni("fieldofview 50\n");
|
||||
|
||||
Assert.False(installation.SettingsStore.ImportFrom("/nowhere/eu07.ini"));
|
||||
Assert.Equal(1, installation.SettingsStore.Settings.Clouds);
|
||||
Assert.Equal(50, installation.SettingsStore.Settings.FieldOfView);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void An_export_writes_a_complete_file_elsewhere_and_leaves_the_users_one_alone()
|
||||
{
|
||||
var installation = WithIni("calibratein 0 0 0 0\ngfx.clouds low\n");
|
||||
installation.SettingsStore.Settings.Clouds = 3;
|
||||
var installation = WithIni("calibratein 0 0 0 0\nfieldofview 45\n");
|
||||
installation.SettingsStore.Settings.FieldOfView = 60;
|
||||
|
||||
Assert.True(installation.SettingsStore.ExportTo("/export/eu07.ini"));
|
||||
|
||||
string exported = installation.Files.ReadAllText("/export/eu07.ini");
|
||||
Assert.Contains("calibratein 0 0 0 0", exported);
|
||||
Assert.Contains("gfx.clouds high", exported);
|
||||
Assert.Contains("gfx.clouds low", installation.Files.ReadAllText(UserIni));
|
||||
Assert.Contains("fieldofview 60", exported);
|
||||
Assert.Contains("fieldofview 45", installation.Files.ReadAllText(UserIni));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -417,30 +285,34 @@ public class GraphicsSettingsTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_dlss_libraries_are_looked_for_next_to_a_windows_build()
|
||||
public void The_gamepad_is_ignored_unless_the_file_turns_it_on()
|
||||
{
|
||||
var files = new InMemoryFileSystem()
|
||||
.WithDirectory(TestInstallation.Root)
|
||||
.WithExecutable(TestInstallation.At("eu07.exe"), "MZ binary")
|
||||
.WithFile(TestInstallation.At("nvngx_dlss.dll"), "dll");
|
||||
var installation = new TestInstallation(files);
|
||||
|
||||
Assert.Equal((true, false), installation.Executables.DlssLibraries(TestInstallation.At("eu07.exe")));
|
||||
|
||||
files.WithFile(TestInstallation.At("nvngx_dlssg.dll"), "dll");
|
||||
Assert.Equal((true, true), installation.Executables.DlssLibraries(TestInstallation.At("eu07.exe")));
|
||||
Assert.True(Read("").IgnoreGamepad);
|
||||
Assert.Equal("input.gamepad no", Line(Write(Read("")), "input.gamepad"));
|
||||
Assert.False(Read("input.gamepad yes\n").IgnoreGamepad);
|
||||
Assert.True(Read("input.gamepad no\n").IgnoreGamepad);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_dlss_libraries_of_a_linux_build_are_the_shared_objects()
|
||||
public void The_standard_mode_is_where_a_player_starts_and_the_choice_is_kept()
|
||||
{
|
||||
var files = new InMemoryFileSystem()
|
||||
.WithDirectory(TestInstallation.Root)
|
||||
.WithExecutable(TestInstallation.At("eu07"), "\u007fELF binary")
|
||||
.WithFile(TestInstallation.At("libnvidia-ngx-dlssg.so.310.4.0"), "so");
|
||||
var installation = new TestInstallation(files);
|
||||
Assert.False(Read("").AdvancedSettings);
|
||||
Assert.True(Read("starter.settings.advanced yes\n").AdvancedSettings);
|
||||
|
||||
Assert.Equal((false, true), installation.Executables.DlssLibraries(TestInstallation.At("eu07")));
|
||||
var s = Read("");
|
||||
s.AdvancedSettings = true;
|
||||
Assert.Equal("starter.settings.advanced yes", Line(Write(s), "starter.settings.advanced"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_move_to_the_standard_mode_is_marked_in_the_file()
|
||||
{
|
||||
Assert.False(Read("").MovedToStandard);
|
||||
Assert.True(Read("starter.settings.standard yes\n").MovedToStandard);
|
||||
|
||||
var s = Read("");
|
||||
s.MovedToStandard = true;
|
||||
Assert.Equal("starter.settings.standard yes", Line(Write(s), "starter.settings.standard"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -455,139 +327,4 @@ public class GraphicsSettingsTests
|
||||
c.Set("b", "9");
|
||||
Assert.Equal("b 9\nc 3\na 1\n", c.ToText().Replace("\r\n", "\n"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_ao_lighting_and_cab_probe_keys_survive_a_round_trip_in_the_simulators_form()
|
||||
{
|
||||
var s = Read("gfx.postfx.ao.lighting no\ngfx.cabprobe high\ngfx.cabprobe.interval 12\ngfx.cabprobe.bounce 2.5\ngfx.cabprobe.reflections no\n");
|
||||
|
||||
Assert.False(s.AoLighting);
|
||||
Assert.Equal(3, s.CabProbe);
|
||||
Assert.Equal(12, s.CabProbeInterval);
|
||||
Assert.Equal(2.5, s.CabProbeBounce);
|
||||
Assert.False(s.CabProbeReflections);
|
||||
|
||||
string text = Write(s);
|
||||
Assert.Equal("gfx.postfx.ao.lighting no", Line(text, "gfx.postfx.ao.lighting"));
|
||||
Assert.Equal("gfx.cabprobe high", Line(text, "gfx.cabprobe"));
|
||||
Assert.Equal("gfx.cabprobe.interval 12", Line(text, "gfx.cabprobe.interval"));
|
||||
Assert.Equal("gfx.cabprobe.bounce 2.5", Line(text, "gfx.cabprobe.bounce"));
|
||||
Assert.Equal("gfx.cabprobe.reflections no", Line(text, "gfx.cabprobe.reflections"));
|
||||
|
||||
var again = Read(text);
|
||||
Assert.Equal((s.AoLighting, s.CabProbe, s.CabProbeInterval, s.CabProbeBounce, s.CabProbeReflections),
|
||||
(again.AoLighting, again.CabProbe, again.CabProbeInterval, again.CabProbeBounce, again.CabProbeReflections));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Missing_ao_lighting_and_cab_probe_keys_take_the_simulators_defaults_and_are_written_like_its_export()
|
||||
{
|
||||
var s = Read("");
|
||||
|
||||
Assert.Equal((true, 2, 4, 1.0, true), (s.AoLighting, s.CabProbe, s.CabProbeInterval, s.CabProbeBounce, s.CabProbeReflections));
|
||||
|
||||
string text = Write(s);
|
||||
Assert.Equal("gfx.postfx.ao.lighting yes", Line(text, "gfx.postfx.ao.lighting"));
|
||||
Assert.Equal("gfx.cabprobe medium", Line(text, "gfx.cabprobe"));
|
||||
Assert.Equal("gfx.cabprobe.interval 4", Line(text, "gfx.cabprobe.interval"));
|
||||
Assert.Equal("gfx.cabprobe.bounce 1", Line(text, "gfx.cabprobe.bounce"));
|
||||
Assert.Equal("gfx.cabprobe.reflections yes", Line(text, "gfx.cabprobe.reflections"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Unknown_ao_lighting_and_cab_probe_values_fall_back_to_the_simulators_defaults()
|
||||
{
|
||||
var s = Read("gfx.postfx.ao.lighting maybe\ngfx.cabprobe bogus\ngfx.cabprobe.interval abc\ngfx.cabprobe.bounce x\ngfx.cabprobe.reflections ?\n");
|
||||
|
||||
Assert.Equal((true, 2, 4, 1.0, true), (s.AoLighting, s.CabProbe, s.CabProbeInterval, s.CabProbeBounce, s.CabProbeReflections));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("no", 0)]
|
||||
[InlineData("0", 0)]
|
||||
[InlineData("low", 1)]
|
||||
[InlineData("1", 1)]
|
||||
[InlineData("medium", 2)]
|
||||
[InlineData("yes", 2)]
|
||||
[InlineData("2", 2)]
|
||||
[InlineData("high", 3)]
|
||||
[InlineData("3", 3)]
|
||||
public void The_cab_probe_level_is_read_with_the_aliases_the_simulator_takes(string value, int expected)
|
||||
{
|
||||
Assert.Equal(expected, Read($"gfx.cabprobe {value}\n").CabProbe);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_cab_probe_numbers_are_kept_within_the_simulators_ranges()
|
||||
{
|
||||
var s = Read("gfx.cabprobe.interval 500\ngfx.cabprobe.bounce 9\n");
|
||||
Assert.Equal((120, 4.0), (s.CabProbeInterval, s.CabProbeBounce));
|
||||
|
||||
s = Read("gfx.cabprobe.interval 0\ngfx.cabprobe.bounce -1\n");
|
||||
Assert.Equal((1, 0.0), (s.CabProbeInterval, s.CabProbeBounce));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_ao_lighting_counts_with_gtao_only()
|
||||
{
|
||||
Assert.True(GraphicsRules.AoLightingUsed(Read("gfx.postfx.ao gtao\n")));
|
||||
Assert.False(GraphicsRules.AoLightingUsed(Read("gfx.postfx.ao ssao\n")));
|
||||
Assert.False(GraphicsRules.AoLightingUsed(Read("gfx.postfx.ao no\n")));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("gfx.ssr no\ngfx.contactshadows no\n", true)]
|
||||
[InlineData("gfx.ssr low\ngfx.contactshadows no\n", false)]
|
||||
[InlineData("gfx.ssr no\ngfx.contactshadows low\n", false)]
|
||||
[InlineData("gfx.ssr no\ngfx.contactshadows no\ngfx.depthprepass.scene yes\n", false)]
|
||||
[InlineData("gfx.ssr no\ngfx.contactshadows no\ngfx.postfx.ao.lighting no\n", false)]
|
||||
[InlineData("gfx.ssr no\ngfx.contactshadows no\ngfx.postfx.ao ssao\n", false)]
|
||||
public void The_ao_lighting_adds_the_depth_pass_only_when_nothing_else_draws_it(string text, bool expected)
|
||||
{
|
||||
Assert.Equal(expected, GraphicsRules.AoLightingAddsDepthPrepass(Read(text)));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("gfx.cabprobe medium\n", true, true)]
|
||||
[InlineData("gfx.cabprobe no\n", false, false)]
|
||||
[InlineData("gfx.cabprobe low\ngfx.lights.clustered no\n", true, false)]
|
||||
[InlineData("gfx.cabprobe high\ngfx.lights.cab no\n", true, false)]
|
||||
public void The_cab_probe_lights_the_cab_only_with_its_lamp_as_a_light(string text, bool used, bool lights)
|
||||
{
|
||||
var s = Read(text);
|
||||
|
||||
Assert.Equal(used, GraphicsRules.CabProbeUsed(s));
|
||||
Assert.Equal(lights, GraphicsRules.CabProbeLights(s));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(0, false, 0, 8, false)]
|
||||
[InlineData(1, false, 0, 8, false)]
|
||||
[InlineData(2, false, 1, 8, true)]
|
||||
[InlineData(3, true, 2, 4, true)]
|
||||
[InlineData(4, true, 3, 3, true)]
|
||||
[InlineData(5, true, 3, 2, true)]
|
||||
public void A_level_sets_the_ao_lighting_and_the_cab_probe(int place, bool aoLighting, int probe, int interval, bool reflections)
|
||||
{
|
||||
var level = GraphicsPreset.All[place];
|
||||
var s = new SimulatorSettings { CabProbeBounce = 2.5 };
|
||||
|
||||
level.ApplyTo(s);
|
||||
|
||||
Assert.Equal((aoLighting, probe, interval, reflections), (s.AoLighting, s.CabProbe, s.CabProbeInterval, s.CabProbeReflections));
|
||||
Assert.Equal(2.5, s.CabProbeBounce);
|
||||
Assert.Same(level, GraphicsPreset.Matching(s));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void An_import_keeps_the_lamp_switch_of_the_users_own_file()
|
||||
{
|
||||
var installation = WithIni("gfx.lights.cab no\n");
|
||||
installation.Files.WithFile("/backup/eu07.ini", "gfx.lights.cab yes\ngfx.cabprobe high\n");
|
||||
|
||||
Assert.True(installation.SettingsStore.ImportFrom("/backup/eu07.ini"));
|
||||
|
||||
Assert.False(installation.SettingsStore.Settings.CabLampLight);
|
||||
Assert.Equal(3, installation.SettingsStore.Settings.CabProbe);
|
||||
}
|
||||
}
|
||||
|
||||
61
StarterNG.Tests/MonitorsTests.cs
Normal file
61
StarterNG.Tests/MonitorsTests.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using StarterNG.Infrastructure;
|
||||
|
||||
namespace StarterNG.Tests;
|
||||
|
||||
public class MonitorsTests
|
||||
{
|
||||
[Fact]
|
||||
public void A_monitor_is_named_as_the_simulator_names_it()
|
||||
{
|
||||
Assert.Equal("Generic_PnP_Monitor:1920,0", Monitors.IdOf("Generic PnP Monitor", 1920, 0));
|
||||
Assert.Equal("HDMI-1:-1280,-200", Monitors.IdOf("HDMI-1", -1280, -200));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Xrandr_lists_the_connected_outputs_with_their_place()
|
||||
{
|
||||
const string report =
|
||||
"Screen 0: minimum 320 x 200, current 4480 x 1440, maximum 16384 x 16384\n" +
|
||||
"eDP-1 connected primary 1920x1080+0+360 (normal left inverted right x axis y axis) 344mm x 194mm\n" +
|
||||
" 1920x1080 60.00*+\n" +
|
||||
"HDMI-1 connected 2560x1440+1920+0 (normal left inverted right x axis y axis) 597mm x 336mm\n" +
|
||||
"DP-1 disconnected (normal left inverted right x axis y axis)\n" +
|
||||
"DP-2 connected (normal left inverted right x axis y axis)\n";
|
||||
|
||||
var monitors = Monitors.Parse(report);
|
||||
|
||||
Assert.Equal(2, monitors.Count);
|
||||
Assert.Equal(new DisplayMonitor("eDP-1:0,360", "eDP-1", 1920, 1080, true, 60), monitors[0]);
|
||||
Assert.Equal(new DisplayMonitor("HDMI-1:1920,0", "HDMI-1", 2560, 1440, false), monitors[1]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Xrandr_gives_each_monitor_the_rate_its_mode_runs_at()
|
||||
{
|
||||
const string report =
|
||||
"DP-1 connected primary 2560x1440+0+0 (normal left inverted right x axis y axis) 597mm x 336mm\n" +
|
||||
" 2560x1440 59.95 + 165.08* 143.97\n" +
|
||||
" 1920x1080 60.00 50.00\n" +
|
||||
"HDMI-1 connected 1920x1080+2560+0 (normal left inverted right x axis y axis) 527mm x 296mm\n" +
|
||||
" 1920x1080 60.00*+ 50.00\n" +
|
||||
"DP-2 disconnected (normal left inverted right x axis y axis)\n" +
|
||||
" 1280x1024 75.02*\n";
|
||||
|
||||
var monitors = Monitors.Parse(report);
|
||||
|
||||
Assert.Equal(new[] { 165, 60 }, monitors.Select(m => m.RefreshRate));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_monitor_is_written_only_when_one_is_chosen()
|
||||
{
|
||||
var s = new StarterNG.Domain.Settings.SimulatorSettings();
|
||||
var c = StarterNG.Classes.ConfigFile.Parse("");
|
||||
new StarterNG.Infrastructure.Settings.SettingsSerializer().Write(s, c);
|
||||
Assert.False(c.Has("fullscreenmonitor"));
|
||||
|
||||
s.FullscreenMonitor = "HDMI-1:1920,0";
|
||||
new StarterNG.Infrastructure.Settings.SettingsSerializer().Write(s, c);
|
||||
Assert.Equal("HDMI-1:1920,0", c.GetRaw("fullscreenmonitor"));
|
||||
}
|
||||
}
|
||||
17
StarterNG.Tests/RenderersTests.cs
Normal file
17
StarterNG.Tests/RenderersTests.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using StarterNG.Domain.Settings;
|
||||
|
||||
namespace StarterNG.Tests;
|
||||
|
||||
public class RenderersTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("default", RendererKind.Modern)]
|
||||
[InlineData("full", RendererKind.Modern)]
|
||||
[InlineData("vulkan", RendererKind.Modern)]
|
||||
[InlineData("legacy", RendererKind.Legacy)]
|
||||
[InlineData("simple", RendererKind.Legacy)]
|
||||
[InlineData("simpleshader", RendererKind.Legacy)]
|
||||
[InlineData("OFF", RendererKind.Legacy)]
|
||||
public void A_renderer_word_draws_with_the_renderer_master_gives_it(string word, RendererKind kind) =>
|
||||
Assert.Equal(kind, Renderers.KindOf(word));
|
||||
}
|
||||
@@ -158,14 +158,12 @@ public class ScreenReaderNamesTests
|
||||
var slider = new Slider();
|
||||
var row = new SettingRow { Label = "Ekran", Content = Row(check, slider) };
|
||||
row.Description = "Gra zajmie cały ekran.";
|
||||
row.IdleNote = "Ten symulator nie zna tego ustawienia.";
|
||||
|
||||
Assert.Equal("Gra zajmie cały ekran., Ten symulator nie zna tego ustawienia.", AutomationProperties.GetHelpText(check));
|
||||
Assert.Equal("Gra zajmie cały ekran.", AutomationProperties.GetHelpText(check));
|
||||
Assert.Equal(AutomationProperties.GetHelpText(check), AutomationProperties.GetHelpText(slider));
|
||||
Assert.Null(AutomationProperties.GetName(check));
|
||||
|
||||
row.Description = null;
|
||||
row.IdleNote = null;
|
||||
Assert.Null(AutomationProperties.GetHelpText(check));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,154 +0,0 @@
|
||||
using StarterNG.Domain.Settings;
|
||||
using StarterNG.Tests.Fakes;
|
||||
|
||||
namespace StarterNG.Tests;
|
||||
|
||||
public class SettingReachTests
|
||||
{
|
||||
private static SimulatorTarget Linux(string renderer = "full", bool server = false) =>
|
||||
new(WindowsBuild: false, renderer, server);
|
||||
|
||||
[Theory]
|
||||
[InlineData("feedbackmode")]
|
||||
[InlineData("feedbackport")]
|
||||
[InlineData("showsystemconsole")]
|
||||
[InlineData("gfx.angleplatform")]
|
||||
public void Windows_only_keys_idle_on_a_linux_build(string key)
|
||||
{
|
||||
Assert.Equal(IdleReason.WindowsBuildOnly, SettingReach.Why(key, Linux()));
|
||||
Assert.Equal(IdleReason.None, SettingReach.Why(key, Linux() with { WindowsBuild = true }));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("full", IdleReason.LegacyRendererOnly)]
|
||||
[InlineData("experimental", IdleReason.LegacyRendererOnly)]
|
||||
[InlineData("legacy", IdleReason.None)]
|
||||
[InlineData("simpleshader", IdleReason.None)]
|
||||
[InlineData("simple", IdleReason.None)]
|
||||
public void Legacy_renderer_keys_follow_the_renderer(string renderer, IdleReason expected)
|
||||
{
|
||||
Assert.Equal(expected, SettingReach.Why("smoothtraction", Linux(renderer)));
|
||||
Assert.Equal(expected, SettingReach.Why("usevbo", Linux(renderer)));
|
||||
Assert.Equal(expected, SettingReach.Why("gfx.shadows.cab.range", Linux(renderer)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Pausing_in_the_background_needs_a_network_server()
|
||||
{
|
||||
Assert.Equal(IdleReason.NeedsNetworkServer, SettingReach.Why("inactivepause", Linux()));
|
||||
Assert.Equal(IdleReason.None, SettingReach.Why("inactivepause", Linux(server: true)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_starters_own_keys_never_idle()
|
||||
{
|
||||
Assert.Equal(IdleReason.None, SettingReach.Why("starter.autoclose", Linux()));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("width, height")]
|
||||
[InlineData("fullscreen")]
|
||||
public void The_monitors_own_mode_overrides_size_and_full_screen(string key)
|
||||
{
|
||||
Assert.Equal(IdleReason.MonitorModeInstead,
|
||||
SettingReach.Why(key, Linux() with { FullscreenWindowed = true }));
|
||||
Assert.Equal(IdleReason.None, SettingReach.Why(key, Linux()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void An_ordinary_key_works_everywhere()
|
||||
{
|
||||
Assert.Equal(IdleReason.None, SettingReach.Why("fieldofview", Linux()));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("full", IdleReason.None)]
|
||||
[InlineData("legacy", IdleReason.ModernRendererOnly)]
|
||||
[InlineData("experimental", IdleReason.ModernRendererOnly)]
|
||||
public void Effects_of_the_full_renderer_follow_the_renderer(string renderer, IdleReason expected)
|
||||
{
|
||||
Assert.Equal(expected, SettingReach.Why("gfx.postfx.motionblur.enabled", Linux(renderer)));
|
||||
Assert.Equal(expected, SettingReach.Why("gfx.envmap.enabled", Linux(renderer)));
|
||||
Assert.Equal(expected, SettingReach.Why("sleeperdistance", Linux(renderer)));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("vulkan", IdleReason.None)]
|
||||
[InlineData("vulkan14", IdleReason.None)]
|
||||
[InlineData("full", IdleReason.VulkanOnly)]
|
||||
[InlineData("gl46", IdleReason.VulkanOnly)]
|
||||
[InlineData("legacy", IdleReason.VulkanOnly)]
|
||||
public void What_only_vulkan_reads_follows_the_renderer(string renderer, IdleReason expected)
|
||||
{
|
||||
Assert.Equal(expected, SettingReach.Why("gfx.dlss.preset", Linux(renderer)));
|
||||
Assert.Equal(expected, SettingReach.Why("gfx.framegeneration", Linux(renderer)));
|
||||
Assert.Equal(expected, SettingReach.Why("gfx.raytracing", Linux(renderer)));
|
||||
// Both renderers of the new simulator read this one.
|
||||
Assert.Equal(IdleReason.None, SettingReach.Why("gfx.postfx.ao", Linux(renderer)));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("vulkan")]
|
||||
[InlineData("vulkan14")]
|
||||
[InlineData("opengl")]
|
||||
[InlineData("gl46")]
|
||||
public void The_new_simulators_renderers_read_what_the_full_one_does(string renderer)
|
||||
{
|
||||
Assert.Equal(IdleReason.None, SettingReach.Why("gfx.envmap.enabled", Linux(renderer)));
|
||||
Assert.Equal(IdleReason.None, SettingReach.Why("multisampling", Linux(renderer)));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("full", IdleReason.None)]
|
||||
[InlineData("legacy", IdleReason.None)]
|
||||
[InlineData("experimental", IdleReason.OpenGlRenderersOnly)]
|
||||
public void The_experimental_renderer_passes_over_what_only_opengl_reads(string renderer, IdleReason expected)
|
||||
{
|
||||
Assert.Equal(expected, SettingReach.Why("multisampling", Linux(renderer)));
|
||||
Assert.Equal(expected, SettingReach.Why("anisotropicfiltering", Linux(renderer)));
|
||||
Assert.Equal(expected, SettingReach.Why("gfx.smoke", Linux(renderer)));
|
||||
// ...but reads the rest of the reflections and shadows.
|
||||
Assert.Equal(IdleReason.None, SettingReach.Why("gfx.reflections.fidelity", Linux(renderer)));
|
||||
Assert.Equal(IdleReason.None, SettingReach.Why("shadowtune", Linux(renderer)));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, 0, false)]
|
||||
[InlineData(0.0, 0, false)]
|
||||
[InlineData(60.0, 0, true)]
|
||||
[InlineData(null, 50, true)] // fpsaverage, the older regulator
|
||||
public void The_draw_range_factor_needs_a_regulator(double? targetFps, double fpsAverage, bool regulated)
|
||||
{
|
||||
var target = Linux() with { TargetFps = targetFps, FpsAverage = fpsAverage };
|
||||
|
||||
Assert.Equal(regulated ? IdleReason.None : IdleReason.NeedsFrameRateTarget,
|
||||
SettingReach.Why("gfx.drawrange.factor.max", target));
|
||||
}
|
||||
|
||||
// ── The rest of the target ───────────────────────────────────────────────
|
||||
|
||||
[Fact]
|
||||
public void A_windows_build_is_told_from_its_header()
|
||||
{
|
||||
var files = new InMemoryFileSystem()
|
||||
.WithExecutable(TestInstallation.At("eu07"), "\u007fELF binary")
|
||||
.WithFile(TestInstallation.At("eu07.exe"), "MZ binary");
|
||||
var installation = new TestInstallation(files);
|
||||
|
||||
Assert.False(installation.Executables.IsWindowsBuild("eu07"));
|
||||
Assert.True(installation.Executables.IsWindowsBuild("eu07.exe"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_network_server_in_the_ini_is_noticed()
|
||||
{
|
||||
string ini = Path.Combine("/home/kolejarz", ".config", "MaSzyna", "eu07.ini");
|
||||
var installation = new TestInstallation(new InMemoryFileSystem()
|
||||
.WithFile(ini, "network.server tcp 0.0.0.0:7424\n"));
|
||||
installation.Environment.With("HOME", "/home/kolejarz");
|
||||
|
||||
installation.SettingsStore.Load();
|
||||
|
||||
Assert.True(installation.SettingsStore.Settings.NetworkServer);
|
||||
}
|
||||
}
|
||||
@@ -492,7 +492,7 @@ public class SettingsStoreTests
|
||||
[InlineData("mousescale 1.5 0.5", false, true, "mousescale 1.5 -0.5")]
|
||||
[InlineData("mousescale 1.5 0.5", true, false, "mousescale -1.5 0.5")]
|
||||
[InlineData("mousescale -1.5 -0.5", false, false, "mousescale 1.5 0.5")]
|
||||
[InlineData("mousescale 2.5 0.123456", false, true, "mousescale 2.5 -0.123456")]
|
||||
[InlineData("mousescale 2.5 0.5", false, true, "mousescale 2.5 -0.5")]
|
||||
// Further than the slider goes.
|
||||
[InlineData("mousescale 12 0.5", true, false, "mousescale -12 0.5")]
|
||||
public void A_mouse_scale_keeps_its_numbers_when_an_axis_is_inverted(
|
||||
@@ -540,7 +540,35 @@ public class SettingsStoreTests
|
||||
|
||||
installation.SettingsStore.Save();
|
||||
|
||||
Assert.Equal("mousescale 2 0.2", LineFor(installation, "mousescale"));
|
||||
Assert.Equal("mousescale 2 0.5", LineFor(installation, "mousescale"));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
// The second number is always 0.5, as the old starter wrote it; its sign is the inversion.
|
||||
[InlineData("mousescale 1.5 0.23", "mousescale 1.5 0.5")]
|
||||
[InlineData("mousescale 1.5 -0.23", "mousescale 1.5 -0.5")]
|
||||
[InlineData("mousescale 1.5 -2", "mousescale 1.5 -0.5")]
|
||||
// A zero locks that axis in the simulator: the camera turns only left/right.
|
||||
// X goes back to the default.
|
||||
[InlineData("mousescale 0.5 0", "mousescale 0.5 0.5")]
|
||||
[InlineData("mousescale 0.5 -0", "mousescale 0.5 0.5")]
|
||||
[InlineData("mousescale 0 0.5", "mousescale 2 0.5")]
|
||||
[InlineData("mousescale 0 0", "mousescale 2 0.5")]
|
||||
[InlineData("mousescale 1.5 NaN", "mousescale 1.5 0.5")]
|
||||
[InlineData("mousescale Infinity -0.5", "mousescale 2 -0.5")]
|
||||
// One number: the simulator takes the next word of the file ("mousecontrol") for Y, and reads it as 0.
|
||||
[InlineData("mousescale 1.5", "mousescale 1.5 0.5")]
|
||||
[InlineData("mousescale 0.5\t// (3.2 0.5) komentarz", "mousescale 0.5 0.5\t// (3.2 0.5) komentarz")]
|
||||
// A decimal comma: the simulator reads "0,2" as 0.
|
||||
[InlineData("mousescale 0.5 0,2", "mousescale 0.5 0.5")]
|
||||
public void A_mouse_scale_axis_that_would_not_move_gets_the_default(string line, string written)
|
||||
{
|
||||
var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, line + "\n"));
|
||||
installation.SettingsStore.Load();
|
||||
|
||||
installation.SettingsStore.Save();
|
||||
|
||||
Assert.Equal(written, LineFor(installation, "mousescale"));
|
||||
}
|
||||
|
||||
// ── A file that could not be read ────────────────────────────────────────
|
||||
@@ -885,12 +913,8 @@ public class SettingsStoreTests
|
||||
[InlineData("default")]
|
||||
[InlineData("simpleshader")]
|
||||
[InlineData("off")]
|
||||
[InlineData("opengl")]
|
||||
[InlineData("gl46")]
|
||||
[InlineData("vulkan14")]
|
||||
[InlineData("legacy")]
|
||||
[InlineData("simple")]
|
||||
[InlineData("experimental")]
|
||||
public void A_renderer_word_the_simulator_reads_as_another_stays_until_changed(string word)
|
||||
{
|
||||
var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, $"gfxrenderer {word}\n"));
|
||||
@@ -901,16 +925,33 @@ public class SettingsStoreTests
|
||||
Assert.Contains($"gfxrenderer {word}\n", SavedLines(installation));
|
||||
}
|
||||
|
||||
// Words master does not know start the full renderer with a line in its log, and the
|
||||
// experimental renderer is not in a player's build: a save puts "default" in their place.
|
||||
[Theory]
|
||||
[InlineData(0, "full")]
|
||||
[InlineData("full")]
|
||||
[InlineData("opengl")]
|
||||
[InlineData("gl46")]
|
||||
[InlineData("vulkan14")]
|
||||
[InlineData("experimental")]
|
||||
[InlineData("null")]
|
||||
public void A_renderer_word_master_does_not_run_is_saved_as_default(string word)
|
||||
{
|
||||
var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, $"gfxrenderer {word}\n"));
|
||||
installation.SettingsStore.Load();
|
||||
|
||||
installation.SettingsStore.Save();
|
||||
|
||||
Assert.Contains("gfxrenderer default\n", SavedLines(installation));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(0, "default")]
|
||||
[InlineData(1, "legacy")]
|
||||
[InlineData(2, "simple")]
|
||||
[InlineData(3, "experimental")]
|
||||
[InlineData(4, "vulkan")]
|
||||
public void A_chosen_renderer_is_saved_as_the_simulator_reads_it(int engine, string saved)
|
||||
{
|
||||
// application.cpp knows full (or default), experimental and simple; every
|
||||
// other word - "simpleshader" and "off" from older starters - is legacy.
|
||||
// application.cpp on master knows default, legacy and simple; "simpleshader" and "off"
|
||||
// from older starters are legacy, and any other word gets the full renderer.
|
||||
var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, "gfxrenderer simpleshader\n"));
|
||||
installation.SettingsStore.Load();
|
||||
installation.SettingsStore.Settings.RenderEngine = engine == 1 ? 0 : engine;
|
||||
@@ -926,8 +967,10 @@ public class SettingsStoreTests
|
||||
[InlineData("full", 0)]
|
||||
[InlineData("gl46", 0)]
|
||||
[InlineData("opengl", 0)]
|
||||
[InlineData("vulkan", 4)]
|
||||
[InlineData("VULKAN14", 4)]
|
||||
[InlineData("vulkan", 0)]
|
||||
[InlineData("VULKAN14", 0)]
|
||||
[InlineData("whatever", 0)]
|
||||
[InlineData("experimental", 0)]
|
||||
[InlineData("simpleshader", 1)]
|
||||
public void A_renderer_word_stands_where_the_simulator_reads_it(string word, int engine)
|
||||
{
|
||||
@@ -935,7 +978,7 @@ public class SettingsStoreTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_buffer_is_written_for_old_and_new_simulators()
|
||||
public void The_buffer_is_written_as_the_framebuffer_master_reads()
|
||||
{
|
||||
var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, "width 1000\nheight 500\n"));
|
||||
installation.SettingsStore.Load();
|
||||
@@ -944,19 +987,20 @@ public class SettingsStoreTests
|
||||
installation.SettingsStore.Save();
|
||||
|
||||
string saved = SavedLines(installation);
|
||||
Assert.Contains("gfx.buffer.percent 50\n", saved);
|
||||
Assert.DoesNotContain("gfx.buffer.percent", saved);
|
||||
Assert.Contains("gfx.framebuffer.width 500\n", saved);
|
||||
Assert.Contains("gfx.framebuffer.height 250\n", saved);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("gfx.buffer.percent 0.5\n", 50)]
|
||||
[InlineData("gfx.buffer.percent 75\n", 75)]
|
||||
[InlineData("gfx.buffer.percent 10\n", 25)]
|
||||
[InlineData("gfx.buffer.percent 300\n", 200)]
|
||||
[InlineData("width 1000\ngfx.framebuffer.width 500\n", 50)]
|
||||
[InlineData("width 1000\ngfx.framebuffer.width 100\n", 25)]
|
||||
[InlineData("width 1000\ngfx.framebuffer.width 3000\n", 100)]
|
||||
[InlineData("gfx.framebuffer.width 500\n", 100)]
|
||||
[InlineData("starter.bufferscale 60\n", 60)]
|
||||
[InlineData("starter.bufferscale 60\ngfx.buffer.percent 80\n", 80)]
|
||||
public void The_buffer_is_read_from_the_key_the_new_simulator_goes_by(string ini, int percent)
|
||||
[InlineData("starter.bufferscale 60\nwidth 1000\ngfx.framebuffer.width 800\n", 60)]
|
||||
[InlineData("gfx.buffer.percent 0.5\n", 100)]
|
||||
public void The_buffer_is_read_from_the_starters_key_or_the_framebuffer(string ini, int percent)
|
||||
{
|
||||
var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, ini));
|
||||
|
||||
@@ -965,36 +1009,6 @@ public class SettingsStoreTests
|
||||
Assert.Equal(percent, installation.SettingsStore.Settings.BufferScalePercent);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_two_anti_aliasing_keys_untouched_keep_their_order()
|
||||
{
|
||||
// Moving them would change which of the two the simulator goes by.
|
||||
const string ini = "gfx.antialiasing taa\nwidth 800\nmultisampling 2\n";
|
||||
var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, ini));
|
||||
installation.SettingsStore.Load();
|
||||
|
||||
installation.SettingsStore.Save();
|
||||
|
||||
string saved = SavedLines(installation);
|
||||
Assert.True(saved.IndexOf("gfx.antialiasing taa", StringComparison.Ordinal) < saved.IndexOf("multisampling 2", StringComparison.Ordinal), saved);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_chosen_anti_aliasing_is_saved_below_multisampling_for_the_later_line_to_count()
|
||||
{
|
||||
var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, "gfx.antialiasing msaax4\nwidth 800\nmultisampling 2\n"));
|
||||
installation.SettingsStore.Load();
|
||||
|
||||
installation.SettingsStore.Settings.AntiAliasing = AntiAliasingMode.Taa;
|
||||
installation.SettingsStore.Save();
|
||||
|
||||
string saved = SavedLines(installation);
|
||||
Assert.True(saved.IndexOf("multisampling ", StringComparison.Ordinal) < saved.IndexOf("gfx.antialiasing taa", StringComparison.Ordinal), saved);
|
||||
var again = WithHome(installation.Files);
|
||||
again.SettingsStore.Load();
|
||||
Assert.Equal(AntiAliasingMode.Taa, again.SettingsStore.Settings.AntiAliasing);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_field_of_view_down_to_ten_degrees_survives_a_save()
|
||||
{
|
||||
|
||||
54
StarterNG.Tests/SliderStepsTests.cs
Normal file
54
StarterNG.Tests/SliderStepsTests.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using StarterNG.Domain.Settings;
|
||||
using StarterNG.Views;
|
||||
|
||||
namespace StarterNG.Tests;
|
||||
|
||||
[Collection(AvaloniaControls.Name)]
|
||||
public class SliderStepsTests
|
||||
{
|
||||
[Fact]
|
||||
public void The_old_starters_steps_are_offered_and_a_value_outside_them_stays()
|
||||
{
|
||||
var slider = new Avalonia.Controls.Slider();
|
||||
var steps = new SliderSteps(slider, SliderRanges.ReflectionUpdates) { Value = 1 / 300.0 };
|
||||
|
||||
// The simulator's own once in five minutes, shown before the old starter's 1 to 60.
|
||||
Assert.Equal(1 / 300.0, steps.Value);
|
||||
Assert.Equal(SliderRanges.ReflectionUpdates.Length, slider.Maximum);
|
||||
|
||||
slider.Value = slider.Maximum;
|
||||
Assert.Equal(60, steps.Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_frame_limit_above_the_list_stays_as_the_file_has_it()
|
||||
{
|
||||
var slider = new Avalonia.Controls.Slider();
|
||||
var steps = new SliderSteps(slider, SliderRanges.FrameRateLimits) { Value = 300 };
|
||||
|
||||
Assert.Equal(300, steps.Value);
|
||||
Assert.Equal(SliderRanges.FrameRateLimits.Length, slider.Maximum);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Clamping_puts_a_value_past_either_end_at_that_end()
|
||||
{
|
||||
var slider = new Avalonia.Controls.Slider();
|
||||
var steps = new SliderSteps(slider, SliderRanges.FrameRateLimits) { Clamps = true, Value = 300 };
|
||||
|
||||
Assert.Equal(240, steps.Value);
|
||||
Assert.Equal(SliderRanges.FrameRateLimits.Length - 1, slider.Maximum);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Clamping_leaves_a_value_between_two_steps_where_it_is()
|
||||
{
|
||||
var slider = new Avalonia.Controls.Slider();
|
||||
var steps = new SliderSteps(slider, SliderRanges.CabShadowRanges) { Clamps = true, Value = 15 };
|
||||
|
||||
Assert.Equal(15, steps.Value);
|
||||
|
||||
steps.Value = -5;
|
||||
Assert.Equal(0, steps.Value);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using StarterNG.Classes;
|
||||
using StarterNG.Domain;
|
||||
using StarterNG.Domain.Settings;
|
||||
using StarterNG.Views;
|
||||
|
||||
namespace StarterNG.Tests;
|
||||
@@ -58,6 +59,63 @@ public class TrainsetDisplayTests
|
||||
Assert.False(TrainsetDisplay.ListedIn(picked, showAi: false, drivableOnly: true, current: picked));
|
||||
}
|
||||
|
||||
private static SimulatorSettings Mode(bool advanced) =>
|
||||
new() { AdvancedSettings = advanced, ShowAiVehicles = true, DrivableOnly = false };
|
||||
|
||||
[Fact]
|
||||
public void The_standard_mode_lists_every_consist_but_starts_only_in_one_a_player_drives()
|
||||
{
|
||||
var standard = Mode(advanced: false);
|
||||
var decor = new Trainset("trainset a tor 0 0 //$decor\nnode -1 0 v1 dynamic d s m 0 headdriver 3 0 enddynamic\nendtrainset");
|
||||
Assert.True(decor.Decor);
|
||||
|
||||
foreach (var consist in new[] { Consist(), Consist(description: "-ai"), Consist(driver: "nobody"), decor })
|
||||
Assert.True(TrainsetDisplay.ListedIn(consist, standard, current: null));
|
||||
|
||||
Assert.True(TrainsetDisplay.StartableIn(Consist(), standard));
|
||||
Assert.True(TrainsetDisplay.StartableIn(Consist(driver: "nobody"), standard));
|
||||
Assert.False(TrainsetDisplay.StartableIn(Consist(description: "-ai"), standard));
|
||||
Assert.False(TrainsetDisplay.StartableIn(decor, standard));
|
||||
Assert.True(TrainsetDisplay.StartableIn(decor, Mode(advanced: true)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_filters_work_in_the_advanced_mode()
|
||||
{
|
||||
var settings = Mode(advanced: true);
|
||||
|
||||
settings.ShowAiVehicles = false;
|
||||
Assert.False(TrainsetDisplay.ListedIn(Consist(description: "-ai"), settings, current: null));
|
||||
Assert.True(TrainsetDisplay.ListedIn(Consist(), settings, current: null));
|
||||
|
||||
settings.DrivableOnly = true;
|
||||
Assert.False(TrainsetDisplay.ListedIn(Consist(driver: "nobody"), settings, current: null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_standard_mode_has_no_filters_and_leaves_out_empty_consists()
|
||||
{
|
||||
var standard = new SimulatorSettings { AdvancedSettings = false, ShowAiVehicles = false, DrivableOnly = true };
|
||||
var empty = new Trainset("trainset a tor 0 0\nendtrainset");
|
||||
|
||||
Assert.True(TrainsetDisplay.ListedIn(Consist(description: "-ai"), standard, current: null));
|
||||
Assert.True(TrainsetDisplay.ListedIn(Consist(driver: "nobody"), standard, current: null));
|
||||
Assert.False(TrainsetDisplay.ListedIn(empty, standard, current: null));
|
||||
Assert.False(TrainsetDisplay.ListedIn(empty, standard, current: empty));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_advanced_mode_lists_by_its_own_filters()
|
||||
{
|
||||
var advanced = Mode(advanced: true);
|
||||
|
||||
Assert.True(TrainsetDisplay.ListedIn(Consist(description: "-ai"), advanced, current: null));
|
||||
Assert.True(TrainsetDisplay.ListedIn(Consist(driver: "nobody"), advanced, current: null));
|
||||
|
||||
advanced.ShowAiVehicles = false;
|
||||
Assert.False(TrainsetDisplay.ListedIn(Consist(description: "-ai"), advanced, current: null));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(eDriverType.Headdriver, 0)]
|
||||
[InlineData(eDriverType.Reardriver, 1)]
|
||||
|
||||
Reference in New Issue
Block a user