1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 00:13:19 +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

@ -147,17 +147,25 @@ namespace osu.Game.Screens.Edit.Timing
trackedType = null;
else
{
// 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.
if (selectedGroup.Value.ControlPoints.Count == 0)
trackedType = null;
// If the selected group only has one control point, update the tracking type.
if (selectedGroup.Value.ControlPoints.Count == 1)
trackedType = selectedGroup.Value?.ControlPoints.Single().GetType();
// 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.
else if (trackedType == null)
trackedType = selectedGroup.Value?.ControlPoints.FirstOrDefault()?.GetType();
switch (selectedGroup.Value.ControlPoints.Count)
{
// 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.
case 0:
trackedType = null;
break;
// If the selected group only has one control point, update the tracking type.
case 1:
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 we don't already have a singular tracked type.
default:
trackedType ??= selectedGroup.Value?.ControlPoints.FirstOrDefault()?.GetType();
break;
}
}
if (trackedType != null)