Compare commits

..

8 Commits

Author SHA1 Message Date
952618be13 Merge pull request #52 from MaSzyna-EU07/fix/exe-list-refresh
fix: a simulator copied in while the starter runs is on the list
2026-11-16 09:16:17 +00:00
156af3fdd1 Merge pull request #51 from MaSzyna-EU07/fix/noavx2-exe
fix: without AVX2 the starter starts the simulator built without it
2026-11-16 09:16:05 +00:00
49b76aa66c Merge pull request #49 from MaSzyna-EU07/fix/reshade-beside-starter
fix: graphics wrappers beside the starter no longer reach its window
2026-11-16 09:15:52 +00:00
maj00r
38802845c7 test: no-AVX2 build names carry the date as the simulator writes it, 2026-11-15 2026-11-15 21:35:58 +01:00
maj00r
bba9e3ef48 fix: without AVX2 the starter starts the simulator built without it
The simulator now also comes built without AVX2, its file name ending in
_noavx2 (eu07-x64_<date>_<hash>_noavx2.exe, eu07_noavx2 on Linux), and both
builds can lie side by side in the game folder. The automatic choice took
eu07.exe or the shortest name and never that one, so a processor without
AVX2 got a simulator that stops at its first instruction and a notice
telling it to build its own.

Without AVX2 the automatic choice now takes the newest _noavx2 build, even
one through Wine before a native build that would not run. With AVX2 the
build made for it stays first and a _noavx2 one is used only when it is all
there is.

The notice comes only when what would start still needs AVX2. With a
_noavx2 build in the folder but another chosen by hand it names both and
offers to go back to the automatic choice; with none it says what such a
build is called and that the starter picks it up from the game folder.
2026-11-15 21:28:47 +01:00
maj00r
f29ce10f5c fix: a simulator copied in while the starter runs is on the list
The list of simulators in the settings was filled when they opened, so a new
eu07*.exe from CI or one's own build stayed missing until the starter was
reopened, and the older file was easy to start by mistake. The folder is now
looked at again when the settings page is shown, when the list takes focus
and when the window comes back to the front.

Looking again never changes the choice: a file picked from elsewhere, or one
since removed, stays chosen rather than falling back to automatic, and
nothing waits for Save after it. A list that did not change is left alone.

Closes #48
2026-11-15 21:13:53 +01:00
maj00r
6e2dbf9eac test: the system graphics libraries and the software render switch
Taking the libraries and the switch's options are apart from Main, so they are
tested on every system, not only where Windows has them to load.
2026-11-15 17:30:13 +01:00
maj00r
91c496ab48 fix: graphics wrappers beside the starter no longer reach its window
ReShade installed for Direct3D as dxgi.dll in the simulator's folder was
loaded into the starter as well, and its window came up empty. The system
dxgi, d3d11, d3d9 and opengl32 are loaded first, and the window code's own
imports are handed those. The simulator still finds its wrappers.

--software-render draws the window on the processor, on Windows and X11,
for a machine on which it still comes up empty.
2026-11-15 14:41:48 +01:00
18 changed files with 570 additions and 22 deletions

View File

@@ -0,0 +1,53 @@
using StarterNG.Views;
namespace StarterNG.Tests;
public class ExecutableListTests
{
[Fact]
public void A_build_copied_in_joins_the_list_and_the_choice_stays()
{
var (entries, chosen) = ExecutableList.Refreshed(["eu07_new.exe", "eu07.exe"], "eu07.exe");
Assert.Equal(new[] { "eu07_new.exe", "eu07.exe" }, entries);
Assert.Equal(1, chosen);
}
[Fact]
public void Automatic_stays_automatic()
{
var (entries, chosen) = ExecutableList.Refreshed(["eu07_new.exe", "eu07.exe"], null);
Assert.Equal(new[] { "eu07_new.exe", "eu07.exe" }, entries);
Assert.Equal(-1, chosen);
}
[Fact]
public void A_simulator_picked_from_elsewhere_stays_on_the_list_and_chosen()
{
const string picked = @"D:\build\eu07.exe";
var (entries, chosen) = ExecutableList.Refreshed(["eu07.exe"], picked);
Assert.Equal(new[] { "eu07.exe", picked }, entries);
Assert.Equal(1, chosen);
}
[Fact]
public void A_chosen_file_since_removed_stays_chosen_rather_than_switch_silently()
{
var (entries, chosen) = ExecutableList.Refreshed(["eu07.exe"], "eu07_old.exe");
Assert.Equal(new[] { "eu07.exe", "eu07_old.exe" }, entries);
Assert.Equal(1, chosen);
}
[Fact]
public void The_choice_is_found_whatever_the_case_of_its_name()
{
var (entries, chosen) = ExecutableList.Refreshed(["EU07.exe"], "eu07.exe");
Assert.Equal(new[] { "EU07.exe" }, entries);
Assert.Equal(0, chosen);
}
}

