mirror of
https://github.com/ppy/osu.git
synced 2025-02-12 22:32:57 +08:00
Merge pull request #9274 from BananeVolante/Issue#9170
This commit is contained in:
commit
d42a4e943a
@ -11,6 +11,7 @@ using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
@ -221,6 +222,31 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
confirmExited();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPauseSoundLoop()
|
||||
{
|
||||
AddStep("seek before gameplay", () => Player.GameplayClockContainer.Seek(-5000));
|
||||
|
||||
SkinnableSound getLoop() => Player.ChildrenOfType<PauseOverlay>().FirstOrDefault()?.ChildrenOfType<SkinnableSound>().FirstOrDefault();
|
||||
|
||||
pauseAndConfirm();
|
||||
AddAssert("loop is playing", () => getLoop().IsPlaying);
|
||||
|
||||
resumeAndConfirm();
|
||||
AddUntilStep("loop is stopped", () => !getLoop().IsPlaying);
|
||||
|
||||
AddUntilStep("pause again", () =>
|
||||
{
|
||||
Player.Pause();
|
||||
return !Player.GameplayClockContainer.GameplayClock.IsRunning;
|
||||
});
|
||||
|
||||
AddAssert("loop is playing", () => getLoop().IsPlaying);
|
||||
|
||||
resumeAndConfirm();
|
||||
AddUntilStep("loop is stopped", () => !getLoop().IsPlaying);
|
||||
}
|
||||
|
||||
private void pauseAndConfirm()
|
||||
{
|
||||
pause();
|
||||
|
@ -24,7 +24,8 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
public abstract class GameplayMenuOverlay : OverlayContainer, IKeyBindingHandler<GlobalAction>
|
||||
{
|
||||
private const int transition_duration = 200;
|
||||
protected const int TRANSITION_DURATION = 200;
|
||||
|
||||
private const int button_height = 70;
|
||||
private const float background_alpha = 0.75f;
|
||||
|
||||
@ -156,8 +157,8 @@ namespace osu.Game.Screens.Play
|
||||
}
|
||||
}
|
||||
|
||||
protected override void PopIn() => this.FadeIn(transition_duration, Easing.In);
|
||||
protected override void PopOut() => this.FadeOut(transition_duration, Easing.In);
|
||||
protected override void PopIn() => this.FadeIn(TRANSITION_DURATION, Easing.In);
|
||||
protected override void PopOut() => this.FadeOut(TRANSITION_DURATION, Easing.In);
|
||||
|
||||
// Don't let mouse down events through the overlay or people can click circles while paused.
|
||||
protected override bool OnMouseDown(MouseDownEvent e) => true;
|
||||
|
@ -4,7 +4,10 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
@ -13,17 +16,46 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
public Action OnResume;
|
||||
|
||||
public override bool IsPresent => base.IsPresent || pauseLoop.IsPlaying;
|
||||
|
||||
public override string Header => "paused";
|
||||
public override string Description => "you're not going to do what i think you're going to do, are ya?";
|
||||
|
||||
private SkinnableSound pauseLoop;
|
||||
|
||||
protected override Action BackAction => () => InternalButtons.Children.First().Click();
|
||||
|
||||
private const float minimum_volume = 0.0001f;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
AddButton("Continue", colours.Green, () => OnResume?.Invoke());
|
||||
AddButton("Retry", colours.YellowDark, () => OnRetry?.Invoke());
|
||||
AddButton("Quit", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke());
|
||||
|
||||
AddInternal(pauseLoop = new SkinnableSound(new SampleInfo("pause-loop"))
|
||||
{
|
||||
Looping = true,
|
||||
});
|
||||
|
||||
// SkinnableSound only plays a sound if its aggregate volume is > 0, so the volume must be turned up before playing it
|
||||
pauseLoop.VolumeTo(minimum_volume);
|
||||
}
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
base.PopIn();
|
||||
|
||||
pauseLoop.VolumeTo(1.0f, TRANSITION_DURATION, Easing.InQuint);
|
||||
pauseLoop.Play();
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
base.PopOut();
|
||||
|
||||
pauseLoop.VolumeTo(minimum_volume, TRANSITION_DURATION, Easing.OutQuad).Finally(_ => pauseLoop.Stop());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,6 +48,10 @@ namespace osu.Game.Skinning
|
||||
|
||||
public BindableNumber<double> Tempo => samplesContainer.Tempo;
|
||||
|
||||
public override bool IsPresent => Scheduler.HasPendingTasks || IsPlaying;
|
||||
|
||||
public bool IsPlaying => samplesContainer.Any(s => s.Playing);
|
||||
|
||||
/// <summary>
|
||||
/// Smoothly adjusts <see cref="Volume"/> over time.
|
||||
/// </summary>
|
||||
@ -97,8 +101,6 @@ namespace osu.Game.Skinning
|
||||
|
||||
public void Stop() => samplesContainer.ForEach(c => c.Stop());
|
||||
|
||||
public override bool IsPresent => Scheduler.HasPendingTasks;
|
||||
|
||||
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
||||
{
|
||||
bool wasPlaying = samplesContainer.Any(s => s.Playing);
|
||||
|
Loading…
Reference in New Issue
Block a user