mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 02:22:56 +08:00
Remove previous fix and move filtered logic to carousel.
- Add an optional bool parameter to SelectBeatmap to skip selecting filtered maps
This commit is contained in:
parent
81c1ec2005
commit
25fb527cc7
@ -169,20 +169,29 @@ namespace osu.Game.Screens.Select
|
||||
});
|
||||
}
|
||||
|
||||
public void SelectBeatmap(BeatmapInfo beatmap)
|
||||
/// <summary>
|
||||
/// Selects a given beatmap on the carousel.
|
||||
/// </summary>
|
||||
/// <param name="beatmap">The beatmap to select.</param>
|
||||
/// <param name="skipFiltered">Whether to skip selecting filtered beatmaps.</param>
|
||||
/// <returns>True if a selection was made, false if it was skipped.</returns>
|
||||
public bool SelectBeatmap(BeatmapInfo beatmap, bool skipFiltered = false)
|
||||
{
|
||||
if (beatmap?.Hidden != false)
|
||||
return;
|
||||
return false;
|
||||
|
||||
foreach (CarouselBeatmapSet group in beatmapSets)
|
||||
{
|
||||
var item = group.Beatmaps.FirstOrDefault(p => p.Beatmap.Equals(beatmap));
|
||||
if (item != null)
|
||||
{
|
||||
select(item);
|
||||
return;
|
||||
}
|
||||
}
|
||||
var group = beatmapSets.FirstOrDefault(s => s.BeatmapSet.OnlineBeatmapSetID == beatmap.BeatmapSet.OnlineBeatmapSetID);
|
||||
|
||||
if (group == null || !skipFiltered && group.Filtered)
|
||||
return false;
|
||||
|
||||
var item = group.Beatmaps.FirstOrDefault(p => p.Beatmap.Equals(beatmap));
|
||||
|
||||
if (item == null || !skipFiltered && item.Filtered)
|
||||
return false;
|
||||
|
||||
select(item);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -267,10 +267,7 @@ namespace osu.Game.Screens.Select
|
||||
protected void WorkingBeatmapChanged(WorkingBeatmap beatmap)
|
||||
{
|
||||
if (IsCurrentScreen)
|
||||
{
|
||||
Carousel.SelectBeatmap(beatmap?.BeatmapInfo);
|
||||
ensurePlayableRuleset();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -328,7 +325,6 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
base.OnEntering(last);
|
||||
|
||||
ensurePlayableRuleset();
|
||||
Content.FadeInFromZero(250);
|
||||
FilterControl.Activate();
|
||||
}
|
||||
@ -456,34 +452,6 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
}
|
||||
|
||||
private void ensurePlayableRuleset()
|
||||
{
|
||||
if (Beatmap.IsDefault)
|
||||
// DummyBeatmap won't be playable anyway
|
||||
return;
|
||||
|
||||
bool conversionAllowed = rulesetConversionAllowed.Value;
|
||||
int? currentRuleset = Ruleset.Value.ID;
|
||||
int beatmapRuleset = Beatmap.Value.BeatmapInfo.RulesetID;
|
||||
|
||||
if (currentRuleset == beatmapRuleset || conversionAllowed && beatmapRuleset == 0)
|
||||
// Current beatmap is playable, nothing more to do
|
||||
return;
|
||||
|
||||
// Otherwise, first check if the current beatmapset has any playable beatmaps
|
||||
BeatmapInfo beatmap = Beatmap.Value.BeatmapSetInfo.Beatmaps?.FirstOrDefault(b => b.RulesetID == currentRuleset || conversionAllowed && b.RulesetID == 0);
|
||||
|
||||
// If it does then update the WorkingBeatmap
|
||||
if (beatmap != null)
|
||||
{
|
||||
Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap);
|
||||
return;
|
||||
}
|
||||
|
||||
// If it doesn't, then update the current ruleset so that the current beatmap is playable
|
||||
Ruleset.Value = Beatmap.Value.BeatmapInfo.Ruleset;
|
||||
}
|
||||
|
||||
private void onBeatmapSetAdded(BeatmapSetInfo s) => Carousel.UpdateBeatmapSet(s);
|
||||
private void onBeatmapSetRemoved(BeatmapSetInfo s) => Carousel.RemoveBeatmapSet(s);
|
||||
private void onBeatmapRestored(BeatmapInfo b) => Carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
|
||||
|
Loading…
Reference in New Issue
Block a user