View File

@@ -0,0 +1,82 @@
using StarterNG.Domain.Settings;
using StarterNG.Infrastructure.Settings;
using StarterNG.Tests.Fakes;
namespace StarterNG.Tests;
public class ExecutableNoAvx2Tests
{
private const string Elf = "\u007fELF binary";
private static readonly DateTime Older = new(2026, 11, 1, 0, 0, 0, DateTimeKind.Utc);
private static readonly DateTime Newer = new(2026, 11, 15, 0, 0, 0, DateTimeKind.Utc);
private static InMemoryFileSystem With(params string[] names)
{
var files = new InMemoryFileSystem();
foreach (string name in names)
files.WithExecutable(TestInstallation.At(name), Elf);
return files;
}
private static string Automatic(InMemoryFileSystem files, bool lacksAvx2) =>
Path.GetFileName(new TestInstallation(files, lacksAvx2: lacksAvx2).Executables
.Resolve(new SimulatorSettings(), out _));
[Theory]
[InlineData("eu07_noavx2", true)]
[InlineData("eu07-x64_2026-11-15_abc1234_noavx2.exe", true)]
[InlineData("EU07_NOAVX2.EXE", true)]
[InlineData("eu07", false)]
[InlineData("eu07-x64_2026-11-15_abc1234.exe", false)]
[InlineData("eu07_noavx2_old.exe", false)]
public void A_build_without_avx2_is_known_by_the_end_of_its_name(string name, bool noAvx2) =>
Assert.Equal(noAvx2, ExecutableLocator.IsNoAvx2(name));
[Fact]
public void Without_avx2_the_build_without_it_is_chosen_over_the_canonical_one() =>
Assert.Equal("eu07_noavx2", Automatic(With("eu07", "eu07_noavx2"), lacksAvx2: true));
[Fact]
public void With_avx2_the_build_made_for_it_stays_first() =>
Assert.Equal("eu07", Automatic(With("eu07", "eu07_noavx2"), lacksAvx2: false));
[Fact]
public void With_avx2_a_build_without_it_is_used_when_it_is_the_only_one() =>
Assert.Equal("eu07_noavx2", Automatic(With("eu07_noavx2"), lacksAvx2: false));
[Fact]
public void Without_avx2_the_newest_build_without_it_is_chosen()
{
var files = With("eu07_2026-11-01_aaa_noavx2", "eu07_2026-11-15_bbb_noavx2")
.WrittenAt(TestInstallation.At("eu07_2026-11-01_aaa_noavx2"), Older)
.WrittenAt(TestInstallation.At("eu07_2026-11-15_bbb_noavx2"), Newer);
Assert.Equal("eu07_2026-11-15_bbb_noavx2", Automatic(files, lacksAvx2: true));
}
[Fact]
public void Without_avx2_and_no_build_without_it_the_usual_choice_stands() =>
Assert.Equal("eu07", Automatic(With("eu07-dev", "eu07"), lacksAvx2: true));
[Fact]
public void Only_a_build_with_avx2_on_a_processor_without_it_will_not_run()
{
var lacking = new TestInstallation(lacksAvx2: true).Executables;
var able = new TestInstallation(lacksAvx2: false).Executables;
Assert.True(lacking.WillNotRunHere("eu07.exe"));
Assert.False(lacking.WillNotRunHere("eu07-x64_noavx2.exe"));
Assert.False(able.WillNotRunHere("eu07.exe"));
}
[Fact]
public void The_newest_build_without_avx2_is_offered_by_name()
{
var files = With("eu07", "eu07_2026-11-01_aaa_noavx2", "eu07_2026-11-15_bbb_noavx2")
.WrittenAt(TestInstallation.At("eu07_2026-11-01_aaa_noavx2"), Older)
.WrittenAt(TestInstallation.At("eu07_2026-11-15_bbb_noavx2"), Newer);
Assert.Equal("eu07_2026-11-15_bbb_noavx2", new TestInstallation(files).Executables.NewestNoAvx2());
Assert.Null(new TestInstallation(With("eu07")).Executables.NewestNoAvx2());
}
}

View File

