2023-05-08 18:38:53 +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 System.Collections.Generic;
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
using osu.Game.Audio;
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|
|
|
{
|
|
|
|
public partial class NodeSamplePointPiece : SamplePointPiece
|
|
|
|
{
|
|
|
|
public readonly int NodeIndex;
|
|
|
|
|
|
|
|
public NodeSamplePointPiece(HitObject hitObject, int nodeIndex)
|
|
|
|
: base(hitObject)
|
|
|
|
{
|
|
|
|
if (hitObject is not IHasRepeats)
|
|
|
|
throw new System.ArgumentException($"HitObject must implement {nameof(IHasRepeats)}", nameof(hitObject));
|
|
|
|
|
|
|
|
NodeIndex = nodeIndex;
|
|
|
|
}
|
|
|
|
|
2024-07-05 20:16:51 +08:00
|
|
|
protected override double GetTime()
|
2024-07-04 17:47:45 +08:00
|
|
|
{
|
|
|
|
var hasRepeats = (IHasRepeats)HitObject;
|
2024-07-05 20:16:51 +08:00
|
|
|
return HitObject.StartTime + hasRepeats.Duration * NodeIndex / hasRepeats.SpanCount();
|
2024-07-04 17:47:45 +08:00
|
|
|
}
|
|
|
|
|
2023-05-08 18:38:53 +08:00
|
|
|
protected override IList<HitSampleInfo> GetSamples()
|
|
|
|
{
|
|
|
|
var hasRepeats = (IHasRepeats)HitObject;
|
|
|
|
return NodeIndex < hasRepeats.NodeSamples.Count ? hasRepeats.NodeSamples[NodeIndex] : HitObject.Samples;
|
|
|
|
}
|
|
|
|
|
2023-05-08 19:05:53 +08:00
|
|
|
public override Popover GetPopover() => new NodeSampleEditPopover(HitObject, NodeIndex);
|
2023-05-08 18:38:53 +08:00
|
|
|
|
|
|
|
public partial class NodeSampleEditPopover : SampleEditPopover
|
|
|
|
{
|
|
|
|
private readonly int nodeIndex;
|
|
|
|
|
2024-07-23 20:34:48 +08:00
|
|
|
protected override IEnumerable<(HitObject hitObject, IList<HitSampleInfo> samples)> GetRelevantSamples(HitObject[] hitObjects)
|
2023-05-08 18:38:53 +08:00
|
|
|
{
|
2024-07-23 20:34:48 +08:00
|
|
|
if (hitObjects.Length > 1 || hitObjects[0] is not IHasRepeats hasRepeats)
|
|
|
|
return base.GetRelevantSamples(hitObjects);
|
2023-05-08 21:57:30 +08:00
|
|
|
|
2024-07-23 20:34:48 +08:00
|
|
|
return [(hitObjects[0], nodeIndex < hasRepeats.NodeSamples.Count ? hasRepeats.NodeSamples[nodeIndex] : hitObjects[0].Samples)];
|
2023-05-08 18:38:53 +08:00
|
|
|
}
|
|
|
|
|
2023-05-08 19:05:53 +08:00
|
|
|
public NodeSampleEditPopover(HitObject hitObject, int nodeIndex)
|
2023-05-08 18:38:53 +08:00
|
|
|
: base(hitObject)
|
|
|
|
{
|
|
|
|
this.nodeIndex = nodeIndex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|