Simplify getting core names by using the constant instead of reflection

This commit is contained in:
adelikat 2020-05-23 20:28:28 -05:00
parent e94432dbd8
commit d4aa057664
6 changed files with 13 additions and 24 deletions

View File

@ -1,6 +1,6 @@
using System;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Nintendo.Gameboy;
using BizHawk.Emulation.Cores;
namespace BizHawk.Client.Common
{
@ -61,13 +61,10 @@ namespace BizHawk.Client.Common
return Convert.ToUInt64(Header[HeaderKeys.VBlankCount]);
}
if (Header.ContainsKey(HeaderKeys.CycleCount))
if (Header.ContainsKey(HeaderKeys.CycleCount)
&& Header[HeaderKeys.Core] == CoreNames.Gambatte)
{
var gambatteName = ((CoreAttribute)Attribute.GetCustomAttribute(typeof(Gameboy), typeof(CoreAttribute))).CoreName;
if (Header[HeaderKeys.Core] == gambatteName)
{
return Convert.ToUInt64(Header[HeaderKeys.CycleCount]);
}
return Convert.ToUInt64(Header[HeaderKeys.CycleCount]);
}
return (ulong)Log.Count;

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Text;
using BizHawk.Common.BufferExtensions;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores;
using BizHawk.Emulation.Cores.Nintendo.NES;
namespace BizHawk.Client.Common.movie.import
@ -17,8 +17,7 @@ namespace BizHawk.Client.Common.movie.import
protected override void RunImport()
{
var neshawkName = ((CoreAttribute)Attribute.GetCustomAttribute(typeof(NES), typeof(CoreAttribute))).CoreName;
Result.Movie.HeaderEntries[HeaderKeys.Core] = neshawkName;
Result.Movie.HeaderEntries[HeaderKeys.Core] = CoreNames.NesHawk;
using var r = new BinaryReader(SourceFile.Open(FileMode.Open, FileAccess.Read));
var signature = new string(r.ReadChars(4));

View File

@ -2,7 +2,7 @@
using BizHawk.Common;
using BizHawk.Common.BufferExtensions;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores;
using BizHawk.Emulation.Cores.Nintendo.NES;
namespace BizHawk.Client.Common
@ -14,8 +14,7 @@ namespace BizHawk.Client.Common
{
protected override void RunImport()
{
var neshawkName = ((CoreAttribute)Attribute.GetCustomAttribute(typeof(NES), typeof(CoreAttribute))).CoreName;
Result.Movie.HeaderEntries[HeaderKeys.Core] = neshawkName;
Result.Movie.HeaderEntries[HeaderKeys.Core] = CoreNames.NesHawk;
const string emulator = "FCEUX";
var platform = "NES"; // TODO: FDS?

View File

@ -1,5 +1,4 @@
using System;
using System.IO;
using System.IO;
using System.Linq;
using System.Text;
using BizHawk.Common;
@ -18,8 +17,7 @@ namespace BizHawk.Client.Common.movie.import
private LibsnesControllerDeck _deck;
protected override void RunImport()
{
var bsnesName = ((CoreAttribute)Attribute.GetCustomAttribute(typeof(LibsnesCore), typeof(CoreAttribute))).CoreName;
Result.Movie.HeaderEntries[HeaderKeys.Core] = bsnesName;
Result.Movie.HeaderEntries[HeaderKeys.Core] = CoreNames.Bsnes;
var hf = new HawkFile(SourceFile.FullName);

View File

@ -2,7 +2,6 @@
using System.IO;
using System.Linq;
using System.Text;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores;
using BizHawk.Emulation.Cores.Nintendo.SNES;
@ -17,8 +16,7 @@ namespace BizHawk.Client.Common.movie.import
protected override void RunImport()
{
var bsnesName = ((CoreAttribute)Attribute.GetCustomAttribute(typeof(LibsnesCore), typeof(CoreAttribute))).CoreName;
Result.Movie.HeaderEntries[HeaderKeys.Core] = bsnesName;
Result.Movie.HeaderEntries[HeaderKeys.Core] = CoreNames.Bsnes;
using var fs = SourceFile.Open(FileMode.Open, FileAccess.Read);
using var r = new BinaryReader(fs);

View File

@ -1,5 +1,4 @@
using System;
using System.IO;
using System.IO;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores;
using BizHawk.Emulation.Cores.Nintendo.GBA;
@ -115,8 +114,7 @@ namespace BizHawk.Client.Common.movie.import
if (isGBA)
{
platform = "GBA";
var mGBAName = ((CoreAttribute)Attribute.GetCustomAttribute(typeof(MGBAHawk), typeof(CoreAttribute))).CoreName;
Result.Movie.HeaderEntries[HeaderKeys.Core] = mGBAName;
Result.Movie.HeaderEntries[HeaderKeys.Core] = CoreNames.Mgba;
}
if (isGBC)