2020-10-01 16:54:54 +08:00
|
|
|
// 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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2020-10-01 16:54:54 +08:00
|
|
|
using System.Collections.Specialized;
|
2022-12-16 17:16:26 +08:00
|
|
|
using System.Diagnostics;
|
2020-10-01 16:54:54 +08:00
|
|
|
using System.Linq;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
|
|
using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// The part of the timeline that displays the control points.
|
|
|
|
/// </summary>
|
|
|
|
public partial class TimelineControlPointDisplay : TimelinePart<TimelineControlPointGroup>
|
|
|
|
{
|
2020-11-04 14:29:14 +08:00
|
|
|
private readonly IBindableList<ControlPointGroup> controlPointGroups = new BindableList<ControlPointGroup>();
|
2020-10-01 16:54:54 +08:00
|
|
|
|
2021-01-25 17:43:36 +08:00
|
|
|
protected override void LoadBeatmap(EditorBeatmap beatmap)
|
2020-10-01 16:54:54 +08:00
|
|
|
{
|
|
|
|
base.LoadBeatmap(beatmap);
|
|
|
|
|
2020-11-08 03:59:41 +08:00
|
|
|
controlPointGroups.UnbindAll();
|
2021-01-25 17:43:36 +08:00
|
|
|
controlPointGroups.BindTo(beatmap.ControlPointInfo.Groups);
|
2022-06-24 20:25:23 +08:00
|
|
|
controlPointGroups.BindCollectionChanged((_, args) =>
|
2020-10-01 16:54:54 +08:00
|
|
|
{
|
|
|
|
switch (args.Action)
|
|
|
|
{
|
|
|
|
case NotifyCollectionChangedAction.Reset:
|
|
|
|
Clear();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NotifyCollectionChangedAction.Add:
|
2022-12-16 17:16:26 +08:00
|
|
|
Debug.Assert(args.NewItems != null);
|
|
|
|
|
2020-10-01 16:54:54 +08:00
|
|
|
foreach (var group in args.NewItems.OfType<ControlPointGroup>())
|
|
|
|
Add(new TimelineControlPointGroup(group));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NotifyCollectionChangedAction.Remove:
|
2022-12-16 17:16:26 +08:00
|
|
|
Debug.Assert(args.OldItems != null);
|
|
|
|
|
2020-10-01 16:54:54 +08:00
|
|
|
foreach (var group in args.OldItems.OfType<ControlPointGroup>())
|
|
|
|
{
|
2022-06-20 15:53:03 +08:00
|
|
|
var matching = Children.SingleOrDefault(gv => ReferenceEquals(gv.Group, group));
|
2020-10-01 16:54:54 +08:00
|
|
|
|
|
|
|
matching?.Expire();
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|