mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Separate out timeline control point display from summary timeline display
This commit is contained in:
@ -0,0 +1,57 @@
|
||||
// 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.
|
||||
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps;
|
||||
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 class TimelineControlPointDisplay : TimelinePart<TimelineControlPointGroup>
|
||||
{
|
||||
private IBindableList<ControlPointGroup> controlPointGroups;
|
||||
|
||||
public TimelineControlPointDisplay()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
protected override void LoadBeatmap(WorkingBeatmap beatmap)
|
||||
{
|
||||
base.LoadBeatmap(beatmap);
|
||||
|
||||
controlPointGroups = beatmap.Beatmap.ControlPointInfo.Groups.GetBoundCopy();
|
||||
controlPointGroups.BindCollectionChanged((sender, args) =>
|
||||
{
|
||||
switch (args.Action)
|
||||
{
|
||||
case NotifyCollectionChangedAction.Reset:
|
||||
Clear();
|
||||
break;
|
||||
|
||||
case NotifyCollectionChangedAction.Add:
|
||||
foreach (var group in args.NewItems.OfType<ControlPointGroup>())
|
||||
Add(new TimelineControlPointGroup(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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user