mirror of
https://github.com/ppy/osu.git
synced 2025-03-22 22:17:46 +08:00
Add the playable beatmap as check argument
This is different from the working beatmap's `.Beatmap` property in that it is mutated by the ruleset/editor. So hit objects, for example, are actually of type `Slider` and such instead of the legacy `ConvertSlider`. This should be preferred over `workingBeatmap.Beatmap`.
This commit is contained in:
parent
9a69ca34a6
commit
8656176ab8
@ -224,12 +224,12 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor.Checks
|
||||
|
||||
private void assertOk(IBeatmap beatmap)
|
||||
{
|
||||
Assert.That(check.Run(new TestWorkingBeatmap(beatmap)), Is.Empty);
|
||||
Assert.That(check.Run(beatmap, new TestWorkingBeatmap(beatmap)), Is.Empty);
|
||||
}
|
||||
|
||||
private void assertOffscreenCircle(IBeatmap beatmap)
|
||||
{
|
||||
var issues = check.Run(new TestWorkingBeatmap(beatmap)).ToList();
|
||||
var issues = check.Run(beatmap, new TestWorkingBeatmap(beatmap)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckOffscreenObjects.IssueTemplateOffscreenCircle);
|
||||
@ -237,7 +237,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor.Checks
|
||||
|
||||
private void assertOffscreenSlider(IBeatmap beatmap)
|
||||
{
|
||||
var issues = check.Run(new TestWorkingBeatmap(beatmap)).ToList();
|
||||
var issues = check.Run(beatmap, new TestWorkingBeatmap(beatmap)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckOffscreenObjects.IssueTemplateOffscreenSlider);
|
||||
|
@ -31,9 +31,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Checks
|
||||
new IssueTemplateOffscreenSlider(this)
|
||||
};
|
||||
|
||||
public IEnumerable<Issue> Run(IWorkingBeatmap workingBeatmap)
|
||||
public IEnumerable<Issue> Run(IBeatmap playableBeatmap, IWorkingBeatmap workingBeatmap)
|
||||
{
|
||||
foreach (var hitobject in workingBeatmap.Beatmap.HitObjects)
|
||||
foreach (var hitobject in playableBeatmap.HitObjects)
|
||||
{
|
||||
switch (hitobject)
|
||||
{
|
||||
|
@ -17,6 +17,9 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
new CheckOffscreenObjects()
|
||||
};
|
||||
|
||||
public IEnumerable<Issue> Run(WorkingBeatmap workingBeatmap) => checks.SelectMany(check => check.Run(workingBeatmap));
|
||||
public IEnumerable<Issue> Run(IBeatmap playableBeatmap, WorkingBeatmap workingBeatmap)
|
||||
{
|
||||
return checks.SelectMany(check => check.Run(playableBeatmap, workingBeatmap));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
beatmap.Metadata.BackgroundFile = null;
|
||||
var mock = getMockWorkingBeatmap(null, System.Array.Empty<byte>());
|
||||
|
||||
Assert.That(check.Run(mock.Object), Is.Empty);
|
||||
Assert.That(check.Run(beatmap, mock.Object), Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -63,7 +63,7 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
var mock = getMockWorkingBeatmap(new Texture(1920, 1080));
|
||||
|
||||
Assert.That(check.Run(mock.Object), Is.Empty);
|
||||
Assert.That(check.Run(beatmap, mock.Object), Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -71,7 +71,7 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
var mock = getMockWorkingBeatmap(new Texture(3840, 2160));
|
||||
|
||||
var issues = check.Run(mock.Object).ToList();
|
||||
var issues = check.Run(beatmap, mock.Object).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckBackgroundQuality.IssueTemplateTooHighResolution);
|
||||
@ -82,7 +82,7 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
var mock = getMockWorkingBeatmap(new Texture(640, 480));
|
||||
|
||||
var issues = check.Run(mock.Object).ToList();
|
||||
var issues = check.Run(beatmap, mock.Object).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckBackgroundQuality.IssueTemplateLowResolution);
|
||||
@ -93,7 +93,7 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
var mock = getMockWorkingBeatmap(new Texture(100, 100));
|
||||
|
||||
var issues = check.Run(mock.Object).ToList();
|
||||
var issues = check.Run(beatmap, mock.Object).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckBackgroundQuality.IssueTemplateTooLowResolution);
|
||||
@ -104,7 +104,7 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
var mock = getMockWorkingBeatmap(new Texture(1920, 1080), new byte[1024 * 1024 * 3]);
|
||||
|
||||
var issues = check.Run(mock.Object).ToList();
|
||||
var issues = check.Run(beatmap, mock.Object).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckBackgroundQuality.IssueTemplateTooUncompressed);
|
||||
|
@ -15,13 +15,13 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
public class CheckFilePresenceTest
|
||||
{
|
||||
private CheckBackgroundPresence check;
|
||||
private WorkingBeatmap beatmap;
|
||||
private IBeatmap beatmap;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
check = new CheckBackgroundPresence();
|
||||
beatmap = new TestWorkingBeatmap(new Beatmap<HitObject>
|
||||
beatmap = new Beatmap<HitObject>
|
||||
{
|
||||
BeatmapInfo = new BeatmapInfo
|
||||
{
|
||||
@ -34,13 +34,13 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBackgroundSetAndInFiles()
|
||||
{
|
||||
Assert.That(check.Run(beatmap), Is.Empty);
|
||||
Assert.That(check.Run(beatmap, new TestWorkingBeatmap(beatmap)), Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -48,7 +48,7 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
beatmap.BeatmapInfo.BeatmapSet.Files.Clear();
|
||||
|
||||
var issues = check.Run(beatmap).ToList();
|
||||
var issues = check.Run(beatmap, new TestWorkingBeatmap(beatmap)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckFilePresence.IssueTemplateDoesNotExist);
|
||||
@ -59,7 +59,7 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
beatmap.Metadata.BackgroundFile = null;
|
||||
|
||||
var issues = check.Run(beatmap).ToList();
|
||||
var issues = check.Run(beatmap, new TestWorkingBeatmap(beatmap)).ToList();
|
||||
|
||||
Assert.That(issues, Has.Count.EqualTo(1));
|
||||
Assert.That(issues.Single().Template is CheckFilePresence.IssueTemplateNoneSet);
|
||||
|
@ -23,6 +23,9 @@ namespace osu.Game.Rulesets.Edit
|
||||
new CheckAudioPresence(),
|
||||
};
|
||||
|
||||
public IEnumerable<Issue> Run(WorkingBeatmap workingBeatmap) => checks.SelectMany(check => check.Run(workingBeatmap));
|
||||
public IEnumerable<Issue> Run(IBeatmap playableBeatmap, WorkingBeatmap workingBeatmap)
|
||||
{
|
||||
return checks.SelectMany(check => check.Run(playableBeatmap, workingBeatmap));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,9 +30,9 @@ namespace osu.Game.Rulesets.Edit.Checks
|
||||
new IssueTemplateTooUncompressed(this)
|
||||
};
|
||||
|
||||
public IEnumerable<Issue> Run(IWorkingBeatmap workingBeatmap)
|
||||
public IEnumerable<Issue> Run(IBeatmap playableBeatmap, IWorkingBeatmap workingBeatmap)
|
||||
{
|
||||
var backgroundFile = workingBeatmap.Beatmap.Metadata?.BackgroundFile;
|
||||
var backgroundFile = playableBeatmap.Metadata?.BackgroundFile;
|
||||
if (backgroundFile == null)
|
||||
yield break;
|
||||
|
||||
@ -48,7 +48,7 @@ namespace osu.Game.Rulesets.Edit.Checks
|
||||
else if (texture.Width < low_width || texture.Height < low_height)
|
||||
yield return new IssueTemplateLowResolution(this).Create(texture.Width, texture.Height);
|
||||
|
||||
string storagePath = workingBeatmap.Beatmap.BeatmapInfo.BeatmapSet.GetPathForFile(backgroundFile);
|
||||
string storagePath = playableBeatmap.BeatmapInfo.BeatmapSet.GetPathForFile(backgroundFile);
|
||||
double filesizeMb = workingBeatmap.GetStream(storagePath).Length / (1024d * 1024d);
|
||||
|
||||
if (filesizeMb > max_filesize_mb)
|
||||
|
@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Edit.Checks
|
||||
new IssueTemplateDoesNotExist(this)
|
||||
};
|
||||
|
||||
public IEnumerable<Issue> Run(IWorkingBeatmap workingBeatmap)
|
||||
public IEnumerable<Issue> Run(IBeatmap playableBeatmap, IWorkingBeatmap workingBeatmap)
|
||||
{
|
||||
var filename = GetFilename(workingBeatmap);
|
||||
|
||||
@ -33,7 +33,7 @@ namespace osu.Game.Rulesets.Edit.Checks
|
||||
}
|
||||
|
||||
// If the file is set, also make sure it still exists.
|
||||
var storagePath = workingBeatmap.Beatmap.BeatmapInfo.BeatmapSet.GetPathForFile(filename);
|
||||
var storagePath = playableBeatmap.BeatmapInfo.BeatmapSet.GetPathForFile(filename);
|
||||
if (storagePath != null)
|
||||
yield break;
|
||||
|
||||
|
@ -24,7 +24,8 @@ namespace osu.Game.Rulesets.Edit.Checks.Components
|
||||
/// <summary>
|
||||
/// Runs this check and returns any issues detected for the provided beatmap.
|
||||
/// </summary>
|
||||
/// <param name="workingBeatmap">The beatmap to run the check on.</param>
|
||||
public IEnumerable<Issue> Run(IWorkingBeatmap workingBeatmap);
|
||||
/// <param name="playableBeatmap">The playable beatmap of the beatmap to run the check on.</param>
|
||||
/// <param name="workingBeatmap">The working beatmap of the beatmap to run the check on.</param>
|
||||
public IEnumerable<Issue> Run(IBeatmap playableBeatmap, IWorkingBeatmap workingBeatmap);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,6 @@ namespace osu.Game.Rulesets.Edit
|
||||
/// </summary>
|
||||
public interface IBeatmapVerifier
|
||||
{
|
||||
public IEnumerable<Issue> Run(WorkingBeatmap workingBeatmap);
|
||||
public IEnumerable<Issue> Run(IBeatmap playableBeatmap, WorkingBeatmap workingBeatmap);
|
||||
}
|
||||
}
|
||||
|
@ -124,10 +124,10 @@ namespace osu.Game.Screens.Edit.Verify
|
||||
private void refresh()
|
||||
{
|
||||
var workingBeatmap = beatmapManager.GetWorkingBeatmap(beatmap.BeatmapInfo);
|
||||
var issues = generalVerifier.Run(workingBeatmap);
|
||||
var issues = generalVerifier.Run(beatmap.PlayableBeatmap, workingBeatmap);
|
||||
|
||||
if (rulesetVerifier != null)
|
||||
issues = issues.Concat(rulesetVerifier.Run(workingBeatmap));
|
||||
issues = issues.Concat(rulesetVerifier.Run(beatmap.PlayableBeatmap, workingBeatmap));
|
||||
|
||||
table.Issues = issues
|
||||
.OrderBy(issue => issue.Template.Type)
|
||||
|
Loading…
x
Reference in New Issue
Block a user