Add CoreInventory.SystemsFlat list and use in UI gen elsewhere
This commit is contained in:
parent
fca37ddccf
commit
ed4ddb13ce
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using BizHawk.Client.EmuHawk.Properties;
|
using BizHawk.Client.EmuHawk.Properties;
|
||||||
using BizHawk.Common;
|
using BizHawk.Common;
|
||||||
using BizHawk.Emulation.Common;
|
using BizHawk.Emulation.Cores;
|
||||||
|
|
||||||
namespace BizHawk.Client.EmuHawk
|
namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
|
@ -46,16 +46,10 @@ namespace BizHawk.Client.EmuHawk
|
||||||
VersionLabel.Text = $"Version {mainVersion}";
|
VersionLabel.Text = $"Version {mainVersion}";
|
||||||
DateLabel.Text = VersionInfo.ReleaseDate;
|
DateLabel.Text = VersionInfo.ReleaseDate;
|
||||||
|
|
||||||
var cores = Emulation.Cores.ReflectionCache.Types
|
foreach (var core in CoreInventory.Instance.SystemsFlat.Where(core => core.CoreAttr.Released)
|
||||||
.Where(t => typeof(IEmulator).IsAssignableFrom(t))
|
.OrderByDescending(core => core.Name.ToLowerInvariant()))
|
||||||
.Select(t => t.GetCustomAttributes(false).OfType<CoreAttribute>().FirstOrDefault())
|
|
||||||
.Where(a => a != null)
|
|
||||||
.Where(a => a.Released)
|
|
||||||
.OrderByDescending(a => a.CoreName.ToLower());
|
|
||||||
|
|
||||||
foreach (var core in cores)
|
|
||||||
{
|
{
|
||||||
CoreInfoPanel.Controls.Add(new BizBoxInfoControl(core)
|
CoreInfoPanel.Controls.Add(new BizBoxInfoControl(core.CoreAttr)
|
||||||
{
|
{
|
||||||
Dock = DockStyle.Top
|
Dock = DockStyle.Top
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,6 +7,7 @@ using System.Reflection;
|
||||||
|
|
||||||
using BizHawk.Client.Common;
|
using BizHawk.Client.Common;
|
||||||
using BizHawk.Emulation.Common;
|
using BizHawk.Emulation.Common;
|
||||||
|
using BizHawk.Emulation.Cores;
|
||||||
|
|
||||||
namespace BizHawk.Client.EmuHawk
|
namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
|
@ -201,15 +202,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
CoreTree.ImageList.Images.Add("Bad", Properties.Resources.ExclamationRed);
|
CoreTree.ImageList.Images.Add("Bad", Properties.Resources.ExclamationRed);
|
||||||
CoreTree.ImageList.Images.Add("Unknown", Properties.Resources.RetroQuestion);
|
CoreTree.ImageList.Images.Add("Unknown", Properties.Resources.RetroQuestion);
|
||||||
|
|
||||||
var possibleCoreTypes = Emulation.Cores.ReflectionCache.Types
|
var possibleCoreTypes = CoreInventory.Instance.SystemsFlat
|
||||||
.Where(t => typeof(IEmulator).IsAssignableFrom(t) && !t.IsAbstract)
|
.OrderByDescending(core => core.CoreAttr.Released)
|
||||||
.Select(t => new
|
.ThenBy(core => core.Name)
|
||||||
{
|
|
||||||
Type = t,
|
|
||||||
CoreAttributes = (CoreAttribute)t.GetCustomAttributes(typeof(CoreAttribute), false).First()
|
|
||||||
})
|
|
||||||
.OrderByDescending(t => t.CoreAttributes.Released)
|
|
||||||
.ThenBy(t => t.CoreAttributes.CoreName)
|
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
toolStripStatusLabel1.Text = $"Total: {possibleCoreTypes.Count} Released: {KnownCores.Values.Count(c => c.Released)} Profiled: {KnownCores.Count}";
|
toolStripStatusLabel1.Text = $"Total: {possibleCoreTypes.Count} Released: {KnownCores.Values.Count(c => c.Released)} Profiled: {KnownCores.Count}";
|
||||||
|
@ -228,15 +223,15 @@ namespace BizHawk.Client.EmuHawk
|
||||||
CoreTree.Nodes.Add(coreNode);
|
CoreTree.Nodes.Add(coreNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var t in possibleCoreTypes)
|
foreach (var core in possibleCoreTypes)
|
||||||
{
|
{
|
||||||
if (!KnownCores.ContainsKey(t.CoreAttributes.CoreName))
|
if (!KnownCores.ContainsKey(core.Name))
|
||||||
{
|
{
|
||||||
string img = "Unknown";
|
string img = "Unknown";
|
||||||
var coreNode = new TreeNode
|
var coreNode = new TreeNode
|
||||||
{
|
{
|
||||||
Text = t.CoreAttributes.CoreName + (t.CoreAttributes.Released ? "" : " (UNRELEASED)"),
|
Text = core.Name + (core.CoreAttr.Released ? "" : " (UNRELEASED)"),
|
||||||
ForeColor = t.CoreAttributes.Released ? Color.Black : Color.DarkGray,
|
ForeColor = core.CoreAttr.Released ? Color.Black : Color.DarkGray,
|
||||||
ImageKey = img,
|
ImageKey = img,
|
||||||
SelectedImageKey = img,
|
SelectedImageKey = img,
|
||||||
StateImageKey = img
|
StateImageKey = img
|
||||||
|
|
|
@ -13,6 +13,8 @@ namespace BizHawk.Emulation.Cores
|
||||||
{
|
{
|
||||||
private readonly Dictionary<string, List<Core>> _systems = new Dictionary<string, List<Core>>();
|
private readonly Dictionary<string, List<Core>> _systems = new Dictionary<string, List<Core>>();
|
||||||
|
|
||||||
|
public readonly IReadOnlyCollection<Core> SystemsFlat;
|
||||||
|
|
||||||
public class Core
|
public class Core
|
||||||
{
|
{
|
||||||
private class RomGameFake : IRomAsset
|
private class RomGameFake : IRomAsset
|
||||||
|
@ -135,6 +137,7 @@ namespace BizHawk.Emulation.Cores
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CoreInventory(IEnumerable<IEnumerable<Type>> assys)
|
public CoreInventory(IEnumerable<IEnumerable<Type>> assys)
|
||||||
{
|
{
|
||||||
|
var systemsFlat = new Dictionary<Type, Core>();
|
||||||
void ProcessConstructor(Type type, CoreConstructorAttribute consAttr, CoreAttribute coreAttr, ConstructorInfo cons)
|
void ProcessConstructor(Type type, CoreConstructorAttribute consAttr, CoreAttribute coreAttr, ConstructorInfo cons)
|
||||||
{
|
{
|
||||||
var core = new Core(type, consAttr, coreAttr, cons);
|
var core = new Core(type, consAttr, coreAttr, cons);
|
||||||
|
@ -145,6 +148,7 @@ namespace BizHawk.Emulation.Cores
|
||||||
}
|
}
|
||||||
|
|
||||||
ss.Add(core);
|
ss.Add(core);
|
||||||
|
systemsFlat[type] = core;
|
||||||
}
|
}
|
||||||
foreach (var assy in assys)
|
foreach (var assy in assys)
|
||||||
{
|
{
|
||||||
|
@ -167,6 +171,7 @@ namespace BizHawk.Emulation.Cores
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
SystemsFlat = systemsFlat.Values;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly CoreInventory Instance = new CoreInventory(new[] { Emulation.Cores.ReflectionCache.Types });
|
public static readonly CoreInventory Instance = new CoreInventory(new[] { Emulation.Cores.ReflectionCache.Types });
|
||||||
|
|
Loading…
Reference in New Issue