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 System;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Nintendo.Gameboy; using BizHawk.Emulation.Cores;
namespace BizHawk.Client.Common namespace BizHawk.Client.Common
{ {
@ -61,13 +61,10 @@ namespace BizHawk.Client.Common
return Convert.ToUInt64(Header[HeaderKeys.VBlankCount]); 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; return Convert.ToUInt64(Header[HeaderKeys.CycleCount]);
if (Header[HeaderKeys.Core] == gambatteName)
{
return Convert.ToUInt64(Header[HeaderKeys.CycleCount]);
}
} }
return (ulong)Log.Count; return (ulong)Log.Count;

View File

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

View File

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

View File

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

View File

@ -2,7 +2,6 @@
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores; using BizHawk.Emulation.Cores;
using BizHawk.Emulation.Cores.Nintendo.SNES; using BizHawk.Emulation.Cores.Nintendo.SNES;
@ -17,8 +16,7 @@ namespace BizHawk.Client.Common.movie.import
protected override void RunImport() protected override void RunImport()
{ {
var bsnesName = ((CoreAttribute)Attribute.GetCustomAttribute(typeof(LibsnesCore), typeof(CoreAttribute))).CoreName; Result.Movie.HeaderEntries[HeaderKeys.Core] = CoreNames.Bsnes;
Result.Movie.HeaderEntries[HeaderKeys.Core] = bsnesName;
using var fs = SourceFile.Open(FileMode.Open, FileAccess.Read); using var fs = SourceFile.Open(FileMode.Open, FileAccess.Read);
using var r = new BinaryReader(fs); 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.Common;
using BizHawk.Emulation.Cores; using BizHawk.Emulation.Cores;
using BizHawk.Emulation.Cores.Nintendo.GBA; using BizHawk.Emulation.Cores.Nintendo.GBA;
@ -115,8 +114,7 @@ namespace BizHawk.Client.Common.movie.import
if (isGBA) if (isGBA)
{ {
platform = "GBA"; platform = "GBA";
var mGBAName = ((CoreAttribute)Attribute.GetCustomAttribute(typeof(MGBAHawk), typeof(CoreAttribute))).CoreName; Result.Movie.HeaderEntries[HeaderKeys.Core] = CoreNames.Mgba;
Result.Movie.HeaderEntries[HeaderKeys.Core] = mGBAName;
} }
if (isGBC) if (isGBC)