1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 09:07:25 +08:00

Invert if to reduce nesting

This commit is contained in:
Bartłomiej Dach 2020-05-25 20:18:17 +02:00
parent 719da48922
commit ca68d94cf7

View File

@ -226,25 +226,25 @@ namespace osu.Game.Tournament.Screens
base.Action = () =>
{
if (numberBox.Text.Length > 0)
if (string.IsNullOrEmpty(numberBox.Text))
return;
// box contains text
if (!int.TryParse(numberBox.Text, out var number))
{
// box contains text
if (!int.TryParse(numberBox.Text, out var number))
{
// at this point, the only reason we can arrive here is if the input number was too big to parse into an int
// so clamp to max allowed value
number = height_max_allowed_value;
}
else
{
number = Math.Clamp(number, height_min_allowed_value, height_max_allowed_value);
}
// in case number got clamped, reset number in numberBox
numberBox.Text = number.ToString();
Action?.Invoke(number);
// at this point, the only reason we can arrive here is if the input number was too big to parse into an int
// so clamp to max allowed value
number = height_max_allowed_value;
}
else
{
number = Math.Clamp(number, height_min_allowed_value, height_max_allowed_value);
}
// in case number got clamped, reset number in numberBox
numberBox.Text = number.ToString();
Action?.Invoke(number);
};
return drawable;
}