mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09: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:
@ -224,12 +224,12 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor.Checks
|
|||||||
|
|
||||||
private void assertOk(IBeatmap beatmap)
|
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)
|
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, Has.Count.EqualTo(1));
|
||||||
Assert.That(issues.Single().Template is CheckOffscreenObjects.IssueTemplateOffscreenCircle);
|
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)
|
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, Has.Count.EqualTo(1));
|
||||||
Assert.That(issues.Single().Template is CheckOffscreenObjects.IssueTemplateOffscreenSlider);
|
Assert.That(issues.Single().Template is CheckOffscreenObjects.IssueTemplateOffscreenSlider);
|
||||||
|
@ -31,9 +31,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Checks
|
|||||||
new IssueTemplateOffscreenSlider(this)
|
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)
|
switch (hitobject)
|
||||||
{
|
{
|
||||||
|
@ -17,6 +17,9 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
new CheckOffscreenObjects()
|
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;
|
beatmap.Metadata.BackgroundFile = null;
|
||||||
var mock = getMockWorkingBeatmap(null, System.Array.Empty<byte>());
|
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]
|
[Test]
|
||||||
@ -63,7 +63,7 @@ namespace osu.Game.Tests.Editing.Checks
|
|||||||
{
|
{
|
||||||
var mock = getMockWorkingBeatmap(new Texture(1920, 1080));
|
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]
|
[Test]
|
||||||
@ -71,7 +71,7 @@ namespace osu.Game.Tests.Editing.Checks
|
|||||||
{
|
{
|
||||||
var mock = getMockWorkingBeatmap(new Texture(3840, 2160));
|
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, Has.Count.EqualTo(1));
|
||||||
Assert.That(issues.Single().Template is CheckBackgroundQuality.IssueTemplateTooHighResolution);
|
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 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, Has.Count.EqualTo(1));
|
||||||
Assert.That(issues.Single().Template is CheckBackgroundQuality.IssueTemplateLowResolution);
|
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 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, Has.Count.EqualTo(1));
|
||||||
Assert.That(issues.Single().Template is CheckBackgroundQuality.IssueTemplateTooLowResolution);
|
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 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, Has.Count.EqualTo(1));
|
||||||
Assert.That(issues.Single().Template is CheckBackgroundQuality.IssueTemplateTooUncompressed);
|
Assert.That(issues.Single().Template is CheckBackgroundQuality.IssueTemplateTooUncompressed);
|
||||||
|
@ -15,13 +15,13 @@ namespace osu.Game.Tests.Editing.Checks
|
|||||||
public class CheckFilePresenceTest
|
public class CheckFilePresenceTest
|
||||||
{
|
{
|
||||||
private CheckBackgroundPresence check;
|
private CheckBackgroundPresence check;
|
||||||
private WorkingBeatmap beatmap;
|
private IBeatmap beatmap;
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
{
|
{
|
||||||
check = new CheckBackgroundPresence();
|
check = new CheckBackgroundPresence();
|
||||||
beatmap = new TestWorkingBeatmap(new Beatmap<HitObject>
|
beatmap = new Beatmap<HitObject>
|
||||||
{
|
{
|
||||||
BeatmapInfo = new BeatmapInfo
|
BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
@ -34,13 +34,13 @@ namespace osu.Game.Tests.Editing.Checks
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestBackgroundSetAndInFiles()
|
public void TestBackgroundSetAndInFiles()
|
||||||
{
|
{
|
||||||
Assert.That(check.Run(beatmap), Is.Empty);
|
Assert.That(check.Run(beatmap, new TestWorkingBeatmap(beatmap)), Is.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -48,7 +48,7 @@ namespace osu.Game.Tests.Editing.Checks
|
|||||||
{
|
{
|
||||||
beatmap.BeatmapInfo.BeatmapSet.Files.Clear();
|
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, Has.Count.EqualTo(1));
|
||||||
Assert.That(issues.Single().Template is CheckFilePresence.IssueTemplateDoesNotExist);
|
Assert.That(issues.Single().Template is CheckFilePresence.IssueTemplateDoesNotExist);
|
||||||
@ -59,7 +59,7 @@ namespace osu.Game.Tests.Editing.Checks
|
|||||||
{
|
{
|
||||||
beatmap.Metadata.BackgroundFile = null;
|
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, Has.Count.EqualTo(1));
|
||||||
Assert.That(issues.Single().Template is CheckFilePresence.IssueTemplateNoneSet);
|
Assert.That(issues.Single().Template is CheckFilePresence.IssueTemplateNoneSet);
|
||||||
|
@ -23,6 +23,9 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
new CheckAudioPresence(),
|
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)
|
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)
|
if (backgroundFile == null)
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ namespace osu.Game.Rulesets.Edit.Checks
|
|||||||
else if (texture.Width < low_width || texture.Height < low_height)
|
else if (texture.Width < low_width || texture.Height < low_height)
|
||||||
yield return new IssueTemplateLowResolution(this).Create(texture.Width, texture.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);
|
double filesizeMb = workingBeatmap.GetStream(storagePath).Length / (1024d * 1024d);
|
||||||
|
|
||||||
if (filesizeMb > max_filesize_mb)
|
if (filesizeMb > max_filesize_mb)
|
||||||
|
@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Edit.Checks
|
|||||||
new IssueTemplateDoesNotExist(this)
|
new IssueTemplateDoesNotExist(this)
|
||||||
};
|
};
|
||||||
|
|
||||||
public IEnumerable<Issue> Run(IWorkingBeatmap workingBeatmap)
|
public IEnumerable<Issue> Run(IBeatmap playableBeatmap, IWorkingBeatmap workingBeatmap)
|
||||||
{
|
{
|
||||||
var filename = GetFilename(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.
|
// 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)
|
if (storagePath != null)
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
|
@ -24,7 +24,8 @@ namespace osu.Game.Rulesets.Edit.Checks.Components
|
|||||||
/// <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="workingBeatmap">The beatmap to run the check on.</param>
|
/// <param name="playableBeatmap">The playable beatmap of the beatmap to run the check on.</param>
|
||||||
public IEnumerable<Issue> Run(IWorkingBeatmap workingBeatmap);
|
/// <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>
|
/// </summary>
|
||||||
public interface IBeatmapVerifier
|
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()
|
private void refresh()
|
||||||
{
|
{
|
||||||
var workingBeatmap = beatmapManager.GetWorkingBeatmap(beatmap.BeatmapInfo);
|
var workingBeatmap = beatmapManager.GetWorkingBeatmap(beatmap.BeatmapInfo);
|
||||||
var issues = generalVerifier.Run(workingBeatmap);
|
var issues = generalVerifier.Run(beatmap.PlayableBeatmap, workingBeatmap);
|
||||||
|
|
||||||
if (rulesetVerifier != null)
|
if (rulesetVerifier != null)
|
||||||
issues = issues.Concat(rulesetVerifier.Run(workingBeatmap));
|
issues = issues.Concat(rulesetVerifier.Run(beatmap.PlayableBeatmap, workingBeatmap));
|
||||||
|
|
||||||
table.Issues = issues
|
table.Issues = issues
|
||||||
.OrderBy(issue => issue.Template.Type)
|
.OrderBy(issue => issue.Template.Type)
|
||||||
|
Reference in New Issue
Block a user