mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 12:17:26 +08:00
Merge pull request #11447 from bdach/fix-play-button-crashes
Fix track previews crashing on completion
This commit is contained in:
commit
2abeda5e0f
@ -38,7 +38,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels
|
|||||||
private Container content;
|
private Container content;
|
||||||
|
|
||||||
public PreviewTrack Preview => PlayButton.Preview;
|
public PreviewTrack Preview => PlayButton.Preview;
|
||||||
public Bindable<bool> PreviewPlaying => PlayButton?.Playing;
|
public IBindable<bool> PreviewPlaying => PlayButton?.Playing;
|
||||||
|
|
||||||
protected abstract PlayButton PlayButton { get; }
|
protected abstract PlayButton PlayButton { get; }
|
||||||
protected abstract Box PreviewBar { get; }
|
protected abstract Box PreviewBar { get; }
|
||||||
|
@ -18,7 +18,10 @@ namespace osu.Game.Overlays.BeatmapListing.Panels
|
|||||||
{
|
{
|
||||||
public class PlayButton : Container
|
public class PlayButton : Container
|
||||||
{
|
{
|
||||||
public readonly BindableBool Playing = new BindableBool();
|
public IBindable<bool> Playing => playing;
|
||||||
|
|
||||||
|
private readonly BindableBool playing = new BindableBool();
|
||||||
|
|
||||||
public PreviewTrack Preview { get; private set; }
|
public PreviewTrack Preview { get; private set; }
|
||||||
|
|
||||||
private BeatmapSetInfo beatmapSet;
|
private BeatmapSetInfo beatmapSet;
|
||||||
@ -36,7 +39,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels
|
|||||||
Preview?.Expire();
|
Preview?.Expire();
|
||||||
Preview = null;
|
Preview = null;
|
||||||
|
|
||||||
Playing.Value = false;
|
playing.Value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +85,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
Playing.ValueChanged += playingStateChanged;
|
playing.ValueChanged += playingStateChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
@ -96,7 +99,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels
|
|||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
protected override bool OnClick(ClickEvent e)
|
||||||
{
|
{
|
||||||
Playing.Toggle();
|
playing.Toggle();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +111,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels
|
|||||||
|
|
||||||
protected override void OnHoverLost(HoverLostEvent e)
|
protected override void OnHoverLost(HoverLostEvent e)
|
||||||
{
|
{
|
||||||
if (!Playing.Value)
|
if (!playing.Value)
|
||||||
icon.FadeColour(Color4.White, 120, Easing.InOutQuint);
|
icon.FadeColour(Color4.White, 120, Easing.InOutQuint);
|
||||||
base.OnHoverLost(e);
|
base.OnHoverLost(e);
|
||||||
}
|
}
|
||||||
@ -122,7 +125,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels
|
|||||||
{
|
{
|
||||||
if (BeatmapSet == null)
|
if (BeatmapSet == null)
|
||||||
{
|
{
|
||||||
Playing.Value = false;
|
playing.Value = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,10 +145,12 @@ namespace osu.Game.Overlays.BeatmapListing.Panels
|
|||||||
|
|
||||||
AddInternal(preview);
|
AddInternal(preview);
|
||||||
loading = false;
|
loading = false;
|
||||||
preview.Stopped += () => Playing.Value = false;
|
// make sure that the update of value of Playing (and the ensuing value change callbacks)
|
||||||
|
// are marshaled back to the update thread.
|
||||||
|
preview.Stopped += () => Schedule(() => playing.Value = false);
|
||||||
|
|
||||||
// user may have changed their mind.
|
// user may have changed their mind.
|
||||||
if (Playing.Value)
|
if (playing.Value)
|
||||||
attemptStart();
|
attemptStart();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -159,13 +164,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels
|
|||||||
private void attemptStart()
|
private void attemptStart()
|
||||||
{
|
{
|
||||||
if (Preview?.Start() != true)
|
if (Preview?.Start() != true)
|
||||||
Playing.Value = false;
|
playing.Value = false;
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
|
||||||
{
|
|
||||||
base.Dispose(isDisposing);
|
|
||||||
Playing.Value = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,13 +18,12 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
|
|||||||
{
|
{
|
||||||
public class PreviewButton : OsuClickableContainer
|
public class PreviewButton : OsuClickableContainer
|
||||||
{
|
{
|
||||||
private const float transition_duration = 500;
|
|
||||||
|
|
||||||
private readonly Box background, progress;
|
private readonly Box background, progress;
|
||||||
private readonly PlayButton playButton;
|
private readonly PlayButton playButton;
|
||||||
|
|
||||||
private PreviewTrack preview => playButton.Preview;
|
private PreviewTrack preview => playButton.Preview;
|
||||||
public Bindable<bool> Playing => playButton.Playing;
|
|
||||||
|
public IBindable<bool> Playing => playButton.Playing;
|
||||||
|
|
||||||
public BeatmapSetInfo BeatmapSet
|
public BeatmapSetInfo BeatmapSet
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user