mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-23 00:24:41 +01:00
The daily GitHub check, the top-bar button, the stable/staging channel and "check now" go, with their settings and texts.
59 lines
2.0 KiB
C#
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;
|
|
}
|