mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 02:22:56 +08:00
Merge pull request #10304 from peppy/fix-control-point-bindable-updates
Fix control point timeline display not updating with changes
This commit is contained in:
commit
148e2769c8
@ -1,70 +1,50 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Collections.Specialized;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Graphics;
|
|
||||||
using osu.Game.Screens.Edit.Components.Timelines.Summary.Visualisations;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The part of the timeline that displays the control points.
|
/// The part of the timeline that displays the control points.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ControlPointPart : TimelinePart
|
public class ControlPointPart : TimelinePart<GroupVisualisation>
|
||||||
{
|
{
|
||||||
|
private IBindableList<ControlPointGroup> controlPointGroups;
|
||||||
|
|
||||||
protected override void LoadBeatmap(WorkingBeatmap beatmap)
|
protected override void LoadBeatmap(WorkingBeatmap beatmap)
|
||||||
{
|
{
|
||||||
base.LoadBeatmap(beatmap);
|
base.LoadBeatmap(beatmap);
|
||||||
|
|
||||||
ControlPointInfo cpi = beatmap.Beatmap.ControlPointInfo;
|
controlPointGroups = beatmap.Beatmap.ControlPointInfo.Groups.GetBoundCopy();
|
||||||
|
controlPointGroups.BindCollectionChanged((sender, args) =>
|
||||||
cpi.TimingPoints.ForEach(addTimingPoint);
|
|
||||||
|
|
||||||
// Consider all non-timing points as the same type
|
|
||||||
cpi.SamplePoints.Select(c => (ControlPoint)c)
|
|
||||||
.Concat(cpi.EffectPoints)
|
|
||||||
.Concat(cpi.DifficultyPoints)
|
|
||||||
.Distinct()
|
|
||||||
// Non-timing points should not be added where there are timing points
|
|
||||||
.Where(c => cpi.TimingPointAt(c.Time).Time != c.Time)
|
|
||||||
.ForEach(addNonTimingPoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addTimingPoint(ControlPoint controlPoint) => Add(new TimingPointVisualisation(controlPoint));
|
|
||||||
private void addNonTimingPoint(ControlPoint controlPoint) => Add(new NonTimingPointVisualisation(controlPoint));
|
|
||||||
|
|
||||||
private class TimingPointVisualisation : ControlPointVisualisation
|
|
||||||
{
|
|
||||||
public TimingPointVisualisation(ControlPoint controlPoint)
|
|
||||||
: base(controlPoint)
|
|
||||||
{
|
{
|
||||||
}
|
switch (args.Action)
|
||||||
|
{
|
||||||
|
case NotifyCollectionChangedAction.Reset:
|
||||||
|
Clear();
|
||||||
|
break;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
case NotifyCollectionChangedAction.Add:
|
||||||
private void load(OsuColour colours) => Colour = colours.YellowDark;
|
foreach (var group in args.NewItems.OfType<ControlPointGroup>())
|
||||||
}
|
Add(new GroupVisualisation(group));
|
||||||
|
break;
|
||||||
|
|
||||||
private class NonTimingPointVisualisation : ControlPointVisualisation
|
case NotifyCollectionChangedAction.Remove:
|
||||||
{
|
foreach (var group in args.OldItems.OfType<ControlPointGroup>())
|
||||||
public NonTimingPointVisualisation(ControlPoint controlPoint)
|
{
|
||||||
: base(controlPoint)
|
var matching = Children.SingleOrDefault(gv => gv.Group == group);
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
matching?.Expire();
|
||||||
private void load(OsuColour colours) => Colour = colours.Green;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private abstract class ControlPointVisualisation : PointVisualisation
|
break;
|
||||||
{
|
}
|
||||||
protected ControlPointVisualisation(ControlPoint controlPoint)
|
}, true);
|
||||||
: base(controlPoint.Time)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
// 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.Linq;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Screens.Edit.Components.Timelines.Summary.Visualisations;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
||||||
|
{
|
||||||
|
public class GroupVisualisation : PointVisualisation
|
||||||
|
{
|
||||||
|
public readonly ControlPointGroup Group;
|
||||||
|
|
||||||
|
private BindableList<ControlPoint> controlPoints;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuColour colours { get; set; }
|
||||||
|
|
||||||
|
public GroupVisualisation(ControlPointGroup group)
|
||||||
|
: base(group.Time)
|
||||||
|
{
|
||||||
|
Group = group;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
controlPoints = (BindableList<ControlPoint>)Group.ControlPoints.GetBoundCopy();
|
||||||
|
controlPoints.BindCollectionChanged((_, __) =>
|
||||||
|
{
|
||||||
|
if (controlPoints.Count == 0)
|
||||||
|
{
|
||||||
|
Colour = Color4.Transparent;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Colour = controlPoints.Any(c => c is TimingControlPoint) ? colours.YellowDark : colours.Green;
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user