mirror of
https://github.com/ppy/osu.git
synced 2025-03-15 21:17:46 +08:00
Move filter matching code into own method to simplify early returns
This commit is contained in:
parent
1fcf41379d
commit
5af41bb1c8
@ -26,6 +26,11 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
{
|
{
|
||||||
base.Filter(criteria);
|
base.Filter(criteria);
|
||||||
|
|
||||||
|
Filtered.Value = !checkMatch(criteria);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool checkMatch(FilterCriteria criteria)
|
||||||
|
{
|
||||||
bool match =
|
bool match =
|
||||||
criteria.Ruleset == null ||
|
criteria.Ruleset == null ||
|
||||||
BeatmapInfo.Ruleset.ShortName == criteria.Ruleset.ShortName ||
|
BeatmapInfo.Ruleset.ShortName == criteria.Ruleset.ShortName ||
|
||||||
@ -34,8 +39,7 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
if (BeatmapInfo.BeatmapSet?.Equals(criteria.SelectedBeatmapSet) == true)
|
if (BeatmapInfo.BeatmapSet?.Equals(criteria.SelectedBeatmapSet) == true)
|
||||||
{
|
{
|
||||||
// only check ruleset equality or convertability for selected beatmap
|
// only check ruleset equality or convertability for selected beatmap
|
||||||
Filtered.Value = !match;
|
return match;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match &= !criteria.StarDifficulty.HasFilter || criteria.StarDifficulty.IsInRange(BeatmapInfo.StarRating);
|
match &= !criteria.StarDifficulty.HasFilter || criteria.StarDifficulty.IsInRange(BeatmapInfo.StarRating);
|
||||||
@ -49,11 +53,7 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
match &= !criteria.BeatDivisor.HasFilter || criteria.BeatDivisor.IsInRange(BeatmapInfo.BeatDivisor);
|
match &= !criteria.BeatDivisor.HasFilter || criteria.BeatDivisor.IsInRange(BeatmapInfo.BeatDivisor);
|
||||||
match &= !criteria.OnlineStatus.HasFilter || criteria.OnlineStatus.IsInRange(BeatmapInfo.Status);
|
match &= !criteria.OnlineStatus.HasFilter || criteria.OnlineStatus.IsInRange(BeatmapInfo.Status);
|
||||||
|
|
||||||
if (!match)
|
if (!match) return false;
|
||||||
{
|
|
||||||
Filtered.Value = !match;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
match &= !criteria.Creator.HasFilter || criteria.Creator.Matches(BeatmapInfo.Metadata.Author.Username);
|
match &= !criteria.Creator.HasFilter || criteria.Creator.Matches(BeatmapInfo.Metadata.Author.Username);
|
||||||
match &= !criteria.Artist.HasFilter || criteria.Artist.Matches(BeatmapInfo.Metadata.Artist) ||
|
match &= !criteria.Artist.HasFilter || criteria.Artist.Matches(BeatmapInfo.Metadata.Artist) ||
|
||||||
@ -61,11 +61,7 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
|
|
||||||
match &= !criteria.UserStarDifficulty.HasFilter || criteria.UserStarDifficulty.IsInRange(BeatmapInfo.StarRating);
|
match &= !criteria.UserStarDifficulty.HasFilter || criteria.UserStarDifficulty.IsInRange(BeatmapInfo.StarRating);
|
||||||
|
|
||||||
if (!match)
|
if (!match) return false;
|
||||||
{
|
|
||||||
Filtered.Value = !match;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (criteria.SearchTerms.Length > 0)
|
if (criteria.SearchTerms.Length > 0)
|
||||||
{
|
{
|
||||||
@ -99,18 +95,14 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!match)
|
if (!match) return false;
|
||||||
{
|
|
||||||
Filtered.Value = !match;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
match &= criteria.CollectionBeatmapMD5Hashes?.Contains(BeatmapInfo.MD5Hash) ?? true;
|
match &= criteria.CollectionBeatmapMD5Hashes?.Contains(BeatmapInfo.MD5Hash) ?? true;
|
||||||
|
|
||||||
if (match && criteria.RulesetCriteria != null)
|
if (match && criteria.RulesetCriteria != null)
|
||||||
match &= criteria.RulesetCriteria.Matches(BeatmapInfo);
|
match &= criteria.RulesetCriteria.Matches(BeatmapInfo);
|
||||||
|
|
||||||
Filtered.Value = !match;
|
return match;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int CompareTo(FilterCriteria criteria, CarouselItem other)
|
public override int CompareTo(FilterCriteria criteria, CarouselItem other)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user