break off settings methods from config to extension methods
This commit is contained in:
parent
86078addd4
commit
e30eb0cde6
|
@ -2,7 +2,6 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
// ReSharper disable FieldCanBeMadeReadOnly.Global
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
@ -279,73 +278,10 @@ namespace BizHawk.Client.Common
|
|||
public int GifWriterDelay = -1;
|
||||
public bool VideoWriterAudioSync = true;
|
||||
|
||||
#region emulation core settings
|
||||
|
||||
// Emulation core settings
|
||||
public Dictionary<string, object> CoreSettings = new Dictionary<string, object>();
|
||||
public Dictionary<string, object> CoreSyncSettings = new Dictionary<string, object>();
|
||||
|
||||
public object GetCoreSettings<T>()
|
||||
where T : IEmulator
|
||||
{
|
||||
return GetCoreSettings(typeof(T));
|
||||
}
|
||||
|
||||
public object GetCoreSettings(Type t)
|
||||
{
|
||||
CoreSettings.TryGetValue(t.ToString(), out var ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void PutCoreSettings<T>(object o)
|
||||
where T : IEmulator
|
||||
{
|
||||
PutCoreSettings(o, typeof(T));
|
||||
}
|
||||
|
||||
public void PutCoreSettings(object o, Type t)
|
||||
{
|
||||
if (o != null)
|
||||
{
|
||||
CoreSettings[t.ToString()] = o;
|
||||
}
|
||||
else
|
||||
{
|
||||
CoreSettings.Remove(t.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public object GetCoreSyncSettings<T>()
|
||||
where T : IEmulator
|
||||
{
|
||||
return GetCoreSyncSettings(typeof(T));
|
||||
}
|
||||
|
||||
public object GetCoreSyncSettings(Type t)
|
||||
{
|
||||
CoreSyncSettings.TryGetValue(t.ToString(), out var ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void PutCoreSyncSettings<T>(object o)
|
||||
where T : IEmulator
|
||||
{
|
||||
PutCoreSyncSettings(o, typeof(T));
|
||||
}
|
||||
|
||||
public void PutCoreSyncSettings(object o, Type t)
|
||||
{
|
||||
if (o != null)
|
||||
{
|
||||
CoreSyncSettings[t.ToString()] = o;
|
||||
}
|
||||
else
|
||||
{
|
||||
CoreSyncSettings.Remove(t.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public Dictionary<string, ToolDialogSettings> CommonToolSettings = new Dictionary<string, ToolDialogSettings>();
|
||||
public Dictionary<string, Dictionary<string, object>> CustomToolSettings = new Dictionary<string, Dictionary<string, object>>();
|
||||
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
using System;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
public static class ConfigExtensions
|
||||
{
|
||||
public static object GetCoreSettings(this Config config, Type t)
|
||||
{
|
||||
config.CoreSettings.TryGetValue(t.ToString(), out var ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static object GetCoreSettings<T>(this Config config)
|
||||
where T : IEmulator
|
||||
{
|
||||
return config.GetCoreSettings(typeof(T));
|
||||
}
|
||||
|
||||
public static void PutCoreSettings(this Config config, object o, Type t)
|
||||
{
|
||||
if (o != null)
|
||||
{
|
||||
config.CoreSettings[t.ToString()] = o;
|
||||
}
|
||||
else
|
||||
{
|
||||
config.CoreSettings.Remove(t.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public static void PutCoreSettings<T>(this Config config, object o)
|
||||
where T : IEmulator
|
||||
{
|
||||
config.PutCoreSettings(o, typeof(T));
|
||||
}
|
||||
|
||||
public static object GetCoreSyncSettings<T>(this Config config)
|
||||
where T : IEmulator
|
||||
{
|
||||
return config.GetCoreSyncSettings(typeof(T));
|
||||
}
|
||||
|
||||
public static object GetCoreSyncSettings(this Config config, Type t)
|
||||
{
|
||||
config.CoreSyncSettings.TryGetValue(t.ToString(), out var ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void PutCoreSyncSettings(this Config config, object o, Type t)
|
||||
{
|
||||
if (o != null)
|
||||
{
|
||||
config.CoreSyncSettings[t.ToString()] = o;
|
||||
}
|
||||
else
|
||||
{
|
||||
config.CoreSyncSettings.Remove(t.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public static void PutCoreSyncSettings<T>(this Config config, object o)
|
||||
where T : IEmulator
|
||||
{
|
||||
config.PutCoreSyncSettings(o, typeof(T));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue