diff --git a/src/Ryujinx/Utilities/PlayReport/Analyzer.cs b/src/Ryujinx/Utilities/PlayReport/Analyzer.cs index 668eb526c..0b5284673 100644 --- a/src/Ryujinx/Utilities/PlayReport/Analyzer.cs +++ b/src/Ryujinx/Utilities/PlayReport/Analyzer.cs @@ -31,8 +31,7 @@ namespace Ryujinx.Ava.Utilities.PlayReport Guard.Ensure(ulong.TryParse(titleId, NumberStyles.HexNumber, null, out _), $"Cannot use a non-hexadecimal string as the Title ID for a {nameof(GameSpec)}."); - _specs.Add(transform(new GameSpec { TitleIds = [titleId] })); - return this; + return AddSpec(transform(GameSpec.Create(titleId))); } /// @@ -46,8 +45,7 @@ namespace Ryujinx.Ava.Utilities.PlayReport Guard.Ensure(ulong.TryParse(titleId, NumberStyles.HexNumber, null, out _), $"Cannot use a non-hexadecimal string as the Title ID for a {nameof(GameSpec)}."); - _specs.Add(new GameSpec { TitleIds = [titleId] }.Apply(transform)); - return this; + return AddSpec(GameSpec.Create(titleId).Apply(transform)); } /// @@ -63,8 +61,7 @@ namespace Ryujinx.Ava.Utilities.PlayReport Guard.Ensure(tids.All(x => ulong.TryParse(x, NumberStyles.HexNumber, null, out _)), $"Cannot use a non-hexadecimal string as the Title ID for a {nameof(GameSpec)}."); - _specs.Add(transform(new GameSpec { TitleIds = [..tids] })); - return this; + return AddSpec(transform(GameSpec.Create(tids))); } /// @@ -79,7 +76,17 @@ namespace Ryujinx.Ava.Utilities.PlayReport Guard.Ensure(tids.All(x => ulong.TryParse(x, NumberStyles.HexNumber, null, out _)), $"Cannot use a non-hexadecimal string as the Title ID for a {nameof(GameSpec)}."); - _specs.Add(new GameSpec { TitleIds = [..tids] }.Apply(transform)); + return AddSpec(GameSpec.Create(tids).Apply(transform)); + } + + /// + /// Add an analysis spec matching a specific game by title ID, with the provided pre-configured spec. + /// + /// The to add. + /// The current , for chaining convenience. + public Analyzer AddSpec(GameSpec spec) + { + _specs.Add(spec); return this; } diff --git a/src/Ryujinx/Utilities/PlayReport/Specs.cs b/src/Ryujinx/Utilities/PlayReport/Specs.cs index e7972fbb4..837c37e76 100644 --- a/src/Ryujinx/Utilities/PlayReport/Specs.cs +++ b/src/Ryujinx/Utilities/PlayReport/Specs.cs @@ -14,6 +14,12 @@ namespace Ryujinx.Ava.Utilities.PlayReport /// public class GameSpec { + public static GameSpec Create(string requiredTitleId, params IEnumerable otherTitleIds) + => new() { TitleIds = otherTitleIds.Prepend(requiredTitleId).ToArray() }; + + public static GameSpec Create(IEnumerable titleIds) + => new() { TitleIds = titleIds.ToArray() }; + private int _lastPriority; public required string[] TitleIds { get; init; }