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-01-14 15:29:26 +08:00
|
|
|
using System.Linq;
|
2024-08-31 12:14:56 +08:00
|
|
|
using osu.Framework.Allocation;
|
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
|
|
|
|
2024-08-31 12:14:56 +08:00
|
|
|
private bool showScrollSpeed;
|
|
|
|
|
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;
|
2024-08-31 12:14:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(EditorBeatmap beatmap)
|
|
|
|
{
|
|
|
|
showScrollSpeed = beatmap.BeatmapInfo.Ruleset.CreateInstance().EditorShowScrollSpeed;
|
2020-09-30 17:34:13 +08:00
|
|
|
|
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:
|
2024-07-12 12:57:36 +08:00
|
|
|
AddInternal(new ControlPointVisualisation(point)
|
|
|
|
{
|
2024-07-16 17:32:54 +08:00
|
|
|
// importantly, override the x position being set since we do that above.
|
|
|
|
X = 0,
|
2024-07-12 12:57:36 +08:00
|
|
|
Y = -0.4f,
|
|
|
|
});
|
2021-04-15 17:42:30 +08:00
|
|
|
break;
|
|
|
|
|
2024-08-31 12:14:56 +08:00
|
|
|
case EffectControlPoint:
|
|
|
|
if (!showScrollSpeed)
|
|
|
|
return;
|
|
|
|
|
|
|
|
AddInternal(new ControlPointVisualisation(point)
|
|
|
|
{
|
|
|
|
// importantly, override the x position being set since we do that above.
|
|
|
|
X = 0,
|
|
|
|
});
|
2021-04-15 17:42:30 +08:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|