2019-01-24 16:43:03 +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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2020-09-30 17:34:13 +08:00
|
|
|
using System.Collections.Specialized;
|
2018-04-13 17:19:50 +08:00
|
|
|
using System.Linq;
|
2020-09-30 17:34:13 +08:00
|
|
|
using osu.Framework.Bindables;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// The part of the timeline that displays the control points.
|
|
|
|
/// </summary>
|
2020-09-30 17:34:13 +08:00
|
|
|
public class ControlPointPart : TimelinePart<GroupVisualisation>
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2020-11-04 14:29:14 +08:00
|
|
|
private readonly IBindableList<ControlPointGroup> controlPointGroups = new BindableList<ControlPointGroup>();
|
2020-09-30 17:34:13 +08:00
|
|
|
|
2021-01-25 17:43:36 +08:00
|
|
|
protected override void LoadBeatmap(EditorBeatmap beatmap)
|
2018-04-13 17:19:50 +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);
|
2020-09-30 17:34:13 +08:00
|
|
|
controlPointGroups.BindCollectionChanged((sender, args) =>
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2020-09-30 17:34:13 +08:00
|
|
|
switch (args.Action)
|
|
|
|
{
|
|
|
|
case NotifyCollectionChangedAction.Reset:
|
|
|
|
Clear();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NotifyCollectionChangedAction.Add:
|
|
|
|
foreach (var group in args.NewItems.OfType<ControlPointGroup>())
|
|
|
|
Add(new GroupVisualisation(group));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NotifyCollectionChangedAction.Remove:
|
|
|
|
foreach (var group in args.OldItems.OfType<ControlPointGroup>())
|
|
|
|
{
|
|
|
|
var matching = Children.SingleOrDefault(gv => gv.Group == group);
|
|
|
|
|
|
|
|
matching?.Expire();
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}, true);
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|