mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 07:33:20 +08:00
Add colon parsing support in search length criteria
This commit is contained in:
parent
a5a8fac66f
commit
6baaef432f
@ -312,9 +312,25 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
private static bool tryUpdateLengthRange(FilterCriteria criteria, Operator op, string val)
|
||||
{
|
||||
if (val.Contains(':'))
|
||||
{
|
||||
if (val.Contains('h') || val.Contains('m') || val.Contains('s'))
|
||||
return false;
|
||||
|
||||
int count = val.Count(c => c == ':');
|
||||
if (count > 3)
|
||||
return false;
|
||||
|
||||
if (count > 2)
|
||||
val = val.Replace(':', 'h');
|
||||
|
||||
val = val.Replace(':', 'm');
|
||||
}
|
||||
|
||||
string[] parts = Regex.Split(val, @"(?<=[msh])").Where(x => x.Length > 0).ToArray();
|
||||
double totalLength = 0;
|
||||
int minScale = 1000;
|
||||
|
||||
foreach (string part in parts)
|
||||
{
|
||||
if (!tryParseDoubleWithPoint(part.TrimEnd('m', 's', 'h'), out double length))
|
||||
@ -323,6 +339,7 @@ namespace osu.Game.Screens.Select
|
||||
totalLength += length * scale;
|
||||
minScale = Math.Min(minScale, scale);
|
||||
}
|
||||
|
||||
return tryUpdateCriteriaRange(ref criteria.Length, op, totalLength, minScale / 2.0);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user