Files
StarterNG/StarterNG/Infrastructure/Settings/SettingsPaths.cs
maj00r 52ad490fb7 Drop the update check - Steam updates the starter
The daily GitHub check, the top-bar button, the stable/staging channel and
"check now" go, with their settings and texts.
2026-10-04 18:46:38 +02:00

59 lines
2.0 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");
public string UserConfigDirectory() =>
Path.GetDirectoryName(UserConfigPath()) ?? _environment.BaseDirectory;
}