1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 19:32:55 +08:00

Add ruleset interface for extending filter criteria

This commit is contained in:
Bartłomiej Dach 2021-03-02 20:07:11 +01:00
parent e46543a4a9
commit 14e249a134
2 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1,44 @@
// 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.
using osu.Game.Beatmaps;
using osu.Game.Screens.Select;
using osu.Game.Screens.Select.Filter;
namespace osu.Game.Rulesets.Filter
{
/// <summary>
/// Allows for extending the beatmap filtering capabilities of song select (as implemented in <see cref="FilterCriteria"/>)
/// with ruleset-specific criteria.
/// </summary>
public interface IRulesetFilterCriteria
{
/// <summary>
/// Checks whether the supplied <paramref name="beatmap"/> satisfies ruleset-specific custom criteria,
/// in addition to the ones mandated by song select.
/// </summary>
/// <param name="beatmap">The beatmap to test the criteria against.</param>
/// <returns>
/// <c>true</c> if the beatmap matches the ruleset-specific custom filtering criteria,
/// <c>false</c> otherwise.
/// </returns>
bool Matches(BeatmapInfo beatmap);
/// <summary>
/// Attempts to parse a single custom keyword criterion, given by the user via the song select search box.
/// The format of the criterion is:
/// <code>
/// {key}{op}{value}
/// </code>
/// </summary>
/// <param name="key">The key (name) of the criterion.</param>
/// <param name="op">The operator in the criterion.</param>
/// <param name="value">The value of the criterion.</param>
/// <returns>
/// <c>true</c> if the keyword criterion is valid, <c>false</c> if it has been ignored.
/// Valid criteria are stripped from <see cref="FilterCriteria.SearchText"/>,
/// while ignored criteria are included in <see cref="FilterCriteria.SearchText"/>.
/// </returns>
bool TryParseCustomKeywordCriteria(string key, Operator op, string value);
}
}

View File

@ -26,6 +26,7 @@ using JetBrains.Annotations;
using osu.Framework.Extensions;
using osu.Framework.Extensions.EnumExtensions;
using osu.Framework.Testing;
using osu.Game.Rulesets.Filter;
using osu.Game.Screens.Ranking.Statistics;
namespace osu.Game.Rulesets
@ -306,5 +307,11 @@ namespace osu.Game.Rulesets
/// <param name="result">The result type to get the name for.</param>
/// <returns>The display name.</returns>
public virtual string GetDisplayNameForHitResult(HitResult result) => result.GetDescription();
/// <summary>
/// Creates ruleset-specific beatmap filter criteria to be used on the song select screen.
/// </summary>
[CanBeNull]
public virtual IRulesetFilterCriteria CreateRulesetFilterCriteria() => null;
}
}