diff --git a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs index 2a66783b2a..31184d04e9 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs @@ -29,7 +29,7 @@ public override void Reset() AddButton("Add Retry", delegate { retryCount++; - pauseOverlay.SetRetries(retryCount); + pauseOverlay.Retries = retryCount; }); pauseOverlay.OnResume += () => Logger.Log(@"Resume"); diff --git a/osu.Game/Overlays/Pause/PauseButton.cs b/osu.Game/Overlays/Pause/PauseButton.cs index 0696dba452..ed56cc7b85 100644 --- a/osu.Game/Overlays/Pause/PauseButton.cs +++ b/osu.Game/Overlays/Pause/PauseButton.cs @@ -30,7 +30,7 @@ public Color4 ButtonColour set { buttonColour = value; - reapplyGlow(); + updateGlow(); if (colourContainer == null) return; colourContainer.Colour = ButtonColour; } @@ -118,9 +118,8 @@ private void flash() flash.Expire(); } - private void reapplyGlow() + private void updateGlow() { - if (leftGlow == null || centerGlow == null || rightGlow == null) return; leftGlow.ColourInfo = ColourInfo.GradientHorizontal(new Color4(ButtonColour.R, ButtonColour.G, ButtonColour.B, 0f), ButtonColour); centerGlow.Colour = ButtonColour; rightGlow.ColourInfo = ColourInfo.GradientHorizontal(ButtonColour, new Color4(ButtonColour.R, ButtonColour.G, ButtonColour.B, 0f)); @@ -228,7 +227,7 @@ public PauseButton() } }; - reapplyGlow(); + updateGlow(); } } } diff --git a/osu.Game/Overlays/Pause/PauseOverlay.cs b/osu.Game/Overlays/Pause/PauseOverlay.cs index e05be76927..733133f005 100644 --- a/osu.Game/Overlays/Pause/PauseOverlay.cs +++ b/osu.Game/Overlays/Pause/PauseOverlay.cs @@ -15,31 +15,67 @@ namespace osu.Game.Overlays.Pause { public class PauseOverlay : OverlayContainer { - private const int transitionDuration = 200; - private const int buttonHeight = 70; - private const float backgroundAlpha = 0.75f; + private const int transition_duration = 200; + private const int button_height = 70; + private const float background_alpha = 0.75f; public Action OnResume; public Action OnRetry; public Action OnQuit; + public int Retries + { + set + { + if (retryCounterContainer != null) + { + // "You've retried 1,065 times in this session" + // "You've retried 1 time in this session" + + retryCounterContainer.Children = new Drawable[] + { + new SpriteText + { + Text = "You've retried ", + Shadow = true, + ShadowColour = new Color4(0, 0, 0, 0.25f), + TextSize = 18 + }, + new SpriteText + { + Text = String.Format("{0:n0}", value), + Font = @"Exo2.0-Bold", + Shadow = true, + ShadowColour = new Color4(0, 0, 0, 0.25f), + TextSize = 18 + }, + new SpriteText + { + Text = $" time{((value == 1) ? "" : "s")} in this session", + Shadow = true, + ShadowColour = new Color4(0, 0, 0, 0.25f), + TextSize = 18 + } + }; + } + } + } + private FlowContainer retryCounterContainer; public override bool Contains(Vector2 screenSpacePos) => true; public override bool HandleInput => State == Visibility.Visible; - protected override void PopIn() => FadeIn(transitionDuration, EasingTypes.In); - protected override void PopOut() => FadeOut(transitionDuration, EasingTypes.In); + protected override void PopIn() => FadeIn(transition_duration, EasingTypes.In); + protected override void PopOut() => FadeOut(transition_duration, EasingTypes.In); protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { - switch (args.Key) + if (args.Key == Key.Escape) { - case Key.Escape: - if (State == Visibility.Hidden) return false; - Hide(); - OnResume?.Invoke(); - return true; + if (State == Visibility.Hidden) return false; + resume(); + return true; } return base.OnKeyDown(state, args); } @@ -53,7 +89,7 @@ private void load(OsuColour colours) { RelativeSizeAxes = Axes.Both, Colour = Color4.Black, - Alpha = backgroundAlpha, + Alpha = background_alpha, }, new FlowContainer { @@ -88,7 +124,7 @@ private void load(OsuColour colours) }, new SpriteText { - Text = @"you're not going to do what i think you're going to do, ain't ya?", + Text = @"you're not going to do what i think you're going to do, are ya?", Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, Shadow = true, @@ -104,9 +140,8 @@ private void load(OsuColour colours) EdgeEffect = new EdgeEffect { Type = EdgeEffectType.Shadow, - Colour = new Color4(0, 0, 0, 150), - Radius = 50, - Offset = new Vector2(0, 0), + Colour = Color4.Black.Opacity(0.6f), + Radius = 50 }, Children = new Drawable[] { @@ -115,19 +150,15 @@ private void load(OsuColour colours) RelativeSizeAxes = Axes.X, Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, - Height = buttonHeight, - Action = delegate - { - Hide(); - OnResume?.Invoke(); - } + Height = button_height, + Action = resume }, new RetryButton { RelativeSizeAxes = Axes.X, Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, - Height = buttonHeight, + Height = button_height, Action = delegate { Hide(); @@ -139,7 +170,7 @@ private void load(OsuColour colours) RelativeSizeAxes = Axes.X, Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, - Height = buttonHeight, + Height = button_height, Action = delegate { Hide(); @@ -164,47 +195,14 @@ private void load(OsuColour colours) } }; - SetRetries(0); + Retries = 0; } - public void SetRetries(int count) + private void resume() { - if (retryCounterContainer != null) - { - // "You've retried 1,065 times in this session" - // "You've retried 1 time in this session" - - string leading = "You've retried "; - string countString = String.Format("{0:n0}", count); - string trailing = $" time{((count == 1) ? "" : "s")} in this session"; - - retryCounterContainer.Children = new Drawable[] - { - new SpriteText - { - Text = leading, - Shadow = true, - ShadowColour = new Color4(0, 0, 0, 0.25f), - TextSize = 18 - }, - new SpriteText - { - Text = countString, - Font = @"Exo2.0-Bold", - Shadow = true, - ShadowColour = new Color4(0, 0, 0, 0.25f), - TextSize = 18 - }, - new SpriteText - { - Text = trailing, - Shadow = true, - ShadowColour = new Color4(0, 0, 0, 0.25f), - TextSize = 18 - } - }; - } - } + Hide(); + OnResume?.Invoke(); + } public PauseOverlay() { diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 931764c2be..106a419b7d 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -163,7 +163,7 @@ public void Pause(bool force = false) lastPauseActionTime = Time.Current; playerInputManager.PassThrough = true; scoreOverlay.KeyCounter.IsCounting = false; - pauseOverlay.SetRetries(RestartCount); + pauseOverlay.Retries = RestartCount; pauseOverlay.Show(); sourceClock.Stop(); isPaused = true;