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:
parent
e46543a4a9
commit
14e249a134
44
osu.Game/Rulesets/Filter/IRulesetFilterCriteria.cs
Normal file
44
osu.Game/Rulesets/Filter/IRulesetFilterCriteria.cs
Normal 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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user