diff --git a/BizHawk.Client.Common/PathManager.cs b/BizHawk.Client.Common/PathManager.cs deleted file mode 100644 index c56819922a..0000000000 --- a/BizHawk.Client.Common/PathManager.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.IO; -using System.Reflection; -using BizHawk.Common.PathExtensions; - -namespace BizHawk.Client.Common -{ - public static class PathManager - { - static PathManager() - { - var defaultIni = Path.Combine(PathUtils.GetExeDirectoryAbsolute(), "config.ini"); - SetDefaultIniPath(defaultIni); - } - - /// - /// The location of the default INI file - /// - public static string DefaultIniPath { get; private set; } - - public static void SetDefaultIniPath(string newDefaultIniPath) - { - DefaultIniPath = newDefaultIniPath; - } - } -} diff --git a/BizHawk.Client.Common/config/Config.cs b/BizHawk.Client.Common/config/Config.cs index 313611570c..134732aff7 100644 --- a/BizHawk.Client.Common/config/Config.cs +++ b/BizHawk.Client.Common/config/Config.cs @@ -9,6 +9,14 @@ namespace BizHawk.Client.Common public class Config { public static string ControlDefaultPath => Path.Combine(PathUtils.GetExeDirectoryAbsolute(), "defctrl.json"); + + public static string DefaultIniPath { get; private set; } = Path.Combine(PathUtils.GetExeDirectoryAbsolute(), "config.ini"); + + // Shenanigans + public static void SetDefaultIniPath(string newDefaultIniPath) + { + DefaultIniPath = newDefaultIniPath; + } public Config() { diff --git a/BizHawk.Client.EmuHawk/MainForm.Events.cs b/BizHawk.Client.EmuHawk/MainForm.Events.cs index 3bc2824e64..e19acc471f 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -1339,7 +1339,7 @@ namespace BizHawk.Client.EmuHawk private void SaveConfigAsMenuItem_Click(object sender, EventArgs e) { - var path = PathManager.DefaultIniPath; + var path = Config.DefaultIniPath; using var sfd = new SaveFileDialog { InitialDirectory = Path.GetDirectoryName(path), @@ -1356,15 +1356,15 @@ namespace BizHawk.Client.EmuHawk private void LoadConfigMenuItem_Click(object sender, EventArgs e) { - Config = ConfigService.Load(PathManager.DefaultIniPath); + Config = ConfigService.Load(Config.DefaultIniPath); Config.ResolveDefaults(); InitControls(); // rebind hotkeys - AddOnScreenMessage($"Config file loaded: {PathManager.DefaultIniPath}"); + AddOnScreenMessage($"Config file loaded: {Config.DefaultIniPath}"); } private void LoadConfigFromMenuItem_Click(object sender, EventArgs e) { - var path = PathManager.DefaultIniPath; + var path = Config.DefaultIniPath; using var ofd = new OpenFileDialog { InitialDirectory = Path.GetDirectoryName(path), diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index 38a3fb7a35..bc6682f166 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -2350,7 +2350,7 @@ namespace BizHawk.Client.EmuHawk if (string.IsNullOrEmpty(path)) { - path = PathManager.DefaultIniPath; + path = Config.DefaultIniPath; } ConfigService.Save(path, Config); diff --git a/BizHawk.Client.EmuHawk/Program.cs b/BizHawk.Client.EmuHawk/Program.cs index a40004d29d..f900e7313e 100644 --- a/BizHawk.Client.EmuHawk/Program.cs +++ b/BizHawk.Client.EmuHawk/Program.cs @@ -104,18 +104,18 @@ namespace BizHawk.Client.EmuHawk HawkFile.DearchivalMethod = SharpCompressDearchivalMethod.Instance; string cmdConfigFile = ArgParser.GetCmdConfigFile(args); - if (cmdConfigFile != null) PathManager.SetDefaultIniPath(cmdConfigFile); + if (cmdConfigFile != null) Config.SetDefaultIniPath(cmdConfigFile); try { - Global.Config = ConfigService.Load(PathManager.DefaultIniPath); + Global.Config = ConfigService.Load(Config.DefaultIniPath); } catch (Exception e) { new ExceptionBox(e).ShowDialog(); new ExceptionBox("Since your config file is corrupted or from a different BizHawk version, we're going to recreate it. Back it up before proceeding if you want to investigate further.").ShowDialog(); - File.Delete(PathManager.DefaultIniPath); - Global.Config = ConfigService.Load(PathManager.DefaultIniPath); + File.Delete(Config.DefaultIniPath); + Global.Config = ConfigService.Load(Config.DefaultIniPath); } Global.Config.ResolveDefaults();