mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 12:42:54 +08:00
Merge pull request #2469 from UselessToucan/multiple_previews_different_overlays
Centralise preview track handling
This commit is contained in:
commit
2801c18845
127
osu.Game.Tests/Visual/TestCasePreviewTrackManager.cs
Normal file
127
osu.Game.Tests/Visual/TestCasePreviewTrackManager.cs
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Audio.Track;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Game.Audio;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual
|
||||||
|
{
|
||||||
|
public class TestCasePreviewTrackManager : OsuTestCase, IPreviewTrackOwner
|
||||||
|
{
|
||||||
|
private readonly PreviewTrackManager trackManager = new TestPreviewTrackManager();
|
||||||
|
|
||||||
|
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent)
|
||||||
|
{
|
||||||
|
var dependencies = new DependencyContainer(base.CreateLocalDependencies(parent));
|
||||||
|
dependencies.CacheAs(trackManager);
|
||||||
|
dependencies.CacheAs<IPreviewTrackOwner>(this);
|
||||||
|
return dependencies;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
AddInternal(trackManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestStartStop()
|
||||||
|
{
|
||||||
|
PreviewTrack track = null;
|
||||||
|
|
||||||
|
AddStep("get track", () => track = getOwnedTrack());
|
||||||
|
AddStep("start", () => track.Start());
|
||||||
|
AddAssert("started", () => track.IsRunning);
|
||||||
|
AddStep("stop", () => track.Stop());
|
||||||
|
AddAssert("stopped", () => !track.IsRunning);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestStartMultipleTracks()
|
||||||
|
{
|
||||||
|
PreviewTrack track1 = null;
|
||||||
|
PreviewTrack track2 = null;
|
||||||
|
|
||||||
|
AddStep("get tracks", () =>
|
||||||
|
{
|
||||||
|
track1 = getOwnedTrack();
|
||||||
|
track2 = getOwnedTrack();
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("start track 1", () => track1.Start());
|
||||||
|
AddStep("start track 2", () => track2.Start());
|
||||||
|
AddAssert("track 1 stopped", () => !track1.IsRunning);
|
||||||
|
AddAssert("track 2 started", () => track2.IsRunning);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestCancelFromOwner()
|
||||||
|
{
|
||||||
|
PreviewTrack track = null;
|
||||||
|
|
||||||
|
AddStep("get track", () => track = getOwnedTrack());
|
||||||
|
AddStep("start", () => track.Start());
|
||||||
|
AddStep("stop by owner", () => trackManager.StopAnyPlaying(this));
|
||||||
|
AddAssert("stopped", () => !track.IsRunning);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestCancelFromNonOwner()
|
||||||
|
{
|
||||||
|
TestTrackOwner owner = null;
|
||||||
|
PreviewTrack track = null;
|
||||||
|
|
||||||
|
AddStep("get track", () => AddInternal(owner = new TestTrackOwner(track = getTrack())));
|
||||||
|
AddStep("start", () => track.Start());
|
||||||
|
AddStep("attempt stop", () => trackManager.StopAnyPlaying(this));
|
||||||
|
AddAssert("not stopped", () => track.IsRunning);
|
||||||
|
AddStep("stop by true owner", () => trackManager.StopAnyPlaying(owner));
|
||||||
|
AddAssert("stopped", () => !track.IsRunning);
|
||||||
|
}
|
||||||
|
|
||||||
|
private PreviewTrack getTrack() => trackManager.Get(null);
|
||||||
|
|
||||||
|
private PreviewTrack getOwnedTrack()
|
||||||
|
{
|
||||||
|
var track = getTrack();
|
||||||
|
|
||||||
|
AddInternal(track);
|
||||||
|
|
||||||
|
return track;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestTrackOwner : CompositeDrawable, IPreviewTrackOwner
|
||||||
|
{
|
||||||
|
public TestTrackOwner(PreviewTrack track)
|
||||||
|
{
|
||||||
|
AddInternal(track);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent)
|
||||||
|
{
|
||||||
|
var dependencies = new DependencyContainer(base.CreateLocalDependencies(parent));
|
||||||
|
dependencies.CacheAs<IPreviewTrackOwner>(this);
|
||||||
|
return dependencies;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestPreviewTrackManager : PreviewTrackManager
|
||||||
|
{
|
||||||
|
protected override TrackManagerPreviewTrack CreatePreviewTrack(BeatmapSetInfo beatmapSetInfo, TrackManager trackManager) => new TestPreviewTrack(beatmapSetInfo, trackManager);
|
||||||
|
|
||||||
|
protected class TestPreviewTrack : TrackManagerPreviewTrack
|
||||||
|
{
|
||||||
|
public TestPreviewTrack(BeatmapSetInfo beatmapSetInfo, TrackManager trackManager)
|
||||||
|
: base(beatmapSetInfo, trackManager)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Track GetTrack() => new TrackVirtual { Length = 100000 };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
16
osu.Game/Audio/IPreviewTrackOwner.cs
Normal file
16
osu.Game/Audio/IPreviewTrackOwner.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
namespace osu.Game.Audio
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interface for objects that can own <see cref="IPreviewTrack"/>s.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// <see cref="IPreviewTrackOwner"/>s can cancel the currently playing <see cref="PreviewTrack"/> through the
|
||||||
|
/// global <see cref="PreviewTrackManager"/> if they're the owner of the playing <see cref="PreviewTrack"/>.
|
||||||
|
/// </remarks>
|
||||||
|
public interface IPreviewTrackOwner
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
103
osu.Game/Audio/PreviewTrack.cs
Normal file
103
osu.Game/Audio/PreviewTrack.cs
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Audio.Track;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Threading;
|
||||||
|
|
||||||
|
namespace osu.Game.Audio
|
||||||
|
{
|
||||||
|
public abstract class PreviewTrack : Component
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked when this <see cref="PreviewTrack"/> has stopped playing.
|
||||||
|
/// </summary>
|
||||||
|
public event Action Stopped;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked when this <see cref="PreviewTrack"/> has started playing.
|
||||||
|
/// </summary>
|
||||||
|
public event Action Started;
|
||||||
|
|
||||||
|
private Track track;
|
||||||
|
private bool hasStarted;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
track = GetTrack();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Length of the track.
|
||||||
|
/// </summary>
|
||||||
|
public double Length => track?.Length ?? 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The current track time.
|
||||||
|
/// </summary>
|
||||||
|
public double CurrentTime => track?.CurrentTime ?? 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the track is loaded.
|
||||||
|
/// </summary>
|
||||||
|
public bool TrackLoaded => track?.IsLoaded ?? false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the track is playing.
|
||||||
|
/// </summary>
|
||||||
|
public bool IsRunning => track?.IsRunning ?? false;
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
// Todo: Track currently doesn't signal its completion, so we have to handle it manually
|
||||||
|
if (hasStarted && track.HasCompleted)
|
||||||
|
Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ScheduledDelegate startDelegate;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Starts playing this <see cref="PreviewTrack"/>.
|
||||||
|
/// </summary>
|
||||||
|
public void Start() => startDelegate = Schedule(() =>
|
||||||
|
{
|
||||||
|
if (track == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (hasStarted)
|
||||||
|
return;
|
||||||
|
hasStarted = true;
|
||||||
|
|
||||||
|
track.Restart();
|
||||||
|
Started?.Invoke();
|
||||||
|
});
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stops playing this <see cref="PreviewTrack"/>.
|
||||||
|
/// </summary>
|
||||||
|
public void Stop()
|
||||||
|
{
|
||||||
|
startDelegate?.Cancel();
|
||||||
|
|
||||||
|
if (track == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!hasStarted)
|
||||||
|
return;
|
||||||
|
hasStarted = false;
|
||||||
|
|
||||||
|
track.Stop();
|
||||||
|
Stopped?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the audio track.
|
||||||
|
/// </summary>
|
||||||
|
protected abstract Track GetTrack();
|
||||||
|
}
|
||||||
|
}
|
107
osu.Game/Audio/PreviewTrackManager.cs
Normal file
107
osu.Game/Audio/PreviewTrackManager.cs
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Audio;
|
||||||
|
using osu.Framework.Audio.Track;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.IO.Stores;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
|
||||||
|
namespace osu.Game.Audio
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A central store for the retrieval of <see cref="PreviewTrack"/>s.
|
||||||
|
/// </summary>
|
||||||
|
public class PreviewTrackManager : Component
|
||||||
|
{
|
||||||
|
private readonly BindableDouble muteBindable = new BindableDouble();
|
||||||
|
|
||||||
|
private AudioManager audio;
|
||||||
|
private TrackManager trackManager;
|
||||||
|
|
||||||
|
private TrackManagerPreviewTrack current;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(AudioManager audio, FrameworkConfigManager config)
|
||||||
|
{
|
||||||
|
trackManager = new TrackManager(new OnlineStore());
|
||||||
|
|
||||||
|
this.audio = audio;
|
||||||
|
audio.AddItem(trackManager);
|
||||||
|
|
||||||
|
config.BindWith(FrameworkSetting.VolumeMusic, trackManager.Volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves a <see cref="PreviewTrack"/> for a <see cref="BeatmapSetInfo"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="beatmapSetInfo">The <see cref="BeatmapSetInfo"/> to retrieve the preview track for.</param>
|
||||||
|
/// <returns>The playable <see cref="PreviewTrack"/>.</returns>
|
||||||
|
public PreviewTrack Get(BeatmapSetInfo beatmapSetInfo)
|
||||||
|
{
|
||||||
|
var track = CreatePreviewTrack(beatmapSetInfo, trackManager);
|
||||||
|
|
||||||
|
track.Started += () =>
|
||||||
|
{
|
||||||
|
current?.Stop();
|
||||||
|
current = track;
|
||||||
|
audio.Track.AddAdjustment(AdjustableProperty.Volume, muteBindable);
|
||||||
|
};
|
||||||
|
|
||||||
|
track.Stopped += () =>
|
||||||
|
{
|
||||||
|
current = null;
|
||||||
|
audio.Track.RemoveAdjustment(AdjustableProperty.Volume, muteBindable);
|
||||||
|
};
|
||||||
|
|
||||||
|
return track;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stops any currently playing <see cref="PreviewTrack"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Only the immediate owner (an object that implements <see cref="IPreviewTrackOwner"/>) of the playing <see cref="PreviewTrack"/>
|
||||||
|
/// can globally stop the currently playing <see cref="PreviewTrack"/>. The object holding a reference to the <see cref="PreviewTrack"/>
|
||||||
|
/// can always stop the <see cref="PreviewTrack"/> themselves through <see cref="PreviewTrack.Stop()"/>.
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="source">The <see cref="IPreviewTrackOwner"/> which may be the owner of the <see cref="PreviewTrack"/>.</param>
|
||||||
|
public void StopAnyPlaying(IPreviewTrackOwner source)
|
||||||
|
{
|
||||||
|
if (current == null || current.Owner != source)
|
||||||
|
return;
|
||||||
|
|
||||||
|
current.Stop();
|
||||||
|
current = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates the <see cref="TrackManagerPreviewTrack"/>.
|
||||||
|
/// </summary>
|
||||||
|
protected virtual TrackManagerPreviewTrack CreatePreviewTrack(BeatmapSetInfo beatmapSetInfo, TrackManager trackManager) => new TrackManagerPreviewTrack(beatmapSetInfo, trackManager);
|
||||||
|
|
||||||
|
protected class TrackManagerPreviewTrack : PreviewTrack
|
||||||
|
{
|
||||||
|
public IPreviewTrackOwner Owner { get; private set; }
|
||||||
|
|
||||||
|
private readonly BeatmapSetInfo beatmapSetInfo;
|
||||||
|
private readonly TrackManager trackManager;
|
||||||
|
|
||||||
|
public TrackManagerPreviewTrack(BeatmapSetInfo beatmapSetInfo, TrackManager trackManager)
|
||||||
|
{
|
||||||
|
this.beatmapSetInfo = beatmapSetInfo;
|
||||||
|
this.trackManager = trackManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(IPreviewTrackOwner owner)
|
||||||
|
{
|
||||||
|
Owner = owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Track GetTrack() => trackManager.Get($"https://b.ppy.sh/preview/{beatmapSetInfo?.OnlineBeatmapSetID}.mp3");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,20 +8,32 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
|
using osu.Game.Audio;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
|
|
||||||
namespace osu.Game.Graphics.Containers
|
namespace osu.Game.Graphics.Containers
|
||||||
{
|
{
|
||||||
public class OsuFocusedOverlayContainer : FocusedOverlayContainer
|
public class OsuFocusedOverlayContainer : FocusedOverlayContainer, IPreviewTrackOwner
|
||||||
{
|
{
|
||||||
private SampleChannel samplePopIn;
|
private SampleChannel samplePopIn;
|
||||||
private SampleChannel samplePopOut;
|
private SampleChannel samplePopOut;
|
||||||
|
|
||||||
|
private PreviewTrackManager previewTrackManager;
|
||||||
|
|
||||||
protected readonly Bindable<OverlayActivation> OverlayActivationMode = new Bindable<OverlayActivation>(OverlayActivation.All);
|
protected readonly Bindable<OverlayActivation> OverlayActivationMode = new Bindable<OverlayActivation>(OverlayActivation.All);
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent)
|
||||||
private void load(OsuGame osuGame, AudioManager audio)
|
|
||||||
{
|
{
|
||||||
|
var dependencies = new DependencyContainer(base.CreateLocalDependencies(parent));
|
||||||
|
dependencies.CacheAs<IPreviewTrackOwner>(this);
|
||||||
|
return dependencies;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader(true)]
|
||||||
|
private void load(OsuGame osuGame, AudioManager audio, PreviewTrackManager previewTrackManager)
|
||||||
|
{
|
||||||
|
this.previewTrackManager = previewTrackManager;
|
||||||
|
|
||||||
if (osuGame != null)
|
if (osuGame != null)
|
||||||
OverlayActivationMode.BindTo(osuGame.OverlayActivationMode);
|
OverlayActivationMode.BindTo(osuGame.OverlayActivationMode);
|
||||||
|
|
||||||
@ -66,5 +78,11 @@ namespace osu.Game.Graphics.Containers
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void PopOut()
|
||||||
|
{
|
||||||
|
base.PopOut();
|
||||||
|
previewTrackManager.StopAnyPlaying(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ using osu.Game.Online.API;
|
|||||||
using osu.Framework.Graphics.Performance;
|
using osu.Framework.Graphics.Performance;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
|
using osu.Game.Audio;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Graphics.Textures;
|
using osu.Game.Graphics.Textures;
|
||||||
using osu.Game.Input;
|
using osu.Game.Input;
|
||||||
@ -187,6 +188,10 @@ namespace osu.Game
|
|||||||
|
|
||||||
KeyBindingStore.Register(globalBinding);
|
KeyBindingStore.Register(globalBinding);
|
||||||
dependencies.Cache(globalBinding);
|
dependencies.Cache(globalBinding);
|
||||||
|
|
||||||
|
PreviewTrackManager previewTrackManager;
|
||||||
|
dependencies.Cache(previewTrackManager = new PreviewTrackManager());
|
||||||
|
Add(previewTrackManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio.Track;
|
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
|
using osu.Game.Audio;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
@ -25,7 +25,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
|
|||||||
private readonly Box bg, progress;
|
private readonly Box bg, progress;
|
||||||
private readonly PlayButton playButton;
|
private readonly PlayButton playButton;
|
||||||
|
|
||||||
private Track preview => playButton.Preview;
|
private PreviewTrack preview => playButton.Preview;
|
||||||
public Bindable<bool> Playing => playButton.Playing;
|
public Bindable<bool> Playing => playButton.Playing;
|
||||||
|
|
||||||
public BeatmapSetInfo BeatmapSet
|
public BeatmapSetInfo BeatmapSet
|
||||||
@ -66,7 +66,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
Action = () => Playing.Value = !Playing.Value;
|
Action = () => playButton.TriggerOnClick();
|
||||||
Playing.ValueChanged += newValue => progress.FadeTo(newValue ? 1 : 0, 100);
|
Playing.ValueChanged += newValue => progress.FadeTo(newValue ? 1 : 0, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,12 +89,6 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
|
|||||||
progress.Width = 0;
|
progress.Width = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
|
||||||
{
|
|
||||||
Playing.Value = false;
|
|
||||||
base.Dispose(isDisposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnHover(InputState state)
|
protected override bool OnHover(InputState state)
|
||||||
{
|
{
|
||||||
bg.FadeColour(Color4.Black.Opacity(0.5f), 100);
|
bg.FadeColour(Color4.Black.Opacity(0.5f), 100);
|
||||||
|
@ -102,8 +102,6 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
updateDisplay();
|
updateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StopPreview() => preview.Playing.Value = false;
|
|
||||||
|
|
||||||
private class DetailBox : Container
|
private class DetailBox : Container
|
||||||
{
|
{
|
||||||
private readonly Container content;
|
private readonly Container content;
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using OpenTK;
|
|
||||||
using OpenTK.Graphics;
|
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -15,9 +14,10 @@ using osu.Game.Graphics.Containers;
|
|||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Overlays.BeatmapSet;
|
using osu.Game.Overlays.BeatmapSet;
|
||||||
using osu.Game.Rulesets;
|
|
||||||
using osu.Game.Overlays.BeatmapSet.Scores;
|
using osu.Game.Overlays.BeatmapSet.Scores;
|
||||||
using System.Linq;
|
using osu.Game.Rulesets;
|
||||||
|
using OpenTK;
|
||||||
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
{
|
{
|
||||||
@ -124,8 +124,6 @@ namespace osu.Game.Overlays
|
|||||||
protected override void PopOut()
|
protected override void PopOut()
|
||||||
{
|
{
|
||||||
base.PopOut();
|
base.PopOut();
|
||||||
header.Details.StopPreview();
|
|
||||||
|
|
||||||
FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.Out).OnComplete(_ => BeatmapSet = null);
|
FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.Out).OnComplete(_ => BeatmapSet = null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,22 +4,22 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using OpenTK;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
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.Input;
|
||||||
|
using osu.Game.Audio;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.Drawables;
|
using osu.Game.Beatmaps.Drawables;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using OpenTK.Graphics;
|
|
||||||
using osu.Framework.Input;
|
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Framework.Configuration;
|
using OpenTK;
|
||||||
using osu.Framework.Audio.Track;
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Direct
|
namespace osu.Game.Overlays.Direct
|
||||||
{
|
{
|
||||||
@ -35,7 +35,7 @@ namespace osu.Game.Overlays.Direct
|
|||||||
private BeatmapManager beatmaps;
|
private BeatmapManager beatmaps;
|
||||||
private BeatmapSetOverlay beatmapSetOverlay;
|
private BeatmapSetOverlay beatmapSetOverlay;
|
||||||
|
|
||||||
public Track Preview => PlayButton.Preview;
|
public PreviewTrack Preview => PlayButton.Preview;
|
||||||
public Bindable<bool> PreviewPlaying => PlayButton.Playing;
|
public Bindable<bool> PreviewPlaying => PlayButton.Playing;
|
||||||
protected abstract PlayButton PlayButton { get; }
|
protected abstract PlayButton PlayButton { get; }
|
||||||
protected abstract Box PreviewBar { get; }
|
protected abstract Box PreviewBar { get; }
|
||||||
@ -113,7 +113,7 @@ namespace osu.Game.Overlays.Direct
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
if (PreviewPlaying && Preview != null && Preview.IsLoaded)
|
if (PreviewPlaying && Preview != null && Preview.TrackLoaded)
|
||||||
{
|
{
|
||||||
PreviewBar.Width = (float)(Preview.CurrentTime / Preview.Length);
|
PreviewBar.Width = (float)(Preview.CurrentTime / Preview.Length);
|
||||||
}
|
}
|
||||||
@ -141,7 +141,6 @@ namespace osu.Game.Overlays.Direct
|
|||||||
protected override bool OnClick(InputState state)
|
protected override bool OnClick(InputState state)
|
||||||
{
|
{
|
||||||
ShowInformation();
|
ShowInformation();
|
||||||
PreviewPlaying.Value = false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,25 +1,23 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using OpenTK.Graphics;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
|
||||||
using osu.Framework.Audio.Track;
|
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Framework.IO.Stores;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Direct
|
namespace osu.Game.Overlays.Direct
|
||||||
{
|
{
|
||||||
public class PlayButton : Container
|
public class PlayButton : Container
|
||||||
{
|
{
|
||||||
public readonly Bindable<bool> Playing = new Bindable<bool>();
|
public readonly BindableBool Playing = new BindableBool();
|
||||||
public Track Preview { get; private set; }
|
public PreviewTrack Preview { get; private set; }
|
||||||
|
|
||||||
private BeatmapSetInfo beatmapSet;
|
private BeatmapSetInfo beatmapSet;
|
||||||
|
|
||||||
@ -31,9 +29,11 @@ namespace osu.Game.Overlays.Direct
|
|||||||
if (value == beatmapSet) return;
|
if (value == beatmapSet) return;
|
||||||
beatmapSet = value;
|
beatmapSet = value;
|
||||||
|
|
||||||
Playing.Value = false;
|
Preview?.Stop();
|
||||||
trackLoader = null;
|
Preview?.Expire();
|
||||||
Preview = null;
|
Preview = null;
|
||||||
|
|
||||||
|
Playing.Value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,8 +41,6 @@ namespace osu.Game.Overlays.Direct
|
|||||||
private readonly SpriteIcon icon;
|
private readonly SpriteIcon icon;
|
||||||
private readonly LoadingAnimation loadingAnimation;
|
private readonly LoadingAnimation loadingAnimation;
|
||||||
|
|
||||||
private readonly BindableDouble muteBindable = new BindableDouble();
|
|
||||||
|
|
||||||
private const float transition_duration = 500;
|
private const float transition_duration = 500;
|
||||||
|
|
||||||
private bool loading
|
private bool loading
|
||||||
@ -50,15 +48,9 @@ namespace osu.Game.Overlays.Direct
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value)
|
if (value)
|
||||||
{
|
|
||||||
loadingAnimation.Show();
|
loadingAnimation.Show();
|
||||||
icon.FadeOut(transition_duration * 5, Easing.OutQuint);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
loadingAnimation.Hide();
|
loadingAnimation.Hide();
|
||||||
icon.FadeIn(transition_duration, Easing.OutQuint);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,19 +70,22 @@ namespace osu.Game.Overlays.Direct
|
|||||||
loadingAnimation = new LoadingAnimation(),
|
loadingAnimation = new LoadingAnimation(),
|
||||||
});
|
});
|
||||||
|
|
||||||
Playing.ValueChanged += updatePreviewTrack;
|
Playing.ValueChanged += playingStateChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private PreviewTrackManager previewTrackManager;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colour, AudioManager audio)
|
private void load(OsuColour colour, PreviewTrackManager previewTrackManager)
|
||||||
{
|
{
|
||||||
|
this.previewTrackManager = previewTrackManager;
|
||||||
|
|
||||||
hoverColour = colour.Yellow;
|
hoverColour = colour.Yellow;
|
||||||
this.audio = audio;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnClick(InputState state)
|
protected override bool OnClick(InputState state)
|
||||||
{
|
{
|
||||||
Playing.Value = !Playing.Value;
|
Playing.Toggle();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,44 +102,44 @@ namespace osu.Game.Overlays.Direct
|
|||||||
base.OnHoverLost(state);
|
base.OnHoverLost(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
private void playingStateChanged(bool playing)
|
||||||
{
|
{
|
||||||
base.Update();
|
|
||||||
|
|
||||||
if (Preview?.HasCompleted ?? false)
|
|
||||||
{
|
|
||||||
Playing.Value = false;
|
|
||||||
Preview = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updatePreviewTrack(bool playing)
|
|
||||||
{
|
|
||||||
if (playing && BeatmapSet == null)
|
|
||||||
{
|
|
||||||
Playing.Value = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
icon.Icon = playing ? FontAwesome.fa_stop : FontAwesome.fa_play;
|
icon.Icon = playing ? FontAwesome.fa_stop : FontAwesome.fa_play;
|
||||||
icon.FadeColour(playing || IsHovered ? hoverColour : Color4.White, 120, Easing.InOutQuint);
|
icon.FadeColour(playing || IsHovered ? hoverColour : Color4.White, 120, Easing.InOutQuint);
|
||||||
|
|
||||||
if (playing)
|
if (playing)
|
||||||
{
|
{
|
||||||
if (Preview == null)
|
if (BeatmapSet == null)
|
||||||
{
|
{
|
||||||
beginAudioLoad();
|
Playing.Value = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Preview.Restart();
|
if (Preview != null)
|
||||||
|
{
|
||||||
|
Preview.Start();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
audio.Track.AddAdjustment(AdjustableProperty.Volume, muteBindable);
|
loading = true;
|
||||||
|
|
||||||
|
LoadComponentAsync(Preview = previewTrackManager.Get(beatmapSet), preview =>
|
||||||
|
{
|
||||||
|
// beatmapset may have changed.
|
||||||
|
if (Preview != preview)
|
||||||
|
return;
|
||||||
|
|
||||||
|
AddInternal(preview);
|
||||||
|
loading = false;
|
||||||
|
preview.Stopped += () => Playing.Value = false;
|
||||||
|
|
||||||
|
// user may have changed their mind.
|
||||||
|
if (Playing)
|
||||||
|
preview.Start();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
audio.Track.RemoveAdjustment(AdjustableProperty.Volume, muteBindable);
|
|
||||||
|
|
||||||
Preview?.Stop();
|
Preview?.Stop();
|
||||||
loading = false;
|
loading = false;
|
||||||
}
|
}
|
||||||
@ -155,64 +150,5 @@ namespace osu.Game.Overlays.Direct
|
|||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
Playing.Value = false;
|
Playing.Value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TrackLoader trackLoader;
|
|
||||||
private AudioManager audio;
|
|
||||||
|
|
||||||
private void beginAudioLoad()
|
|
||||||
{
|
|
||||||
if (trackLoader != null)
|
|
||||||
{
|
|
||||||
Preview = trackLoader.Preview;
|
|
||||||
Playing.TriggerChange();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
loading = true;
|
|
||||||
|
|
||||||
LoadComponentAsync(trackLoader = new TrackLoader($"https://b.ppy.sh/preview/{BeatmapSet.OnlineBeatmapSetID}.mp3"),
|
|
||||||
d =>
|
|
||||||
{
|
|
||||||
// We may have been replaced by another loader
|
|
||||||
if (trackLoader != d) return;
|
|
||||||
|
|
||||||
Preview = d?.Preview;
|
|
||||||
updatePreviewTrack(Playing);
|
|
||||||
loading = false;
|
|
||||||
|
|
||||||
Add(trackLoader);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private class TrackLoader : Drawable
|
|
||||||
{
|
|
||||||
private readonly string preview;
|
|
||||||
|
|
||||||
public Track Preview;
|
|
||||||
private TrackManager trackManager;
|
|
||||||
|
|
||||||
public TrackLoader(string preview)
|
|
||||||
{
|
|
||||||
this.preview = preview;
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(AudioManager audio, FrameworkConfigManager config)
|
|
||||||
{
|
|
||||||
// create a local trackManager to bypass the mute we are applying above.
|
|
||||||
audio.AddItem(trackManager = new TrackManager(new OnlineStore()));
|
|
||||||
|
|
||||||
// add back the user's music volume setting (since we are no longer in the global TrackManager's hierarchy).
|
|
||||||
config.BindWith(FrameworkSetting.VolumeMusic, trackManager.Volume);
|
|
||||||
|
|
||||||
Preview = trackManager.Get(preview);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
|
||||||
{
|
|
||||||
base.Dispose(isDisposing);
|
|
||||||
trackManager?.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,12 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using OpenTK;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
|
using osu.Game.Audio;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
@ -18,6 +18,7 @@ using osu.Game.Online.API.Requests;
|
|||||||
using osu.Game.Overlays.Direct;
|
using osu.Game.Overlays.Direct;
|
||||||
using osu.Game.Overlays.SearchableList;
|
using osu.Game.Overlays.SearchableList;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
@ -32,7 +33,6 @@ namespace osu.Game.Overlays
|
|||||||
private readonly FillFlowContainer resultCountsContainer;
|
private readonly FillFlowContainer resultCountsContainer;
|
||||||
private readonly OsuSpriteText resultCountsText;
|
private readonly OsuSpriteText resultCountsText;
|
||||||
private FillFlowContainer<DirectPanel> panels;
|
private FillFlowContainer<DirectPanel> panels;
|
||||||
private DirectPanel playing;
|
|
||||||
|
|
||||||
protected override Color4 BackgroundColour => OsuColour.FromHex(@"485e74");
|
protected override Color4 BackgroundColour => OsuColour.FromHex(@"485e74");
|
||||||
protected override Color4 TrianglesColourLight => OsuColour.FromHex(@"465b71");
|
protected override Color4 TrianglesColourLight => OsuColour.FromHex(@"465b71");
|
||||||
@ -176,10 +176,11 @@ namespace osu.Game.Overlays
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours, APIAccess api, RulesetStore rulesets)
|
private void load(OsuColour colours, APIAccess api, RulesetStore rulesets, PreviewTrackManager previewTrackManager)
|
||||||
{
|
{
|
||||||
this.api = api;
|
this.api = api;
|
||||||
this.rulesets = rulesets;
|
this.rulesets = rulesets;
|
||||||
|
this.previewTrackManager = previewTrackManager;
|
||||||
|
|
||||||
resultCountsContainer.Colour = colours.Yellow;
|
resultCountsContainer.Colour = colours.Yellow;
|
||||||
}
|
}
|
||||||
@ -206,12 +207,6 @@ namespace osu.Game.Overlays
|
|||||||
panels.FadeOut(200);
|
panels.FadeOut(200);
|
||||||
panels.Expire();
|
panels.Expire();
|
||||||
panels = null;
|
panels = null;
|
||||||
|
|
||||||
if (playing != null)
|
|
||||||
{
|
|
||||||
playing.PreviewPlaying.Value = false;
|
|
||||||
playing = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BeatmapSets == null) return;
|
if (BeatmapSets == null) return;
|
||||||
@ -242,17 +237,6 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
if (panels != null) ScrollFlow.Remove(panels);
|
if (panels != null) ScrollFlow.Remove(panels);
|
||||||
ScrollFlow.Add(panels = newPanels);
|
ScrollFlow.Add(panels = newPanels);
|
||||||
|
|
||||||
foreach (DirectPanel panel in p.Children)
|
|
||||||
panel.PreviewPlaying.ValueChanged += newValue =>
|
|
||||||
{
|
|
||||||
if (newValue)
|
|
||||||
{
|
|
||||||
if (playing != null && playing != panel)
|
|
||||||
playing.PreviewPlaying.Value = false;
|
|
||||||
playing = panel;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,6 +245,7 @@ namespace osu.Game.Overlays
|
|||||||
private readonly Bindable<string> currentQuery = new Bindable<string>();
|
private readonly Bindable<string> currentQuery = new Bindable<string>();
|
||||||
|
|
||||||
private ScheduledDelegate queryChangedDebounce;
|
private ScheduledDelegate queryChangedDebounce;
|
||||||
|
private PreviewTrackManager previewTrackManager;
|
||||||
|
|
||||||
private void updateSearch()
|
private void updateSearch()
|
||||||
{
|
{
|
||||||
@ -277,6 +262,8 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
if (Header.Tabs.Current.Value == DirectTab.Search && (Filter.Search.Text == string.Empty || currentQuery == string.Empty)) return;
|
if (Header.Tabs.Current.Value == DirectTab.Search && (Filter.Search.Text == string.Empty || currentQuery == string.Empty)) return;
|
||||||
|
|
||||||
|
previewTrackManager.StopAnyPlaying(this);
|
||||||
|
|
||||||
getSetsRequest = new SearchBeatmapSetsRequest(currentQuery.Value ?? string.Empty,
|
getSetsRequest = new SearchBeatmapSetsRequest(currentQuery.Value ?? string.Empty,
|
||||||
((FilterControl)Filter).Ruleset.Value,
|
((FilterControl)Filter).Ruleset.Value,
|
||||||
Filter.DisplayStyleControl.Dropdown.Current.Value,
|
Filter.DisplayStyleControl.Dropdown.Current.Value,
|
||||||
@ -300,14 +287,6 @@ namespace osu.Game.Overlays
|
|||||||
api.Queue(getSetsRequest);
|
api.Queue(getSetsRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PopOut()
|
|
||||||
{
|
|
||||||
base.PopOut();
|
|
||||||
|
|
||||||
if (playing != null)
|
|
||||||
playing.PreviewPlaying.Value = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int distinctCount(List<string> list) => list.Distinct().ToArray().Length;
|
private int distinctCount(List<string> list) => list.Distinct().ToArray().Length;
|
||||||
|
|
||||||
public class ResultCounts
|
public class ResultCounts
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
using System.Linq;
|
||||||
using OpenTK;
|
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Overlays.Direct;
|
using osu.Game.Overlays.Direct;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
using System.Linq;
|
using OpenTK;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Profile.Sections.Beatmaps
|
namespace osu.Game.Overlays.Profile.Sections.Beatmaps
|
||||||
{
|
{
|
||||||
@ -18,10 +17,6 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps
|
|||||||
|
|
||||||
private readonly BeatmapSetType type;
|
private readonly BeatmapSetType type;
|
||||||
|
|
||||||
private DirectPanel currentlyPlaying;
|
|
||||||
|
|
||||||
public event Action<PaginatedBeatmapContainer> BeganPlayingPreview;
|
|
||||||
|
|
||||||
public PaginatedBeatmapContainer(BeatmapSetType type, Bindable<User> user, string header, string missing = "None... yet.")
|
public PaginatedBeatmapContainer(BeatmapSetType type, Bindable<User> user, string header, string missing = "None... yet.")
|
||||||
: base(user, header, missing)
|
: base(user, header, missing)
|
||||||
{
|
{
|
||||||
@ -56,28 +51,10 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps
|
|||||||
|
|
||||||
var panel = new DirectGridPanel(s.ToBeatmapSet(Rulesets));
|
var panel = new DirectGridPanel(s.ToBeatmapSet(Rulesets));
|
||||||
ItemsContainer.Add(panel);
|
ItemsContainer.Add(panel);
|
||||||
|
|
||||||
panel.PreviewPlaying.ValueChanged += isPlaying =>
|
|
||||||
{
|
|
||||||
StopPlayingPreview();
|
|
||||||
|
|
||||||
if (isPlaying)
|
|
||||||
{
|
|
||||||
BeganPlayingPreview?.Invoke(this);
|
|
||||||
currentlyPlaying = panel;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Api.Queue(req);
|
Api.Queue(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StopPlayingPreview()
|
|
||||||
{
|
|
||||||
if (currentlyPlaying == null) return;
|
|
||||||
currentlyPlaying.PreviewPlaying.Value = false;
|
|
||||||
currentlyPlaying = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System.Linq;
|
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Overlays.Profile.Sections.Beatmaps;
|
using osu.Game.Overlays.Profile.Sections.Beatmaps;
|
||||||
|
|
||||||
@ -22,15 +21,6 @@ namespace osu.Game.Overlays.Profile.Sections
|
|||||||
new PaginatedBeatmapContainer(BeatmapSetType.Unranked, User, "Pending Beatmaps"),
|
new PaginatedBeatmapContainer(BeatmapSetType.Unranked, User, "Pending Beatmaps"),
|
||||||
new PaginatedBeatmapContainer(BeatmapSetType.Graveyard, User, "Graveyarded Beatmaps"),
|
new PaginatedBeatmapContainer(BeatmapSetType.Graveyard, User, "Graveyarded Beatmaps"),
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach (var paginatedBeatmapContainer in Children.OfType<PaginatedBeatmapContainer>())
|
|
||||||
{
|
|
||||||
paginatedBeatmapContainer.BeganPlayingPreview += _ =>
|
|
||||||
{
|
|
||||||
foreach (var bc in Children.OfType<PaginatedBeatmapContainer>())
|
|
||||||
bc.StopPlayingPreview();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenTK;
|
|
||||||
using OpenTK.Graphics;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -18,6 +16,8 @@ using osu.Game.Online.API.Requests;
|
|||||||
using osu.Game.Overlays.Profile;
|
using osu.Game.Overlays.Profile;
|
||||||
using osu.Game.Overlays.Profile.Sections;
|
using osu.Game.Overlays.Profile.Sections;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
|
using OpenTK;
|
||||||
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user