Skip to content

Commit

Permalink
Extract subtype PortedCoreAttribute from CoreAttribute
Browse files Browse the repository at this point in the history
  • Loading branch information
YoshiRulz committed May 6, 2021
1 parent 796d065 commit 98b07c4
Show file tree
Hide file tree
Showing 53 changed files with 89 additions and 209 deletions.
6 changes: 3 additions & 3 deletions src/BizHawk.Client.EmuHawk/BizBoxInfoControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public BizBoxInfoControl(CoreAttribute attributes)
CoreAuthorLabel.Visible = false;
}

if (attributes.Ported)
if (attributes is PortedCoreAttribute ported)
{
CorePortedLabel.Text = " (Ported)";
_url = attributes.PortedUrl;
CoreUrlLink.Text = attributes.PortedVersion;
_url = ported.PortedUrl;
CoreUrlLink.Text = ported.PortedVersion;
CoreUrlLink.Visible = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/BizHawk.Client.EmuHawk/Extensions/CoreExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static Bitmap Icon(this IEmulator core)
{
var attributes = core.Attributes();

if (!attributes.Ported)
if (attributes is not PortedCoreAttribute)
{
return Properties.Resources.CorpHawkSmall;
}
Expand Down
2 changes: 1 addition & 1 deletion src/BizHawk.Client.EmuHawk/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2795,7 +2795,7 @@ private void UpdateCoreStatusBarButton()

CoreNameStatusBarButton.Text = coreDispName;
CoreNameStatusBarButton.Image = Emulator.Icon();
CoreNameStatusBarButton.ToolTipText = attributes.Ported ? "(ported) " : "";
CoreNameStatusBarButton.ToolTipText = attributes is PortedCoreAttribute ? "(ported) " : "";


if (Emulator.SystemId == "ZXSpectrum")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace BizHawk.Emulation.Common
{
[Core("NullHawk", "", false, true)]
[Core("NullHawk", "")]
[ServiceNotApplicable(new[] {
typeof(IVideoProvider),
typeof(IBoardInfo),
Expand Down
48 changes: 34 additions & 14 deletions src/BizHawk.Emulation.Common/CoreAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,47 @@
using System;
#nullable enable

using System;

namespace BizHawk.Emulation.Common
{
[AttributeUsage(AttributeTargets.Class)]
public sealed class CoreAttribute : Attribute
public class CoreAttribute : Attribute
{
public CoreAttribute(string name, string author, bool isPorted, bool isReleased, string portedVersion = null, string portedUrl = null, bool singleInstance = false)
public readonly string Author;

public readonly string CoreName;

public readonly bool Released;

public readonly bool SingleInstance;

public CoreAttribute(string name, string author, bool singleInstance = false, bool isReleased = true)
{
CoreName = name;
Author = author;
Ported = isPorted;
CoreName = name;
Released = isReleased;
PortedVersion = portedVersion ?? string.Empty;
PortedUrl = portedUrl ?? string.Empty;
SingleInstance = singleInstance;
}
}

[AttributeUsage(AttributeTargets.Class)]
public sealed class PortedCoreAttribute : CoreAttribute
{
public readonly string PortedUrl;

public string CoreName { get; }
public string Author { get; }
public bool Ported { get; }
public bool Released { get; }
public string PortedVersion { get; }
public string PortedUrl { get; }
public bool SingleInstance { get; }
public readonly string PortedVersion;

public PortedCoreAttribute(
string name,
string author,
string portedVersion = "",
string portedUrl = "",
bool singleInstance = false,
bool isReleased = true)
: base(name, author, singleInstance, isReleased)
{
PortedUrl = portedUrl;
PortedVersion = portedVersion;
}
}
}
11 changes: 2 additions & 9 deletions src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,7 @@ made that way to make the buffer persist actoss C API calls.

namespace BizHawk.Emulation.Cores.Arcades.MAME
{
[Core(
name: CoreNames.MAME,
author: "MAMEDev",
isPorted: true,
isReleased: false,
portedVersion: "0.230",
portedUrl: "https://github.com/mamedev/mame.git",
singleInstance: false)]
[PortedCore(CoreNames.MAME, "MAMEDev", "0.230", "https://github.com/mamedev/mame.git", isReleased: false)]
public partial class MAME : IEmulator, IVideoProvider, ISoundProvider, ISettable<object, MAME.SyncSettings>, IStatable, IInputPollable
{
public MAME(string dir, string file, MAME.SyncSettings syncSettings, out string gamename)
Expand Down Expand Up @@ -210,7 +203,7 @@ private void UpdateGameName()
private void CheckVersions()
{
var mameVersion = MameGetString(MAMELuaCommand.GetVersion);
var version = this.Attributes().PortedVersion;
var version = ((PortedCoreAttribute) this.Attributes()).PortedVersion;
Debug.Assert(version == mameVersion,
"MAME versions desync!\n\n" +
$"MAME is { mameVersion }\n" +
Expand Down
6 changes: 1 addition & 5 deletions src/BizHawk.Emulation.Cores/Calculator/TI83.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
// http://www.ticalc.org/pub/text/calcinfo/
namespace BizHawk.Emulation.Cores.Calculators
{
[Core(
CoreNames.TI83Hawk,
"zeromus",
isPorted: false,
isReleased: true)]
[Core(CoreNames.TI83Hawk, "zeromus")]
[ServiceNotApplicable(new[] { typeof(IBoardInfo), typeof(IDriveLight), typeof(IRegionable), typeof(ISaveRam), typeof(ISoundProvider) })]
public partial class TI83 : IEmulator, IVideoProvider, IDebuggable, IInputPollable, ISettable<TI83.TI83Settings, object>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
/// CPCHawk: Core Class
/// * Main Initialization *
/// </summary>
[Core(
CoreNames.CPCHawk,
"Asnivor",
isPorted: false,
isReleased: false)]
[Core(CoreNames.CPCHawk, "Asnivor", isReleased: false)]
public partial class AmstradCPC : IRegionable, IDriveLight
{
[CoreConstructor("AmstradCPC")]
Expand Down
6 changes: 1 addition & 5 deletions src/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@

namespace BizHawk.Emulation.Cores.Computers.AppleII
{
[Core(
CoreNames.Virtu,
"fool",
isPorted: true,
isReleased: true)]
[PortedCore(CoreNames.Virtu, "fool")]
[ServiceNotApplicable(new[] { typeof(IBoardInfo), typeof(IRegionable), typeof(ISaveRam) })]
public partial class AppleII : IEmulator, ISoundProvider, IVideoProvider, IStatable, IDriveLight
{
Expand Down
6 changes: 1 addition & 5 deletions src/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@

namespace BizHawk.Emulation.Cores.Computers.Commodore64
{
[Core(
CoreNames.C64Hawk,
"SaxxonPike",
isPorted: false,
isReleased: true)]
[Core(CoreNames.C64Hawk, "SaxxonPike")]
public sealed partial class C64 : IEmulator, IRegionable, IBoardInfo, IRomInfo
{
[CoreConstructor("C64")]
Expand Down
2 changes: 1 addition & 1 deletion src/BizHawk.Emulation.Cores/Computers/MSX/MSX.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace BizHawk.Emulation.Cores.Computers.MSX
{
[Core(CoreNames.MSXHawk, "", isPorted: false, isReleased: false)]
[Core(CoreNames.MSXHawk, "", isReleased: false)]
[ServiceNotApplicable(new[] { typeof(IDriveLight) })]
public partial class MSX : IEmulator, IVideoProvider, ISoundProvider, ISaveRam, IInputPollable, IRegionable, ISettable<MSX.MSXSettings, MSX.MSXSyncSettings>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// ZXHawk: Core Class
/// * Main Initialization *
/// </summary>
[Core(
CoreNames.ZXHawk,
"Asnivor, Alyosha",
isPorted: false,
isReleased: true)]
[Core(CoreNames.ZXHawk, "Asnivor, Alyosha")]
public partial class ZXSpectrum : IRegionable, IDriveLight
{
[CoreConstructor("ZXSpectrum")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace BizHawk.Emulation.Cores.Atari.Atari2600
{
[Core(CoreNames.Atari2600Hawk, "Micro500, Alyosha, adelikat, natt", isPorted: false, isReleased: true)]
[Core(CoreNames.Atari2600Hawk, "Micro500, Alyosha, adelikat, natt")]
[ServiceNotApplicable(new[] { typeof(IDriveLight), typeof(ISaveRam) })]
public partial class Atari2600 : IEmulator, IDebuggable, IInputPollable, IBoardInfo, IRomInfo,
IRegionable, ICreateGameDBEntries, ISettable<Atari2600.A2600Settings, Atari2600.A2600SyncSettings>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@

namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
{
[Core(
CoreNames.A7800Hawk,
"",
isPorted: false,
isReleased: true)]
[Core(CoreNames.A7800Hawk, "")]
[ServiceNotApplicable(new[] { typeof(IDriveLight), typeof(ISettable<,>) })]
public partial class A7800Hawk : IEmulator, ISaveRam, IDebuggable, IInputPollable,
IRegionable, IBoardInfo, ISettable<A7800Hawk.A7800Settings, A7800Hawk.A7800SyncSettings>
Expand Down
2 changes: 1 addition & 1 deletion src/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace BizHawk.Emulation.Cores.Atari.Lynx
{
[Core(CoreNames.Handy, "K. Wilkins, Mednafen Team", true, true, "mednafen 0-9-34-1", "http://mednafen.sourceforge.net/", false)]
[PortedCore(CoreNames.Handy, "K. Wilkins, Mednafen Team", "mednafen 0-9-34-1", "http://mednafen.sourceforge.net/")]
[ServiceNotApplicable(new[] { typeof(IDriveLight), typeof(IRegionable), typeof(ISettable<,>) })]
public partial class Lynx : IEmulator, IVideoProvider, ISoundProvider, ISaveRam, IStatable, IInputPollable
{
Expand Down
2 changes: 1 addition & 1 deletion src/BizHawk.Emulation.Cores/Consoles/Belogic/Uzem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace BizHawk.Emulation.Cores.Consoles.Belogic
{
[Core(CoreNames.Uzem, "David Etherton", true, true, "", "", false)]
[PortedCore(CoreNames.Uzem, "David Etherton")]
public class Uzem : WaterboxCore
{
private LibUzem _uze;
Expand Down
6 changes: 1 addition & 5 deletions src/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@

namespace BizHawk.Emulation.Cores.ColecoVision
{
[Core(
CoreNames.ColecoHawk,
"Vecna",
isPorted: false,
isReleased: true)]
[Core(CoreNames.ColecoHawk, "Vecna")]
[ServiceNotApplicable(new[] { typeof(IDriveLight), typeof(ISaveRam) })]
public sealed partial class ColecoVision : IEmulator, IDebuggable, IInputPollable, ISettable<ColecoVision.ColecoSettings, ColecoVision.ColecoSyncSettings>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@

namespace BizHawk.Emulation.Cores.Consoles.ChannelF
{
[Core(
CoreNames.ChannelFHawk,
"Asnivor",
isPorted: false,
isReleased: false)]
[Core(CoreNames.ChannelFHawk, "Asnivor", isReleased: false)]
[ServiceNotApplicable(new[] { typeof(IDriveLight) })]
public partial class ChannelF
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace BizHawk.Emulation.Cores.Consoles.Vectrex
{
[Core(CoreNames.VectrexHawk, "", isPorted: false, isReleased: true)]
[Core(CoreNames.VectrexHawk, "")]
[ServiceNotApplicable(new[] { typeof(IDriveLight) })]
public partial class VectrexHawk : IEmulator, ISaveRam, IDebuggable, IInputPollable, IRegionable,
ISettable<object, VectrexHawk.VectrexSyncSettings>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@

namespace BizHawk.Emulation.Cores.Intellivision
{
[Core(
CoreNames.IntelliHawk,
"BrandonE, Alyosha",
isPorted: false,
isReleased: true)]
[Core(CoreNames.IntelliHawk, "BrandonE, Alyosha")]
[ServiceNotApplicable(new[] { typeof(IDriveLight), typeof(IRegionable), typeof(ISaveRam) })]
public sealed partial class Intellivision : IEmulator, IInputPollable, IDisassemblable,
IBoardInfo, IDebuggable, ISettable<Intellivision.IntvSettings, Intellivision.IntvSyncSettings>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{
[Core(CoreNames.O2Hawk, "", isPorted: false, isReleased: true)]
[Core(CoreNames.O2Hawk, "")]
[ServiceNotApplicable(new[] { typeof(IDriveLight) })]
public partial class O2Hawk : IEmulator, ISaveRam, IDebuggable, IInputPollable, IRegionable, ISettable<O2Hawk.O2Settings, O2Hawk.O2SyncSettings>, IBoardInfo
{
Expand Down
2 changes: 1 addition & 1 deletion src/BizHawk.Emulation.Cores/Consoles/NEC/PCE/HyperNyma.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace BizHawk.Emulation.Cores.Consoles.NEC.PCE
{
[Core(CoreNames.HyperNyma, "Mednafen Team", true, true, "1.26.1", "https://mednafen.github.io/releases/", false)]
[PortedCore(CoreNames.HyperNyma, "Mednafen Team", "1.26.1", "https://mednafen.github.io/releases/")]
public class HyperNyma : NymaCore, IRegionable, IPceGpuView
{
private readonly LibHyperNyma _hyperNyma;
Expand Down
2 changes: 1 addition & 1 deletion src/BizHawk.Emulation.Cores/Consoles/NEC/PCE/TurboNyma.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace BizHawk.Emulation.Cores.Consoles.NEC.PCE
{
[Core(CoreNames.TurboNyma, "Mednafen Team", true, true, "1.26.1", "https://mednafen.github.io/releases/", false)]
[PortedCore(CoreNames.TurboNyma, "Mednafen Team", "1.26.1", "https://mednafen.github.io/releases/")]
public class TurboNyma : NymaCore, IRegionable, IPceGpuView
{
private readonly LibTurboNyma _turboNyma;
Expand Down
8 changes: 1 addition & 7 deletions src/BizHawk.Emulation.Cores/Consoles/NEC/PCFX/Tst.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@

namespace BizHawk.Emulation.Cores.Consoles.NEC.PCFX
{
[Core(CoreNames.TST,
author: "Mednafen Team",
isPorted: true,
isReleased: true,
portedVersion: "1.26.1",
portedUrl: "https://mednafen.github.io/releases/",
singleInstance: false)]
[PortedCore(CoreNames.TST, "Mednafen Team", "1.26.1", "https://mednafen.github.io/releases/")]
public class Tst : NymaCore
{
[CoreConstructor("PCFX")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Faust
{
[Core(CoreNames.Faust, "Mednafen Team", true, true, "1.26.1", "https://mednafen.github.io/releases/", false)]
[PortedCore(CoreNames.Faust, "Mednafen Team", "1.26.1", "https://mednafen.github.io/releases/")]
public class Faust : NymaCore, IRegionable
{
[CoreConstructor("SNES")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace BizHawk.Emulation.Cores.Nintendo.GBA
{
[Core(CoreNames.Mgba, "endrift", true, true, "0.8", "https://mgba.io/", false)]
[PortedCore(CoreNames.Mgba, "endrift", "0.8", "https://mgba.io/")]
[ServiceNotApplicable(new[] { typeof(IDriveLight), typeof(IRegionable) })]
public partial class MGBAHawk : IEmulator, IVideoProvider, ISoundProvider, IGBAGPUViewable,
ISaveRam, IStatable, IInputPollable, ISettable<MGBAHawk.Settings, MGBAHawk.SyncSettings>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@

namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
{
[Core(
CoreNames.GbHawk,
"",
isPorted: false,
isReleased: true)]
[Core(CoreNames.GbHawk, "")]
[ServiceNotApplicable(new[] { typeof(IDriveLight) })]
public partial class GBHawk : IEmulator, ISaveRam, IDebuggable, IInputPollable, IRegionable, IGameboyCommon,
ISettable<GBHawk.GBSettings, GBHawk.GBSyncSettings>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink
{
[Core(CoreNames.GBHawkLink, "", isPorted: false, isReleased: true)]
[Core(CoreNames.GBHawkLink, "")]
[ServiceNotApplicable(new[] { typeof(IDriveLight) })]
public partial class GBHawkLink : IEmulator, ISaveRam, IDebuggable, IStatable, IInputPollable, IRegionable, ILinkable,
ISettable<GBHawkLink.GBLinkSettings, GBHawkLink.GBLinkSyncSettings>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x
{
[Core(CoreNames.GBHawkLink3x, "", isPorted: false, isReleased: true)]
[Core(CoreNames.GBHawkLink3x, "")]
[ServiceNotApplicable(new[] { typeof(IDriveLight) })]
public partial class GBHawkLink3x : IEmulator, ISaveRam, IDebuggable, IStatable, IInputPollable, IRegionable,
ISettable<GBHawkLink3x.GBLink3xSettings, GBHawkLink3x.GBLink3xSyncSettings>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x
{
[Core(CoreNames.GBHawkLink4x, "", isPorted: false, isReleased: true)]
[Core(CoreNames.GBHawkLink4x, "")]
[ServiceNotApplicable(new[] { typeof(IDriveLight) })]
public partial class GBHawkLink4x : IEmulator, ISaveRam, IDebuggable, IStatable, IInputPollable, IRegionable,
ISettable<GBHawkLink4x.GBLink4xSettings, GBHawkLink4x.GBLink4xSyncSettings>
Expand Down
Loading

0 comments on commit 98b07c4

Please sign in to comment.