From a73fd9e9bdb18d198cbfaf45108aec23db78db71 Mon Sep 17 00:00:00 2001 From: Xpl0itR Date: Fri, 14 Feb 2020 19:19:13 +0000 Subject: [PATCH] Changes to configuration (#811) * config loading changes - load config from either ryufs or ryujinx.exe parent folder with parent folder taking priority - config file in repo is only copied to parent directory if built in debug mode * AcK's requested changes * add "Profile Debug" as a condition to copy the default config to output --- Ryujinx/Program.cs | 24 ++++++++++++++++++++---- Ryujinx/Ryujinx.csproj | 2 +- Ryujinx/Ui/MainWindow.cs | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Ryujinx/Program.cs b/Ryujinx/Program.cs index 5fca0933..1f417f5a 100644 --- a/Ryujinx/Program.cs +++ b/Ryujinx/Program.cs @@ -14,6 +14,8 @@ namespace Ryujinx { public static string Version { get; private set; } + public static string ConfigurationPath { get; set; } + static void Main(string[] args) { Toolkit.Init(new ToolkitOptions @@ -40,19 +42,33 @@ namespace Ryujinx // Initialize Discord integration DiscordIntegrationModule.Initialize(); - string configurationPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.json"); + string localConfigurationPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.json"); + string globalConfigurationPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Ryujinx", "Config.json"); // Now load the configuration as the other subsystems are now registered - if (File.Exists(configurationPath)) + if (File.Exists(localConfigurationPath)) { - ConfigurationFileFormat configurationFileFormat = ConfigurationFileFormat.Load(configurationPath); + ConfigurationPath = localConfigurationPath; + + ConfigurationFileFormat configurationFileFormat = ConfigurationFileFormat.Load(localConfigurationPath); + + ConfigurationState.Instance.Load(configurationFileFormat); + } + else if (File.Exists(globalConfigurationPath)) + { + ConfigurationPath = globalConfigurationPath; + + ConfigurationFileFormat configurationFileFormat = ConfigurationFileFormat.Load(globalConfigurationPath); + ConfigurationState.Instance.Load(configurationFileFormat); } else { // No configuration, we load the default values and save it on disk + ConfigurationPath = globalConfigurationPath; + ConfigurationState.Instance.LoadDefault(); - ConfigurationState.Instance.ToFileFormat().SaveConfig(configurationPath); + ConfigurationState.Instance.ToFileFormat().SaveConfig(globalConfigurationPath); } Profile.Initialize(); diff --git a/Ryujinx/Ryujinx.csproj b/Ryujinx/Ryujinx.csproj index 9bd2de66..25eb8ff4 100644 --- a/Ryujinx/Ryujinx.csproj +++ b/Ryujinx/Ryujinx.csproj @@ -90,7 +90,7 @@ - + PreserveNewest diff --git a/Ryujinx/Ui/MainWindow.cs b/Ryujinx/Ui/MainWindow.cs index e9e79d77..51b40b94 100644 --- a/Ryujinx/Ui/MainWindow.cs +++ b/Ryujinx/Ui/MainWindow.cs @@ -1116,7 +1116,7 @@ namespace Ryujinx.Ui public static void SaveConfig() { - ConfigurationState.Instance.ToFileFormat().SaveConfig(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.json")); + ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath); } } }