Merge branch 'master' into dho-remove-onparentreceived

This commit is contained in:
Dean Herbert
2020-12-04 11:04:56 +09:00
committed by GitHub
29 changed files with 550 additions and 105 deletions

View File

@ -10,7 +10,6 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.TypeExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Logging;
using osu.Framework.Threading;
@ -156,8 +155,6 @@ namespace osu.Game.Rulesets.Objects.Drawables
[Resolved(CanBeNull = true)]
private IPooledHitObjectProvider pooledObjectProvider { get; set; }
private Container<PausableSkinnableSound> samplesContainer;
/// <summary>
/// Whether the initialization logic in <see cref="Playfield" /> has applied.
/// </summary>
@ -181,7 +178,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
config.BindWith(OsuSetting.PositionalHitSounds, userPositionalHitSounds);
// Explicit non-virtual function call.
base.AddInternal(samplesContainer = new Container<PausableSkinnableSound> { RelativeSizeAxes = Axes.Both });
base.AddInternal(Samples = new PausableSkinnableSound());
}
protected override void LoadAsyncComplete()
@ -305,6 +302,9 @@ namespace osu.Game.Rulesets.Objects.Drawables
// In order to stop this needless update, the event is unbound and re-bound as late as possible in Apply().
samplesBindable.CollectionChanged -= onSamplesChanged;
// Release the samples for other hitobjects to use.
Samples.Samples = null;
if (nestedHitObjects.IsValueCreated)
{
foreach (var obj in nestedHitObjects.Value)
@ -362,9 +362,6 @@ namespace osu.Game.Rulesets.Objects.Drawables
/// </summary>
protected virtual void LoadSamples()
{
samplesContainer.Clear();
Samples = null;
var samples = GetSamples().ToArray();
if (samples.Length <= 0)
@ -376,7 +373,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
+ $" This is an indication that {nameof(HitObject.ApplyDefaults)} has not been invoked on {this}.");
}
samplesContainer.Add(Samples = new PausableSkinnableSound(samples.Select(s => HitObject.SampleControlPoint.ApplyTo(s))));
Samples.Samples = samples.Select(s => HitObject.SampleControlPoint.ApplyTo(s)).Cast<ISampleInfo>().ToArray();
}
private void onSamplesChanged(object sender, NotifyCollectionChangedEventArgs e) => LoadSamples();