Move DefaultIniPath property to Config, and delete PathManager.cs
This commit is contained in:
parent
e16dc33722
commit
b1cac9ba00
|
@ -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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The location of the default INI file
|
||||
/// </summary>
|
||||
public static string DefaultIniPath { get; private set; }
|
||||
|
||||
public static void SetDefaultIniPath(string newDefaultIniPath)
|
||||
{
|
||||
DefaultIniPath = newDefaultIniPath;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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<Config>(PathManager.DefaultIniPath);
|
||||
Config = ConfigService.Load<Config>(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),
|
||||
|
|
|
@ -2350,7 +2350,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
path = PathManager.DefaultIniPath;
|
||||
path = Config.DefaultIniPath;
|
||||
}
|
||||
|
||||
ConfigService.Save(path, Config);
|
||||
|
|
|
@ -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<Config>(PathManager.DefaultIniPath);
|
||||
Global.Config = ConfigService.Load<Config>(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<Config>(PathManager.DefaultIniPath);
|
||||
File.Delete(Config.DefaultIniPath);
|
||||
Global.Config = ConfigService.Load<Config>(Config.DefaultIniPath);
|
||||
}
|
||||
|
||||
Global.Config.ResolveDefaults();
|
||||
|
|
Loading…
Reference in New Issue