mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 12:25:04 +08:00
Handle changes via SamplePoints list for simplicity
This commit is contained in:
parent
bfa6ae1b66
commit
3adf451e82
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -21,7 +22,7 @@ namespace osu.Game.Rulesets.Taiko.Audio
|
|||||||
private readonly ControlPointInfo controlPoints;
|
private readonly ControlPointInfo controlPoints;
|
||||||
private readonly Dictionary<double, DrumSample> mappings = new Dictionary<double, DrumSample>();
|
private readonly Dictionary<double, DrumSample> mappings = new Dictionary<double, DrumSample>();
|
||||||
|
|
||||||
private IBindableList<ControlPointGroup> groups;
|
private IBindableList<SampleControlPoint> samplePoints;
|
||||||
|
|
||||||
public DrumSampleContainer(ControlPointInfo controlPoints)
|
public DrumSampleContainer(ControlPointInfo controlPoints)
|
||||||
{
|
{
|
||||||
@ -31,8 +32,8 @@ namespace osu.Game.Rulesets.Taiko.Audio
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
groups = controlPoints.Groups.GetBoundCopy();
|
samplePoints = controlPoints.SamplePoints.GetBoundCopy();
|
||||||
groups.BindCollectionChanged((_, __) => recreateMappings(), true);
|
samplePoints.BindCollectionChanged((_, __) => recreateMappings(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void recreateMappings()
|
private void recreateMappings()
|
||||||
@ -40,14 +41,16 @@ namespace osu.Game.Rulesets.Taiko.Audio
|
|||||||
mappings.Clear();
|
mappings.Clear();
|
||||||
ClearInternal();
|
ClearInternal();
|
||||||
|
|
||||||
IReadOnlyList<SampleControlPoint> samplePoints = controlPoints.SamplePoints.Count == 0 ? new[] { controlPoints.SamplePointAt(double.MinValue) } : controlPoints.SamplePoints;
|
SampleControlPoint[] points = samplePoints.Count == 0
|
||||||
|
? new[] { controlPoints.SamplePointAt(double.MinValue) }
|
||||||
|
: samplePoints.ToArray();
|
||||||
|
|
||||||
for (int i = 0; i < samplePoints.Count; i++)
|
for (int i = 0; i < points.Length; i++)
|
||||||
{
|
{
|
||||||
var samplePoint = samplePoints[i];
|
var samplePoint = points[i];
|
||||||
|
|
||||||
var lifetimeStart = i > 0 ? samplePoint.Time : double.MinValue;
|
var lifetimeStart = i > 0 ? samplePoint.Time : double.MinValue;
|
||||||
var lifetimeEnd = i + 1 < samplePoints.Count ? samplePoints[i + 1].Time : double.MaxValue;
|
var lifetimeEnd = i + 1 < points.Length ? points[i + 1].Time : double.MaxValue;
|
||||||
|
|
||||||
AddInternal(mappings[samplePoint.Time] = new DrumSample(samplePoint)
|
AddInternal(mappings[samplePoint.Time] = new DrumSample(samplePoint)
|
||||||
{
|
{
|
||||||
|
@ -41,9 +41,9 @@ namespace osu.Game.Beatmaps.ControlPoints
|
|||||||
/// All sound points.
|
/// All sound points.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty]
|
[JsonProperty]
|
||||||
public IReadOnlyList<SampleControlPoint> SamplePoints => samplePoints;
|
public IBindableList<SampleControlPoint> SamplePoints => samplePoints;
|
||||||
|
|
||||||
private readonly SortedList<SampleControlPoint> samplePoints = new SortedList<SampleControlPoint>(Comparer<SampleControlPoint>.Default);
|
private readonly BindableList<SampleControlPoint> samplePoints = new BindableList<SampleControlPoint>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// All effect points.
|
/// All effect points.
|
||||||
|
Loading…
Reference in New Issue
Block a user