2021-03-30 07:07:04 +00:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
2024-04-15 12:07:36 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using osu.Framework.Bindables;
|
2021-03-30 07:07:04 +00:00
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Rulesets.Filter;
|
|
|
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
2024-04-15 12:07:36 +00:00
|
|
|
using osu.Game.Rulesets.Mania.Mods;
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2024-04-01 08:02:32 +00:00
|
|
|
using osu.Game.Rulesets.Scoring.Legacy;
|
2021-03-30 07:07:04 +00:00
|
|
|
using osu.Game.Screens.Select;
|
|
|
|
using osu.Game.Screens.Select.Filter;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania
|
|
|
|
{
|
|
|
|
public class ManiaFilterCriteria : IRulesetFilterCriteria
|
|
|
|
{
|
|
|
|
private FilterCriteria.OptionalRange<float> keys;
|
|
|
|
|
2024-03-28 14:02:25 +00:00
|
|
|
public bool Matches(BeatmapInfo beatmapInfo, FilterCriteria criteria)
|
2021-03-30 07:07:04 +00:00
|
|
|
{
|
2024-04-01 08:02:32 +00:00
|
|
|
return !keys.HasFilter || keys.IsInRange(ManiaBeatmapConverter.GetColumnCount(LegacyBeatmapConversionDifficultyInfo.FromBeatmapInfo(beatmapInfo), criteria.Mods));
|
2021-03-30 07:07:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public bool TryParseCustomKeywordCriteria(string key, Operator op, string value)
|
|
|
|
{
|
|
|
|
switch (key)
|
|
|
|
{
|
|
|
|
case "key":
|
|
|
|
case "keys":
|
|
|
|
return FilterQueryParser.TryUpdateCriteriaRange(ref keys, op, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2024-04-15 12:07:36 +00:00
|
|
|
|
|
|
|
public bool FilterMayChangeFromMods(ValueChangedEvent<IReadOnlyList<Mod>> mods)
|
|
|
|
{
|
|
|
|
if (keys.HasFilter)
|
|
|
|
{
|
|
|
|
// Interpreting as the Mod type is required for equality comparison.
|
|
|
|
HashSet<Mod> oldSet = mods.OldValue.OfType<ManiaKeyMod>().AsEnumerable<Mod>().ToHashSet();
|
|
|
|
HashSet<Mod> newSet = mods.NewValue.OfType<ManiaKeyMod>().AsEnumerable<Mod>().ToHashSet();
|
|
|
|
|
|
|
|
if (!oldSet.SetEquals(newSet))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2021-03-30 07:07:04 +00:00
|
|
|
}
|
|
|
|
}
|