2020-09-30 17:34:13 +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
|
|
|
|
|
2022-01-14 15:29:26 +08:00
|
|
|
using System.Linq;
|
2020-09-30 17:34:13 +08:00
|
|
|
using osu.Framework.Bindables;
|
2021-04-15 17:42:30 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2020-09-30 17:34:13 +08:00
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
|
|
|
{
|
2021-04-15 17:42:30 +08:00
|
|
|
public partial class GroupVisualisation : CompositeDrawable
|
2020-09-30 17:34:13 +08:00
|
|
|
{
|
|
|
|
public readonly ControlPointGroup Group;
|
|
|
|
|
2020-11-04 14:29:14 +08:00
|
|
|
private readonly IBindableList<ControlPoint> controlPoints = new BindableList<ControlPoint>();
|
2020-09-30 17:34:13 +08:00
|
|
|
|
|
|
|
public GroupVisualisation(ControlPointGroup group)
|
|
|
|
{
|
2021-04-15 17:42:30 +08:00
|
|
|
RelativePositionAxes = Axes.X;
|
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
Origin = Anchor.TopLeft;
|
|
|
|
|
2020-09-30 17:34:13 +08:00
|
|
|
Group = group;
|
2021-04-15 17:42:30 +08:00
|
|
|
X = (float)group.Time;
|
2020-09-30 17:34:13 +08:00
|
|
|
|
2022-01-14 15:29:26 +08:00
|
|
|
// Run in constructor so IsRedundant calls can work correctly.
|
2020-11-04 14:29:14 +08:00
|
|
|
controlPoints.BindTo(Group.ControlPoints);
|
2022-06-24 20:25:23 +08:00
|
|
|
controlPoints.BindCollectionChanged((_, _) =>
|
2020-09-30 17:34:13 +08:00
|
|
|
{
|
2021-04-15 17:42:30 +08:00
|
|
|
ClearInternal();
|
|
|
|
|
2020-09-30 17:34:13 +08:00
|
|
|
if (controlPoints.Count == 0)
|
|
|
|
return;
|
|
|
|
|
2021-04-15 17:42:30 +08:00
|
|
|
foreach (var point in Group.ControlPoints)
|
|
|
|
{
|
|
|
|
switch (point)
|
|
|
|
{
|
2022-06-24 20:25:23 +08:00
|
|
|
case TimingControlPoint:
|
2021-04-15 17:42:30 +08:00
|
|
|
AddInternal(new ControlPointVisualisation(point) { Y = 0, });
|
|
|
|
break;
|
|
|
|
|
2022-06-24 20:25:23 +08:00
|
|
|
case DifficultyControlPoint:
|
2021-04-15 17:42:30 +08:00
|
|
|
AddInternal(new ControlPointVisualisation(point) { Y = 0.25f, });
|
|
|
|
break;
|
|
|
|
|
2022-06-24 20:25:23 +08:00
|
|
|
case SampleControlPoint:
|
2021-04-15 17:42:30 +08:00
|
|
|
AddInternal(new ControlPointVisualisation(point) { Y = 0.5f, });
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EffectControlPoint effect:
|
|
|
|
AddInternal(new EffectPointVisualisation(effect) { Y = 0.75f });
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-09-30 17:34:13 +08:00
|
|
|
}, true);
|
|
|
|
}
|
2022-01-14 15:29:26 +08:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// For display purposes, check whether the proposed group is made redundant by this visualisation group.
|
|
|
|
/// </summary>
|
2022-01-15 22:55:11 +08:00
|
|
|
public bool IsVisuallyRedundant(ControlPointGroup other) =>
|
2022-01-19 13:56:44 +08:00
|
|
|
other.ControlPoints.All(c => InternalChildren.OfType<IControlPointVisualisation>().Any(c2 => c2.IsVisuallyRedundant(c)));
|
2020-09-30 17:34:13 +08:00
|
|
|
}
|
|
|
|
}
|