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.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2024-07-12 13:18:41 +08:00
|
|
|
using osu.Framework.Graphics.Cursor;
|
2024-07-08 18:41:23 +08:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
2024-07-12 13:18:41 +08:00
|
|
|
using osu.Framework.Localisation;
|
2021-04-15 17:42:30 +08:00
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2024-07-12 13:18:41 +08:00
|
|
|
using osu.Game.Extensions;
|
2021-04-15 17:42:30 +08:00
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2024-07-12 13:18:41 +08:00
|
|
|
AddInternal(new KiaiVisualisation(effect.Time, nextControlPoint.Time)
|
2022-07-29 17:52:50 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2024-07-08 18:41:23 +08:00
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
2024-07-12 12:57:36 +08:00
|
|
|
Height = 0.4f,
|
2022-07-29 17:52:50 +08:00
|
|
|
Depth = float.MaxValue,
|
2024-07-12 12:57:36 +08:00
|
|
|
Colour = effect.GetRepresentingColour(colours),
|
2022-07-29 17:52:50 +08:00
|
|
|
});
|
|
|
|
}
|
2021-04-15 17:42:30 +08:00
|
|
|
}
|
2022-01-14 15:29:26 +08:00
|
|
|
|
2024-07-12 13:18:41 +08:00
|
|
|
private partial class KiaiVisualisation : Circle, IHasTooltip
|
|
|
|
{
|
|
|
|
private readonly double startTime;
|
|
|
|
private readonly double endTime;
|
|
|
|
|
|
|
|
public KiaiVisualisation(double startTime, double endTime)
|
|
|
|
{
|
|
|
|
this.startTime = startTime;
|
|
|
|
this.endTime = endTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
public LocalisableString TooltipText => $"{startTime.ToEditorFormattedString()} - {endTime.ToEditorFormattedString()} kiai time";
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|