1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 06:52:56 +08:00

Apply NRT and fix code style

This commit is contained in:
Dean Herbert 2022-09-09 23:29:04 +09:00
parent d961b96897
commit 602ffebd54

View File

@ -1,8 +1,6 @@
// 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.
#nullable disable
using System;
using System.Collections.Generic;
using System.Globalization;
@ -126,16 +124,21 @@ namespace osu.Game.Screens.Select
{
if (Enum.TryParse(value, true, out result)) return true;
value = Enum.GetNames(typeof(TEnum)).FirstOrDefault(name => name.StartsWith(value, true, CultureInfo.InvariantCulture));
string? prefixMatch = Enum.GetNames(typeof(TEnum)).FirstOrDefault(name => name.StartsWith(value, true, CultureInfo.InvariantCulture));
if (prefixMatch == null)
return false;
return Enum.TryParse(value, true, out result);
}
private static GroupCollection tryMatchRegex(string value, string regex)
private static GroupCollection? tryMatchRegex(string value, string regex)
{
Match matchs = Regex.Match(value, regex);
if (matchs.Success)
{
return matchs.Groups;
}
Match matches = Regex.Match(value, regex);
if (matches.Success)
return matches.Groups;
return null;
}
@ -324,7 +327,8 @@ namespace osu.Game.Screens.Select
{
List<string> parts = new List<string>();
GroupCollection match = null;
GroupCollection? match = null;
match ??= tryMatchRegex(val, @"^((?<hours>\d+):)?(?<minutes>\d+):(?<seconds>\d+)$");
match ??= tryMatchRegex(val, @"^((?<hours>\d+(\.\d+)?)h)?((?<minutes>\d+(\.\d+)?)m)?((?<seconds>\d+(\.\d+)?)s)?$");
match ??= tryMatchRegex(val, @"^(?<seconds>\d+(\.\d+)?)$");
@ -358,6 +362,7 @@ namespace osu.Game.Screens.Select
totalLength += length * scale;
minScale = Math.Min(minScale, scale);
}
return tryUpdateCriteriaRange(ref criteria.Length, op, totalLength, minScale / 2.0);
}
}