1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 04:02:59 +08:00

Fix ugly casts

This commit is contained in:
smoogipoo 2019-09-19 17:11:28 +09:00
parent 0915a94470
commit 167bb9fcc1

View File

@ -239,8 +239,36 @@ namespace osu.Game.Screens.Select
} }
} }
private void updateCriteriaRange<T>(ref FilterCriteria.OptionalRange<T> range, string op, T value, double tolerance = 0.05f) private void updateCriteriaRange(ref FilterCriteria.OptionalRange<float> range, string op, float value, float tolerance = 0.05f)
where T : struct, IComparable<T> {
switch (op)
{
case "=":
case ":":
range.Min = value - tolerance;
range.Max = value + tolerance;
break;
}
updateCriteriaRange(ref range, op, value);
}
private void updateCriteriaRange(ref FilterCriteria.OptionalRange<double> range, string op, double value, double tolerance = 0.05f)
{
switch (op)
{
case "=":
case ":":
range.Min = value - tolerance;
range.Max = value + tolerance;
break;
}
updateCriteriaRange(ref range, op, value);
}
private void updateCriteriaRange<T>(ref FilterCriteria.OptionalRange<T> range, string op, T value)
where T : struct, IComparable
{ {
switch (op) switch (op)
{ {
@ -250,20 +278,6 @@ namespace osu.Game.Screens.Select
case "=": case "=":
case ":": case ":":
range.IsInclusive = true; range.IsInclusive = true;
switch (value)
{
case float _:
range.Min = (T)(object)((float)(object)value - tolerance);
range.Max = (T)(object)((float)(object)value + tolerance);
break;
case double _:
range.Min = (T)(object)((double)(object)value - tolerance);
range.Max = (T)(object)((double)(object)value + tolerance);
break;
}
break; break;
case ">": case ">":