diff --git a/src/BizHawk.Client.Common/Api/ExternalToolAttributes.cs b/src/BizHawk.Client.Common/Api/ExternalToolAttributes.cs index 6dd3fef977..59c8b9ecfe 100644 --- a/src/BizHawk.Client.Common/Api/ExternalToolAttributes.cs +++ b/src/BizHawk.Client.Common/Api/ExternalToolAttributes.cs @@ -34,6 +34,29 @@ namespace BizHawk.Client.Common } [AttributeUsage(AttributeTargets.Class)] + public sealed class RomList : ExternalToolApplicabilityAttributeBase + { + private readonly IList _romHashes; + + private readonly string _sysID; + + public RomList(string sysID, params string[] romHashes) + { + 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)); + _romHashes = romHashes.ToList(); + _sysID = sysID; + } + + public override bool NotApplicableTo(string sysID) + => sysID != _sysID; + + public override bool NotApplicableTo(string romHash, string? sysID) + => sysID != _sysID || !_romHashes.Contains(romHash); + } + + [AttributeUsage(AttributeTargets.Class)] + [Obsolete("renamed RomWhitelist-->RomList")] public sealed class RomWhitelist : ExternalToolApplicabilityAttributeBase { private readonly IList _romHashes;