mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 22:22:54 +08:00
Add support for previewing tracks on spectator screen
This commit is contained in:
parent
aae59dc3cf
commit
b344a13734
@ -13,6 +13,7 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
|
using osu.Game.Audio;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
@ -35,7 +36,8 @@ using osuTK;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
{
|
{
|
||||||
public class Spectator : OsuScreen
|
[Cached(typeof(IPreviewTrackOwner))]
|
||||||
|
public class Spectator : OsuScreen, IPreviewTrackOwner
|
||||||
{
|
{
|
||||||
private readonly User targetUser;
|
private readonly User targetUser;
|
||||||
|
|
||||||
@ -62,6 +64,9 @@ namespace osu.Game.Screens.Play
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private RulesetStore rulesets { get; set; }
|
private RulesetStore rulesets { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private PreviewTrackManager previewTrackManager { get; set; }
|
||||||
|
|
||||||
private Score score;
|
private Score score;
|
||||||
|
|
||||||
private readonly object scoreLock = new object();
|
private readonly object scoreLock = new object();
|
||||||
@ -275,6 +280,7 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
watchButton.Enabled.Value = false;
|
watchButton.Enabled.Value = false;
|
||||||
beatmapPanelContainer.Clear();
|
beatmapPanelContainer.Clear();
|
||||||
|
previewTrackManager.StopAnyPlaying(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void attemptStart()
|
private void attemptStart()
|
||||||
@ -326,7 +332,6 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
if (state?.BeatmapID == null)
|
if (state?.BeatmapID == null)
|
||||||
{
|
{
|
||||||
beatmapPanelContainer.Clear();
|
|
||||||
onlineBeatmap = null;
|
onlineBeatmap = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -359,6 +364,12 @@ namespace osu.Game.Screens.Play
|
|||||||
beatmaps.Download(onlineBeatmap);
|
beatmaps.Download(onlineBeatmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool OnExiting(IScreen next)
|
||||||
|
{
|
||||||
|
previewTrackManager.StopAnyPlaying(this);
|
||||||
|
return base.OnExiting(next);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
Loading…
Reference in New Issue
Block a user