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);
}
}