mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 14:46:38 +09:00
Still does not support switching skins after Pause overlay loading, there will be no sound for the first pause (works fine the the nexts) Also, the pause loop seems to play for approximately 1 second when exiting the screens via restart or quit finally, since SkinnableSound does not play a sound if its aggregate volume is at 0, i had turn up the volume a bit before playing the loop
64 lines
2.0 KiB
C#
64 lines
2.0 KiB
C#
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
using System;
|
|
using System.Linq;
|
|
using Humanizer;
|
|
using NUnit.Framework.Internal;
|
|
using osu.Framework.Allocation;
|
|
using osu.Framework.Audio;
|
|
using osu.Framework.Audio.Sample;
|
|
using osu.Framework.Graphics;
|
|
using osu.Framework.Graphics.Audio;
|
|
using osu.Game.Audio;
|
|
using osu.Game.Graphics;
|
|
using osu.Game.Skinning;
|
|
using osuTK.Graphics;
|
|
|
|
namespace osu.Game.Screens.Play
|
|
{
|
|
public class PauseOverlay : GameplayMenuOverlay
|
|
{
|
|
public Action OnResume;
|
|
|
|
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();
|
|
|
|
[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,
|
|
});
|
|
|
|
}
|
|
|
|
protected override void PopIn()
|
|
{
|
|
base.PopIn();
|
|
|
|
//SkinnableSound only plays a sound if its aggregate volume is > 0, so the volume must be turned up before playing it
|
|
pauseLoop?.TransformBindableTo(pauseLoop.Volume, 0.00001);
|
|
pauseLoop?.TransformBindableTo(pauseLoop.Volume, 1.0f, 400, Easing.InQuint);
|
|
pauseLoop?.Play();
|
|
}
|
|
|
|
protected override void PopOut()
|
|
{
|
|
base.PopOut();
|
|
pauseLoop?.Stop();
|
|
pauseLoop?.TransformBindableTo(pauseLoop.Volume, 0.0f);
|
|
}
|
|
|
|
}
|
|
}
|