From 6baaef432f086209c163b52d5393d3d32ce62e7c Mon Sep 17 00:00:00 2001 From: solstice23 Date: Thu, 21 Jul 2022 18:49:13 +0800 Subject: [PATCH] Add colon parsing support in search length criteria --- osu.Game/Screens/Select/FilterQueryParser.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/osu.Game/Screens/Select/FilterQueryParser.cs b/osu.Game/Screens/Select/FilterQueryParser.cs index 436beae30d..ee7a1617cd 100644 --- a/osu.Game/Screens/Select/FilterQueryParser.cs +++ b/osu.Game/Screens/Select/FilterQueryParser.cs @@ -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); } }