diff --git a/osu.Game/Overlays/Pause/PauseButton.cs b/osu.Game/Overlays/Pause/PauseButton.cs index eabf56192a..956cb31109 100644 --- a/osu.Game/Overlays/Pause/PauseButton.cs +++ b/osu.Game/Overlays/Pause/PauseButton.cs @@ -21,6 +21,7 @@ namespace osu.Game.Overlays.Pause private float colourExpandTime = 500; private float shear = 0.2f; private float glowGradientEndAlpha = 0f; + private double pressExpandTime = 100; private Color4 buttonColour; private Color4 backgroundColour = OsuColour.Gray(34); @@ -54,12 +55,18 @@ namespace osu.Game.Overlays.Pause private Container backgroundContainer; private Container colourContainer; private Container glowContainer; - private SpriteText spriteText; public override bool Contains(Vector2 screenSpacePos) => backgroundContainer.Contains(screenSpacePos); + protected override bool OnMouseDown(Framework.Input.InputState state, MouseDownEventArgs args) + { + colourContainer.ResizeTo(new Vector2(colourWidth, 1f), 1000, EasingTypes.Out); + return true; + } + protected override bool OnMouseUp(Framework.Input.InputState state, MouseUpEventArgs args) { + colourContainer.ResizeTo(new Vector2(1.1f, 1f), pressExpandTime, EasingTypes.In); sampleClick?.Play(); return true; } @@ -67,7 +74,7 @@ namespace osu.Game.Overlays.Pause protected override bool OnHover(Framework.Input.InputState state) { colourContainer.ResizeTo(new Vector2(colourExpandedWidth, 1f), colourExpandTime, EasingTypes.OutElastic); - glowContainer.FadeTo(1f, colourExpandTime, EasingTypes.Out); + glowContainer.FadeTo(1f, colourExpandTime / 2, EasingTypes.Out); sampleHover?.Play(); return true; } @@ -75,7 +82,7 @@ namespace osu.Game.Overlays.Pause protected override void OnHoverLost(Framework.Input.InputState state) { colourContainer.ResizeTo(new Vector2(colourWidth, 1f), colourExpandTime, EasingTypes.OutElastic); - glowContainer.FadeTo(0f, colourExpandTime, EasingTypes.Out); + glowContainer.FadeTo(0f, colourExpandTime / 2, EasingTypes.Out); } [BackgroundDependencyLoader] @@ -187,7 +194,7 @@ namespace osu.Game.Overlays.Pause }, } }, - spriteText = new SpriteText + new SpriteText { Text = Text, Anchor = Anchor.Centre, diff --git a/osu.Game/Overlays/Pause/PauseOverlay.cs b/osu.Game/Overlays/Pause/PauseOverlay.cs index 1590b8b726..2fa4239749 100644 --- a/osu.Game/Overlays/Pause/PauseOverlay.cs +++ b/osu.Game/Overlays/Pause/PauseOverlay.cs @@ -3,8 +3,6 @@ using OpenTK; using OpenTK.Input; using OpenTK.Graphics; using osu.Game.Graphics; -using osu.Game.Screens.Menu; -using osu.Game.Screens.Play; using osu.Framework.Input; using osu.Framework.Allocation; using osu.Framework.Graphics; @@ -20,18 +18,29 @@ namespace osu.Game.Overlays.Pause public Action OnResume; public Action OnRetry; - public Action OnQuit; + public Action OnQuit; + + private SpriteText retryCounter; private PauseProgressBar progressBar; + [BackgroundDependencyLoader] private void load(OsuColour colours) { Children = new Drawable[] { - new Box + new ClickableContainer { RelativeSizeAxes = Axes.Both, - Colour = Color4.Black, - Alpha = 0.75f, + + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + Alpha = 0.75f, + } + } }, new SpriteText { @@ -56,7 +65,7 @@ namespace osu.Game.Overlays.Pause Shadow = true, ShadowColour = new Color4(0, 0, 0, 0.25f), }, - new SpriteText + retryCounter = new SpriteText { Text = @"You've retried 0 times in this session", Origin = Anchor.TopCentre, @@ -67,6 +76,12 @@ namespace osu.Game.Overlays.Pause ShadowColour = new Color4(0, 0, 0, 0.25f), TextSize = 18, }, + progressBar = new PauseProgressBar + { + Origin = Anchor.BottomCentre, + Anchor = Anchor.BottomCentre, + Width = 1f, + }, new FlowContainer { RelativeSizeAxes = Axes.X, @@ -82,7 +97,6 @@ namespace osu.Game.Overlays.Pause Radius = 50, Offset = new Vector2(0, 0), }, - Children = new Drawable[] { new PauseButton @@ -138,10 +152,11 @@ namespace osu.Game.Overlays.Pause switch (args.Key) { case Key.Escape: + if (State == Visibility.Hidden) return false; Hide(); OnResume?.Invoke(); return true; - } + } return base.OnKeyDown(state, args); } @@ -149,7 +164,6 @@ namespace osu.Game.Overlays.Pause { RelativeSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both; - Depth = -1; } } } diff --git a/osu.Game/Overlays/Pause/PauseProgressBar.cs b/osu.Game/Overlays/Pause/PauseProgressBar.cs new file mode 100644 index 0000000000..2c48bf8689 --- /dev/null +++ b/osu.Game/Overlays/Pause/PauseProgressBar.cs @@ -0,0 +1,141 @@ +using System; +using OpenTK; +using OpenTK.Input; +using OpenTK.Graphics; +using osu.Game.Graphics; +using osu.Framework.Input; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Transformations; +using osu.Framework.Graphics.UserInterface; +using osu.Game.Beatmaps; +using osu.Framework.Graphics.Primitives; + +namespace osu.Game.Overlays.Pause +{ + public class PauseProgressBar : Container + { + private Container fill; + private WorkingBeatmap current; + + [BackgroundDependencyLoader] + private void load(OsuGameBase osuGame) + { + current = osuGame.Beatmap.Value; + } + + protected override void Update() + { + base.Update(); + + if (current?.TrackLoaded ?? false) + { + fill.Width = (float)(current.Track.CurrentTime / current.Track.Length); + } + } + + public PauseProgressBar() + { + RelativeSizeAxes = Axes.X; + Height = 60; + + Children = new Drawable[] + { + new Container + { + Origin = Anchor.BottomRight, + Anchor = Anchor.BottomRight, + RelativeSizeAxes = Axes.X, + Height = 5, + + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = new Color4(0, 0, 0, 255), + Alpha = 0.5f, + } + } + }, + fill = new Container + { + RelativeSizeAxes = Axes.X, + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + Width = 0, + Height = 60, + Children = new Drawable[] + { + new Container + { + RelativeSizeAxes = Axes.Both, + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + Masking = true, + Children = new Drawable[] + { + new Container + { + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + RelativeSizeAxes = Axes.X, + Height = 5, + Masking = true, + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Glow, + Colour = new Color4(130, 204, 255, 150), + Radius = 5, + }, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = new Color4(221, 255, 255, 255), + } + } + }, + } + }, + new Container + { + Origin = Anchor.BottomRight, + Anchor = Anchor.BottomRight, + Width = 2, + Height = 35, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.White, + }, + new Container + { + Origin = Anchor.BottomCentre, + Anchor = Anchor.TopCentre, + Width = 14, + Height = 25, + CornerRadius = 5, + Masking = true, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.White + } + } + } + } + } + } + } + }; + } + } +} diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 82cff73508..e1ef040307 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -104,9 +104,9 @@ namespace osu.Game.Screens.Play scoreOverlay = ruleset.CreateScoreOverlay(); scoreOverlay.BindProcessor(scoreProcessor = ruleset.CreateScoreProcessor(beatmap.HitObjects.Count)); - pauseOverlay = new PauseOverlay(); + pauseOverlay = new PauseOverlay { Depth = -1 }; pauseOverlay.OnResume = Resume; - //pauseOverlay.OnRetry = Retry; Add when retrying is implemented + pauseOverlay.OnRetry = Restart; pauseOverlay.OnQuit = Exit; hitRenderer = ruleset.CreateHitRendererWith(beatmap.HitObjects); @@ -137,9 +137,9 @@ namespace osu.Game.Screens.Play }; } - public void Pause() + public void Pause(bool force = false) { - if (Time.Current >= (lastActionTime + pauseCooldown)) + if (Time.Current >= (lastActionTime + pauseCooldown) || force) { lastActionTime = Time.Current; isPaused = true; @@ -165,7 +165,12 @@ namespace osu.Game.Screens.Play public void TogglePaused() { isPaused = !isPaused; - (isPaused ? (Action)Pause : Resume)?.Invoke(); + if (isPaused) Pause(); else Resume(); + } + + public void Restart() + { + // TODO: Implement retrying } protected override void LoadComplete() diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 388b8ff77e..cf0fc50373 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -238,6 +238,7 @@ +