@@ -14,7 +14,7 @@ public sealed class TestInstallation
{
public const string Root = "game";
public TestInstallation(InMemoryFileSystem? files = null, DateTime? now = null)
public TestInstallation(InMemoryFileSystem? files = null, DateTime? now = null, bool lacksAvx2 = false)
{
Files = files ?? new InMemoryFileSystem();
Paths = new GamePaths(Root);
@@ -35,7 +35,8 @@ public sealed class TestInstallation
SettingsPaths.VehicleCacheDirectory());
Library = new GameLibrary(VehicleCache, Sceneries, MiniTextures, Physics, Log);
Executables = new ExecutableLocator(Files, Paths, Environment, Log);
// The processor of the machine running the tests is not the one tested.
Executables = new ExecutableLocator(Files, Paths, Environment, Log, lacksAvx2);
SettingsStore = new SettingsStore(Files, Clock, Log, SettingsPaths, new SettingsSerializer(), Executables);
Tapes = new HaslerTapes(Files, Paths, Log, Clock, new TimetableLocator(Files), () => SimulatorRunning);
}

View File

@@ -0,0 +1,45 @@
using Avalonia;
using StarterNG.Infrastructure;
namespace StarterNG.Tests;
public class SoftwareRenderTests
{
[Theory]
[InlineData("--software-render")]
[InlineData("--Software-Render")]
public void The_switch_asks_for_it_in_any_case(string arg)
{
Assert.True(SoftwareRender.AskedIn(new[] { "--other", arg }));
}
[Fact]
public void Without_the_switch_the_graphics_card_draws()
{
Assert.False(SoftwareRender.AskedIn(Array.Empty<string>()));
Assert.False(SoftwareRender.AskedIn(new[] { "--software" }));
}
[Fact]
public void Windows_draws_on_the_processor_into_a_plain_window_surface()
{
var options = SoftwareRender.Win32Options;
Assert.Equal(new[] { Win32RenderingMode.Software }, options.RenderingMode);
Assert.Equal(new[] { Win32CompositionMode.RedirectionSurface }, options.CompositionMode);
}
[Fact]
public void X11_draws_on_the_processor()
{
Assert.Equal(new[] { X11RenderingMode.Software }, SoftwareRender.X11Options.RenderingMode);
}
[Fact]
public void Both_platforms_options_go_to_the_same_builder()
{
var builder = AppBuilder.Configure<Avalonia.Application>();
Assert.Same(builder, SoftwareRender.ApplyTo(builder));
}
}

View File

@@ -0,0 +1,98 @@
using StarterNG.Infrastructure;
namespace StarterNG.Tests;
public class SystemGraphicsLibrariesTests
{
private const string System32 = @"C:\Windows\System32";
private const string Game = @"E:\SteamLibrary\steamapps\common\MaSzyna";
private static readonly IntPtr Dxgi = new(0x1000);
private static readonly IntPtr D3d11 = new(0x2000);
private static SystemGraphicsLibraries Take(Func<string, bool> beside, Dictionary<string, IntPtr> system)
{
return SystemGraphicsLibraries.Take(System32, Game, beside, Load);
bool Load(string path, out IntPtr handle)
{
handle = system.GetValueOrDefault(Path.GetFileName(path));
return handle != IntPtr.Zero;
}
}
private static SystemGraphicsLibraries WithDxgiAndD3d11(Func<string, bool> beside) =>
Take(beside, new Dictionary<string, IntPtr> { ["dxgi.dll"] = Dxgi, ["d3d11.dll"] = D3d11 });
[Fact]
public void An_import_by_name_gets_the_system_library_with_or_without_its_extension()
{
var taken = WithDxgiAndD3d11(_ => false);
Assert.Equal(Dxgi, taken.Resolve("dxgi"));
Assert.Equal(Dxgi, taken.Resolve("dxgi.dll"));
Assert.Equal(D3d11, taken.Resolve("D3D11.DLL"));
}
[Fact]
public void Other_libraries_and_ones_the_system_lacks_are_left_to_the_usual_search()
{
var taken = WithDxgiAndD3d11(_ => false);
Assert.Equal(IntPtr.Zero, taken.Resolve("user32.dll"));
Assert.Equal(IntPtr.Zero, taken.Resolve("opengl32"));
}
[Fact]
public void They_are_loaded_from_the_system_folder_dxgi_first()
{
var asked = new List<string>();
SystemGraphicsLibraries.Take(System32, Game, _ => false, Load);
Assert.Equal(SystemGraphicsLibraries.Names.Select(n => Path.Combine(System32, n + ".dll")), asked);
Assert.Equal("dxgi", SystemGraphicsLibraries.Names[0]);
bool Load(string path, out IntPtr handle)
{
asked.Add(path);
handle = IntPtr.Zero;
return false;
}
}
[Fact]
public void A_wrapper_beside_the_starter_is_noted()
{
var taken = WithDxgiAndD3d11(path => path == Path.Combine(Game, "dxgi.dll"));
Assert.Equal(new[] { "dxgi.dll" }, taken.Shadowed);
Assert.Contains("dxgi.dll", taken.Note);
}
[Fact]
public void With_nothing_beside_the_starter_there_is_nothing_to_note()
{
var taken = WithDxgiAndD3d11(_ => false);
Assert.Empty(taken.Shadowed);
Assert.Null(taken.Note);
}
[Fact]
public void Only_windows_has_system_libraries_to_take()
{
var taken = SystemGraphicsLibraries.TakeOnWindows();
Assert.Equal(OperatingSystem.IsWindows(), taken is not null);
}
[Fact]
public void An_assembly_with_a_resolver_of_its_own_keeps_it()
{
var taken = WithDxgiAndD3d11(_ => false);
var assembly = typeof(SystemGraphicsLibrariesTests).Assembly;
Assert.True(taken.ServeTo(assembly));
Assert.False(taken.ServeTo(assembly));
}
}

