mirror of
https://github.com/ppy/osu.git
synced 2026-05-24 06:19:55 +08:00
71 lines
2.7 KiB
C#
71 lines
2.7 KiB
C#
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using osu.Game.Rulesets.Edit;
|
|
using osu.Game.Rulesets.Edit.Checks.Components;
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Edit.Checks
|
|
{
|
|
public class CheckTaikoInconsistentSkipBarLine : ICheck
|
|
{
|
|
public CheckMetadata Metadata => new CheckMetadata(CheckCategory.Timing, "Inconsistent \"Skip Bar Line\" setting");
|
|
|
|
public IEnumerable<IssueTemplate> PossibleTemplates => new IssueTemplate[]
|
|
{
|
|
new IssueTemplateInconsistentOmitFirstBarLine(this)
|
|
};
|
|
|
|
public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
|
{
|
|
var difficulties = context.BeatmapsetDifficulties;
|
|
|
|
if (difficulties.Count <= 1)
|
|
yield break;
|
|
|
|
// Inconsistent bar line omission only matters for osu!taiko difficulties, so only check those
|
|
var taikoBeatmaps = difficulties.Where(b => b.BeatmapInfo.Ruleset.ShortName == "taiko").ToList();
|
|
|
|
if (taikoBeatmaps.Count <= 1)
|
|
yield break;
|
|
|
|
var referenceBeatmap = context.Beatmap;
|
|
var referenceTimingPoints = referenceBeatmap.ControlPointInfo.TimingPoints;
|
|
|
|
foreach (var beatmap in taikoBeatmaps)
|
|
{
|
|
if (beatmap == referenceBeatmap)
|
|
continue;
|
|
|
|
var timingPoints = beatmap.ControlPointInfo.TimingPoints;
|
|
|
|
foreach (var referencePoint in referenceTimingPoints)
|
|
{
|
|
var matchingPoint = TimingCheckUtils.FindExactMatchingTimingPoint(timingPoints, referencePoint.Time);
|
|
|
|
if (matchingPoint == null)
|
|
// Inconsistent timing points - that's handled by `CheckInconsistentTimingControlPoints`, so skip
|
|
continue;
|
|
|
|
if (referencePoint.OmitFirstBarLine != matchingPoint.OmitFirstBarLine)
|
|
{
|
|
yield return new IssueTemplateInconsistentOmitFirstBarLine(this).Create(referencePoint.Time, beatmap.BeatmapInfo.DifficultyName);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public class IssueTemplateInconsistentOmitFirstBarLine : IssueTemplate
|
|
{
|
|
public IssueTemplateInconsistentOmitFirstBarLine(ICheck check)
|
|
: base(check, IssueType.Problem, "Inconsistent \"Skip Bar Line\" setting in {0}.")
|
|
{
|
|
}
|
|
|
|
public Issue Create(double time, string difficultyName)
|
|
=> new Issue(time, this, difficultyName);
|
|
}
|
|
}
|
|
}
|