Lua console - implement saving/loading of column info
This commit is contained in:
parent
f802f48754
commit
6c22e1c4c6
|
@ -123,6 +123,7 @@
|
||||||
<Compile Include="config\ConfigPersistAttribute.cs" />
|
<Compile Include="config\ConfigPersistAttribute.cs" />
|
||||||
<Compile Include="config\ConfigService.cs" />
|
<Compile Include="config\ConfigService.cs" />
|
||||||
<Compile Include="config\PathEntry.cs" />
|
<Compile Include="config\PathEntry.cs" />
|
||||||
|
<Compile Include="config\RestoreDefaultsAttribute.cs" />
|
||||||
<Compile Include="config\ToolDialogSettings.cs" />
|
<Compile Include="config\ToolDialogSettings.cs" />
|
||||||
<Compile Include="ControllerBinding.cs" />
|
<Compile Include="ControllerBinding.cs" />
|
||||||
<Compile Include="CoreFileProvider.cs" />
|
<Compile Include="CoreFileProvider.cs" />
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace BizHawk.Client.Common
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Defines a method to be called when a tool dialog's Restore Defaults method is called
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Method)]
|
||||||
|
public class RestoreDefaultsAttribute : Attribute
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -134,7 +134,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
private void LuaConsole_Load(object sender, EventArgs e)
|
private void LuaConsole_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// Hack for previous config settings
|
// Hack for previous config settings
|
||||||
if (Settings.Columns.Any(c => string.IsNullOrWhiteSpace(c.Text)))
|
if (Settings.Columns.Any(c => c.Text == null))
|
||||||
{
|
{
|
||||||
Settings = new LuaConsoleSettings();
|
Settings = new LuaConsoleSettings();
|
||||||
}
|
}
|
||||||
|
@ -154,6 +154,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LuaListView.AllColumns.Clear();
|
||||||
SetColumns();
|
SetColumns();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1468,5 +1469,14 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[RestoreDefaults]
|
||||||
|
private void RestoreDefaults()
|
||||||
|
{
|
||||||
|
Settings = new LuaConsoleSettings();
|
||||||
|
LuaListView.AllColumns.Clear();
|
||||||
|
SetColumns();
|
||||||
|
UpdateDialog();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -323,6 +323,11 @@ namespace BizHawk.Client.EmuHawk
|
||||||
settings.RestoreDefaults();
|
settings.RestoreDefaults();
|
||||||
RefreshSettings(form, dest, settings, idx);
|
RefreshSettings(form, dest, settings, idx);
|
||||||
form.Size = oldsize;
|
form.Size = oldsize;
|
||||||
|
|
||||||
|
form.GetType()
|
||||||
|
.GetMethodsWithAttrib(typeof(RestoreDefaultsAttribute))
|
||||||
|
.FirstOrDefault()
|
||||||
|
?.Invoke(form, new object[0]);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,12 @@ namespace BizHawk.Common.ReflectionExtensions
|
||||||
.Where(p => p.GetCustomAttributes(attributeType, false).Length > 0);
|
.Where(p => p.GetCustomAttributes(attributeType, false).Length > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IEnumerable<MethodInfo> GetMethodsWithAttrib(this Type type, Type attributeType)
|
||||||
|
{
|
||||||
|
return type.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic)
|
||||||
|
.Where(p => p.GetCustomAttributes(attributeType, false).Length > 0);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the description attribute from an object
|
/// Gets the description attribute from an object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in New Issue