View File

@@ -207,8 +207,12 @@ public partial class App : Avalonia.Application
if (check.ExecutableMissing())
await main.OfferExecutablePickAsync();
if (CpuFeatures.LacksAvx2 && AppServices.Current.Settings.CpuNotice)
await main.ShowCpuNoticeAsync();
// A build without AVX2 in the folder is started instead, and needs no notice.
var services = AppServices.Current;
if (services.Settings.CpuNotice
&& services.Executables.Resolve(services.Settings, out _) is var executable
&& services.Executables.WillNotRunHere(executable))
await main.ShowCpuNoticeAsync(executable);
});
});
}

View File

@@ -22,15 +22,37 @@ public sealed class ExecutableLocator
private string? _wine;
private bool _wineLookedUp;
private string? _missingPickLogged;
private readonly bool _lacksAvx2;
public ExecutableLocator(IFileSystem files, IGamePaths paths, IEnvironment environment, IDiagnosticsLog log)
/// <param name="lacksAvx2">Whether this processor runs no AVX2; asked of it when left out.</param>
public ExecutableLocator(IFileSystem files, IGamePaths paths, IEnvironment environment, IDiagnosticsLog log,
bool? lacksAvx2 = null)
{
_files = files;
_paths = paths;
_environment = environment;
_log = log;
_lacksAvx2 = lacksAvx2 ?? CpuFeatures.LacksAvx2;
}
/// <summary>
/// The end of the name of a simulator built without AVX2, last before any extension:
/// eu07-x64_2026-11-15_abc1234_noavx2.exe, eu07_noavx2. It runs on any x86-64 processor.
/// </summary>
public const string NoAvx2Suffix = "_noavx2";
public static bool IsNoAvx2(string path) =>
Path.GetFileNameWithoutExtension(path).EndsWith(NoAvx2Suffix, StringComparison.OrdinalIgnoreCase);
/// <summary>
/// Whether <paramref name="executable"/> stops at its first instruction here: a build
/// with AVX2 on a processor without it. Such a processor is told so before a start.
/// </summary>
public bool WillNotRunHere(string executable) => _lacksAvx2 && !IsNoAvx2(executable);
/// <summary>The newest build without AVX2 in the installation, or null where there is none.</summary>
public string? NewestNoAvx2() => ListCandidates().FirstOrDefault(IsNoAvx2);
public string CanonicalName => _environment.IsWindows ? "eu07.exe" : "eu07";
/// <summary>
@@ -71,7 +93,8 @@ public sealed class ExecutableLocator
{
var candidates = _files.GetFiles(_paths.Root, "eu07*")
.Where(IsCandidate)
.OrderBy(path => IsExeOnLinux(path) ? 1 : 0)
.OrderBy(Rank)
.ThenByDescending(path => _lacksAvx2 && IsNoAvx2(path) ? _files.GetLastWriteTimeUtc(path) : DateTime.MinValue)
.ThenBy(path => string.Equals(Path.GetFileName(path), CanonicalName,
StringComparison.OrdinalIgnoreCase) ? 0 : 1)
.ThenBy(path => Path.GetFileName(path).Length);
@@ -101,6 +124,18 @@ public sealed class ExecutableLocator
return CanonicalName;
}
/// <summary>
/// The order of the search. Without AVX2 a build without it comes first, the newest of
/// them, even through Wine: the others stop at once. With AVX2 one is the last resort,
/// as the build made for the processor runs faster; native before Wine either way.
/// </summary>
private int Rank(string path)
{
int wine = IsExeOnLinux(path) ? 1 : 0;
int noAvx2 = IsNoAvx2(path) ? 1 : 0;
return _lacksAvx2 ? (1 - noAvx2) * 2 + wine : wine * 2 + noAvx2;
}
public List<string> ListCandidates(string? directory = null)
{
try

View File

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Avalonia;
namespace StarterNG.Infrastructure;
/// <summary>
/// Drawn by the processor instead of the graphics card, for a machine on which the
/// window comes up empty. Each platform reads only its own options, so both are given.
/// </summary>
public static class SoftwareRender
{
public const string Switch = "--software-render";
public static bool AskedIn(IEnumerable<string> args) =>
args.Any(a => string.Equals(a, Switch, StringComparison.OrdinalIgnoreCase));
public static Win32PlatformOptions Win32Options => new()
{
RenderingMode = new[] { Win32RenderingMode.Software },
CompositionMode = new[] { Win32CompositionMode.RedirectionSurface }
};
public static X11PlatformOptions X11Options => new()
{
RenderingMode = new[] { X11RenderingMode.Software }
};
public static AppBuilder ApplyTo(AppBuilder builder) =>
builder.With(Win32Options).With(X11Options);
}

View File

@@ -0,0 +1,90 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
namespace StarterNG.Infrastructure;
/// <summary>
/// The starter sits in the simulator's folder, and so do the graphics wrappers a player
/// puts there for the simulator - ReShade and the like, named after the system library
/// they stand in for. Windows looks in the program's own folder first, so the starter's
/// window drew through them too, and with some of them it drew nothing at all.
/// Loaded from System32 by full path before anything asks for them, these names are
/// taken: a native library that asks by name gets the system one. .NET looks beside the
/// program by full path before it asks by name, so the window code's own imports are
/// handed the same libraries. The simulator is a process of its own and still finds its
/// wrappers.
/// Elsewhere there is nothing of the kind to keep out. Under Wine or Proton the system
/// folder is the prefix's, so what is taken there is what would have been taken anyway.
/// </summary>
public sealed class SystemGraphicsLibraries
{
public delegate bool Loader(string path, out IntPtr handle);
// dxgi ahead of d3d11, which asks for it.
public static readonly IReadOnlyList<string> Names = new[] { "dxgi", "d3d11", "d3d9", "opengl32" };
private readonly Dictionary<string, IntPtr> _loaded = new(StringComparer.OrdinalIgnoreCase);
private readonly List<string> _shadowed = new();
private SystemGraphicsLibraries()
{
}
/// <summary>The files of these names that lay beside the starter.</summary>
public IReadOnlyList<string> Shadowed => _shadowed;
/// <summary>What goes to the log about them, or null when none lay there.</summary>
public string? Note => _shadowed.Count > 0
? $"Graphics libraries beside the starter, left to the simulator: {string.Join(", ", _shadowed)}"
: null;
/// <summary>The libraries of this Windows, or null on any other system.</summary>
public static SystemGraphicsLibraries? TakeOnWindows() =>
OperatingSystem.IsWindows()
? Take(Environment.SystemDirectory, AppContext.BaseDirectory, File.Exists, NativeLibrary.TryLoad)
: null;
public static SystemGraphicsLibraries Take(string systemDirectory, string ownDirectory,
Func<string, bool> exists, Loader load)
{
var taken = new SystemGraphicsLibraries();
foreach (string name in Names)
{
string file = name + ".dll";
if (exists(Path.Combine(ownDirectory, file)))
taken._shadowed.Add(file);
if (load(Path.Combine(systemDirectory, file), out IntPtr handle))
taken._loaded[name] = handle;
}
return taken;
}
/// <summary>The system library for an import of one of these names; zero leaves it to the usual search.</summary>
public IntPtr Resolve(string libraryName)
{
string name = libraryName.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)
? libraryName[..^4]
: libraryName;
return _loaded.TryGetValue(name, out IntPtr handle) ? handle : IntPtr.Zero;
}
/// <summary>
/// The assembly's imports of these names get the system libraries. False when it
/// has a resolver of its own already; that one decides.
/// </summary>
public bool ServeTo(Assembly importer)
{
try
{
NativeLibrary.SetDllImportResolver(importer, (name, _, _) => Resolve(name));
return true;
}
catch (InvalidOperationException)
{
return false;
}
}
}

