mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Clean up check logic
Makes use of the new `BeatmapSet.GetPathForFile` method and removes dependency on `WorkingBeatmap` specifically, allowing us to switch to `IWorkingBeatmap` later.
This commit is contained in:
@ -2,7 +2,6 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Edit.Checks.Components;
|
using osu.Game.Rulesets.Edit.Checks.Components;
|
||||||
|
|
||||||
@ -20,7 +19,9 @@ namespace osu.Game.Rulesets.Edit.Checks
|
|||||||
|
|
||||||
public IEnumerable<Issue> Run(WorkingBeatmap workingBeatmap)
|
public IEnumerable<Issue> Run(WorkingBeatmap workingBeatmap)
|
||||||
{
|
{
|
||||||
if (workingBeatmap.Metadata?.BackgroundFile == null)
|
string backgroundFile = workingBeatmap.Beatmap.Metadata?.BackgroundFile;
|
||||||
|
|
||||||
|
if (backgroundFile == null)
|
||||||
{
|
{
|
||||||
yield return new IssueTemplateNoneSet(this).Create();
|
yield return new IssueTemplateNoneSet(this).Create();
|
||||||
|
|
||||||
@ -28,14 +29,11 @@ namespace osu.Game.Rulesets.Edit.Checks
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the background is set, also make sure it still exists.
|
// If the background is set, also make sure it still exists.
|
||||||
|
var storagePath = workingBeatmap.Beatmap.BeatmapInfo.BeatmapSet.GetPathForFile(backgroundFile);
|
||||||
var set = workingBeatmap.BeatmapInfo.BeatmapSet;
|
if (storagePath != null)
|
||||||
var file = set.Files.FirstOrDefault(f => f.Filename == workingBeatmap.Metadata.BackgroundFile);
|
|
||||||
|
|
||||||
if (file != null)
|
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
yield return new IssueTemplateDoesNotExist(this).Create(workingBeatmap.Metadata.BackgroundFile);
|
yield return new IssueTemplateDoesNotExist(this).Create(backgroundFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class IssueTemplateNoneSet : IssueTemplate
|
public class IssueTemplateNoneSet : IssueTemplate
|
||||||
|
@ -32,7 +32,8 @@ namespace osu.Game.Rulesets.Edit.Checks
|
|||||||
|
|
||||||
public IEnumerable<Issue> Run(WorkingBeatmap workingBeatmap)
|
public IEnumerable<Issue> Run(WorkingBeatmap workingBeatmap)
|
||||||
{
|
{
|
||||||
if (workingBeatmap.Metadata?.BackgroundFile == null)
|
var backgroundFile = workingBeatmap.Beatmap.Metadata?.BackgroundFile;
|
||||||
|
if (backgroundFile == null)
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
var texture = workingBeatmap.Background;
|
var texture = workingBeatmap.Background;
|
||||||
@ -47,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.BeatmapInfo.BeatmapSet.GetPathForFile(workingBeatmap.Metadata.BackgroundFile);
|
string storagePath = workingBeatmap.Beatmap.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)
|
||||||
|
Reference in New Issue
Block a user