mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-26 01:49:12 +01:00
Compare commits
4 Commits
v1.6.325
...
fix/black-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac8ed6d5fe | ||
|
|
f9939fd566 | ||
|
|
4f749ff576 | ||
| 94112af005 |
14
.github/dependabot.yml
vendored
14
.github/dependabot.yml
vendored
@@ -1,14 +0,0 @@
|
||||
# Pull requests for new versions of the pinned actions and of the NuGet packages,
|
||||
# so a fix for a vulnerability reaches the build without anyone watching for it.
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: github-actions
|
||||
directory: /
|
||||
schedule:
|
||||
interval: weekly
|
||||
|
||||
- package-ecosystem: nuget
|
||||
directory: /
|
||||
schedule:
|
||||
interval: weekly
|
||||
open-pull-requests-limit: 5
|
||||
@@ -65,6 +65,36 @@ public class PhysicsAndAssetsTests
|
||||
Assert.Equal(125, physics.VMax);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Comments_between_include_parameters_are_not_parameters()
|
||||
{
|
||||
// As in the game: db/zans_v1/astra_rail_14_96m_86m3_ke_1.fiz feeds zans.fiz.inc this way.
|
||||
const string fiz = """
|
||||
include
|
||||
zans.fiz.inc
|
||||
21000 //masa
|
||||
68 //MaxLoad
|
||||
aviation_fuel,crude_oil,petrol
|
||||
14.96 //L
|
||||
end
|
||||
""";
|
||||
var installation = new TestInstallation(new InMemoryFileSystem()
|
||||
.WithFile(Fiz("db", "zans_v1", "astra"), fiz)
|
||||
.WithFile(TestInstallation.At("dynamic", "db", "zans_v1", "zans.fiz.inc"),
|
||||
"""
|
||||
Param. Category=train M=(p1) Vmax=100 # masa [kg]
|
||||
Load: MaxLoad=(p2) LoadQ=tonns LoadAccepted=(p3) LoadSpeed=0.1
|
||||
Dimensions: L=(p4) H=4.285
|
||||
"""));
|
||||
|
||||
var physics = installation.Physics.For("db/zans_v1/", "astra")!;
|
||||
|
||||
Assert.Equal(21000, physics.Mass);
|
||||
Assert.Equal(68, physics.MaxLoad);
|
||||
Assert.Equal("aviation_fuel,crude_oil,petrol", physics.LoadAccepted);
|
||||
Assert.Equal(14.96, physics.Length);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void An_include_named_in_other_case_is_followed()
|
||||
{
|
||||
|
||||
33
StarterNG.Tests/WindowSurfacesTests.cs
Normal file
33
StarterNG.Tests/WindowSurfacesTests.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Avalonia;
|
||||
using StarterNG.Infrastructure;
|
||||
|
||||
namespace StarterNG.Tests;
|
||||
|
||||
public class WindowSurfacesTests
|
||||
{
|
||||
[Fact]
|
||||
public void Windows_draws_into_the_window_surface_and_never_through_winui_composition()
|
||||
{
|
||||
var options = WindowSurfaces.Win32Options;
|
||||
|
||||
Assert.Equal(new[] { Win32CompositionMode.RedirectionSurface }, options.CompositionMode);
|
||||
Assert.DoesNotContain(Win32CompositionMode.WinUIComposition, options.CompositionMode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_graphics_card_still_draws()
|
||||
{
|
||||
Assert.Equal(new Win32PlatformOptions().RenderingMode, WindowSurfaces.Win32Options.RenderingMode);
|
||||
Assert.Contains(Win32RenderingMode.AngleEgl, WindowSurfaces.Win32Options.RenderingMode);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(false)]
|
||||
[InlineData(true)]
|
||||
public void The_options_go_to_the_same_builder_with_or_without_the_processor(bool softwareRender)
|
||||
{
|
||||
var builder = AppBuilder.Configure<Avalonia.Application>();
|
||||
|
||||
Assert.Same(builder, WindowSurfaces.ApplyTo(builder, softwareRender));
|
||||
}
|
||||
}
|
||||
@@ -265,10 +265,14 @@ public sealed class FizPhysicsRepository : IPhysicsRepository
|
||||
var sb = new StringBuilder();
|
||||
foreach (string line in text.Split('\n'))
|
||||
{
|
||||
// Both kinds the game skips: "68 //MaxLoad" passes one include parameter, not two.
|
||||
string stripped = line;
|
||||
int comment = stripped.IndexOf('#');
|
||||
if (comment >= 0)
|
||||
stripped = stripped[..comment];
|
||||
int slashes = stripped.IndexOf("//", StringComparison.Ordinal);
|
||||
if (slashes >= 0)
|
||||
stripped = stripped[..slashes];
|
||||
sb.Append(stripped).Append(' ');
|
||||
}
|
||||
|
||||
|
||||
25
StarterNG/Infrastructure/WindowSurfaces.cs
Normal file
25
StarterNG/Infrastructure/WindowSurfaces.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Avalonia;
|
||||
|
||||
namespace StarterNG.Infrastructure;
|
||||
|
||||
/// <summary>
|
||||
/// On Windows the graphics card draws each window of the starter into a surface of that
|
||||
/// window, not into Avalonia's default WinUI composition visual. On Windows 11 25H2 that
|
||||
/// visual was left empty on many starts: the main window, or a dialog opened later,
|
||||
/// stayed black while the others drew, and came back only now and then. Composition is
|
||||
/// there for see-through windows and backdrops, and the starter has none.
|
||||
/// </summary>
|
||||
public static class WindowSurfaces
|
||||
{
|
||||
public static Win32PlatformOptions Win32Options => new()
|
||||
{
|
||||
CompositionMode = new[] { Win32CompositionMode.RedirectionSurface }
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// The options a platform reads are the last given, so the processor, when asked
|
||||
/// for, draws with <see cref="SoftwareRender"/>'s own and these are left out.
|
||||
/// </summary>
|
||||
public static AppBuilder ApplyTo(AppBuilder builder, bool softwareRender) =>
|
||||
softwareRender ? SoftwareRender.ApplyTo(builder) : builder.With(Win32Options);
|
||||
}
|
||||
@@ -73,8 +73,9 @@ static class Program
|
||||
};
|
||||
}
|
||||
|
||||
// Without the switch the graphics card draws, into the window surfaces.
|
||||
private static AppBuilder WithSoftwareRenderIfAsked(this AppBuilder builder) =>
|
||||
_softwareRender ? SoftwareRender.ApplyTo(builder) : builder;
|
||||
WindowSurfaces.ApplyTo(builder, _softwareRender);
|
||||
|
||||
public static AppBuilder BuildAvaloniaApp()
|
||||
=> AppBuilder.Configure<App>()
|
||||
|
||||
Reference in New Issue
Block a user