mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 20:53:04 +08: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:
parent
42604afcdc
commit
65ebdd8f7a
@ -9,7 +9,7 @@ using osuTK;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Edit.Checks
|
namespace osu.Game.Rulesets.Osu.Edit.Checks
|
||||||
{
|
{
|
||||||
public class CheckOffscreenObjects : Check
|
public class CheckOffscreenObjects : ICheck
|
||||||
{
|
{
|
||||||
// These are close approximates to the edges of the screen
|
// These are close approximates to the edges of the screen
|
||||||
// in gameplay on a 4:3 aspect ratio for osu!stable.
|
// in gameplay on a 4:3 aspect ratio for osu!stable.
|
||||||
@ -22,13 +22,13 @@ namespace osu.Game.Rulesets.Osu.Edit.Checks
|
|||||||
// (higher = more performant, but higher false-negative chance).
|
// (higher = more performant, but higher false-negative chance).
|
||||||
private const int path_step_size = 5;
|
private const int path_step_size = 5;
|
||||||
|
|
||||||
public override CheckMetadata Metadata { get; } = new CheckMetadata
|
public CheckMetadata Metadata { get; } = new CheckMetadata
|
||||||
(
|
(
|
||||||
category: CheckCategory.Compose,
|
category: CheckCategory.Compose,
|
||||||
description: "Offscreen hitobjects."
|
description: "Offscreen hitobjects."
|
||||||
);
|
);
|
||||||
|
|
||||||
public override IEnumerable<IssueTemplate> PossibleTemplates => new[]
|
public IEnumerable<IssueTemplate> PossibleTemplates => new[]
|
||||||
{
|
{
|
||||||
templateOffscreen,
|
templateOffscreen,
|
||||||
templateOffscreenSliderPath
|
templateOffscreenSliderPath
|
||||||
@ -46,7 +46,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Checks
|
|||||||
unformattedMessage: "This slider goes offscreen here on a 4:3 aspect ratio."
|
unformattedMessage: "This slider goes offscreen here on a 4:3 aspect ratio."
|
||||||
);
|
);
|
||||||
|
|
||||||
public override IEnumerable<Issue> Run(IBeatmap beatmap)
|
public IEnumerable<Issue> Run(IBeatmap beatmap)
|
||||||
{
|
{
|
||||||
foreach (var hitobject in beatmap.HitObjects)
|
foreach (var hitobject in beatmap.HitObjects)
|
||||||
{
|
{
|
||||||
@ -63,7 +63,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Checks
|
|||||||
case HitCircle circle:
|
case HitCircle circle:
|
||||||
{
|
{
|
||||||
if (isOffscreen(circle.StackedPosition, circle.Radius))
|
if (isOffscreen(circle.StackedPosition, circle.Radius))
|
||||||
yield return new Issue(circle, templateOffscreen);
|
yield return new Issue(this, circle, templateOffscreen);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Checks
|
|||||||
|
|
||||||
// `SpanDuration` ensures we don't include reverses.
|
// `SpanDuration` ensures we don't include reverses.
|
||||||
double time = slider.StartTime + progress * slider.SpanDuration;
|
double time = slider.StartTime + progress * slider.SpanDuration;
|
||||||
yield return new Issue(slider, templateOffscreenSliderPath) { Time = time };
|
yield return new Issue(this, slider, templateOffscreenSliderPath) { Time = time };
|
||||||
|
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
@ -98,7 +98,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Checks
|
|||||||
if (!isOffscreen(slider.StackedEndPosition, slider.Radius))
|
if (!isOffscreen(slider.StackedEndPosition, slider.Radius))
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
yield return new Issue(slider, templateOffscreenSliderPath) { Time = slider.EndTime };
|
yield return new Issue(this, slider, templateOffscreenSliderPath) { Time = slider.EndTime };
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool isOffscreen(Vector2 position, double radius)
|
private bool isOffscreen(Vector2 position, double radius)
|
||||||
|
@ -12,7 +12,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
{
|
{
|
||||||
public class OsuBeatmapVerifier : BeatmapVerifier
|
public class OsuBeatmapVerifier : BeatmapVerifier
|
||||||
{
|
{
|
||||||
private readonly List<Check> checks = new List<Check>
|
private readonly List<ICheck> checks = new List<ICheck>
|
||||||
{
|
{
|
||||||
new CheckOffscreenObjects()
|
new CheckOffscreenObjects()
|
||||||
};
|
};
|
||||||
|
@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
/// Checks which are performed regardless of ruleset.
|
/// Checks which are performed regardless of ruleset.
|
||||||
/// These handle things like beatmap metadata, timing, and other ruleset agnostic elements.
|
/// These handle things like beatmap metadata, timing, and other ruleset agnostic elements.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly IReadOnlyList<Check> generalChecks = new List<Check>
|
private readonly IReadOnlyList<ICheck> generalChecks = new List<ICheck>
|
||||||
{
|
{
|
||||||
new CheckBackground()
|
new CheckBackground()
|
||||||
};
|
};
|
||||||
|
@ -8,15 +8,15 @@ using osu.Game.Rulesets.Edit.Checks.Components;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Edit.Checks
|
namespace osu.Game.Rulesets.Edit.Checks
|
||||||
{
|
{
|
||||||
public class CheckBackground : Check
|
public class CheckBackground : ICheck
|
||||||
{
|
{
|
||||||
public override CheckMetadata Metadata { get; } = new CheckMetadata
|
public CheckMetadata Metadata { get; } = new CheckMetadata
|
||||||
(
|
(
|
||||||
category: CheckCategory.Resources,
|
category: CheckCategory.Resources,
|
||||||
description: "Missing background."
|
description: "Missing background."
|
||||||
);
|
);
|
||||||
|
|
||||||
public override IEnumerable<IssueTemplate> PossibleTemplates => new[]
|
public IEnumerable<IssueTemplate> PossibleTemplates => new[]
|
||||||
{
|
{
|
||||||
templateNoneSet,
|
templateNoneSet,
|
||||||
templateDoesNotExist
|
templateDoesNotExist
|
||||||
@ -34,11 +34,11 @@ namespace osu.Game.Rulesets.Edit.Checks
|
|||||||
unformattedMessage: "The background file \"{0}\" is does not exist."
|
unformattedMessage: "The background file \"{0}\" is does not exist."
|
||||||
);
|
);
|
||||||
|
|
||||||
public override IEnumerable<Issue> Run(IBeatmap beatmap)
|
public IEnumerable<Issue> Run(IBeatmap beatmap)
|
||||||
{
|
{
|
||||||
if (beatmap.Metadata.BackgroundFile == null)
|
if (beatmap.Metadata.BackgroundFile == null)
|
||||||
{
|
{
|
||||||
yield return new Issue(templateNoneSet);
|
yield return new Issue(this, templateNoneSet);
|
||||||
|
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
@ -51,7 +51,7 @@ namespace osu.Game.Rulesets.Edit.Checks
|
|||||||
if (file != null)
|
if (file != null)
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
yield return new Issue(templateDoesNotExist, beatmap.Metadata.BackgroundFile);
|
yield return new Issue(this, templateDoesNotExist, beatmap.Metadata.BackgroundFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,28 +6,22 @@ using osu.Game.Beatmaps;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Edit.Checks.Components
|
namespace osu.Game.Rulesets.Edit.Checks.Components
|
||||||
{
|
{
|
||||||
public abstract class Check
|
public interface ICheck
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The metadata for this check.
|
/// The metadata for this check.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract CheckMetadata Metadata { get; }
|
public CheckMetadata Metadata { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// All possible templates for issues that this check may return.
|
/// All possible templates for issues that this check may return.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract IEnumerable<IssueTemplate> PossibleTemplates { get; }
|
public IEnumerable<IssueTemplate> PossibleTemplates { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Runs this check and returns any issues detected for the provided beatmap.
|
/// Runs this check and returns any issues detected for the provided beatmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="beatmap">The beatmap to run the check on.</param>
|
/// <param name="beatmap">The beatmap to run the check on.</param>
|
||||||
public abstract IEnumerable<Issue> Run(IBeatmap beatmap);
|
public IEnumerable<Issue> Run(IBeatmap beatmap);
|
||||||
|
|
||||||
protected Check()
|
|
||||||
{
|
|
||||||
foreach (var template in PossibleTemplates)
|
|
||||||
template.Origin = this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,38 +26,41 @@ namespace osu.Game.Rulesets.Edit.Checks.Components
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public IssueTemplate Template;
|
public IssueTemplate Template;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The check that this issue originates from.
|
||||||
|
/// </summary>
|
||||||
|
public ICheck Check;
|
||||||
|
|
||||||
/// <summary>
|
/// <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"/>.
|
/// 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.
|
/// This could for instance include timestamps, which diff is being compared to, what some volume is, etc.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public object[] Arguments;
|
public object[] Arguments;
|
||||||
|
|
||||||
public Issue(IssueTemplate template, params object[] args)
|
public Issue(ICheck check, IssueTemplate template, params object[] args)
|
||||||
{
|
{
|
||||||
|
Check = check;
|
||||||
Time = null;
|
Time = null;
|
||||||
HitObjects = Array.Empty<HitObject>();
|
HitObjects = Array.Empty<HitObject>();
|
||||||
Template = template;
|
Template = template;
|
||||||
Arguments = args;
|
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)
|
public Issue(ICheck check, double? time, IssueTemplate template, params object[] args)
|
||||||
: this(template, args)
|
: this(check, template, args)
|
||||||
{
|
{
|
||||||
Time = time;
|
Time = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Issue(HitObject hitObject, IssueTemplate template, params object[] args)
|
public Issue(ICheck check, HitObject hitObject, IssueTemplate template, params object[] args)
|
||||||
: this(template, args)
|
: this(check, template, args)
|
||||||
{
|
{
|
||||||
Time = hitObject.StartTime;
|
Time = hitObject.StartTime;
|
||||||
HitObjects = new[] { hitObject };
|
HitObjects = new[] { hitObject };
|
||||||
}
|
}
|
||||||
|
|
||||||
public Issue(IEnumerable<HitObject> hitObjects, IssueTemplate template, params object[] args)
|
public Issue(ICheck check, IEnumerable<HitObject> hitObjects, IssueTemplate template, params object[] args)
|
||||||
: this(template, args)
|
: this(check, template, args)
|
||||||
{
|
{
|
||||||
var hitObjectList = hitObjects.ToList();
|
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 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);
|
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>
|
/// <summary>
|
||||||
/// The type of the issue.
|
/// The type of the issue.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -130,7 +130,7 @@ namespace osu.Game.Screens.Edit.Verify
|
|||||||
{
|
{
|
||||||
table.Issues = beatmapVerifier.Run(Beatmap)
|
table.Issues = beatmapVerifier.Run(Beatmap)
|
||||||
.OrderByDescending(issue => issue.Template.Type)
|
.OrderByDescending(issue => issue.Template.Type)
|
||||||
.ThenByDescending(issue => issue.Template.Origin.Metadata.Category);
|
.ThenByDescending(issue => issue.Check.Metadata.Category);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user