mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 22:56:36 +09:00
Move check origin from IssueTemplate
to Issue
As a result we can also make check an interface, and need to provide the check itself when constructing an issue.
This commit is contained in:
@ -6,28 +6,22 @@ using osu.Game.Beatmaps;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Checks.Components
|
||||
{
|
||||
public abstract class Check
|
||||
public interface ICheck
|
||||
{
|
||||
/// <summary>
|
||||
/// The metadata for this check.
|
||||
/// </summary>
|
||||
public abstract CheckMetadata Metadata { get; }
|
||||
public CheckMetadata Metadata { get; }
|
||||
|
||||
/// <summary>
|
||||
/// All possible templates for issues that this check may return.
|
||||
/// </summary>
|
||||
public abstract IEnumerable<IssueTemplate> PossibleTemplates { get; }
|
||||
public IEnumerable<IssueTemplate> PossibleTemplates { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Runs this check and returns any issues detected for the provided beatmap.
|
||||
/// </summary>
|
||||
/// <param name="beatmap">The beatmap to run the check on.</param>
|
||||
public abstract IEnumerable<Issue> Run(IBeatmap beatmap);
|
||||
|
||||
protected Check()
|
||||
{
|
||||
foreach (var template in PossibleTemplates)
|
||||
template.Origin = this;
|
||||
}
|
||||
public IEnumerable<Issue> Run(IBeatmap beatmap);
|
||||
}
|
||||
}
|
||||
|
@ -26,38 +26,41 @@ namespace osu.Game.Rulesets.Edit.Checks.Components
|
||||
/// </summary>
|
||||
public IssueTemplate Template;
|
||||
|
||||
/// <summary>
|
||||
/// The check that this issue originates from.
|
||||
/// </summary>
|
||||
public ICheck Check;
|
||||
|
||||
/// <summary>
|
||||
/// The arguments that give this issue its context, based on the <see cref="IssueTemplate"/>. These are then substituted into the <see cref="IssueTemplate.UnformattedMessage"/>.
|
||||
/// This could for instance include timestamps, which diff is being compared to, what some volume is, etc.
|
||||
/// </summary>
|
||||
public object[] Arguments;
|
||||
|
||||
public Issue(IssueTemplate template, params object[] args)
|
||||
public Issue(ICheck check, IssueTemplate template, params object[] args)
|
||||
{
|
||||
Check = check;
|
||||
Time = null;
|
||||
HitObjects = Array.Empty<HitObject>();
|
||||
Template = template;
|
||||
Arguments = args;
|
||||
|
||||
if (template.Origin == null)
|
||||
throw new ArgumentException("A template had no origin. Make sure the `Templates()` method contains all templates used.");
|
||||
}
|
||||
|
||||
public Issue(double? time, IssueTemplate template, params object[] args)
|
||||
: this(template, args)
|
||||
public Issue(ICheck check, double? time, IssueTemplate template, params object[] args)
|
||||
: this(check, template, args)
|
||||
{
|
||||
Time = time;
|
||||
}
|
||||
|
||||
public Issue(HitObject hitObject, IssueTemplate template, params object[] args)
|
||||
: this(template, args)
|
||||
public Issue(ICheck check, HitObject hitObject, IssueTemplate template, params object[] args)
|
||||
: this(check, template, args)
|
||||
{
|
||||
Time = hitObject.StartTime;
|
||||
HitObjects = new[] { hitObject };
|
||||
}
|
||||
|
||||
public Issue(IEnumerable<HitObject> hitObjects, IssueTemplate template, params object[] args)
|
||||
: this(template, args)
|
||||
public Issue(ICheck check, IEnumerable<HitObject> hitObjects, IssueTemplate template, params object[] args)
|
||||
: this(check, template, args)
|
||||
{
|
||||
var hitObjectList = hitObjects.ToList();
|
||||
|
||||
|
@ -14,11 +14,6 @@ namespace osu.Game.Rulesets.Edit.Checks.Components
|
||||
private static readonly Color4 negligible_green = new Colour4(0.33f, 0.8f, 0.5f, 1.0f);
|
||||
private static readonly Color4 error_gray = new Colour4(0.5f, 0.5f, 0.5f, 1.0f);
|
||||
|
||||
/// <summary>
|
||||
/// The check that this template originates from.
|
||||
/// </summary>
|
||||
public Check Origin;
|
||||
|
||||
/// <summary>
|
||||
/// The type of the issue.
|
||||
/// </summary>
|
||||
|
Reference in New Issue
Block a user