mirror of
https://github.com/ppy/osu
synced 2024-12-27 01:12:45 +00:00
Add helper method to get drain length (and rename some usages)
This commit is contained in:
parent
04c1333b59
commit
9cfe9164fa
@ -16,12 +16,12 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
public class CheckDrainTimeTest
|
||||
{
|
||||
private CheckDrainTime check = null!;
|
||||
private CheckDrainLength check = null!;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
check = new CheckDrainTime();
|
||||
check = new CheckDrainLength();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -40,7 +40,7 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
var issues = check.Run(context).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckDrainTime.IssueTemplateTooShort);
|
||||
Assert.That(issues.Single().Template is CheckDrainLength.IssueTemplateTooShort);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -63,7 +63,7 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
var issues = check.Run(context).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckDrainTime.IssueTemplateTooShort);
|
||||
Assert.That(issues.Single().Template is CheckDrainLength.IssueTemplateTooShort);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -110,6 +110,11 @@ namespace osu.Game.Beatmaps
|
||||
/// </remarks>
|
||||
public static double CalculatePlayableLength(this IBeatmap beatmap) => CalculatePlayableLength(beatmap.HitObjects);
|
||||
|
||||
/// <summary>
|
||||
/// Find the total milliseconds between the first and last hittable objects, excluding any break time.
|
||||
/// </summary>
|
||||
public static double CalculateDrainLength(this IBeatmap beatmap) => CalculatePlayableLength(beatmap.HitObjects) - beatmap.TotalBreakTime;
|
||||
|
||||
/// <summary>
|
||||
/// Find the timestamps in milliseconds of the start and end of the playable region.
|
||||
/// </summary>
|
||||
|
@ -34,7 +34,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
new CheckUnsnappedObjects(),
|
||||
new CheckConcurrentObjects(),
|
||||
new CheckZeroLengthObjects(),
|
||||
new CheckDrainTime(),
|
||||
new CheckDrainLength(),
|
||||
|
||||
// Timing
|
||||
new CheckPreviewTime(),
|
||||
|
@ -7,10 +7,11 @@ using osu.Game.Rulesets.Edit.Checks.Components;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Checks
|
||||
{
|
||||
public class CheckDrainTime : ICheck
|
||||
public class CheckDrainLength : ICheck
|
||||
{
|
||||
private const int min_drain_threshold = 30 * 1000;
|
||||
public CheckMetadata Metadata => new CheckMetadata(CheckCategory.Compose, "Too short drain time");
|
||||
|
||||
public CheckMetadata Metadata => new CheckMetadata(CheckCategory.Compose, "Drain length is too short");
|
||||
|
||||
public IEnumerable<IssueTemplate> PossibleTemplates => new IssueTemplate[]
|
||||
{
|
||||
@ -19,7 +20,7 @@ namespace osu.Game.Rulesets.Edit.Checks
|
||||
|
||||
public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
||||
{
|
||||
double drainTime = context.Beatmap.CalculatePlayableLength() - context.Beatmap.TotalBreakTime;
|
||||
double drainTime = context.Beatmap.CalculateDrainLength();
|
||||
|
||||
if (drainTime < min_drain_threshold)
|
||||
yield return new IssueTemplateTooShort(this).Create((int)(drainTime / 1000));
|
Loading…
Reference in New Issue
Block a user