Updated DrawableStoryboardSample to use GetBoundCopy()

This commit is contained in:
Mysfit 2021-01-21 17:46:47 -05:00
parent b220939650
commit 07ec0c0e0b
2 changed files with 22 additions and 12 deletions

View File

@ -18,6 +18,10 @@ namespace osu.Game.Skinning
protected bool RequestedPlaying { get; private set; }
protected IBindable<bool> SamplePlaybackDisabled => samplePlaybackDisabled;
private readonly Bindable<bool> samplePlaybackDisabled = new Bindable<bool>();
public PausableSkinnableSound()
{
}
@ -32,8 +36,6 @@ namespace osu.Game.Skinning
{
}
protected readonly IBindable<bool> SamplePlaybackDisabled = new Bindable<bool>();
private ScheduledDelegate scheduledStart;
[BackgroundDependencyLoader(true)]

View File

@ -21,11 +21,29 @@ namespace osu.Game.Storyboards.Drawables
public override bool RemoveWhenNotAlive => false;
private readonly IBindable<bool> samplePlaybackDisabled;
public DrawableStoryboardSample(StoryboardSampleInfo sampleInfo)
: base(sampleInfo)
{
this.sampleInfo = sampleInfo;
LifetimeStart = sampleInfo.StartTime;
samplePlaybackDisabled = SamplePlaybackDisabled.GetBoundCopy();
}
[BackgroundDependencyLoader(true)]
private void load()
{
samplePlaybackDisabled.BindValueChanged(disabled =>
{
if (!RequestedPlaying) return;
// Since storyboard samples can be very long we want to stop the playback regardless of
// whether or not the sample is looping or not
if (disabled.NewValue)
Stop();
});
}
[Resolved]
@ -40,16 +58,6 @@ namespace osu.Game.Storyboards.Drawables
foreach (var sample in DrawableSamples)
mod.ApplyToSample(sample);
}
SamplePlaybackDisabled.BindValueChanged(disabled =>
{
if (!RequestedPlaying) return;
// Since storyboard samples can be very long we want to stop the playback regardless of
// whether or not the sample is looping or not
if (disabled.NewValue)
Stop();
});
}
protected override void Update()