1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 09:32:55 +08:00

Add multiple units support in search length criteria

This commit is contained in:
solstice23 2022-07-21 18:24:31 +08:00
parent 8f2287b968
commit a5a8fac66f
No known key found for this signature in database
GPG Key ID: 7E7F5973D9260C8A

View File

@ -312,11 +312,18 @@ namespace osu.Game.Screens.Select
private static bool tryUpdateLengthRange(FilterCriteria criteria, Operator op, string val)
{
if (!tryParseDoubleWithPoint(val.TrimEnd('m', 's', 'h'), out double length))
return false;
int scale = getLengthScale(val);
return tryUpdateCriteriaRange(ref criteria.Length, op, length * scale, scale / 2.0);
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))
return false;
int scale = getLengthScale(part);
totalLength += length * scale;
minScale = Math.Min(minScale, scale);
}
return tryUpdateCriteriaRange(ref criteria.Length, op, totalLength, minScale / 2.0);
}
}
}