mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 09:57:21 +09:00
Enable filter parsing extensibility
This commit is contained in:
parent
5c566a9928
commit
26736d990f
@ -11,7 +11,7 @@ namespace osu.Game.Screens.Select
|
|||||||
internal static class FilterQueryParser
|
internal static class FilterQueryParser
|
||||||
{
|
{
|
||||||
private static readonly Regex query_syntax_regex = new Regex(
|
private static readonly Regex query_syntax_regex = new Regex(
|
||||||
@"\b(?<key>stars|ar|dr|hp|cs|divisor|length|objects|bpm|status|creator|artist)(?<op>[=:><]+)(?<value>("".*"")|(\S*))",
|
@"\b(?<key>\w+)(?<op>[=:><]+)(?<value>("".*"")|(\S*))",
|
||||||
RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
internal static void ApplyQueries(FilterCriteria criteria, string query)
|
internal static void ApplyQueries(FilterCriteria criteria, string query)
|
||||||
@ -22,15 +22,14 @@ namespace osu.Game.Screens.Select
|
|||||||
var op = match.Groups["op"].Value;
|
var op = match.Groups["op"].Value;
|
||||||
var value = match.Groups["value"].Value;
|
var value = match.Groups["value"].Value;
|
||||||
|
|
||||||
parseKeywordCriteria(criteria, key, value, op);
|
if (tryParseKeywordCriteria(criteria, key, value, op))
|
||||||
|
query = query.Replace(match.ToString(), "");
|
||||||
query = query.Replace(match.ToString(), "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
criteria.SearchText = query;
|
criteria.SearchText = query;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void parseKeywordCriteria(FilterCriteria criteria, string key, string value, string op)
|
private static bool tryParseKeywordCriteria(FilterCriteria criteria, string key, string value, string op)
|
||||||
{
|
{
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
@ -75,7 +74,12 @@ namespace osu.Game.Screens.Select
|
|||||||
case "artist":
|
case "artist":
|
||||||
updateCriteriaText(ref criteria.Artist, op, value);
|
updateCriteriaText(ref criteria.Artist, op, value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getLengthScale(string value) =>
|
private static int getLengthScale(string value) =>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user