1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-09 09:37:42 +08:00
osu-lazer/osu.Game/Screens/Play/PauseOverlay.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

75 lines
2.2 KiB
C#
Raw Normal View History

2019-03-18 10:48:11 +08:00
// 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.
2022-06-17 15:37:17 +08:00
#nullable disable
2019-03-18 10:48:11 +08:00
using System;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Audio;
2020-06-22 20:02:21 +08:00
using osu.Framework.Graphics;
using osu.Framework.Input.Events;
2020-06-25 19:26:42 +08:00
using osu.Game.Audio;
2019-03-18 10:48:11 +08:00
using osu.Game.Graphics;
using osu.Game.Input.Bindings;
2020-06-25 19:26:42 +08:00
using osu.Game.Skinning;
2019-03-18 10:48:11 +08:00
using osuTK.Graphics;
namespace osu.Game.Screens.Play
{
public partial class PauseOverlay : GameplayMenuOverlay
{
public Action OnResume;
public override bool IsPresent => base.IsPresent || pauseLoop.IsPlaying;
2019-03-18 10:48:11 +08:00
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;
2020-06-22 20:02:21 +08:00
protected override Action BackAction => () => InternalButtons.First().TriggerClick();
2019-03-18 10:48:11 +08:00
[BackgroundDependencyLoader]
private void load(OsuColour colours)
2019-03-18 10:48:11 +08:00
{
AddButton("Continue", colours.Green, () => OnResume?.Invoke());
AddButton("Retry", colours.YellowDark, () => OnRetry?.Invoke());
AddButton("Quit", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke());
2020-06-22 20:02:21 +08:00
AddInternal(pauseLoop = new SkinnableSound(new SampleInfo("Gameplay/pause-loop"))
2020-06-22 20:02:21 +08:00
{
Looping = true,
Volume = { Value = 0 }
});
2020-06-22 20:02:21 +08:00
}
protected override void PopIn()
{
base.PopIn();
pauseLoop.VolumeTo(1.0f, TRANSITION_DURATION, Easing.InQuint);
2020-07-01 19:30:23 +08:00
pauseLoop.Play();
2020-06-22 20:02:21 +08:00
}
protected override void PopOut()
{
base.PopOut();
pauseLoop.VolumeTo(0, TRANSITION_DURATION, Easing.OutQuad).Finally(_ => pauseLoop.Stop());
2019-03-18 10:48:11 +08:00
}
public override bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
switch (e.Action)
{
case GlobalAction.PauseGameplay:
InternalButtons.First().TriggerClick();
return true;
}
return base.OnPressed(e);
}
2019-03-18 10:48:11 +08:00
}
}