View File

@@ -110,7 +110,13 @@ public partial class MainWindow : Window
_sceneryFilesTimer.Start();
FollowLastRun();
};
Activated += (_, _) => CheckExternalSettings();
Activated += (_, _) =>
{
CheckExternalSettings();
// Back from a build or a download: a new simulator is on the list already.
if (SettingsView.IsVisible)
SettingsView.RefreshExecutables();
};
_sceneryFilesTimer.Tick += async (_, _) => await LookAtSceneryFilesAsync();
Closed += (_, _) => _sceneryFilesTimer.Stop();
}
@@ -521,11 +527,34 @@ public partial class MainWindow : Window
private const string SimulatorBuildGuide = "https://github.com/MaSzyna-EU07/maszyna#getting-started";
/// <summary>
/// Tells a user whose processor lacks AVX2 that the published simulator will
/// not run, and where the instructions for a build of their own are.
/// Tells a user whose processor lacks AVX2 that the simulator that would start will
/// not run. With a build without AVX2 in the folder, chosen away from by hand, the
/// notice offers to go back to the automatic choice, which takes it; with none, it
/// says what such a build is called and where the instructions for one's own are.
/// </summary>
public async Task ShowCpuNoticeAsync()
public async Task ShowCpuNoticeAsync(string executable)
{
var services = AppServices.Current;
if (services.Executables.NewestNoAvx2() is { } noAvx2)
{
var (useIt, quiet) = await MessageBox.ShowNotice(
this, string.Format(App.Loc["CpuNoAvx2Chosen"], Path.GetFileName(executable), noAvx2),
App.Loc["CpuNoAvx2Title"], App.Loc["CpuNoAvx2UseIt"], App.Loc["DontShowAgain"]);
if (useIt)
{
services.Settings.SelectExeAutomatically = true;
services.SettingsStore.Save();
SettingsView.ReloadFromSettings();
UpdateStartButton();
}
if (quiet)
{
services.Settings.CpuNotice = false;
services.SettingsStore.Save();
}
return;
}
var (open, silence) = await MessageBox.ShowNotice(
this, string.Format(App.Loc["CpuNoAvx2"], SimulatorBuildGuide), App.Loc["CpuNoAvx2Title"],
App.Loc["CpuNoAvx2Open"], App.Loc["DontShowAgain"]);

View File

@@ -10,12 +10,22 @@ namespace StarterNG;
static class Program
{
private static bool _softwareRender;
[STAThread]
public static void Main(string[] args)
{
// Ahead of everything that could draw: what lies beside the starter is the simulator's.
var graphics = SystemGraphicsLibraries.TakeOnWindows();
graphics?.ServeTo(typeof(Win32PlatformOptions).Assembly);
_softwareRender = SoftwareRender.AskedIn(args);
// Composition root first: everything below, including the crash handlers,
// resolves its collaborators from this graph.
AppServices.Initialize();
if (graphics?.Note is { } note)
Diagnostics.Log(note);
AppDomain.CurrentDomain.UnhandledException += (_, e) =>
{
@@ -63,9 +73,13 @@ static class Program
};
}
private static AppBuilder WithSoftwareRenderIfAsked(this AppBuilder builder) =>
_softwareRender ? SoftwareRender.ApplyTo(builder) : builder;
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.WithSoftwareRenderIfAsked()
.WithInterFont()
.WithDiagnosticsLogging()
.AfterSetup(_ => LogUiExceptions());

View File

@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace StarterNG.Views;
/// <summary>
/// The simulators offered in the settings after the folder was looked at again: a build
/// copied in while the starter runs joins the list, and what was chosen stays chosen, even
/// a file picked from elsewhere or one since removed - looking again never changes the choice.
/// </summary>
public static class ExecutableList
{
/// <summary>The entries that follow "automatic", and the place of <paramref name="chosen"/> among them.</summary>
/// <param name="found">The simulators in the folder now, newest first.</param>
/// <param name="chosen">The entry chosen, or null for "automatic" or nothing chosen yet.</param>
/// <returns>Entries, and the index of the chosen one in them, -1 when <paramref name="chosen"/> is null.</returns>
public static (IReadOnlyList<string> Entries, int Chosen) Refreshed(IReadOnlyList<string> found, string? chosen)
{
var entries = found.ToList();
if (chosen is null)
return (entries, -1);
int at = entries.FindIndex(entry => string.Equals(entry, chosen, StringComparison.OrdinalIgnoreCase));
if (at >= 0)
return (entries, at);
entries.Add(chosen);
return (entries, entries.Count - 1);
}
}

View File

@@ -105,6 +105,13 @@ public partial class Settings : UserControl, ISettingsCapture
FeedbackCb.SelectionChanged += FeedbackCb_OnSelectionChanged;
SelectExeCb.SelectionChanged += (_, _) => UpdateIdleNotes();
// Coming to the page or to the list is when a new build is looked for.
SelectExeCb.GotFocus += (_, _) => RefreshExecutables();
PropertyChanged += (_, e) =>
{
if (e.Property == IsVisibleProperty && IsVisible)
RefreshExecutables();
};
FullscreenWindowedCb.IsCheckedChanged += (_, _) => UpdateIdleNotes();
App.Loc.LanguageChanged += UpdateIdleNotes;
App.Loc.LanguageChanged += UpdateGpuNote;
@@ -246,16 +253,33 @@ public partial class Settings : UserControl, ISettingsCapture
private void PopulateExeCombo()
{
string? current = (SelectExeCb.SelectedItem as ComboBoxItem)?.Content?.ToString();
int index = SelectExeCb.SelectedIndex;
string? chosen = index > 0 ? (SelectExeCb.SelectedItem as ComboBoxItem)?.Content?.ToString() : null;
var (entries, at) = ExecutableList.Refreshed(AppServices.Current.Executables.ListCandidates(), chosen);
// The same files as shown: left alone, so a reader on the list hears nothing change.
var shown = SelectExeCb.Items.Skip(1).Select(item => (item as ComboBoxItem)?.Content?.ToString() ?? "");
if (SelectExeCb.Items.Count > 0 && shown.SequenceEqual(entries, StringComparer.Ordinal))
return;
SelectExeCb.Items.Clear();
SelectExeCb.Items.Add(new ComboBoxItem { Content = App.Loc["SelectEXEAuto"] });
foreach (string exe in AppServices.Current.Executables.ListCandidates())
foreach (string exe in entries)
SelectExeCb.Items.Add(new ComboBoxItem { Content = exe });
if (current is not null)
{
int idx = FindComboIndexByContent(SelectExeCb, current);
SelectExeCb.SelectedIndex = idx >= 0 ? idx : 0;
}
if (index >= 0)
SelectExeCb.SelectedIndex = at >= 0 ? at + 1 : 0;
}
/// <summary>
/// Looks at the simulator folder again, so a build copied in while the starter runs is
/// on the list without reopening anything. The choice stays as it was and is no edit:
/// nothing waits for Save after it. Not while the list is open under the user's hand.
/// </summary>
public void RefreshExecutables()
{
if (SelectExeCb.IsDropDownOpen)
return;
WhileLoading(PopulateExeCombo);
}
private async void BrowseExeButton_OnClick(object? sender, RoutedEventArgs e) =>

View File

@@ -633,8 +633,10 @@
<String key="About">O programu</String>
<String key="Close">Zavřít</String>
<String key="CpuNoAvx2Title">Procesor bez AVX2</String>
<String key="CpuNoAvx2">Tento procesor nemá AVX2 a oficiální simulátor ho vyžaduje: nespustí se.&#10;&#10;Simulátor lze sestavit bez AVX2 (CMake -DENABLE_AVX2=OFF). Návod:&#10;{0}</String>
<String key="CpuNoAvx2">Tento procesor nemá AVX2 a oficiální simulátor ho vyžaduje: nespustí se.&#10;&#10;Existuje verze simulátoru bez AVX2 - název jejího souboru končí na _noavx2. Vložte ji do složky hry a starter ji sám použije. Simulátor lze také sestavit sám (CMake -DENABLE_AVX2=OFF). Návod:&#10;{0}</String>
<String key="CpuNoAvx2Open">Otevřít návod</String>
<String key="CpuNoAvx2Chosen">Tento procesor nemá AVX2 a zvolený simulátor {0} ho vyžaduje: nespustí se.&#10;&#10;Ve složce hry je verze bez AVX2: {1}. Automatická volba vezme právě ji.</String>
<String key="CpuNoAvx2UseIt">Volit automaticky</String>
<String key="DontShowAgain">Znovu nezobrazovat</String>
<String key="SettingsPath">Nastavení načteno z:</String>

View File

@@ -659,8 +659,10 @@
<String key="About">About</String>
<String key="Close">Close</String>
<String key="CpuNoAvx2Title">Processor without AVX2</String>
<String key="CpuNoAvx2">This processor has no AVX2 and the official simulator needs it: it will not start.&#10;&#10;You can build the simulator without AVX2 (CMake -DENABLE_AVX2=OFF). Instructions:&#10;{0}</String>
<String key="CpuNoAvx2">This processor has no AVX2 and the official simulator needs it: it will not start.&#10;&#10;There is a simulator build without AVX2 - its file name ends in _noavx2. Put it in the game folder and the starter will use it. You can also build the simulator yourself (CMake -DENABLE_AVX2=OFF). Instructions:&#10;{0}</String>
<String key="CpuNoAvx2Open">Open the instructions</String>
<String key="CpuNoAvx2Chosen">This processor has no AVX2 and the chosen simulator {0} needs it: it will not start.&#10;&#10;The game folder has a build without AVX2: {1}. The automatic choice takes that one.</String>
<String key="CpuNoAvx2UseIt">Choose automatically</String>
<String key="DontShowAgain">Don't show again</String>
<String key="SettingsPath">Settings loaded from:</String>

View File

@@ -633,8 +633,10 @@
<String key="About">Névjegy</String>
<String key="Close">Bezárás</String>
<String key="CpuNoAvx2Title">AVX2 nélküli processzor</String>
<String key="CpuNoAvx2">Ez a processzor nem tudja az AVX2-t, a hivatalos szimulátornak pedig kell: nem indul el.&#10;&#10;A szimulátor lefordítható AVX2 nélkül (CMake -DENABLE_AVX2=OFF). Útmutató:&#10;{0}</String>
<String key="CpuNoAvx2">Ez a processzor nem tudja az AVX2-t, a hivatalos szimulátornak pedig kell: nem indul el.&#10;&#10;Van AVX2 nélküli szimulátor-változat - a fájl neve _noavx2-re végződik. Tegye a játék mappájába, és az indító magától azt használja. A szimulátor saját maga is lefordítható (CMake -DENABLE_AVX2=OFF). Útmutató:&#10;{0}</String>
<String key="CpuNoAvx2Open">Útmutató megnyitása</String>
<String key="CpuNoAvx2Chosen">Ez a processzor nem tudja az AVX2-t, a kiválasztott {0} szimulátornak pedig kell: nem indul el.&#10;&#10;A játék mappájában van AVX2 nélküli változat: {1}. Az automatikus választás ezt veszi.</String>
<String key="CpuNoAvx2UseIt">Automatikus választás</String>
<String key="DontShowAgain">Ne mutasd többé</String>
<String key="SettingsPath">Beállítások betöltve innen:</String>

View File

@@ -659,8 +659,10 @@
<String key="About">O programie</String>
<String key="Close">Zamknij</String>
<String key="CpuNoAvx2Title">Procesor bez AVX2</String>
<String key="CpuNoAvx2">Ten procesor nie ma AVX2, a oficjalny symulator go wymaga: nie uruchomi się.&#10;&#10;Można zbudować symulator bez AVX2 (CMake -DENABLE_AVX2=OFF). Instrukcja:&#10;{0}</String>
<String key="CpuNoAvx2">Ten procesor nie ma AVX2, a oficjalny symulator go wymaga: nie uruchomi się.&#10;&#10;Istnieje wersja symulatora bez AVX2 - nazwa jej pliku kończy się na _noavx2. Umieść ją w folderze gry, a starter sam jej użyje. Można też zbudować symulator samemu (CMake -DENABLE_AVX2=OFF). Instrukcja:&#10;{0}</String>
<String key="CpuNoAvx2Open">Otwórz instrukcję</String>
<String key="CpuNoAvx2Chosen">Ten procesor nie ma AVX2, a wybrany symulator {0} go wymaga: nie uruchomi się.&#10;&#10;W folderze gry jest wersja bez AVX2: {1}. Wybór automatyczny weźmie właśnie ją.</String>
<String key="CpuNoAvx2UseIt">Wybieraj automatycznie</String>
<String key="DontShowAgain">Nie pokazuj więcej</String>
<String key="SettingsPath">Lokalizacja wczytanych ustawień:</String>

View File

@@ -633,8 +633,10 @@
<String key="About">О программе</String>
<String key="Close">Закрыть</String>
<String key="CpuNoAvx2Title">Процессор без AVX2</String>
<String key="CpuNoAvx2">Этот процессор не поддерживает AVX2, а официальному симулятору он нужен: симулятор не запустится.&#10;&#10;Можно собрать симулятор без AVX2 (CMake -DENABLE_AVX2=OFF). Инструкция:&#10;{0}</String>
<String key="CpuNoAvx2">Этот процессор не поддерживает AVX2, а официальному симулятору он нужен: симулятор не запустится.&#10;&#10;Есть версия симулятора без AVX2 - имя её файла оканчивается на _noavx2. Положите её в папку игры, и стартер сам её использует. Симулятор можно также собрать самому (CMake -DENABLE_AVX2=OFF). Инструкция:&#10;{0}</String>
<String key="CpuNoAvx2Open">Открыть инструкцию</String>
<String key="CpuNoAvx2Chosen">Этот процессор не поддерживает AVX2, а выбранному симулятору {0} он нужен: он не запустится.&#10;&#10;В папке игры есть версия без AVX2: {1}. Автоматический выбор возьмёт именно её.</String>
<String key="CpuNoAvx2UseIt">Выбирать автоматически</String>
<String key="DontShowAgain">Больше не показывать</String>
<String key="SettingsPath">Настройки загружены из:</String>