mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-10-29 11:07:29 +01:00
Cut the comments from the refactored code
Three survive: why AppServices is hand-wired, the cp1250 registration trap, and the IsDieselEngine note carried over from Physics.cs.
This commit is contained in:
@@ -2,11 +2,6 @@ namespace StarterNG.Application.Abstractions;
|
||||
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Port over the system clock. Scenery weather defaults, timetable rendering and
|
||||
/// log timestamps all depend on "now"; routing them through a clock keeps those
|
||||
/// rules deterministic under test.
|
||||
/// </summary>
|
||||
public interface IClock
|
||||
{
|
||||
DateTime Now { get; }
|
||||
|
||||
@@ -3,11 +3,6 @@ using System.Collections.Generic;
|
||||
|
||||
namespace StarterNG.Application.Abstractions;
|
||||
|
||||
/// <summary>
|
||||
/// Port over the starter's error log. Domain and application code depends on
|
||||
/// this interface only; the file-backed implementation and the message box that
|
||||
/// surfaces faults to the user live in Infrastructure and Presentation.
|
||||
/// </summary>
|
||||
public interface IDiagnosticsLog
|
||||
{
|
||||
void Log(string message);
|
||||
@@ -16,7 +11,6 @@ public interface IDiagnosticsLog
|
||||
|
||||
void Log(IEnumerable<string> messages);
|
||||
|
||||
/// <summary>Everything logged so far, newline separated.</summary>
|
||||
string Text { get; }
|
||||
|
||||
void Clear();
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
namespace StarterNG.Application.Abstractions;
|
||||
|
||||
/// <summary>
|
||||
/// The bits of the host machine the starter has to ask about: which operating
|
||||
/// system it is on, and where that system keeps per-user configuration.
|
||||
/// </summary>
|
||||
public interface IEnvironment
|
||||
{
|
||||
bool IsWindows { get; }
|
||||
@@ -12,9 +8,7 @@ public interface IEnvironment
|
||||
|
||||
bool IsMacOS { get; }
|
||||
|
||||
/// <summary>An environment variable, or null when it is not set.</summary>
|
||||
string? GetVariable(string name);
|
||||
|
||||
/// <summary>The folder the starter's own executable lives in.</summary>
|
||||
string BaseDirectory { get; }
|
||||
}
|
||||
|
||||
@@ -5,18 +5,6 @@ using System.Text;
|
||||
|
||||
namespace StarterNG.Application.Abstractions;
|
||||
|
||||
/// <summary>
|
||||
/// Port over the file system. Everything that reads or writes the MaSzyna
|
||||
/// installation goes through this interface instead of <see cref="File"/> and
|
||||
/// <see cref="Directory"/>, so parsers and use cases can be exercised against an
|
||||
/// in-memory installation in tests.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Kept deliberately narrow: only the operations the application actually
|
||||
/// performs are exposed. Paths are passed through verbatim to the adapter, which
|
||||
/// resolves them relative to the process working directory just like the
|
||||
/// framework methods it replaces.
|
||||
/// </remarks>
|
||||
public interface IFileSystem
|
||||
{
|
||||
bool FileExists(string path);
|
||||
@@ -45,23 +33,13 @@ public interface IFileSystem
|
||||
|
||||
void CopyFile(string sourcePath, string destinationPath, bool overwrite);
|
||||
|
||||
/// <summary>Top-level files, empty when the directory does not exist.</summary>
|
||||
IReadOnlyList<string> GetFiles(string path, string searchPattern = "*");
|
||||
|
||||
/// <summary>Top-level directories, empty when the directory does not exist.</summary>
|
||||
IReadOnlyList<string> GetDirectories(string path);
|
||||
|
||||
/// <summary>
|
||||
/// Files matching the pattern anywhere below the path. Empty when the
|
||||
/// directory does not exist.
|
||||
/// </summary>
|
||||
IReadOnlyList<string> GetFilesRecursive(string path, string searchPattern);
|
||||
|
||||
DateTime GetLastWriteTimeUtc(string path);
|
||||
|
||||
/// <summary>
|
||||
/// Whether the file carries an execute bit. Always true on Windows, where
|
||||
/// executability is a property of the file's contents rather than its mode.
|
||||
/// </summary>
|
||||
bool IsExecutable(string path);
|
||||
}
|
||||
|
||||
@@ -1,34 +1,20 @@
|
||||
namespace StarterNG.Application.Abstractions;
|
||||
|
||||
/// <summary>
|
||||
/// The layout of a MaSzyna installation. Replaces the
|
||||
/// <c>Directory.GetCurrentDirectory()</c> calls and hard-coded "scenery/",
|
||||
/// "dynamic", "textures/mini/" literals that were previously spread across
|
||||
/// parsers, views and the loader.
|
||||
/// </summary>
|
||||
public interface IGamePaths
|
||||
{
|
||||
/// <summary>Installation root: the folder holding eu07.exe.</summary>
|
||||
string Root { get; }
|
||||
|
||||
/// <summary>Scenery definitions (*.scn).</summary>
|
||||
string Scenery { get; }
|
||||
|
||||
/// <summary>Rolling stock: dynamic/<maker>/<vehicle>/textures.txt.</summary>
|
||||
string Dynamic { get; }
|
||||
|
||||
/// <summary>Vehicle thumbnails used by the depot and the consist strip.</summary>
|
||||
string MiniTextures { get; }
|
||||
|
||||
/// <summary>Simulator data files (load_weights.txt and friends).</summary>
|
||||
string Data { get; }
|
||||
|
||||
/// <summary>Starter-owned configuration: presets, profiles, key bindings.</summary>
|
||||
string StarterConfig { get; }
|
||||
|
||||
/// <summary>The starter's own error log (starter/bledy.txt).</summary>
|
||||
string DiagnosticsLog { get; }
|
||||
|
||||
/// <summary>Resolves a path relative to <see cref="Root"/>.</summary>
|
||||
string FromRoot(params string[] segments);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,9 @@
|
||||
namespace StarterNG.Application.Abstractions;
|
||||
|
||||
/// <summary>
|
||||
/// Port over the translation table. Anything that needs a user-facing string
|
||||
/// takes this, rather than reaching for the concrete localization service or a
|
||||
/// static on <c>App</c>.
|
||||
/// </summary>
|
||||
public interface ILocalizedStrings
|
||||
{
|
||||
/// <summary>
|
||||
/// Translation for a key. Missing keys return the key itself (and are logged
|
||||
/// once), so an untranslated screen stays usable.
|
||||
/// </summary>
|
||||
string this[string key] { get; }
|
||||
|
||||
/// <summary>Lookup for a key that may legitimately be absent; "" when missing.</summary>
|
||||
string Opt(string key);
|
||||
|
||||
string CurrentLanguage { get; }
|
||||
|
||||
@@ -1,19 +1,12 @@
|
||||
namespace StarterNG.Application.Abstractions;
|
||||
|
||||
/// <summary>
|
||||
/// The thumbnails in textures/mini, looked up by name. Backed by one directory
|
||||
/// scan; a name with no bitmap falls back to the generic "other" thumbnail.
|
||||
/// </summary>
|
||||
public interface IMiniTextureIndex
|
||||
{
|
||||
/// <summary>Builds the index up front, off the UI thread.</summary>
|
||||
void Preload();
|
||||
|
||||
bool Has(string? miniName);
|
||||
|
||||
/// <summary>Bitmap for the name, the fallback thumbnail, or null when neither exists.</summary>
|
||||
string? PathFor(string? miniName);
|
||||
|
||||
/// <summary>The generic thumbnail shown for unknown stock.</summary>
|
||||
string? FallbackPath { get; }
|
||||
}
|
||||
|
||||
@@ -2,20 +2,11 @@ using StarterNG.Domain.Vehicles;
|
||||
|
||||
namespace StarterNG.Application.Abstractions;
|
||||
|
||||
/// <summary>
|
||||
/// Looks up the .fiz physics of a vehicle type by model name.
|
||||
/// </summary>
|
||||
public interface IPhysicsRepository
|
||||
{
|
||||
/// <summary>Indexes the installation's .fiz files up front, off the UI thread.</summary>
|
||||
void Preload();
|
||||
|
||||
/// <summary>How many vehicle types were indexed; zero means a broken installation.</summary>
|
||||
int IndexedCount { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Physics for a model name (with or without extension), or null when the
|
||||
/// installation has no .fiz for it.
|
||||
/// </summary>
|
||||
VehiclePhysics? For(string? dataFolder, string? model);
|
||||
}
|
||||
|
||||
@@ -4,12 +4,6 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StarterNG.Application.Abstractions;
|
||||
|
||||
/// <summary>
|
||||
/// A process the starter has launched or adopted. Exposes only what the starter
|
||||
/// needs — whether the simulator is still up, and a way to await its exit — so
|
||||
/// the presentation layer never handles <see cref="System.Diagnostics.Process"/>
|
||||
/// directly.
|
||||
/// </summary>
|
||||
public interface IProcessHandle
|
||||
{
|
||||
bool HasExited { get; }
|
||||
@@ -17,26 +11,12 @@ public interface IProcessHandle
|
||||
Task WaitForExitAsync(CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Port over process creation: starting the simulator, opening a file, folder or
|
||||
/// URL in the desktop shell, and adopting an already running simulator.
|
||||
/// </summary>
|
||||
public interface IProcessLauncher
|
||||
{
|
||||
/// <summary>
|
||||
/// Starts an executable with the given arguments. Returns null when the
|
||||
/// process could not be created; <paramref name="error"/> then carries the
|
||||
/// reason for display.
|
||||
/// </summary>
|
||||
IProcessHandle? Start(string executablePath, IReadOnlyList<string> arguments, string? workingDirectory,
|
||||
out string? error);
|
||||
|
||||
/// <summary>
|
||||
/// Hands a path or URL to the desktop shell (explorer, xdg-open, ...).
|
||||
/// Returns false and logs when the shell refused it.
|
||||
/// </summary>
|
||||
bool OpenInShell(string pathOrUrl);
|
||||
|
||||
/// <summary>The first running process with that name, or null.</summary>
|
||||
IProcessHandle? FindRunning(string processName);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
namespace StarterNG.Application.Abstractions;
|
||||
|
||||
/// <summary>
|
||||
/// Port over randomness. Scenery weather deliberately varies between runs (fog
|
||||
/// distance, overcast presets, texture randomiser); routing it through a port
|
||||
/// keeps those rules assertable instead of flaky.
|
||||
/// </summary>
|
||||
public interface IRandomSource
|
||||
{
|
||||
/// <summary>Inclusive lower bound, exclusive upper bound.</summary>
|
||||
int Next(int minInclusive, int maxExclusive);
|
||||
|
||||
/// <summary>Uniform value in [0, 1).</summary>
|
||||
double NextDouble();
|
||||
}
|
||||
|
||||
@@ -4,21 +4,11 @@ using StarterNG.Domain.Sceneries;
|
||||
|
||||
namespace StarterNG.Application.Abstractions;
|
||||
|
||||
/// <summary>How far a scenery sweep has got, for the splash screen.</summary>
|
||||
public readonly record struct SceneryLoadProgress(int Loaded, int Total, string FileName);
|
||||
|
||||
/// <summary>
|
||||
/// Reads the scenarios of an installation. The only route from a .scn on disk to
|
||||
/// a <see cref="Scenery"/>; nothing else constructs one from a path.
|
||||
/// </summary>
|
||||
public interface ISceneryRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// Every scenario in the installation, in no particular order. Files that
|
||||
/// fail to parse are logged and skipped rather than failing the load.
|
||||
/// </summary>
|
||||
IReadOnlyList<Scenery> LoadAll(IProgress<SceneryLoadProgress>? progress = null);
|
||||
|
||||
/// <summary>Reloads a single scenario; null when it is gone or unreadable.</summary>
|
||||
Scenery? Load(string path);
|
||||
}
|
||||
|
||||
@@ -2,22 +2,9 @@ using StarterNG.Domain.Sceneries;
|
||||
|
||||
namespace StarterNG.Application.Abstractions;
|
||||
|
||||
/// <summary>
|
||||
/// The translations a scenery ships alongside itself, in scenery/i18n/*.json.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Scenery text may be an "@key" reference rather than literal prose, resolved
|
||||
/// against the currently loaded scenery's table. The table is per scenery, so
|
||||
/// <see cref="LoadFor"/> replaces it rather than adding to it.
|
||||
/// </remarks>
|
||||
public interface ISceneryTranslations
|
||||
{
|
||||
/// <summary>Loads the tables for one scenery, English first then the user's language.</summary>
|
||||
void LoadFor(Scenery scenery, string langCode);
|
||||
|
||||
/// <summary>
|
||||
/// Resolves an "@key" reference against the loaded table. Text that is not a
|
||||
/// reference, or a key with no translation, comes back unchanged.
|
||||
/// </summary>
|
||||
string Translate(string? text);
|
||||
}
|
||||
|
||||
@@ -2,16 +2,7 @@ using StarterNG.Domain.Vehicles;
|
||||
|
||||
namespace StarterNG.Application.Abstractions;
|
||||
|
||||
/// <summary>
|
||||
/// Reads the installation's rolling stock. The only route from the dynamic/
|
||||
/// folder to a <see cref="VehicleCatalog"/>.
|
||||
/// </summary>
|
||||
public interface IVehicleRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// Fills the catalogue from every textures.txt under dynamic/. Returns the
|
||||
/// number of liveries read, which the caller uses to spot an installation
|
||||
/// with no rolling stock at all.
|
||||
/// </summary>
|
||||
int Load(VehicleCatalog catalog);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user