1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-18 05:39:53 +08:00

address review

- add TODO for refactoring verifier context ctor
- call `GetPlayableBeatmap()` in verifier context ctor
- filter diffs with relevant ruleset in check logic
- fix tests
This commit is contained in:
Hivie
2025-07-16 01:53:22 +01:00
Unverified
parent 806995e951
commit 747bff1df9
4 changed files with 24 additions and 9 deletions
@@ -10,6 +10,7 @@ using osu.Game.Extensions;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Edit.Checks;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Osu;
using osu.Game.Tests.Beatmaps;
namespace osu.Game.Tests.Editing.Checks
@@ -158,7 +159,8 @@ namespace osu.Game.Tests.Editing.Checks
BeatmapInfo = new BeatmapInfo
{
StarRating = starRating,
DifficultyName = difficultyName
DifficultyName = difficultyName,
Ruleset = new OsuRuleset().RulesetInfo
},
HitObjects = new List<HitObject>
{
@@ -177,7 +179,8 @@ namespace osu.Game.Tests.Editing.Checks
BeatmapInfo = new BeatmapInfo
{
StarRating = starRating,
DifficultyName = difficultyName
DifficultyName = difficultyName,
Ruleset = new OsuRuleset().RulesetInfo
},
HitObjects = new List<HitObject>
{
@@ -242,7 +245,7 @@ namespace osu.Game.Tests.Editing.Checks
currentBeatmap,
new TestWorkingBeatmap(currentBeatmap),
currentDifficultyRating,
beatmapInfo => difficultyDict.TryGetValue(beatmapInfo, out var workingBeatmap) ? workingBeatmap : null
beatmapInfo => difficultyDict.TryGetValue(beatmapInfo, out var workingBeatmap) ? workingBeatmap.Beatmap : null
);
}
@@ -33,7 +33,8 @@ namespace osu.Game.Rulesets.Edit
/// </summary>
public readonly IReadOnlyList<IBeatmap> BeatmapsetDifficulties;
public BeatmapVerifierContext(IBeatmap beatmap, IWorkingBeatmap workingBeatmap, DifficultyRating difficultyRating = DifficultyRating.ExpertPlus, Func<BeatmapInfo, IWorkingBeatmap?>? beatmapResolver = null)
// TODO: Refactor this to have a simple constructor that only stores data and move the beatmap resolution logic to a static factory method.
public BeatmapVerifierContext(IBeatmap beatmap, IWorkingBeatmap workingBeatmap, DifficultyRating difficultyRating = DifficultyRating.ExpertPlus, Func<BeatmapInfo, IBeatmap?>? beatmapResolver = null)
{
Beatmap = beatmap;
WorkingBeatmap = workingBeatmap;
@@ -59,9 +60,9 @@ namespace osu.Game.Rulesets.Edit
}
// Try to resolve other difficulties using the provided resolver
var working = beatmapResolver?.Invoke(beatmapInfo);
if (working?.Beatmap != null)
difficulties.Add(working.Beatmap);
var resolvedBeatmap = beatmapResolver?.Invoke(beatmapInfo);
if (resolvedBeatmap != null)
difficulties.Add(resolvedBeatmap);
}
BeatmapsetDifficulties = difficulties;
@@ -27,7 +27,9 @@ namespace osu.Game.Rulesets.Edit.Checks
public IEnumerable<Issue> Run(BeatmapVerifierContext context)
{
IReadOnlyList<IBeatmap> difficulties = context.BeatmapsetDifficulties;
IReadOnlyList<IBeatmap> difficulties = context.BeatmapsetDifficulties
.Where(d => d.BeatmapInfo.Ruleset.Equals(context.Beatmap.BeatmapInfo.Ruleset))
.ToList();
if (difficulties.Count == 0)
yield break;
+10 -1
View File
@@ -46,7 +46,16 @@ namespace osu.Game.Screens.Edit.Verify
generalVerifier = new BeatmapVerifier();
rulesetVerifier = beatmap.BeatmapInfo.Ruleset.CreateInstance().CreateBeatmapVerifier();
context = new BeatmapVerifierContext(beatmap, workingBeatmap.Value, verify.InterpretedDifficulty.Value, beatmapInfo => beatmapManager.GetWorkingBeatmap(beatmapInfo));
context = new BeatmapVerifierContext(
beatmap,
workingBeatmap.Value,
verify.InterpretedDifficulty.Value,
beatmapInfo =>
beatmapManager
.GetWorkingBeatmap(beatmapInfo)
?.GetPlayableBeatmap(beatmapInfo.Ruleset)
);
verify.InterpretedDifficulty.BindValueChanged(difficulty => context.InterpretedDifficulty = difficulty.NewValue);
RelativeSizeAxes = Axes.Both;