From 2f9a15092b460d72caa223a3ae892f6a9e84fb88 Mon Sep 17 00:00:00 2001 From: Andrey Zavadskiy Date: Tue, 28 Mar 2017 04:52:11 +0300 Subject: [PATCH 01/62] Refactor pause buttons --- .../Pause/{ResumeButton.cs => PauseButton.cs} | 9 ++----- osu.Game/Screens/Play/Pause/QuitButton.cs | 26 ------------------- osu.Game/Screens/Play/Pause/RetryButton.cs | 26 ------------------- 3 files changed, 2 insertions(+), 59 deletions(-) rename osu.Game/Screens/Play/Pause/{ResumeButton.cs => PauseButton.cs} (74%) delete mode 100644 osu.Game/Screens/Play/Pause/QuitButton.cs delete mode 100644 osu.Game/Screens/Play/Pause/RetryButton.cs diff --git a/osu.Game/Screens/Play/Pause/ResumeButton.cs b/osu.Game/Screens/Play/Pause/PauseButton.cs similarity index 74% rename from osu.Game/Screens/Play/Pause/ResumeButton.cs rename to osu.Game/Screens/Play/Pause/PauseButton.cs index d4f7555d3c..06e1308c43 100644 --- a/osu.Game/Screens/Play/Pause/ResumeButton.cs +++ b/osu.Game/Screens/Play/Pause/PauseButton.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Game.Graphics; @@ -8,19 +9,13 @@ using osu.Game.Graphics.UserInterface; namespace osu.Game.Screens.Play.Pause { - public class ResumeButton : DialogButton + public class PauseButton : DialogButton { [BackgroundDependencyLoader] private void load(AudioManager audio, OsuColour colours) { - ButtonColour = colours.Green; SampleHover = audio.Sample.Get(@"Menu/menuclick"); SampleClick = audio.Sample.Get(@"Menu/menuback"); } - - public ResumeButton() - { - Text = @"Continue"; - } } } diff --git a/osu.Game/Screens/Play/Pause/QuitButton.cs b/osu.Game/Screens/Play/Pause/QuitButton.cs deleted file mode 100644 index 7b71b4b2fc..0000000000 --- a/osu.Game/Screens/Play/Pause/QuitButton.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Allocation; -using osu.Framework.Audio; -using osu.Game.Graphics.UserInterface; -using OpenTK.Graphics; - -namespace osu.Game.Screens.Play.Pause -{ - public class QuitButton : DialogButton - { - [BackgroundDependencyLoader] - private void load(AudioManager audio) - { - ButtonColour = new Color4(170, 27, 39, 255); // The red from the design isn't in the palette so it's used directly - SampleHover = audio.Sample.Get(@"Menu/menuclick"); - SampleClick = audio.Sample.Get(@"Menu/menuback"); - } - - public QuitButton() - { - Text = @"Quit to Main Menu"; - } - } -} diff --git a/osu.Game/Screens/Play/Pause/RetryButton.cs b/osu.Game/Screens/Play/Pause/RetryButton.cs deleted file mode 100644 index 8f660525c3..0000000000 --- a/osu.Game/Screens/Play/Pause/RetryButton.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Allocation; -using osu.Framework.Audio; -using osu.Game.Graphics; -using osu.Game.Graphics.UserInterface; - -namespace osu.Game.Screens.Play.Pause -{ - public class RetryButton : DialogButton - { - [BackgroundDependencyLoader] - private void load(AudioManager audio, OsuColour colours) - { - ButtonColour = colours.YellowDark; - SampleHover = audio.Sample.Get(@"Menu/menuclick"); - SampleClick = audio.Sample.Get(@"Menu/menu-play-click"); - } - - public RetryButton() - { - Text = @"Retry"; - } - } -} From 5461c6516ad72b103b0e91fb17c0c7f2d6874784 Mon Sep 17 00:00:00 2001 From: Andrey Zavadskiy Date: Tue, 28 Mar 2017 04:53:57 +0300 Subject: [PATCH 02/62] Refactor PauseOverlay, FailDialog -> FailOverlay --- .../Tests/TestCasePauseOverlay.cs | 9 +- osu.Game/Screens/Play/FailDialog.cs | 42 --------- osu.Game/Screens/Play/FailOverlay.cs | 49 +++++++++++ osu.Game/Screens/Play/PauseOverlay.cs | 88 ++++++++----------- osu.Game/Screens/Play/Player.cs | 37 +++++--- osu.Game/osu.Game.csproj | 10 +-- 6 files changed, 121 insertions(+), 114 deletions(-) delete mode 100644 osu.Game/Screens/Play/FailDialog.cs create mode 100644 osu.Game/Screens/Play/FailOverlay.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs index ad8039bc66..32f3380086 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs @@ -1,8 +1,10 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using OpenTK.Graphics; using osu.Framework.Logging; using osu.Framework.Screens.Testing; +using osu.Game.Graphics; using osu.Game.Screens.Play; namespace osu.Desktop.VisualTests.Tests @@ -22,9 +24,12 @@ namespace osu.Desktop.VisualTests.Tests { Depth = -1, OnResume = () => Logger.Log(@"Resume"), - OnRetry = () => Logger.Log(@"Retry"), - OnQuit = () => Logger.Log(@"Quit") }); + + pauseOverlay.AddButton(@"Continue", Color4.Green, delegate { Logger.Log(@"Resume"); }); + pauseOverlay.AddButton(@"Retry", Color4.Yellow, delegate { Logger.Log(@"Retry"); }); + pauseOverlay.AddButton(@"Quit to Main Menu", new Color4(170, 27, 39, 255), delegate { Logger.Log(@"Quit"); }); + AddButton("Pause", pauseOverlay.Show); AddButton("Add Retry", delegate { diff --git a/osu.Game/Screens/Play/FailDialog.cs b/osu.Game/Screens/Play/FailDialog.cs deleted file mode 100644 index 4bdd9d94d3..0000000000 --- a/osu.Game/Screens/Play/FailDialog.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Screens; -using osu.Framework.Graphics; -using osu.Game.Graphics.Sprites; -using osu.Game.Screens.Backgrounds; -using OpenTK; -using OpenTK.Graphics; - -namespace osu.Game.Screens.Play -{ - internal class FailDialog : OsuScreen - { - protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap); - - private static readonly Vector2 background_blur = new Vector2(20); - - public FailDialog() - { - Add(new OsuSpriteText - { - Text = "You failed!", - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - TextSize = 50 - }); - } - - protected override void OnEntering(Screen last) - { - base.OnEntering(last); - Background.Schedule(() => (Background as BackgroundScreenBeatmap)?.BlurTo(background_blur, 1000)); - } - - protected override bool OnExiting(Screen next) - { - Background.Schedule(() => Background.FadeColour(Color4.White, 500)); - return base.OnExiting(next); - } - } -} diff --git a/osu.Game/Screens/Play/FailOverlay.cs b/osu.Game/Screens/Play/FailOverlay.cs new file mode 100644 index 0000000000..cf0deb21c7 --- /dev/null +++ b/osu.Game/Screens/Play/FailOverlay.cs @@ -0,0 +1,49 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Transforms; +using osu.Framework.Input; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Screens.Play.Pause; +using OpenTK; +using OpenTK.Graphics; +using OpenTK.Input; + +namespace osu.Game.Screens.Play +{ + public class FailOverlay : PauseOverlay + { + public Action OnQuit; + + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + if (args.Key == Key.Escape) + { + if (State == Visibility.Hidden) return false; + quit(); + return true; + } + + return base.OnKeyDown(state, args); + } + + private void quit() + { + OnQuit?.Invoke(); + Hide(); + } + + public FailOverlay() + { + title.Text = @"failed"; + description.Text = @"you're dead, try again?"; + } + } +} diff --git a/osu.Game/Screens/Play/PauseOverlay.cs b/osu.Game/Screens/Play/PauseOverlay.cs index 1cc6f9cf02..e79f9362b2 100644 --- a/osu.Game/Screens/Play/PauseOverlay.cs +++ b/osu.Game/Screens/Play/PauseOverlay.cs @@ -27,8 +27,11 @@ namespace osu.Game.Screens.Play protected override bool HideOnEscape => false; public Action OnResume; - public Action OnRetry; - public Action OnQuit; + + protected OsuSpriteText title; + protected OsuSpriteText description; + + private FillFlowContainer buttons; public int Retries { @@ -92,9 +95,33 @@ namespace osu.Game.Screens.Play return base.OnKeyDown(state, args); } - [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void resume() { + OnResume?.Invoke(); + Hide(); + } + + public void AddButton(string text, Color4 colour, Action action) + { + buttons.Add(new PauseButton + { + Text = text, + ButtonColour = colour, + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + Height = button_height, + Action = delegate { + action?.Invoke(); + Hide(); + } + }); + } + + public PauseOverlay() + { + AlwaysReceiveInput = true; + + RelativeSizeAxes = Axes.Both; Children = new Drawable[] { new Box @@ -123,7 +150,7 @@ namespace osu.Game.Screens.Play Spacing = new Vector2(0, 20), Children = new Drawable[] { - new OsuSpriteText + title = new OsuSpriteText { Text = @"paused", Font = @"Exo2.0-Medium", @@ -131,11 +158,11 @@ namespace osu.Game.Screens.Play Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, TextSize = 30, - Colour = colours.Yellow, + Colour = Color4.Yellow, Shadow = true, ShadowColour = new Color4(0, 0, 0, 0.25f) }, - new OsuSpriteText + description = new OsuSpriteText { Text = @"you're not going to do what i think you're going to do, are ya?", Origin = Anchor.TopCentre, @@ -145,12 +172,13 @@ namespace osu.Game.Screens.Play } } }, - new FillFlowContainer + buttons = new FillFlowContainer { Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, Masking = true, EdgeEffect = new EdgeEffect { @@ -158,38 +186,6 @@ namespace osu.Game.Screens.Play Colour = Color4.Black.Opacity(0.6f), Radius = 50 }, - Children = new Drawable[] - { - new ResumeButton - { - Origin = Anchor.TopCentre, - Anchor = Anchor.TopCentre, - Height = button_height, - Action = resume - }, - new RetryButton - { - Origin = Anchor.TopCentre, - Anchor = Anchor.TopCentre, - Height = button_height, - Action = delegate - { - OnRetry?.Invoke(); - Hide(); - } - }, - new QuitButton - { - Origin = Anchor.TopCentre, - Anchor = Anchor.TopCentre, - Height = button_height, - Action = delegate - { - OnQuit?.Invoke(); - Hide(); - } - } - } }, retryCounterContainer = new FillFlowContainer { @@ -209,17 +205,5 @@ namespace osu.Game.Screens.Play Retries = 0; } - - private void resume() - { - OnResume?.Invoke(); - Hide(); - } - - public PauseOverlay() - { - AlwaysReceiveInput = true; - RelativeSizeAxes = Axes.Both; - } } } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 702f907428..c4b37647cb 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -24,6 +24,7 @@ using osu.Game.Screens.Ranking; using System; using System.Linq; using osu.Game.Modes.Scoring; +using osu.Game.Graphics; namespace osu.Game.Screens.Play { @@ -33,7 +34,7 @@ namespace osu.Game.Screens.Play internal override bool ShowOverlays => false; - internal override bool HasLocalCursorDisplayed => !hasReplayLoaded && !IsPaused; + internal override bool HasLocalCursorDisplayed => !hasReplayLoaded && !IsPaused && !IsFailed; private bool hasReplayLoaded => hitRenderer.InputManager.ReplayInputHandler != null; @@ -41,6 +42,8 @@ namespace osu.Game.Screens.Play public bool IsPaused { get; private set; } + public bool IsFailed { get; private set; } + public int RestartCount; private const double pause_cooldown = 1000; @@ -60,9 +63,10 @@ namespace osu.Game.Screens.Play private HudOverlay hudOverlay; private PauseOverlay pauseOverlay; + private FailOverlay failOverlay; [BackgroundDependencyLoader] - private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuConfigManager config) + private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuConfigManager config, OsuColour colours) { var beatmap = Beatmap.Beatmap; @@ -129,9 +133,19 @@ namespace osu.Game.Screens.Play Delay(400); Schedule(Resume); }, - OnRetry = Restart, - OnQuit = Exit }; + pauseOverlay.AddButton(@"Continue", colours.Green, delegate { Delay(400); Schedule(Resume); }); + pauseOverlay.AddButton(@"Retry", colours.YellowDark, Restart); + pauseOverlay.AddButton(@"Quit to Main Menu", new Color4(170, 27, 39, 255), Exit); + + + failOverlay = new FailOverlay + { + Depth = -1, + OnQuit = Exit, + }; + failOverlay.AddButton(@"Retry", colours.YellowDark, Restart); + failOverlay.AddButton(@"Quit to Main Menu", new Color4(170, 27, 39, 255), Exit); if (ReplayInputHandler != null) @@ -161,7 +175,8 @@ namespace osu.Game.Screens.Play } }, hudOverlay, - pauseOverlay + pauseOverlay, + failOverlay }; } @@ -261,15 +276,13 @@ namespace osu.Game.Screens.Play private void onFail() { - Content.FadeColour(Color4.Red, 500); sourceClock.Stop(); Delay(500); - Schedule(delegate - { - ValidForResume = false; - Push(new FailDialog()); - }); + + IsFailed = true; + failOverlay.Retries = RestartCount; + failOverlay.Show(); } protected override void OnEntering(Screen last) @@ -339,6 +352,6 @@ namespace osu.Game.Screens.Play public ReplayInputHandler ReplayInputHandler; - protected override bool OnWheel(InputState state) => mouseWheelDisabled.Value && !IsPaused; + protected override bool OnWheel(InputState state) => mouseWheelDisabled.Value && !IsPaused && !IsFailed; } } \ No newline at end of file diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 32dd814fdc..da69e85cab 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -194,8 +194,10 @@ - + + + @@ -331,12 +333,8 @@ - - - - @@ -396,4 +394,4 @@ --> - + \ No newline at end of file From 457f5c6a890a037dfb3b8b05da6e99146689953e Mon Sep 17 00:00:00 2001 From: Andrey Zavadskiy Date: Tue, 28 Mar 2017 04:58:30 +0300 Subject: [PATCH 03/62] Removed unised using statement --- osu.Game/Screens/Play/Pause/PauseButton.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Play/Pause/PauseButton.cs b/osu.Game/Screens/Play/Pause/PauseButton.cs index 06e1308c43..a6ae5ebe39 100644 --- a/osu.Game/Screens/Play/Pause/PauseButton.cs +++ b/osu.Game/Screens/Play/Pause/PauseButton.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Game.Graphics; From 110d43bc25f6c4f451b3c749d025ef8cd69511c0 Mon Sep 17 00:00:00 2001 From: Andrey Zavadskiy Date: Tue, 28 Mar 2017 05:12:04 +0300 Subject: [PATCH 04/62] fixes --- osu.Game/Screens/Play/FailOverlay.cs | 10 ---------- osu.Game/Screens/Play/Pause/PauseButton.cs | 2 +- osu.Game/Screens/Play/PauseOverlay.cs | 2 -- 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/osu.Game/Screens/Play/FailOverlay.cs b/osu.Game/Screens/Play/FailOverlay.cs index cf0deb21c7..2799954a8b 100644 --- a/osu.Game/Screens/Play/FailOverlay.cs +++ b/osu.Game/Screens/Play/FailOverlay.cs @@ -2,18 +2,8 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using osu.Framework.Allocation; -using osu.Framework.Extensions.Color4Extensions; -using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Transforms; using osu.Framework.Input; -using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; -using osu.Game.Screens.Play.Pause; -using OpenTK; -using OpenTK.Graphics; using OpenTK.Input; namespace osu.Game.Screens.Play diff --git a/osu.Game/Screens/Play/Pause/PauseButton.cs b/osu.Game/Screens/Play/Pause/PauseButton.cs index a6ae5ebe39..afe06edb2e 100644 --- a/osu.Game/Screens/Play/Pause/PauseButton.cs +++ b/osu.Game/Screens/Play/Pause/PauseButton.cs @@ -11,7 +11,7 @@ namespace osu.Game.Screens.Play.Pause public class PauseButton : DialogButton { [BackgroundDependencyLoader] - private void load(AudioManager audio, OsuColour colours) + private void load(AudioManager audio) { SampleHover = audio.Sample.Get(@"Menu/menuclick"); SampleClick = audio.Sample.Get(@"Menu/menuback"); diff --git a/osu.Game/Screens/Play/PauseOverlay.cs b/osu.Game/Screens/Play/PauseOverlay.cs index e79f9362b2..f11a0ef957 100644 --- a/osu.Game/Screens/Play/PauseOverlay.cs +++ b/osu.Game/Screens/Play/PauseOverlay.cs @@ -2,14 +2,12 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transforms; using osu.Framework.Input; -using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Screens.Play.Pause; using OpenTK; From c4500fa270ca3f5cf99c49d89a9a190aaa9c43f5 Mon Sep 17 00:00:00 2001 From: Andrey Zavadskiy Date: Tue, 28 Mar 2017 05:19:32 +0300 Subject: [PATCH 05/62] fixes --- .../Tests/TestCasePauseOverlay.cs | 1 - osu.Game/Screens/Play/FailOverlay.cs | 4 ++-- osu.Game/Screens/Play/Pause/PauseButton.cs | 1 - osu.Game/Screens/Play/PauseOverlay.cs | 12 ++++++------ 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs index 32f3380086..ebb651adb5 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs @@ -4,7 +4,6 @@ using OpenTK.Graphics; using osu.Framework.Logging; using osu.Framework.Screens.Testing; -using osu.Game.Graphics; using osu.Game.Screens.Play; namespace osu.Desktop.VisualTests.Tests diff --git a/osu.Game/Screens/Play/FailOverlay.cs b/osu.Game/Screens/Play/FailOverlay.cs index 2799954a8b..b722d9d338 100644 --- a/osu.Game/Screens/Play/FailOverlay.cs +++ b/osu.Game/Screens/Play/FailOverlay.cs @@ -32,8 +32,8 @@ namespace osu.Game.Screens.Play public FailOverlay() { - title.Text = @"failed"; - description.Text = @"you're dead, try again?"; + Title.Text = @"failed"; + Description.Text = @"you're dead, try again?"; } } } diff --git a/osu.Game/Screens/Play/Pause/PauseButton.cs b/osu.Game/Screens/Play/Pause/PauseButton.cs index afe06edb2e..7698913ea5 100644 --- a/osu.Game/Screens/Play/Pause/PauseButton.cs +++ b/osu.Game/Screens/Play/Pause/PauseButton.cs @@ -3,7 +3,6 @@ using osu.Framework.Allocation; using osu.Framework.Audio; -using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; namespace osu.Game.Screens.Play.Pause diff --git a/osu.Game/Screens/Play/PauseOverlay.cs b/osu.Game/Screens/Play/PauseOverlay.cs index f11a0ef957..dec59fb63b 100644 --- a/osu.Game/Screens/Play/PauseOverlay.cs +++ b/osu.Game/Screens/Play/PauseOverlay.cs @@ -26,10 +26,10 @@ namespace osu.Game.Screens.Play public Action OnResume; - protected OsuSpriteText title; - protected OsuSpriteText description; + protected OsuSpriteText Title; + protected OsuSpriteText Description; - private FillFlowContainer buttons; + private readonly FillFlowContainer buttons; public int Retries { @@ -69,7 +69,7 @@ namespace osu.Game.Screens.Play } } - private FillFlowContainer retryCounterContainer; + private readonly FillFlowContainer retryCounterContainer; public override bool HandleInput => State == Visibility.Visible; @@ -148,7 +148,7 @@ namespace osu.Game.Screens.Play Spacing = new Vector2(0, 20), Children = new Drawable[] { - title = new OsuSpriteText + Title = new OsuSpriteText { Text = @"paused", Font = @"Exo2.0-Medium", @@ -160,7 +160,7 @@ namespace osu.Game.Screens.Play Shadow = true, ShadowColour = new Color4(0, 0, 0, 0.25f) }, - description = new OsuSpriteText + Description = new OsuSpriteText { Text = @"you're not going to do what i think you're going to do, are ya?", Origin = Anchor.TopCentre, From 9774f826abae909f30598d8115179c1693658db2 Mon Sep 17 00:00:00 2001 From: Andrey Zavadskiy Date: Tue, 28 Mar 2017 06:08:31 +0300 Subject: [PATCH 06/62] Pause and fail overlays -> StopOverlay --- .../Tests/TestCasePauseOverlay.cs | 8 ++-- osu.Game/Screens/Play/FailOverlay.cs | 39 ------------------- osu.Game/Screens/Play/Player.cs | 16 +++++--- .../Play/{PauseOverlay.cs => StopOverlay.cs} | 36 +++++++++++------ osu.Game/osu.Game.csproj | 3 +- 5 files changed, 40 insertions(+), 62 deletions(-) delete mode 100644 osu.Game/Screens/Play/FailOverlay.cs rename osu.Game/Screens/Play/{PauseOverlay.cs => StopOverlay.cs} (88%) diff --git a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs index ebb651adb5..34c0d875b4 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs @@ -12,17 +12,19 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Tests the pause overlay"; - private PauseOverlay pauseOverlay; + private StopOverlay pauseOverlay; private int retryCount; public override void Reset() { base.Reset(); - Add(pauseOverlay = new PauseOverlay + Add(pauseOverlay = new StopOverlay { Depth = -1, - OnResume = () => Logger.Log(@"Resume"), + OnEscPressed = () => Logger.Log(@"Resume"), + Title = @"paused", + Description = @"you're not going to do what i think you're going to do, are ya?", }); pauseOverlay.AddButton(@"Continue", Color4.Green, delegate { Logger.Log(@"Resume"); }); diff --git a/osu.Game/Screens/Play/FailOverlay.cs b/osu.Game/Screens/Play/FailOverlay.cs deleted file mode 100644 index b722d9d338..0000000000 --- a/osu.Game/Screens/Play/FailOverlay.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System; -using osu.Framework.Graphics.Containers; -using osu.Framework.Input; -using OpenTK.Input; - -namespace osu.Game.Screens.Play -{ - public class FailOverlay : PauseOverlay - { - public Action OnQuit; - - protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) - { - if (args.Key == Key.Escape) - { - if (State == Visibility.Hidden) return false; - quit(); - return true; - } - - return base.OnKeyDown(state, args); - } - - private void quit() - { - OnQuit?.Invoke(); - Hide(); - } - - public FailOverlay() - { - Title.Text = @"failed"; - Description.Text = @"you're dead, try again?"; - } - } -} diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index c4b37647cb..b6c185853a 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -62,8 +62,8 @@ namespace osu.Game.Screens.Play private SkipButton skipButton; private HudOverlay hudOverlay; - private PauseOverlay pauseOverlay; - private FailOverlay failOverlay; + private StopOverlay pauseOverlay; + private StopOverlay failOverlay; [BackgroundDependencyLoader] private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuConfigManager config, OsuColour colours) @@ -125,24 +125,28 @@ namespace osu.Game.Screens.Play hudOverlay.KeyCounter.Add(ruleset.CreateGameplayKeys()); hudOverlay.BindProcessor(scoreProcessor); - pauseOverlay = new PauseOverlay + pauseOverlay = new StopOverlay { Depth = -1, - OnResume = delegate + OnEscPressed = delegate { Delay(400); Schedule(Resume); }, + Title = @"paused", + Description = @"you're not going to do what i think you're going to do, are ya?", }; pauseOverlay.AddButton(@"Continue", colours.Green, delegate { Delay(400); Schedule(Resume); }); pauseOverlay.AddButton(@"Retry", colours.YellowDark, Restart); pauseOverlay.AddButton(@"Quit to Main Menu", new Color4(170, 27, 39, 255), Exit); - failOverlay = new FailOverlay + failOverlay = new StopOverlay { Depth = -1, - OnQuit = Exit, + OnEscPressed = Exit, + Title = @"failed", + Description = @"you're dead, try again?", }; failOverlay.AddButton(@"Retry", colours.YellowDark, Restart); failOverlay.AddButton(@"Quit to Main Menu", new Color4(170, 27, 39, 255), Exit); diff --git a/osu.Game/Screens/Play/PauseOverlay.cs b/osu.Game/Screens/Play/StopOverlay.cs similarity index 88% rename from osu.Game/Screens/Play/PauseOverlay.cs rename to osu.Game/Screens/Play/StopOverlay.cs index dec59fb63b..dd5986b9c8 100644 --- a/osu.Game/Screens/Play/PauseOverlay.cs +++ b/osu.Game/Screens/Play/StopOverlay.cs @@ -16,7 +16,7 @@ using OpenTK.Input; namespace osu.Game.Screens.Play { - public class PauseOverlay : OverlayContainer + public class StopOverlay : OverlayContainer { private const int transition_duration = 200; private const int button_height = 70; @@ -24,10 +24,22 @@ namespace osu.Game.Screens.Play protected override bool HideOnEscape => false; - public Action OnResume; + public Action OnEscPressed; - protected OsuSpriteText Title; - protected OsuSpriteText Description; + private string title; + private string description; + + public string Title + { + get { return title; } + set { title = value; } + } + + public string Description + { + get { return description; } + set { description = value; } + } private readonly FillFlowContainer buttons; @@ -86,16 +98,16 @@ namespace osu.Game.Screens.Play if (args.Key == Key.Escape) { if (State == Visibility.Hidden) return false; - resume(); + onEscPressed(); return true; } return base.OnKeyDown(state, args); } - private void resume() + private void onEscPressed() { - OnResume?.Invoke(); + OnEscPressed?.Invoke(); Hide(); } @@ -115,7 +127,7 @@ namespace osu.Game.Screens.Play }); } - public PauseOverlay() + public StopOverlay() { AlwaysReceiveInput = true; @@ -148,9 +160,9 @@ namespace osu.Game.Screens.Play Spacing = new Vector2(0, 20), Children = new Drawable[] { - Title = new OsuSpriteText + new OsuSpriteText { - Text = @"paused", + Text = Title, Font = @"Exo2.0-Medium", Spacing = new Vector2(5, 0), Origin = Anchor.TopCentre, @@ -160,9 +172,9 @@ namespace osu.Game.Screens.Play Shadow = true, ShadowColour = new Color4(0, 0, 0, 0.25f) }, - Description = new OsuSpriteText + new OsuSpriteText { - Text = @"you're not going to do what i think you're going to do, are ya?", + Text = Description, Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, Shadow = true, diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index da69e85cab..c81ea4b5d1 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -194,14 +194,13 @@ - - + From 62693a6a59de583006fd2f9f8cd462b158fef14e Mon Sep 17 00:00:00 2001 From: Andrey Zavadskiy Date: Tue, 28 Mar 2017 10:49:58 +0300 Subject: [PATCH 07/62] Again separate classes --- .../Tests/TestCasePauseOverlay.cs | 12 +++---- .../Play/{StopOverlay.cs => FailOverlay.cs} | 19 +++++----- osu.Game/Screens/Play/PauseOverlay.cs | 35 +++++++++++++++++++ osu.Game/Screens/Play/Player.cs | 21 +++++------ osu.Game/osu.Game.csproj | 3 +- 5 files changed, 60 insertions(+), 30 deletions(-) rename osu.Game/Screens/Play/{StopOverlay.cs => FailOverlay.cs} (93%) create mode 100644 osu.Game/Screens/Play/PauseOverlay.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs index 34c0d875b4..5b8bcf3d1b 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs @@ -12,25 +12,23 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Tests the pause overlay"; - private StopOverlay pauseOverlay; + private PauseOverlay pauseOverlay; private int retryCount; public override void Reset() { base.Reset(); - Add(pauseOverlay = new StopOverlay + Add(pauseOverlay = new PauseOverlay { Depth = -1, - OnEscPressed = () => Logger.Log(@"Resume"), + OnResume = () => Logger.Log(@"Resume"), + OnRetry = () => Logger.Log(@"Retry"), + OnQuit = () => Logger.Log(@"Quit"), Title = @"paused", Description = @"you're not going to do what i think you're going to do, are ya?", }); - pauseOverlay.AddButton(@"Continue", Color4.Green, delegate { Logger.Log(@"Resume"); }); - pauseOverlay.AddButton(@"Retry", Color4.Yellow, delegate { Logger.Log(@"Retry"); }); - pauseOverlay.AddButton(@"Quit to Main Menu", new Color4(170, 27, 39, 255), delegate { Logger.Log(@"Quit"); }); - AddButton("Pause", pauseOverlay.Show); AddButton("Add Retry", delegate { diff --git a/osu.Game/Screens/Play/StopOverlay.cs b/osu.Game/Screens/Play/FailOverlay.cs similarity index 93% rename from osu.Game/Screens/Play/StopOverlay.cs rename to osu.Game/Screens/Play/FailOverlay.cs index dd5986b9c8..35a25c5207 100644 --- a/osu.Game/Screens/Play/StopOverlay.cs +++ b/osu.Game/Screens/Play/FailOverlay.cs @@ -13,10 +13,11 @@ using osu.Game.Screens.Play.Pause; using OpenTK; using OpenTK.Graphics; using OpenTK.Input; +using osu.Game.Graphics; namespace osu.Game.Screens.Play { - public class StopOverlay : OverlayContainer + public class FailOverlay : OverlayContainer { private const int transition_duration = 200; private const int button_height = 70; @@ -24,7 +25,8 @@ namespace osu.Game.Screens.Play protected override bool HideOnEscape => false; - public Action OnEscPressed; + public Action OnRetry; + public Action OnQuit; private string title; private string description; @@ -98,19 +100,13 @@ namespace osu.Game.Screens.Play if (args.Key == Key.Escape) { if (State == Visibility.Hidden) return false; - onEscPressed(); + OnQuit(); return true; } return base.OnKeyDown(state, args); } - private void onEscPressed() - { - OnEscPressed?.Invoke(); - Hide(); - } - public void AddButton(string text, Color4 colour, Action action) { buttons.Add(new PauseButton @@ -127,7 +123,7 @@ namespace osu.Game.Screens.Play }); } - public StopOverlay() + public FailOverlay() { AlwaysReceiveInput = true; @@ -214,6 +210,9 @@ namespace osu.Game.Screens.Play }; Retries = 0; + + AddButton(@"Retry", Color4.Yellow, OnRetry); + AddButton(@"Quit to Main Menu", new Color4(170, 27, 39, 255), OnQuit); } } } diff --git a/osu.Game/Screens/Play/PauseOverlay.cs b/osu.Game/Screens/Play/PauseOverlay.cs new file mode 100644 index 0000000000..a1564c6aac --- /dev/null +++ b/osu.Game/Screens/Play/PauseOverlay.cs @@ -0,0 +1,35 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using osu.Framework.Input; +using osu.Game.Graphics; +using OpenTK.Input; +using osu.Framework.Graphics.Containers; +using OpenTK.Graphics; + +namespace osu.Game.Screens.Play +{ + public class PauseOverlay : FailOverlay + { + public Action OnResume; + + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + if (args.Key == Key.Escape) + { + if (State == Visibility.Hidden) return false; + OnResume(); + return true; + } + + return base.OnKeyDown(state, args); + } + + public PauseOverlay() + { + AddButton(@"Continue", Color4.Green, OnResume); + } + } +} + \ No newline at end of file diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index b6c185853a..51faa135f7 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -62,8 +62,8 @@ namespace osu.Game.Screens.Play private SkipButton skipButton; private HudOverlay hudOverlay; - private StopOverlay pauseOverlay; - private StopOverlay failOverlay; + private PauseOverlay pauseOverlay; + private FailOverlay failOverlay; [BackgroundDependencyLoader] private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuConfigManager config, OsuColour colours) @@ -125,31 +125,28 @@ namespace osu.Game.Screens.Play hudOverlay.KeyCounter.Add(ruleset.CreateGameplayKeys()); hudOverlay.BindProcessor(scoreProcessor); - pauseOverlay = new StopOverlay + pauseOverlay = new PauseOverlay { Depth = -1, - OnEscPressed = delegate + OnResume = delegate { Delay(400); Schedule(Resume); }, + OnRetry = Restart, + OnQuit = Exit, Title = @"paused", Description = @"you're not going to do what i think you're going to do, are ya?", }; - pauseOverlay.AddButton(@"Continue", colours.Green, delegate { Delay(400); Schedule(Resume); }); - pauseOverlay.AddButton(@"Retry", colours.YellowDark, Restart); - pauseOverlay.AddButton(@"Quit to Main Menu", new Color4(170, 27, 39, 255), Exit); - - failOverlay = new StopOverlay + failOverlay = new FailOverlay { Depth = -1, - OnEscPressed = Exit, + OnRetry = Restart, + OnQuit = Exit, Title = @"failed", Description = @"you're dead, try again?", }; - failOverlay.AddButton(@"Retry", colours.YellowDark, Restart); - failOverlay.AddButton(@"Quit to Main Menu", new Color4(170, 27, 39, 255), Exit); if (ReplayInputHandler != null) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index c81ea4b5d1..e3faa6544f 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -194,13 +194,14 @@ + + - From 85c2184170da10efc9d97cddc9e99fa6afb1b1ae Mon Sep 17 00:00:00 2001 From: Andrey Zavadskiy Date: Tue, 28 Mar 2017 11:33:56 +0300 Subject: [PATCH 08/62] Fixes --- osu.Game/Screens/Play/FailOverlay.cs | 24 +++++++++++++++++------- osu.Game/Screens/Play/PauseOverlay.cs | 6 ++++-- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/osu.Game/Screens/Play/FailOverlay.cs b/osu.Game/Screens/Play/FailOverlay.cs index 35a25c5207..4ff6c4c18d 100644 --- a/osu.Game/Screens/Play/FailOverlay.cs +++ b/osu.Game/Screens/Play/FailOverlay.cs @@ -14,6 +14,7 @@ using OpenTK; using OpenTK.Graphics; using OpenTK.Input; using osu.Game.Graphics; +using osu.Framework.Allocation; namespace osu.Game.Screens.Play { @@ -43,7 +44,7 @@ namespace osu.Game.Screens.Play set { description = value; } } - private readonly FillFlowContainer buttons; + private FillFlowContainer buttons; public int Retries { @@ -83,7 +84,7 @@ namespace osu.Game.Screens.Play } } - private readonly FillFlowContainer retryCounterContainer; + private FillFlowContainer retryCounterContainer; public override bool HandleInput => State == Visibility.Visible; @@ -123,11 +124,9 @@ namespace osu.Game.Screens.Play }); } - public FailOverlay() + [BackgroundDependencyLoader] + private void load(OsuColour colours) { - AlwaysReceiveInput = true; - - RelativeSizeAxes = Axes.Both; Children = new Drawable[] { new Box @@ -211,8 +210,19 @@ namespace osu.Game.Screens.Play Retries = 0; - AddButton(@"Retry", Color4.Yellow, OnRetry); + AddButtons(colours); + } + + protected virtual void AddButtons(OsuColour colours) + { + AddButton(@"Retry", colours.YellowDark, OnRetry); AddButton(@"Quit to Main Menu", new Color4(170, 27, 39, 255), OnQuit); } + + public FailOverlay() + { + AlwaysReceiveInput = true; + RelativeSizeAxes = Axes.Both; + } } } diff --git a/osu.Game/Screens/Play/PauseOverlay.cs b/osu.Game/Screens/Play/PauseOverlay.cs index a1564c6aac..bad7050d7a 100644 --- a/osu.Game/Screens/Play/PauseOverlay.cs +++ b/osu.Game/Screens/Play/PauseOverlay.cs @@ -26,9 +26,11 @@ namespace osu.Game.Screens.Play return base.OnKeyDown(state, args); } - public PauseOverlay() + protected override void AddButtons(OsuColour colours) { - AddButton(@"Continue", Color4.Green, OnResume); + AddButton(@"Continue", colours.Green, OnResume); + AddButton(@"Retry", colours.YellowDark, OnRetry); + AddButton(@"Quit to Main Menu", new Color4(170, 27, 39, 255), OnQuit); } } } From 60be69d3b08c700c5a1f8a14ebbfb756bb237a1b Mon Sep 17 00:00:00 2001 From: Andrey Zavadskiy Date: Tue, 28 Mar 2017 11:41:08 +0300 Subject: [PATCH 09/62] Fixes --- osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs | 1 - osu.Game/Screens/Play/Player.cs | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs index 5b8bcf3d1b..f6af0acaf8 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK.Graphics; using osu.Framework.Logging; using osu.Framework.Screens.Testing; using osu.Game.Screens.Play; diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 51faa135f7..46e5902459 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK; -using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Track; @@ -66,7 +65,7 @@ namespace osu.Game.Screens.Play private FailOverlay failOverlay; [BackgroundDependencyLoader] - private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuConfigManager config, OsuColour colours) + private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuConfigManager config) { var beatmap = Beatmap.Beatmap; From 687f71e41040a8bf61f7d6b72d8e90195a3a1afa Mon Sep 17 00:00:00 2001 From: Andrey Zavadskiy Date: Tue, 28 Mar 2017 11:45:48 +0300 Subject: [PATCH 10/62] Fixes --- osu.Game/Screens/Play/FailOverlay.cs | 2 +- osu.Game/Screens/Play/Player.cs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/FailOverlay.cs b/osu.Game/Screens/Play/FailOverlay.cs index 4ff6c4c18d..86af45be76 100644 --- a/osu.Game/Screens/Play/FailOverlay.cs +++ b/osu.Game/Screens/Play/FailOverlay.cs @@ -163,7 +163,7 @@ namespace osu.Game.Screens.Play Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, TextSize = 30, - Colour = Color4.Yellow, + Colour = colours.Yellow, Shadow = true, ShadowColour = new Color4(0, 0, 0, 0.25f) }, diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 46e5902459..6ae041710d 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -23,7 +23,6 @@ using osu.Game.Screens.Ranking; using System; using System.Linq; using osu.Game.Modes.Scoring; -using osu.Game.Graphics; namespace osu.Game.Screens.Play { From cf3db49631cc2bece295676ac7b25175c8fb67aa Mon Sep 17 00:00:00 2001 From: Andrey Zavadskiy Date: Tue, 28 Mar 2017 12:09:26 +0300 Subject: [PATCH 11/62] Inherit Pause/Fail overlay from InGameOverlay --- osu.Game/Screens/Play/FailOverlay.cs | 195 +--------------------- osu.Game/Screens/Play/InGameOverlay.cs | 216 +++++++++++++++++++++++++ osu.Game/Screens/Play/PauseOverlay.cs | 2 +- osu.Game/osu.Game.csproj | 1 + 4 files changed, 219 insertions(+), 195 deletions(-) create mode 100644 osu.Game/Screens/Play/InGameOverlay.cs diff --git a/osu.Game/Screens/Play/FailOverlay.cs b/osu.Game/Screens/Play/FailOverlay.cs index 86af45be76..9fa95b008e 100644 --- a/osu.Game/Screens/Play/FailOverlay.cs +++ b/osu.Game/Screens/Play/FailOverlay.cs @@ -18,84 +18,8 @@ using osu.Framework.Allocation; namespace osu.Game.Screens.Play { - public class FailOverlay : OverlayContainer + public class FailOverlay : InGameOverlay { - private const int transition_duration = 200; - private const int button_height = 70; - private const float background_alpha = 0.75f; - - protected override bool HideOnEscape => false; - - public Action OnRetry; - public Action OnQuit; - - private string title; - private string description; - - public string Title - { - get { return title; } - set { title = value; } - } - - public string Description - { - get { return description; } - set { description = value; } - } - - private FillFlowContainer buttons; - - 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 OsuSpriteText - { - Text = "You've retried ", - Shadow = true, - ShadowColour = new Color4(0, 0, 0, 0.25f), - TextSize = 18 - }, - new OsuSpriteText - { - Text = $"{value:n0}", - Font = @"Exo2.0-Bold", - Shadow = true, - ShadowColour = new Color4(0, 0, 0, 0.25f), - TextSize = 18 - }, - new OsuSpriteText - { - Text = $" time{(value == 1 ? "" : "s")} in this session", - Shadow = true, - ShadowColour = new Color4(0, 0, 0, 0.25f), - TextSize = 18 - } - }; - } - } - } - - private FillFlowContainer retryCounterContainer; - - public override bool HandleInput => State == Visibility.Visible; - - protected override void PopIn() => FadeIn(transition_duration, EasingTypes.In); - protected override void PopOut() => FadeOut(transition_duration, EasingTypes.In); - - // Don't let mouse down events through the overlay or people can click circles while paused. - protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true; - - protected override bool OnMouseMove(InputState state) => true; - protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { if (args.Key == Key.Escape) @@ -107,122 +31,5 @@ namespace osu.Game.Screens.Play return base.OnKeyDown(state, args); } - - public void AddButton(string text, Color4 colour, Action action) - { - buttons.Add(new PauseButton - { - Text = text, - ButtonColour = colour, - Origin = Anchor.TopCentre, - Anchor = Anchor.TopCentre, - Height = button_height, - Action = delegate { - action?.Invoke(); - Hide(); - } - }); - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black, - Alpha = background_alpha, - }, - new FillFlowContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - Spacing = new Vector2(0, 50), - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Children = new Drawable[] - { - new FillFlowContainer - { - Origin = Anchor.TopCentre, - Anchor = Anchor.TopCentre, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - Spacing = new Vector2(0, 20), - Children = new Drawable[] - { - new OsuSpriteText - { - Text = Title, - Font = @"Exo2.0-Medium", - Spacing = new Vector2(5, 0), - Origin = Anchor.TopCentre, - Anchor = Anchor.TopCentre, - TextSize = 30, - Colour = colours.Yellow, - Shadow = true, - ShadowColour = new Color4(0, 0, 0, 0.25f) - }, - new OsuSpriteText - { - Text = Description, - Origin = Anchor.TopCentre, - Anchor = Anchor.TopCentre, - Shadow = true, - ShadowColour = new Color4(0, 0, 0, 0.25f) - } - } - }, - buttons = new FillFlowContainer - { - Origin = Anchor.TopCentre, - Anchor = Anchor.TopCentre, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - Masking = true, - EdgeEffect = new EdgeEffect - { - Type = EdgeEffectType.Shadow, - Colour = Color4.Black.Opacity(0.6f), - Radius = 50 - }, - }, - retryCounterContainer = new FillFlowContainer - { - Origin = Anchor.TopCentre, - Anchor = Anchor.TopCentre, - AutoSizeAxes = Axes.Both, - } - } - }, - new PauseProgressBar - { - Origin = Anchor.BottomCentre, - Anchor = Anchor.BottomCentre, - Width = 1f - } - }; - - Retries = 0; - - AddButtons(colours); - } - - protected virtual void AddButtons(OsuColour colours) - { - AddButton(@"Retry", colours.YellowDark, OnRetry); - AddButton(@"Quit to Main Menu", new Color4(170, 27, 39, 255), OnQuit); - } - - public FailOverlay() - { - AlwaysReceiveInput = true; - RelativeSizeAxes = Axes.Both; - } } } diff --git a/osu.Game/Screens/Play/InGameOverlay.cs b/osu.Game/Screens/Play/InGameOverlay.cs new file mode 100644 index 0000000000..b4efe47399 --- /dev/null +++ b/osu.Game/Screens/Play/InGameOverlay.cs @@ -0,0 +1,216 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Transforms; +using osu.Framework.Input; +using osu.Game.Graphics.Sprites; +using osu.Game.Screens.Play.Pause; +using OpenTK; +using OpenTK.Graphics; +using OpenTK.Input; +using osu.Game.Graphics; +using osu.Framework.Allocation; + +namespace osu.Game.Screens.Play +{ + public class InGameOverlay : OverlayContainer + { + private const int transition_duration = 200; + private const int button_height = 70; + private const float background_alpha = 0.75f; + + protected override bool HideOnEscape => false; + + public Action OnRetry; + public Action OnQuit; + + private string title; + private string description; + + public string Title + { + get { return title; } + set { title = value; } + } + + public string Description + { + get { return description; } + set { description = value; } + } + + private FillFlowContainer buttons; + + 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 OsuSpriteText + { + Text = "You've retried ", + Shadow = true, + ShadowColour = new Color4(0, 0, 0, 0.25f), + TextSize = 18 + }, + new OsuSpriteText + { + Text = $"{value:n0}", + Font = @"Exo2.0-Bold", + Shadow = true, + ShadowColour = new Color4(0, 0, 0, 0.25f), + TextSize = 18 + }, + new OsuSpriteText + { + Text = $" time{(value == 1 ? "" : "s")} in this session", + Shadow = true, + ShadowColour = new Color4(0, 0, 0, 0.25f), + TextSize = 18 + } + }; + } + } + } + + private FillFlowContainer retryCounterContainer; + + public override bool HandleInput => State == Visibility.Visible; + + protected override void PopIn() => FadeIn(transition_duration, EasingTypes.In); + protected override void PopOut() => FadeOut(transition_duration, EasingTypes.In); + + // Don't let mouse down events through the overlay or people can click circles while paused. + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true; + + protected override bool OnMouseMove(InputState state) => true; + + public void AddButton(string text, Color4 colour, Action action) + { + buttons.Add(new PauseButton + { + Text = text, + ButtonColour = colour, + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + Height = button_height, + Action = delegate { + action?.Invoke(); + Hide(); + } + }); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + Alpha = background_alpha, + }, + new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, 50), + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Children = new Drawable[] + { + new FillFlowContainer + { + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, 20), + Children = new Drawable[] + { + new OsuSpriteText + { + Text = Title, + Font = @"Exo2.0-Medium", + Spacing = new Vector2(5, 0), + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + TextSize = 30, + Colour = colours.Yellow, + Shadow = true, + ShadowColour = new Color4(0, 0, 0, 0.25f) + }, + new OsuSpriteText + { + Text = Description, + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + Shadow = true, + ShadowColour = new Color4(0, 0, 0, 0.25f) + } + } + }, + buttons = new FillFlowContainer + { + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Masking = true, + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Shadow, + Colour = Color4.Black.Opacity(0.6f), + Radius = 50 + }, + }, + retryCounterContainer = new FillFlowContainer + { + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + AutoSizeAxes = Axes.Both, + } + } + }, + new PauseProgressBar + { + Origin = Anchor.BottomCentre, + Anchor = Anchor.BottomCentre, + Width = 1f + } + }; + + Retries = 0; + + AddButtons(colours); + } + + protected virtual void AddButtons(OsuColour colours) + { + AddButton(@"Retry", colours.YellowDark, OnRetry); + AddButton(@"Quit to Main Menu", new Color4(170, 27, 39, 255), OnQuit); + } + + public InGameOverlay() + { + AlwaysReceiveInput = true; + RelativeSizeAxes = Axes.Both; + } + } +} diff --git a/osu.Game/Screens/Play/PauseOverlay.cs b/osu.Game/Screens/Play/PauseOverlay.cs index bad7050d7a..f359fc3a78 100644 --- a/osu.Game/Screens/Play/PauseOverlay.cs +++ b/osu.Game/Screens/Play/PauseOverlay.cs @@ -10,7 +10,7 @@ using OpenTK.Graphics; namespace osu.Game.Screens.Play { - public class PauseOverlay : FailOverlay + public class PauseOverlay : InGameOverlay { public Action OnResume; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index e3faa6544f..c049b810f0 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -195,6 +195,7 @@ + From 91e18cc63e673e8bd865c811b892dc66cf9a2053 Mon Sep 17 00:00:00 2001 From: Andrey Zavadskiy Date: Tue, 28 Mar 2017 12:12:35 +0300 Subject: [PATCH 12/62] Fix usings --- osu.Game/Screens/Play/FailOverlay.cs | 11 ----------- osu.Game/Screens/Play/InGameOverlay.cs | 1 - 2 files changed, 12 deletions(-) diff --git a/osu.Game/Screens/Play/FailOverlay.cs b/osu.Game/Screens/Play/FailOverlay.cs index 9fa95b008e..906e25d14f 100644 --- a/osu.Game/Screens/Play/FailOverlay.cs +++ b/osu.Game/Screens/Play/FailOverlay.cs @@ -1,20 +1,9 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; -using osu.Framework.Extensions.Color4Extensions; -using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Transforms; using osu.Framework.Input; -using osu.Game.Graphics.Sprites; -using osu.Game.Screens.Play.Pause; -using OpenTK; -using OpenTK.Graphics; using OpenTK.Input; -using osu.Game.Graphics; -using osu.Framework.Allocation; namespace osu.Game.Screens.Play { diff --git a/osu.Game/Screens/Play/InGameOverlay.cs b/osu.Game/Screens/Play/InGameOverlay.cs index b4efe47399..ba2027b4d5 100644 --- a/osu.Game/Screens/Play/InGameOverlay.cs +++ b/osu.Game/Screens/Play/InGameOverlay.cs @@ -12,7 +12,6 @@ using osu.Game.Graphics.Sprites; using osu.Game.Screens.Play.Pause; using OpenTK; using OpenTK.Graphics; -using OpenTK.Input; using osu.Game.Graphics; using osu.Framework.Allocation; From 1c166bdf32da0d0741b367ac335788ccea5aaed5 Mon Sep 17 00:00:00 2001 From: Andrey Zavadskiy Date: Tue, 28 Mar 2017 15:03:12 +0300 Subject: [PATCH 13/62] Edited pause visual test --- ...seOverlay.cs => TestCaseInGameOverlays.cs} | 30 +++++++++++++++++-- .../osu.Desktop.VisualTests.csproj | 6 ++-- 2 files changed, 29 insertions(+), 7 deletions(-) rename osu.Desktop.VisualTests/Tests/{TestCasePauseOverlay.cs => TestCaseInGameOverlays.cs} (51%) diff --git a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCaseInGameOverlays.cs similarity index 51% rename from osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs rename to osu.Desktop.VisualTests/Tests/TestCaseInGameOverlays.cs index f6af0acaf8..e0512f4747 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseInGameOverlays.cs @@ -1,17 +1,19 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Graphics.Containers; using osu.Framework.Logging; using osu.Framework.Screens.Testing; using osu.Game.Screens.Play; namespace osu.Desktop.VisualTests.Tests { - internal class TestCasePauseOverlay : TestCase + internal class TestCaseInGameOverlays : TestCase { - public override string Description => @"Tests the pause overlay"; + public override string Description => @"Tests the pause and fail overlays"; private PauseOverlay pauseOverlay; + private FailOverlay failOverlay; private int retryCount; public override void Reset() @@ -27,12 +29,34 @@ namespace osu.Desktop.VisualTests.Tests Title = @"paused", Description = @"you're not going to do what i think you're going to do, are ya?", }); + Add(failOverlay = new FailOverlay + { + Depth = -1, + OnRetry = () => Logger.Log(@"Retry"), + OnQuit = () => Logger.Log(@"Quit"), + Title = @"failed", + Description = @"you're dead, try again?", + }); - AddButton("Pause", pauseOverlay.Show); + AddButton("Pause", delegate { + if(failOverlay.State == Visibility.Visible) + { + failOverlay.Hide(); + } + pauseOverlay.Show(); + }); + AddButton("Fail", delegate { + if (pauseOverlay.State == Visibility.Visible) + { + pauseOverlay.Hide(); + } + failOverlay.Show(); + }); AddButton("Add Retry", delegate { retryCount++; pauseOverlay.Retries = retryCount; + failOverlay.Retries = retryCount; }); retryCount = 0; diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index f1b4a99510..f52fea22c9 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -185,6 +185,7 @@ + @@ -202,7 +203,6 @@ - @@ -212,9 +212,7 @@ - - - +