1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-19 21:02:55 +08:00

Convert to switch statement

This commit is contained in:
Dean Herbert 2023-08-18 17:27:09 +09:00
parent 360f9750e1
commit 9023059bc0

View File

@ -146,18 +146,26 @@ namespace osu.Game.Screens.Edit.Timing
if (selectedGroup.Value == null) if (selectedGroup.Value == null)
trackedType = null; trackedType = null;
else else
{
switch (selectedGroup.Value.ControlPoints.Count)
{ {
// If the selected group has no control points, clear the tracked type. // If the selected group has no control points, clear the tracked type.
// Otherwise the user will be unable to select a group with no control points. // Otherwise the user will be unable to select a group with no control points.
if (selectedGroup.Value.ControlPoints.Count == 0) case 0:
trackedType = null; trackedType = null;
break;
// If the selected group only has one control point, update the tracking type. // If the selected group only has one control point, update the tracking type.
if (selectedGroup.Value.ControlPoints.Count == 1) case 1:
trackedType = selectedGroup.Value?.ControlPoints.Single().GetType(); trackedType = selectedGroup.Value?.ControlPoints.Single().GetType();
break;
// If the selected group has more than one control point, choose the first as the tracking type // If the selected group has more than one control point, choose the first as the tracking type
// if we don't already have a singular tracked type. // if we don't already have a singular tracked type.
else if (trackedType == null) default:
trackedType = selectedGroup.Value?.ControlPoints.FirstOrDefault()?.GetType(); trackedType ??= selectedGroup.Value?.ControlPoints.FirstOrDefault()?.GetType();
break;
}
} }
if (trackedType != null) if (trackedType != null)