diff options
Diffstat (limited to 'Ryujinx.Common')
| -rw-r--r-- | Ryujinx.Common/Configuration/AppDataManager.cs | 69 | ||||
| -rw-r--r-- | Ryujinx.Common/Configuration/ConfigurationState.cs | 2 | ||||
| -rw-r--r-- | Ryujinx.Common/Logging/Logger.cs | 5 |
3 files changed, 75 insertions, 1 deletions
diff --git a/Ryujinx.Common/Configuration/AppDataManager.cs b/Ryujinx.Common/Configuration/AppDataManager.cs new file mode 100644 index 00000000..6630026f --- /dev/null +++ b/Ryujinx.Common/Configuration/AppDataManager.cs @@ -0,0 +1,69 @@ +using Ryujinx.Common.Logging; +using System; +using System.IO; + +namespace Ryujinx.Common.Configuration +{ + public static class AppDataManager + { + private static readonly string _defaultBaseDirPath; + + private const string DefaultBaseDir = "Ryujinx"; + + // The following 3 are always part of Base Directory + private const string GamesDir = "games"; + private const string ProfilesDir = "profiles"; + private const string KeysDir = "system"; + + public static bool IsCustomBasePath { get; private set; } + public static string BaseDirPath { get; private set; } + public static string GamesDirPath { get; private set; } + public static string ProfilesDirPath { get; private set; } + public static string KeysDirPath { get; private set; } + public static string KeysDirPathAlt { get; } + + public const string DefaultNandDir = "bis"; + public const string DefaultSdcardDir = "sdcard"; + private const string DefaultModsDir = "mods"; + + public static string CustomModsPath { get; set; } + public static string CustomNandPath { get; set; } // TODO: Actually implement this into VFS + public static string CustomSdCardPath { get; set; } // TODO: Actually implement this into VFS + + static AppDataManager() + { + _defaultBaseDirPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), DefaultBaseDir); + KeysDirPathAlt = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".switch"); + } + + public static void Initialize(string baseDirPath) + { + BaseDirPath = _defaultBaseDirPath; + + if (baseDirPath != null && baseDirPath != _defaultBaseDirPath) + { + if (!Directory.Exists(baseDirPath)) + { + Logger.Error?.Print(LogClass.Application, $"Custom Data Directory '{baseDirPath}' does not exist. Using defaults..."); + } + else + { + BaseDirPath = baseDirPath; + IsCustomBasePath = true; + } + } + + SetupBasePaths(); + } + + private static void SetupBasePaths() + { + Directory.CreateDirectory(BaseDirPath); + Directory.CreateDirectory(GamesDirPath = Path.Combine(BaseDirPath, GamesDir)); + Directory.CreateDirectory(ProfilesDirPath = Path.Combine(BaseDirPath, ProfilesDir)); + Directory.CreateDirectory(KeysDirPath = Path.Combine(BaseDirPath, KeysDir)); + } + + public static string GetModsPath() => CustomModsPath ?? Directory.CreateDirectory(Path.Combine(BaseDirPath, DefaultModsDir)).FullName; + } +}
\ No newline at end of file diff --git a/Ryujinx.Common/Configuration/ConfigurationState.cs b/Ryujinx.Common/Configuration/ConfigurationState.cs index 489382cd..7f79dd6e 100644 --- a/Ryujinx.Common/Configuration/ConfigurationState.cs +++ b/Ryujinx.Common/Configuration/ConfigurationState.cs @@ -750,7 +750,7 @@ namespace Ryujinx.Configuration { ToFileFormat().SaveConfig(configurationFilePath); - Common.Logging.Logger.Warning?.Print(LogClass.Application, "Configuration file has been updated!"); + Common.Logging.Logger.Notice.Print(LogClass.Application, $"Configuration file updated to version {ConfigurationFileFormat.CurrentVersion}"); } } diff --git a/Ryujinx.Common/Logging/Logger.cs b/Ryujinx.Common/Logging/Logger.cs index 9246368c..e41eaf53 100644 --- a/Ryujinx.Common/Logging/Logger.cs +++ b/Ryujinx.Common/Logging/Logger.cs @@ -112,6 +112,11 @@ namespace Ryujinx.Common.Logging AsyncLogTargetOverflowAction.Discard)); Notice = new Log(LogLevel.Notice); + + // Enable important log levels before configuration is loaded + Error = new Log(LogLevel.Error); + Warning = new Log(LogLevel.Warning); + Info = new Log(LogLevel.Info); } public static void RestartTime() |
