diff --git a/ExternalToolProjects/HelloWorld/CustomMainForm.cs b/ExternalToolProjects/HelloWorld/CustomMainForm.cs
index dc72a68ff0..a84ef3a5d1 100644
--- a/ExternalToolProjects/HelloWorld/CustomMainForm.cs
+++ b/ExternalToolProjects/HelloWorld/CustomMainForm.cs
@@ -10,7 +10,7 @@ namespace HelloWorld
{
/// All of this is example code, but it's at least a little more substantiative than a simple "hello world".
[ExternalTool("HelloWorld", Description = "An example of how to interact with EmuHawk")]
-// [ExternalToolApplicability.SingleRom(CoreSystem.NES, "EA343F4E445A9050D4B4FBAC2C77D0693B1D0922")] // example of limiting tool usage (this is SMB1)
+// [ExternalToolApplicability.SingleRom(VSystemID.Raw.NES, "EA343F4E445A9050D4B4FBAC2C77D0693B1D0922")] // example of limiting tool usage (this is SMB1)
[ExternalToolEmbeddedIcon("HelloWorld.icon_Hello.ico")]
public partial class CustomMainForm : ToolFormBase, IExternalToolForm
{
diff --git a/src/BizHawk.Client.Common/Api/BizHawkSystemIdToCoreSystemEnumConverter.cs b/src/BizHawk.Client.Common/Api/BizHawkSystemIdToCoreSystemEnumConverter.cs
index 1bf677f53c..dab511b773 100644
--- a/src/BizHawk.Client.Common/Api/BizHawkSystemIdToCoreSystemEnumConverter.cs
+++ b/src/BizHawk.Client.Common/Api/BizHawkSystemIdToCoreSystemEnumConverter.cs
@@ -98,24 +98,35 @@ namespace BizHawk.Client.Common
CoreSystem.AppleII => VSystemID.Raw.AppleII,
CoreSystem.Atari2600 => VSystemID.Raw.A26,
CoreSystem.Atari7800 => VSystemID.Raw.A78,
+ CoreSystem.ChannelF => VSystemID.Raw.ChannelF,
CoreSystem.ColecoVision => VSystemID.Raw.Coleco,
CoreSystem.Commodore64 => VSystemID.Raw.C64,
CoreSystem.GameBoyLink => VSystemID.Raw.GBL,
CoreSystem.GameBoy => VSystemID.Raw.GB,
CoreSystem.GameBoyAdvance => VSystemID.Raw.GBA,
CoreSystem.Genesis => VSystemID.Raw.GEN,
+ CoreSystem.GGL => VSystemID.Raw.GGL,
CoreSystem.Intellivision => VSystemID.Raw.INTV,
CoreSystem.Libretro => VSystemID.Raw.Libretro,
CoreSystem.Lynx => VSystemID.Raw.Lynx,
+ CoreSystem.MAME => VSystemID.Raw.MAME,
CoreSystem.MasterSystem => VSystemID.Raw.SMS,
+ CoreSystem.MSX => VSystemID.Raw.MSX,
+ CoreSystem.NeoGeoPocket => VSystemID.Raw.NGP,
CoreSystem.NES => VSystemID.Raw.NES,
CoreSystem.Nintendo64 => VSystemID.Raw.N64,
+ CoreSystem.NintendoDS => VSystemID.Raw.NDS,
CoreSystem.Null => VSystemID.Raw.NULL,
CoreSystem.PCEngine => VSystemID.Raw.PCE,
+ CoreSystem.PcFx => VSystemID.Raw.PCFX,
CoreSystem.Playstation => VSystemID.Raw.PSX,
CoreSystem.Saturn => VSystemID.Raw.SAT,
CoreSystem.SNES => VSystemID.Raw.SNES,
+ CoreSystem.SuperGameBoy => VSystemID.Raw.SGB,
CoreSystem.TI83 => VSystemID.Raw.TI83,
+ CoreSystem.UzeBox => VSystemID.Raw.UZE,
+ CoreSystem.Vectrex => VSystemID.Raw.VEC,
+ CoreSystem.VirtualBoy => VSystemID.Raw.VB,
CoreSystem.WonderSwan => VSystemID.Raw.WSWAN,
CoreSystem.ZXSpectrum => VSystemID.Raw.ZXSpectrum,
CoreSystem.AmstradCPC => VSystemID.Raw.AmstradCPC,
diff --git a/src/BizHawk.Client.Common/Api/Classes/EmuClientApi.cs b/src/BizHawk.Client.Common/Api/Classes/EmuClientApi.cs
index b35e451d32..0cebf37126 100644
--- a/src/BizHawk.Client.Common/Api/Classes/EmuClientApi.cs
+++ b/src/BizHawk.Client.Common/Api/Classes/EmuClientApi.cs
@@ -21,8 +21,6 @@ namespace BizHawk.Client.Common
private readonly IGameInfo Game;
- public static readonly BizHawkSystemIdToEnumConverter SystemIdConverter = new BizHawkSystemIdToEnumConverter();
-
private readonly IVideoProvider VideoProvider;
public event BeforeQuickLoadEventHandler BeforeQuickLoad;
diff --git a/src/BizHawk.Client.Common/Api/ExternalToolAttributes.cs b/src/BizHawk.Client.Common/Api/ExternalToolAttributes.cs
index adbbf6652d..6dd3fef977 100644
--- a/src/BizHawk.Client.Common/Api/ExternalToolAttributes.cs
+++ b/src/BizHawk.Client.Common/Api/ExternalToolAttributes.cs
@@ -1,8 +1,11 @@
+#nullable enable
+
using System;
using System.Collections.Generic;
using System.Linq;
using BizHawk.Common.StringExtensions;
+using BizHawk.Emulation.Common;
namespace BizHawk.Client.Common
{
@@ -13,17 +16,21 @@ namespace BizHawk.Client.Common
[Obsolete("this is the default behaviour, you can safely omit this attribute")]
public sealed class Always : ExternalToolApplicabilityAttributeBase
{
- public override bool NotApplicableTo(CoreSystem system) => false;
+ public override bool NotApplicableTo(string sysID)
+ => false;
- public override bool NotApplicableTo(string romHash, CoreSystem? system) => false;
+ public override bool NotApplicableTo(string romHash, string? sysID)
+ => false;
}
[AttributeUsage(AttributeTargets.Class)]
public sealed class AnyRomLoaded : ExternalToolApplicabilityAttributeBase
{
- public override bool NotApplicableTo(CoreSystem system) => system == CoreSystem.Null;
+ public override bool NotApplicableTo(string sysID)
+ => sysID is VSystemID.Raw.NULL;
- public override bool NotApplicableTo(string romHash, CoreSystem? system) => system == CoreSystem.Null;
+ public override bool NotApplicableTo(string romHash, string? sysID)
+ => sysID is VSystemID.Raw.NULL;
}
[AttributeUsage(AttributeTargets.Class)]
@@ -31,19 +38,25 @@ namespace BizHawk.Client.Common
{
private readonly IList _romHashes;
- private readonly CoreSystem _system;
+ private readonly string _sysID;
+ [Obsolete("replace CoreSystem with string from VSystemID.Raw")]
public RomWhitelist(CoreSystem system, params string[] romHashes)
+ : this(SystemIdConverter.ConvertBack(system), romHashes) {}
+
+ public RomWhitelist(string sysID, params string[] romHashes)
{
- if (system == CoreSystem.Null) throw new ArgumentException("there are no roms for the NULL system", nameof(system));
+ if (sysID is VSystemID.Raw.NULL) throw new ArgumentException("there are no roms for the NULL system", nameof(sysID));
if (!romHashes.All(NumericStringExtensions.IsHex)) throw new ArgumentException("misformatted hash", nameof(romHashes));
- _system = system;
_romHashes = romHashes.ToList();
+ _sysID = sysID;
}
- public override bool NotApplicableTo(CoreSystem system) => system != _system;
+ public override bool NotApplicableTo(string sysID)
+ => sysID != _sysID;
- public override bool NotApplicableTo(string romHash, CoreSystem? system) => system != _system || !_romHashes.Contains(romHash);
+ public override bool NotApplicableTo(string romHash, string? sysID)
+ => sysID != _sysID || !_romHashes.Contains(romHash);
}
[AttributeUsage(AttributeTargets.Class)]
@@ -51,44 +64,54 @@ namespace BizHawk.Client.Common
{
private readonly string _romHash;
- private readonly CoreSystem _system;
+ private readonly string _sysID;
+ [Obsolete("replace CoreSystem with string from VSystemID.Raw")]
public SingleRom(CoreSystem system, string romHash)
+ : this(SystemIdConverter.ConvertBack(system), romHash) {}
+
+ public SingleRom(string sysID, string romHash)
{
- if (system == CoreSystem.Null) throw new ArgumentException("there are no roms for the NULL system", nameof(system));
+ if (sysID is VSystemID.Raw.NULL) throw new ArgumentException("there are no roms for the NULL system", nameof(sysID));
if (!romHash.IsHex()) throw new ArgumentException("misformatted hash", nameof(romHash));
- _system = system;
_romHash = romHash;
+ _sysID = sysID;
}
- public override bool NotApplicableTo(CoreSystem system) => system != _system;
+ public override bool NotApplicableTo(string sysID)
+ => sysID != _sysID;
- public override bool NotApplicableTo(string romHash, CoreSystem? system) => system != _system || romHash != _romHash;
+ public override bool NotApplicableTo(string romHash, string? sysID)
+ => sysID != _sysID || romHash != _romHash;
}
[AttributeUsage(AttributeTargets.Class)]
public sealed class SingleSystem : ExternalToolApplicabilityAttributeBase
{
- private readonly CoreSystem _system;
+ private readonly string _sysID;
+ [Obsolete("replace CoreSystem with string from VSystemID.Raw")]
public SingleSystem(CoreSystem system)
- {
- _system = system;
- }
+ : this(SystemIdConverter.ConvertBack(system)) {}
- public override bool NotApplicableTo(CoreSystem system) => system != _system;
+ public SingleSystem(string sysID)
+ => _sysID = sysID;
- public override bool NotApplicableTo(string romHash, CoreSystem? system) => system != _system;
+ public override bool NotApplicableTo(string sysID)
+ => sysID != _sysID;
+
+ public override bool NotApplicableTo(string romHash, string? sysID)
+ => sysID != _sysID;
}
}
public abstract class ExternalToolApplicabilityAttributeBase : Attribute
{
- public abstract bool NotApplicableTo(CoreSystem system);
+ protected static readonly BizHawkSystemIdToEnumConverter SystemIdConverter = new();
- public abstract bool NotApplicableTo(string romHash, CoreSystem? system);
+ public abstract bool NotApplicableTo(string sysID);
- public bool NotApplicableTo(string romHash) => NotApplicableTo(romHash, null);
+ public abstract bool NotApplicableTo(string romHash, string? sysID);
public class DuplicateException : Exception {}
}
@@ -96,16 +119,14 @@ namespace BizHawk.Client.Common
[AttributeUsage(AttributeTargets.Class)]
public sealed class ExternalToolAttribute : Attribute
{
- public string Description { get; set; }
+ public string? Description { get; set; }
- public string[] LoadAssemblyFiles { get; set; }
+ public string[]? LoadAssemblyFiles { get; set; }
public readonly string Name;
- public ExternalToolAttribute(string name)
- {
- Name = string.IsNullOrWhiteSpace(name) ? Guid.NewGuid().ToString() : name;
- }
+ public ExternalToolAttribute(string? name)
+ => Name = string.IsNullOrWhiteSpace(name) ? Guid.NewGuid().ToString() : name!;
public class MissingException : Exception {}
}
@@ -118,8 +139,6 @@ namespace BizHawk.Client.Common
/// The full path, including the assembly name.
public ExternalToolEmbeddedIconAttribute(string resourcePath)
- {
- ResourcePath = resourcePath;
- }
+ => ResourcePath = resourcePath;
}
}
diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs
index d7d24c71df..38b409f33a 100644
--- a/src/BizHawk.Client.EmuHawk/MainForm.cs
+++ b/src/BizHawk.Client.EmuHawk/MainForm.cs
@@ -379,7 +379,7 @@ namespace BizHawk.Client.EmuHawk
Controls.Add(_presentationPanel);
Controls.SetChildIndex(_presentationPanel, 0);
- ExtToolManager = new ExternalToolManager(Config.PathEntries, () => (EmuClientApi.SystemIdConverter.Convert(Emulator.SystemId), Game.Hash));
+ ExtToolManager = new ExternalToolManager(Config.PathEntries, () => (Emulator.SystemId, Game.Hash));
Tools = new ToolManager(this, Config, DisplayManager, ExtToolManager, InputManager, Emulator, MovieSession, Game);
// TODO GL - move these event handlers somewhere less obnoxious line in the On* overrides
diff --git a/src/BizHawk.Client.EmuHawk/tools/ExternalToolManager.cs b/src/BizHawk.Client.EmuHawk/tools/ExternalToolManager.cs
index 11bb02bf74..2edfc16f8a 100644
--- a/src/BizHawk.Client.EmuHawk/tools/ExternalToolManager.cs
+++ b/src/BizHawk.Client.EmuHawk/tools/ExternalToolManager.cs
@@ -8,12 +8,13 @@ using System.Reflection;
using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Common;
+using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk
{
public sealed class ExternalToolManager
{
- private readonly Func<(CoreSystem System, string Hash)> _getLoadedRomInfoCallback;
+ private readonly Func<(string SysID, string Hash)> _getLoadedRomInfoCallback;
private PathEntryCollection _paths;
@@ -23,7 +24,7 @@ namespace BizHawk.Client.EmuHawk
internal readonly IList PossibleExtToolTypeNames = new List();
- public ExternalToolManager(PathEntryCollection paths, Func<(CoreSystem System, string Hash)> getLoadedRomInfoCallback)
+ public ExternalToolManager(PathEntryCollection paths, Func<(string SysID, string Hash)> getLoadedRomInfoCallback)
{
_getLoadedRomInfoCallback = getLoadedRomInfoCallback;
Restart(paths);
@@ -102,7 +103,7 @@ namespace BizHawk.Client.EmuHawk
var (system, loadedRomHash) = _getLoadedRomInfoCallback();
if (applicabilityAttrs[0].NotApplicableTo(system))
{
- item.ToolTipText = system == CoreSystem.Null
+ item.ToolTipText = system is VSystemID.Raw.NULL
? "This tool doesn't work when no rom is loaded"
: "This tool doesn't work with this system";
return item;