2021-04-15 17:42:30 +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.
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
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
|
|
|
|
{
|
2022-01-15 22:56:00 +08:00
|
|
|
public partial class EffectPointVisualisation : CompositeDrawable, IControlPointVisualisation
|
2021-04-15 17:42:30 +08:00
|
|
|
{
|
|
|
|
private readonly EffectControlPoint effect;
|
2022-07-29 22:26:38 +08:00
|
|
|
private Bindable<bool> kiai = null!;
|
2021-04-15 17:42:30 +08:00
|
|
|
|
|
|
|
[Resolved]
|
2022-07-29 22:26:38 +08:00
|
|
|
private EditorBeatmap beatmap { get; set; } = null!;
|
2021-04-15 17:42:30 +08:00
|
|
|
|
|
|
|
[Resolved]
|
2022-07-29 22:26:38 +08:00
|
|
|
private OsuColour colours { get; set; } = null!;
|
2021-04-15 17:42:30 +08:00
|
|
|
|
|
|
|
public EffectPointVisualisation(EffectControlPoint point)
|
|
|
|
{
|
|
|
|
RelativePositionAxes = Axes.Both;
|
|
|
|
RelativeSizeAxes = Axes.Y;
|
|
|
|
|
|
|
|
effect = point;
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
kiai = effect.KiaiModeBindable.GetBoundCopy();
|
2022-07-29 17:52:50 +08:00
|
|
|
kiai.BindValueChanged(_ => refreshDisplay(), true);
|
|
|
|
}
|
2021-04-15 17:42:30 +08:00
|
|
|
|
2022-07-29 22:26:38 +08:00
|
|
|
private EffectControlPoint? nextControlPoint;
|
2021-04-15 17:42:30 +08:00
|
|
|
|
2022-07-29 17:52:50 +08:00
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
2021-04-15 17:42:30 +08:00
|
|
|
|
2022-07-29 17:52:50 +08:00
|
|
|
// Due to the limitations of ControlPointInfo, it's impossible to know via event flow when the next kiai point has changed.
|
|
|
|
// This is due to the fact that an EffectPoint can be added to an existing group. We would need to bind to ItemAdded on *every*
|
|
|
|
// future group to track this.
|
|
|
|
//
|
|
|
|
// I foresee this being a potential performance issue on beatmaps with many control points, so let's limit how often we check
|
|
|
|
// for changes. ControlPointInfo needs a refactor to make this flow better, but it should do for now.
|
|
|
|
Scheduler.AddDelayed(() =>
|
|
|
|
{
|
2024-03-01 01:35:20 +08:00
|
|
|
EffectControlPoint? next = null;
|
|
|
|
|
|
|
|
for (int i = 0; i < beatmap.ControlPointInfo.EffectPoints.Count; i++)
|
|
|
|
{
|
|
|
|
var point = beatmap.ControlPointInfo.EffectPoints[i];
|
|
|
|
|
|
|
|
if (point.Time > effect.Time)
|
|
|
|
{
|
|
|
|
next = point;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-04-15 17:42:30 +08:00
|
|
|
|
2022-07-29 17:52:50 +08:00
|
|
|
if (!ReferenceEquals(nextControlPoint, next))
|
2021-04-15 17:42:30 +08:00
|
|
|
{
|
2022-07-29 17:52:50 +08:00
|
|
|
nextControlPoint = next;
|
|
|
|
refreshDisplay();
|
2021-04-15 17:42:30 +08:00
|
|
|
}
|
2022-07-29 17:52:50 +08:00
|
|
|
}, 100, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void refreshDisplay()
|
|
|
|
{
|
|
|
|
ClearInternal();
|
|
|
|
|
|
|
|
AddInternal(new ControlPointVisualisation(effect));
|
|
|
|
|
|
|
|
if (!kiai.Value)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// handle kiai duration
|
|
|
|
// eventually this will be simpler when we have control points with durations.
|
|
|
|
if (nextControlPoint != null)
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
Origin = Anchor.TopLeft;
|
|
|
|
|
|
|
|
Width = (float)(nextControlPoint.Time - effect.Time);
|
|
|
|
|
|
|
|
AddInternal(new PointVisualisation
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Origin = Anchor.TopLeft,
|
|
|
|
Width = 1,
|
|
|
|
Height = 0.25f,
|
|
|
|
Depth = float.MaxValue,
|
|
|
|
Colour = effect.GetRepresentingColour(colours).Darken(0.5f),
|
|
|
|
});
|
|
|
|
}
|
2021-04-15 17:42:30 +08:00
|
|
|
}
|
2022-01-14 15:29:26 +08:00
|
|
|
|
|
|
|
// kiai sections display duration, so are required to be visualised.
|
2022-01-16 21:04:29 +08:00
|
|
|
public bool IsVisuallyRedundant(ControlPoint other) => other is EffectControlPoint otherEffect && effect.KiaiMode == otherEffect.KiaiMode;
|
2021-04-15 17:42:30 +08:00
|
|
|
}
|
|
|
|
}
|