Make PreviewTrack.owner private

This commit is contained in:
Roman Kapustin 2018-06-02 22:06:45 +03:00
parent 5bb6757cbd
commit 9b69e1825d
4 changed files with 12 additions and 8 deletions

View File

@ -13,7 +13,7 @@ namespace osu.Game.Audio
public class PreviewTrack : Component
{
public Track Track { get; private set; }
public readonly OverlayContainer Owner;
private readonly OverlayContainer owner;
private readonly BeatmapSetInfo beatmapSetInfo;
@ -23,7 +23,7 @@ namespace osu.Game.Audio
public PreviewTrack(BeatmapSetInfo beatmapSetInfo, OverlayContainer owner)
{
this.beatmapSetInfo = beatmapSetInfo;
Owner = owner;
this.owner = owner;
}
[BackgroundDependencyLoader]
@ -38,8 +38,14 @@ namespace osu.Game.Audio
Started?.Invoke();
}
public void Stop()
/// <summary>
/// Stop preview playback
/// </summary>
/// <param name="source">An <see cref="OverlayContainer"/> which is probably the owner of this <see cref="PreviewTrack"/></param>
public void Stop(OverlayContainer source = null)
{
if (source != null && owner != source)
return;
Track.Stop();
Stopped?.Invoke();
}

View File

@ -127,8 +127,7 @@ namespace osu.Game.Overlays
protected override void PopOut()
{
base.PopOut();
if (previewTrackManager.CurrentTrack?.Owner == this)
previewTrackManager.CurrentTrack?.Stop();
previewTrackManager.CurrentTrack?.Stop(this);
FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.Out).OnComplete(_ => BeatmapSet = null);
}

View File

@ -302,8 +302,7 @@ namespace osu.Game.Overlays
protected override void PopOut()
{
if (previewTrackManager.CurrentTrack?.Owner == this)
previewTrackManager.CurrentTrack?.Stop();
previewTrackManager.CurrentTrack?.Stop(this);
base.PopOut();
}

View File

@ -73,7 +73,7 @@ namespace osu.Game.Overlays
protected override void PopOut()
{
base.PopOut();
previewTrackManager.CurrentTrack?.Stop();
previewTrackManager.CurrentTrack?.Stop(this);
FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.Out);
}