add core scanning system
This commit is contained in:
parent
64e38e83c8
commit
f356d5b354
|
@ -8,6 +8,7 @@ using BizHawk.Emulation.CPUs.M6502;
|
|||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
[CoreVersion("0.0.0.1",FriendlyName="NESHawk")]
|
||||
public partial class NES : IEmulator
|
||||
{
|
||||
//hardware/state
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
using System.Diagnostics;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
@ -41,6 +42,45 @@ namespace BizHawk
|
|||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class CoreVersion : Attribute
|
||||
{
|
||||
public CoreVersion(string version)
|
||||
{
|
||||
this.Version = version;
|
||||
}
|
||||
|
||||
public string Version { get; set; }
|
||||
public string FriendlyName { get; set; }
|
||||
}
|
||||
|
||||
public static class Introspection
|
||||
{
|
||||
public class CoreInfo
|
||||
{
|
||||
public string ClassName, Version, FriendlyName;
|
||||
}
|
||||
|
||||
public static List<CoreInfo> GetCoreInfo()
|
||||
{
|
||||
var ret = new List<CoreInfo>();
|
||||
//scan types in this assembly to find ones that implement boards to add them to the list
|
||||
foreach (Type type in Assembly.GetExecutingAssembly().GetTypes())
|
||||
{
|
||||
var attrs = type.GetCustomAttributes(typeof(CoreVersion), true);
|
||||
if (attrs.Length == 0) continue;
|
||||
var cv = (CoreVersion)attrs[0];
|
||||
var ci = new CoreInfo();
|
||||
ci.ClassName = type.Name;
|
||||
ci.FriendlyName = cv.FriendlyName;
|
||||
if (string.IsNullOrEmpty(ci.FriendlyName)) ci.FriendlyName = ci.ClassName;
|
||||
ci.Version = cv.Version;
|
||||
ret.Add(ci);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Extensions
|
||||
{
|
||||
public static void CopyTo(this Stream src, Stream dest)
|
||||
|
|
|
@ -87,6 +87,12 @@ namespace BizHawk.MultiClient
|
|||
Global.CoreInputComm = new CoreInputComm();
|
||||
SyncCoreInputComm();
|
||||
|
||||
Console.WriteLine("Scanning cores:");
|
||||
foreach (var ci in Introspection.GetCoreInfo())
|
||||
{
|
||||
Console.WriteLine("{0} - {1} ({2})", ci.FriendlyName, ci.Version, ci.ClassName);
|
||||
}
|
||||
|
||||
Database.LoadDatabase(PathManager.GetExeDirectoryAbsolute() + "\\gamedb.txt");
|
||||
|
||||
SyncPresentationMode();
|
||||
|
|
Loading…
Reference in New Issue