-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23443 from OliBomby/edit-nodesample
Make NodeSamples editable
- Loading branch information
Showing
12 changed files
with
547 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
osu.Game/Screens/Edit/Compose/Components/Timeline/NodeSamplePointPiece.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// 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; | ||
} | ||
|
||
protected override IList<HitSampleInfo> GetSamples() | ||
{ | ||
var hasRepeats = (IHasRepeats)HitObject; | ||
return NodeIndex < hasRepeats.NodeSamples.Count ? hasRepeats.NodeSamples[NodeIndex] : HitObject.Samples; | ||
} | ||
|
||
public override Popover GetPopover() => new NodeSampleEditPopover(HitObject, NodeIndex); | ||
|
||
public partial class NodeSampleEditPopover : SampleEditPopover | ||
{ | ||
private readonly int nodeIndex; | ||
|
||
protected override IList<HitSampleInfo> GetRelevantSamples(HitObject ho) | ||
{ | ||
if (ho is not IHasRepeats hasRepeats) | ||
return ho.Samples; | ||
|
||
return nodeIndex < hasRepeats.NodeSamples.Count ? hasRepeats.NodeSamples[nodeIndex] : ho.Samples; | ||
} | ||
|
||
public NodeSampleEditPopover(HitObject hitObject, int nodeIndex) | ||
: base(hitObject) | ||
{ | ||
this.nodeIndex = nodeIndex; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.