mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 08:32:57 +08:00
Make hitobject samples a bindable list
This commit is contained in:
parent
864b8db638
commit
6fc1be64c2
@ -126,7 +126,7 @@ namespace osu.Game.Rulesets.Catch.Objects
|
||||
|
||||
public double Distance => Path.Distance;
|
||||
|
||||
public List<List<HitSampleInfo>> NodeSamples { get; set; } = new List<List<HitSampleInfo>>();
|
||||
public List<IList<HitSampleInfo>> NodeSamples { get; set; } = new List<IList<HitSampleInfo>>();
|
||||
|
||||
public double? LegacyLastTickOffset { get; set; }
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
|
||||
/// </summary>
|
||||
/// <param name="time">The time to retrieve the sample info list from.</param>
|
||||
/// <returns></returns>
|
||||
private List<HitSampleInfo> sampleInfoListAt(double time)
|
||||
private IList<HitSampleInfo> sampleInfoListAt(double time)
|
||||
{
|
||||
var curveData = HitObject as IHasCurve;
|
||||
|
||||
|
@ -472,7 +472,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||
/// </summary>
|
||||
/// <param name="time">The time to retrieve the sample info list from.</param>
|
||||
/// <returns></returns>
|
||||
private List<HitSampleInfo> sampleInfoListAt(double time)
|
||||
private IList<HitSampleInfo> sampleInfoListAt(double time)
|
||||
{
|
||||
var curveData = HitObject as IHasCurve;
|
||||
|
||||
|
@ -275,7 +275,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
|
||||
private Drawable createCatmull(int repeats = 0)
|
||||
{
|
||||
var repeatSamples = new List<List<HitSampleInfo>>();
|
||||
var repeatSamples = new List<IList<HitSampleInfo>>();
|
||||
for (int i = 0; i < repeats; i++)
|
||||
repeatSamples.Add(new List<HitSampleInfo>());
|
||||
|
||||
@ -297,9 +297,9 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
return createDrawable(slider, 3, 1);
|
||||
}
|
||||
|
||||
private List<List<HitSampleInfo>> createEmptySamples(int repeats)
|
||||
private List<IList<HitSampleInfo>> createEmptySamples(int repeats)
|
||||
{
|
||||
var repeatSamples = new List<List<HitSampleInfo>>();
|
||||
var repeatSamples = new List<IList<HitSampleInfo>>();
|
||||
for (int i = 0; i < repeats; i++)
|
||||
repeatSamples.Add(new List<HitSampleInfo>());
|
||||
return repeatSamples;
|
||||
|
@ -70,7 +70,7 @@ namespace osu.Game.Rulesets.Osu.Objects
|
||||
/// </summary>
|
||||
internal float LazyTravelDistance;
|
||||
|
||||
public List<List<HitSampleInfo>> NodeSamples { get; set; } = new List<List<HitSampleInfo>>();
|
||||
public List<IList<HitSampleInfo>> NodeSamples { get; set; } = new List<IList<HitSampleInfo>>();
|
||||
|
||||
private int repeatCount;
|
||||
|
||||
@ -128,7 +128,7 @@ namespace osu.Game.Rulesets.Osu.Objects
|
||||
foreach (var e in
|
||||
SliderEventGenerator.Generate(StartTime, SpanDuration, Velocity, TickDistance, Path.Distance, this.SpanCount(), LegacyLastTickOffset))
|
||||
{
|
||||
var firstSample = Samples.Find(s => s.Name == HitSampleInfo.HIT_NORMAL)
|
||||
var firstSample = Samples.FirstOrDefault(s => s.Name == HitSampleInfo.HIT_NORMAL)
|
||||
?? Samples.FirstOrDefault(); // TODO: remove this when guaranteed sort is present for samples (https://github.com/ppy/osu/issues/1933)
|
||||
var sampleList = new List<HitSampleInfo>();
|
||||
|
||||
@ -203,7 +203,7 @@ namespace osu.Game.Rulesets.Osu.Objects
|
||||
TailCircle.Position = EndPosition;
|
||||
}
|
||||
|
||||
private List<HitSampleInfo> getNodeSamples(int nodeIndex) =>
|
||||
private IList<HitSampleInfo> getNodeSamples(int nodeIndex) =>
|
||||
nodeIndex < NodeSamples.Count ? NodeSamples[nodeIndex] : Samples;
|
||||
|
||||
public override Judgement CreateJudgement() => new OsuJudgement();
|
||||
|
@ -79,7 +79,7 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
|
||||
var curveData = obj as IHasCurve;
|
||||
|
||||
// Old osu! used hit sounding to determine various hit type information
|
||||
List<HitSampleInfo> samples = obj.Samples;
|
||||
IList<HitSampleInfo> samples = obj.Samples;
|
||||
|
||||
bool strong = samples.Any(s => s.Name == HitSampleInfo.HIT_FINISH);
|
||||
|
||||
@ -117,13 +117,13 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
|
||||
|
||||
if (!isForCurrentRuleset && tickSpacing > 0 && osuDuration < 2 * speedAdjustedBeatLength)
|
||||
{
|
||||
List<List<HitSampleInfo>> allSamples = curveData != null ? curveData.NodeSamples : new List<List<HitSampleInfo>>(new[] { samples });
|
||||
List<IList<HitSampleInfo>> allSamples = curveData != null ? curveData.NodeSamples : new List<IList<HitSampleInfo>>(new[] { samples });
|
||||
|
||||
int i = 0;
|
||||
|
||||
for (double j = obj.StartTime; j <= obj.StartTime + taikoDuration + tickSpacing / 8; j += tickSpacing)
|
||||
{
|
||||
List<HitSampleInfo> currentSamples = allSamples[i];
|
||||
IList<HitSampleInfo> currentSamples = allSamples[i];
|
||||
bool isRim = currentSamples.Any(s => s.Name == HitSampleInfo.HIT_CLAP || s.Name == HitSampleInfo.HIT_WHISTLE);
|
||||
strong = currentSamples.Any(s => s.Name == HitSampleInfo.HIT_FINISH);
|
||||
|
||||
|
@ -45,7 +45,7 @@ namespace osu.Game.Rulesets.Objects
|
||||
set => StartTimeBindable.Value = value;
|
||||
}
|
||||
|
||||
private List<HitSampleInfo> samples;
|
||||
public readonly BindableList<HitSampleInfo> SamplesBindable = new BindableList<HitSampleInfo>();
|
||||
|
||||
/// <summary>
|
||||
/// The samples to be played when this hit object is hit.
|
||||
@ -54,10 +54,14 @@ namespace osu.Game.Rulesets.Objects
|
||||
/// and can be treated as the default samples for the hit object.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public List<HitSampleInfo> Samples
|
||||
public IList<HitSampleInfo> Samples
|
||||
{
|
||||
get => samples ?? (samples = new List<HitSampleInfo>());
|
||||
set => samples = value;
|
||||
get => SamplesBindable;
|
||||
set
|
||||
{
|
||||
SamplesBindable.Clear();
|
||||
SamplesBindable.AddRange(value);
|
||||
}
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
|
@ -38,7 +38,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Catch
|
||||
}
|
||||
|
||||
protected override HitObject CreateSlider(Vector2 position, bool newCombo, int comboOffset, Vector2[] controlPoints, double? length, PathType pathType, int repeatCount,
|
||||
List<List<HitSampleInfo>> nodeSamples)
|
||||
List<IList<HitSampleInfo>> nodeSamples)
|
||||
{
|
||||
newCombo |= forceNewCombo;
|
||||
comboOffset += extraComboOffset;
|
||||
|
@ -181,7 +181,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
||||
}
|
||||
|
||||
// Generate the final per-node samples
|
||||
var nodeSamples = new List<List<HitSampleInfo>>(nodes);
|
||||
var nodeSamples = new List<IList<HitSampleInfo>>(nodes);
|
||||
for (int i = 0; i < nodes; i++)
|
||||
nodeSamples.Add(convertSoundType(nodeSoundTypes[i], nodeBankInfos[i]));
|
||||
|
||||
@ -279,7 +279,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
||||
/// <param name="nodeSamples">The samples to be played when the slider nodes are hit. This includes the head and tail of the slider.</param>
|
||||
/// <returns>The hit object.</returns>
|
||||
protected abstract HitObject CreateSlider(Vector2 position, bool newCombo, int comboOffset, Vector2[] controlPoints, double? length, PathType pathType, int repeatCount,
|
||||
List<List<HitSampleInfo>> nodeSamples);
|
||||
List<IList<HitSampleInfo>> nodeSamples);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a legacy Spinner-type hit object.
|
||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
||||
|
||||
public double Distance => Path.Distance;
|
||||
|
||||
public List<List<HitSampleInfo>> NodeSamples { get; set; }
|
||||
public List<IList<HitSampleInfo>> NodeSamples { get; set; }
|
||||
public int RepeatCount { get; set; }
|
||||
|
||||
public double EndTime => StartTime + this.SpanCount() * Distance / Velocity;
|
||||
|
@ -27,7 +27,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Mania
|
||||
}
|
||||
|
||||
protected override HitObject CreateSlider(Vector2 position, bool newCombo, int comboOffset, Vector2[] controlPoints, double? length, PathType pathType, int repeatCount,
|
||||
List<List<HitSampleInfo>> nodeSamples)
|
||||
List<IList<HitSampleInfo>> nodeSamples)
|
||||
{
|
||||
return new ConvertSlider
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Osu
|
||||
}
|
||||
|
||||
protected override HitObject CreateSlider(Vector2 position, bool newCombo, int comboOffset, Vector2[] controlPoints, double? length, PathType pathType, int repeatCount,
|
||||
List<List<HitSampleInfo>> nodeSamples)
|
||||
List<IList<HitSampleInfo>> nodeSamples)
|
||||
{
|
||||
newCombo |= forceNewCombo;
|
||||
comboOffset += extraComboOffset;
|
||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Taiko
|
||||
}
|
||||
|
||||
protected override HitObject CreateSlider(Vector2 position, bool newCombo, int comboOffset, Vector2[] controlPoints, double? length, PathType pathType, int repeatCount,
|
||||
List<List<HitSampleInfo>> nodeSamples)
|
||||
List<IList<HitSampleInfo>> nodeSamples)
|
||||
{
|
||||
return new ConvertSlider
|
||||
{
|
||||
|
@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Objects.Types
|
||||
/// n-1: The last repeat.<br />
|
||||
/// n: The last node.
|
||||
/// </summary>
|
||||
List<List<HitSampleInfo>> NodeSamples { get; }
|
||||
List<IList<HitSampleInfo>> NodeSamples { get; }
|
||||
}
|
||||
|
||||
public static class HasRepeatsExtensions
|
||||
|
@ -222,7 +222,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
case ThreeStates.Disabled:
|
||||
foreach (var h in SelectedHitObjects)
|
||||
h.Samples.RemoveAll(s => s.Name == sampleName);
|
||||
h.SamplesBindable.RemoveAll(s => s.Name == sampleName);
|
||||
|
||||
break;
|
||||
|
||||
case ThreeStates.Enabled:
|
||||
|
Loading…
Reference in New Issue
Block a user