mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-18 22:45:59 +01:00
The simulator makes a scenery's .sbt on its first load and never checks it against the text again, so an older simulator's file, or one made before a scenery update, keeps showing the old terrain. - CleanupGeneration, raised by a release, clears the .sbt files once per installation on the first start, ahead of the scenery list. A file goes only while its scenery's terrain files (*_ter.scm) are all there and no terrain directive brings terrain from elsewhere; an .sbt standing in for missing terrain stays, and the log says what is missing. Which cleanup each installation had is kept in sbt-cleanup.txt in the user's folder. - "Delete SBT" in the scenery list's menu does the same for one scenery, asking first and refusing where nothing could make the file again. - The .sbt is among the files a scenery is watched by, so one made or removed reaches the list without a reload.
62 lines
2.2 KiB
C#
62 lines
2.2 KiB
C#
using System.IO;
|
|
using StarterNG.Application.Abstractions;
|
|
|
|
namespace StarterNG.Infrastructure.Settings;
|
|
|
|
public sealed class SettingsPaths
|
|
{
|
|
private const string ConfigFileName = "eu07.ini";
|
|
private const string VendorFolder = "MaSzyna";
|
|
|
|
private readonly IEnvironment _environment;
|
|
private readonly IGamePaths _paths;
|
|
|
|
public SettingsPaths(IEnvironment environment, IGamePaths paths)
|
|
{
|
|
_environment = environment;
|
|
_paths = paths;
|
|
}
|
|
|
|
public string UserConfigPath()
|
|
{
|
|
if (_environment.IsWindows)
|
|
{
|
|
string? appData = _environment.GetVariable("APPDATA");
|
|
if (!string.IsNullOrEmpty(appData))
|
|
return Path.Combine(appData, VendorFolder, ConfigFileName);
|
|
}
|
|
else if (_environment.IsMacOS)
|
|
{
|
|
string? home = _environment.GetVariable("HOME");
|
|
if (!string.IsNullOrEmpty(home))
|
|
return Path.Combine(home, "Library", "Application Support", VendorFolder, ConfigFileName);
|
|
}
|
|
else
|
|
{
|
|
string? home = _environment.GetVariable("HOME");
|
|
if (!string.IsNullOrEmpty(home))
|
|
return Path.Combine(home, ".config", VendorFolder, ConfigFileName);
|
|
}
|
|
|
|
return Path.Combine(_environment.BaseDirectory, ConfigFileName);
|
|
}
|
|
|
|
public string InstallationConfigPath() => _paths.FromRoot(ConfigFileName);
|
|
|
|
/// <summary>
|
|
/// Where the starter keeps its own copy of the vehicle database. Per user
|
|
/// rather than under the installation: that one can be read-only, is a working
|
|
/// copy someone updates from under us, and the copy is ours, not the game's.
|
|
/// </summary>
|
|
public string VehicleCacheDirectory() => Path.Combine(UserConfigDirectory(), "vehicles");
|
|
|
|
/// <summary>The sceneries starred in the list.</summary>
|
|
public string FavoritesPath() => Path.Combine(UserConfigDirectory(), "favorites.txt");
|
|
|
|
/// <summary>Which cleanup of the .sbt files each installation had.</summary>
|
|
public string SbtCleanupPath() => Path.Combine(UserConfigDirectory(), "sbt-cleanup.txt");
|
|
|
|
public string UserConfigDirectory() =>
|
|
Path.GetDirectoryName(UserConfigPath()) ?? _environment.BaseDirectory;
|
|
}
|