From fe265c01cbd04d4c42c505a0296f048db9367689 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 27 Jan 2017 05:24:49 -0400 Subject: [PATCH 01/40] Added current work on pause overlay --- .../Tests/TestCasePauseOverlay.cs | 28 +++++ osu.Game/Overlays/Pause/PauseButton.cs | 54 +++++++++ osu.Game/Overlays/Pause/PauseOverlay.cs | 114 ++++++++++++++++++ osu.Game/Screens/Play/Player.cs | 39 +++++- 4 files changed, 232 insertions(+), 3 deletions(-) create mode 100644 osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs create mode 100644 osu.Game/Overlays/Pause/PauseButton.cs create mode 100644 osu.Game/Overlays/Pause/PauseOverlay.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs new file mode 100644 index 0000000000..089d6f3ebd --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs @@ -0,0 +1,28 @@ +using System; +using osu.Framework.GameModes.Testing; +using osu.Framework.Graphics; +using osu.Game.Graphics.UserInterface; +using OpenTK.Input; +using osu.Game.Overlays.Pause; +using osu.Framework.Graphics.Containers; + + +namespace osu.Desktop.VisualTests.Tests +{ + class TestCasePauseOverlay : TestCase + { + public override string Name => @"PauseOverlay"; + + public override string Description => @"Tests the pause overlay"; + + private PauseOverlay pauseOverlay; + + public override void Reset() + { + base.Reset(); + + Children = new[] { pauseOverlay = new PauseOverlay() }; + pauseOverlay.ToggleVisibility(); + } + } +} \ No newline at end of file diff --git a/osu.Game/Overlays/Pause/PauseButton.cs b/osu.Game/Overlays/Pause/PauseButton.cs new file mode 100644 index 0000000000..cddf9a8bef --- /dev/null +++ b/osu.Game/Overlays/Pause/PauseButton.cs @@ -0,0 +1,54 @@ +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Graphics.UserInterface; +using osu.Framework.Graphics.Transformations; +using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Audio.Sample; + +namespace osu.Game.Overlays.Pause +{ + public class PauseButton : Button + { + private float height = 100; + private float width = 300; + private float expandedWidth = 350; + + private AudioSample sampleClick; + private AudioSample sampleHover; + + [BackgroundDependencyLoader] + private void load(AudioManager audio) + { + // Placeholder till the actual samples are added to osu-resources + sampleClick = audio.Sample.Get(@"Menu/menuhit"); + sampleHover = audio.Sample.Get(@"Menu/menuclick"); + } + + protected override bool OnMouseDown(Framework.Input.InputState state, Framework.Graphics.MouseDownEventArgs args) + { + sampleClick.Play(); + + return true; + } + + protected override bool OnHover(Framework.Input.InputState state) + { + sampleHover.Play(); + ResizeTo(new Vector2(expandedWidth, height), 500, EasingTypes.OutElastic); + + return true; + } + + protected override void OnHoverLost(Framework.Input.InputState state) + { + ResizeTo(new Vector2(width, height), 500, EasingTypes.OutElastic); + } + + public PauseButton() + { Size = new Vector2(width, height); + Colour = Color4.Black; + Shear = new Vector2(0.1f, 0); + } + } +} diff --git a/osu.Game/Overlays/Pause/PauseOverlay.cs b/osu.Game/Overlays/Pause/PauseOverlay.cs new file mode 100644 index 0000000000..9bc5d802ba --- /dev/null +++ b/osu.Game/Overlays/Pause/PauseOverlay.cs @@ -0,0 +1,114 @@ +using System; +using OpenTK; +using OpenTK.Input; +using OpenTK.Graphics; +using osu.Game.Screens; +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.UserInterface; +using osu.Framework.Graphics.Transformations; + + +namespace osu.Game.Overlays.Pause +{ + public class PauseOverlay : OverlayContainer + { + private bool paused = false; + + public event Action OnPause; + public event Action OnPlay; + public event Action OnRetry; + public event Action OnQuit; + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + Alpha = 0.6f, + }, + new PauseButton + { + Text = @"Resume", + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Position = new Vector2(0, -200), + Action = Play + }, + new PauseButton + { + Text = @"Retry", + Origin = Anchor.Centre, + Anchor = Anchor.Centre + }, + new PauseButton + { + Text = @"Quit", + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Position = new Vector2(0, 200) + } + }; + } + + protected override void PopIn() + { + this.FadeTo(1, 100, EasingTypes.In); + } + + protected override void PopOut() + { + this.FadeTo(0, 100, EasingTypes.In); + } + + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + switch (args.Key) + { + case Key.Escape: + paused = !paused; + (paused ? (Action)Pause : Play)?.Invoke(); + return true; + } + return base.OnKeyDown(state, args); + } + + private void Pause() + { + paused = true; + Show(); + OnPause?.Invoke(); + } + + private void Play() + { + paused = false; + Hide(); + OnPlay?.Invoke(); + } + + private void Retry() + { + OnRetry?.Invoke(); + } + + private void Quit() + { + OnQuit?.Invoke(); + } + + public PauseOverlay() + { + RelativeSizeAxes = Axes.Both; + AutoSizeAxes = Axes.Both; + } + } +} \ No newline at end of file diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index d6594dd2be..61e9e66036 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -15,6 +15,7 @@ using osu.Game.Modes; using osu.Game.Modes.Objects; using osu.Game.Modes.Objects.Drawables; using osu.Game.Screens.Backgrounds; +using osu.Game.Overlays.Pause; using OpenTK.Input; using MouseState = osu.Framework.Input.MouseState; using OpenTK; @@ -39,7 +40,7 @@ namespace osu.Game.Screens.Play public BeatmapInfo BeatmapInfo; public PlayMode PreferredPlayMode; - + private IAdjustableClock sourceClock; private Ruleset ruleset; @@ -48,6 +49,9 @@ namespace osu.Game.Screens.Play private HitRenderer hitRenderer; private Bindable dimLevel; + private PauseOverlay pauseOverlay; + private ScoreOverlay scoreOverlay; + [BackgroundDependencyLoader] private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuGameBase game, OsuConfigManager config) { @@ -92,9 +96,13 @@ namespace osu.Game.Screens.Play ruleset = Ruleset.GetRuleset(usablePlayMode); - var scoreOverlay = ruleset.CreateScoreOverlay(); + scoreOverlay = ruleset.CreateScoreOverlay(); scoreOverlay.BindProcessor(scoreProcessor = ruleset.CreateScoreProcessor(beatmap.HitObjects.Count)); + pauseOverlay = new PauseOverlay(); + pauseOverlay.OnPause += onPause; + pauseOverlay.OnPlay += onPlay; + hitRenderer = ruleset.CreateHitRendererWith(beatmap.HitObjects); //bind HitRenderer to ScoreProcessor and ourselves (for a pass situation) @@ -119,6 +127,7 @@ namespace osu.Game.Screens.Play } }, scoreOverlay, + pauseOverlay }; } @@ -163,12 +172,25 @@ namespace osu.Game.Screens.Play }); } + private void onPause() + { + scoreOverlay.KeyCounter.IsCounting = false; + + sourceClock.Stop(); + } + + private void onPlay() + { + scoreOverlay.KeyCounter.IsCounting = true; + sourceClock.Start(); + } + protected override void OnEntering(GameMode last) { base.OnEntering(last); (Background as BackgroundModeBeatmap)?.BlurTo(Vector2.Zero, 1000); - Background?.FadeTo((100f- dimLevel)/100, 1000); + Background?.FadeTo((100f - dimLevel) / 100, 1000); Content.Alpha = 0; dimLevel.ValueChanged += dimChanged; @@ -181,6 +203,17 @@ namespace osu.Game.Screens.Play return base.OnExiting(next); } + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + if (args.Key != Key.Escape) + { + return base.OnKeyDown(state, args); + } + else { + return pauseOverlay.TriggerKeyDown(state, args); + } + } + private void dimChanged(object sender, EventArgs e) { Background?.FadeTo((100f - dimLevel) / 100, 800); From dedd6a4bcfe8609e84be142c13bbc7843daaa4e8 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 27 Jan 2017 05:39:15 -0400 Subject: [PATCH 02/40] Small cleanups --- osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs | 2 +- osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj | 1 + osu.Game/Overlays/Pause/PauseButton.cs | 3 ++- osu.Game/Overlays/Pause/PauseOverlay.cs | 2 +- osu.Game/osu.Game.csproj | 2 ++ 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs index 089d6f3ebd..e7fb610cbb 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs @@ -25,4 +25,4 @@ namespace osu.Desktop.VisualTests.Tests pauseOverlay.ToggleVisibility(); } } -} \ No newline at end of file +} diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 70dd0fee46..cd24771967 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -186,6 +186,7 @@ + diff --git a/osu.Game/Overlays/Pause/PauseButton.cs b/osu.Game/Overlays/Pause/PauseButton.cs index cddf9a8bef..a7d72ab31e 100644 --- a/osu.Game/Overlays/Pause/PauseButton.cs +++ b/osu.Game/Overlays/Pause/PauseButton.cs @@ -46,7 +46,8 @@ namespace osu.Game.Overlays.Pause } public PauseButton() - { Size = new Vector2(width, height); + { + Size = new Vector2(width, height); Colour = Color4.Black; Shear = new Vector2(0.1f, 0); } diff --git a/osu.Game/Overlays/Pause/PauseOverlay.cs b/osu.Game/Overlays/Pause/PauseOverlay.cs index 9bc5d802ba..f23e5ede41 100644 --- a/osu.Game/Overlays/Pause/PauseOverlay.cs +++ b/osu.Game/Overlays/Pause/PauseOverlay.cs @@ -111,4 +111,4 @@ namespace osu.Game.Overlays.Pause AutoSizeAxes = Axes.Both; } } -} \ No newline at end of file +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index a90fa2a8cb..388b8ff77e 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -236,6 +236,8 @@ + + From f35974021a302fc7f8244baf0f5a06119876c972 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 27 Jan 2017 06:19:52 -0400 Subject: [PATCH 03/40] Set actions for retry/quit, moved setting paused to PopIn and PopOut, added null propogation for the sound samples for PauseButton(sometimes in the visual tests the audio doesn't load for whatever reason), added a gradient to the background of the PauseOverlay visual test(same as the one in the menu button system test), wired up the retry and quit actions in Player, made the quit action quit the map, retry still does nothing --- .../Tests/TestCasePauseOverlay.cs | 17 +++++++++----- osu.Game/Overlays/Pause/PauseButton.cs | 4 ++-- osu.Game/Overlays/Pause/PauseOverlay.cs | 22 ++++++++++--------- osu.Game/Screens/Play/Player.cs | 12 ++++++++++ 4 files changed, 37 insertions(+), 18 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs index e7fb610cbb..78064791c1 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs @@ -1,12 +1,11 @@ using System; -using osu.Framework.GameModes.Testing; +using OpenTK.Graphics; using osu.Framework.Graphics; -using osu.Game.Graphics.UserInterface; -using OpenTK.Input; using osu.Game.Overlays.Pause; using osu.Framework.Graphics.Containers; - - +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Colour; +using osu.Framework.GameModes.Testing; namespace osu.Desktop.VisualTests.Tests { class TestCasePauseOverlay : TestCase @@ -21,7 +20,13 @@ namespace osu.Desktop.VisualTests.Tests { base.Reset(); - Children = new[] { pauseOverlay = new PauseOverlay() }; + Add(new Box + { + ColourInfo = ColourInfo.GradientVertical(Color4.Gray, Color4.WhiteSmoke), + RelativeSizeAxes = Framework.Graphics.Axes.Both, + }); + Add(pauseOverlay = new PauseOverlay()); + pauseOverlay.ToggleVisibility(); } } diff --git a/osu.Game/Overlays/Pause/PauseButton.cs b/osu.Game/Overlays/Pause/PauseButton.cs index a7d72ab31e..c7f35dcaaa 100644 --- a/osu.Game/Overlays/Pause/PauseButton.cs +++ b/osu.Game/Overlays/Pause/PauseButton.cs @@ -27,14 +27,14 @@ namespace osu.Game.Overlays.Pause protected override bool OnMouseDown(Framework.Input.InputState state, Framework.Graphics.MouseDownEventArgs args) { - sampleClick.Play(); + sampleClick?.Play(); return true; } protected override bool OnHover(Framework.Input.InputState state) { - sampleHover.Play(); + sampleHover?.Play(); ResizeTo(new Vector2(expandedWidth, height), 500, EasingTypes.OutElastic); return true; diff --git a/osu.Game/Overlays/Pause/PauseOverlay.cs b/osu.Game/Overlays/Pause/PauseOverlay.cs index f23e5ede41..78679fac26 100644 --- a/osu.Game/Overlays/Pause/PauseOverlay.cs +++ b/osu.Game/Overlays/Pause/PauseOverlay.cs @@ -2,14 +2,12 @@ using OpenTK; using OpenTK.Input; using OpenTK.Graphics; -using osu.Game.Screens; 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.UserInterface; using osu.Framework.Graphics.Transformations; @@ -47,26 +45,30 @@ namespace osu.Game.Overlays.Pause { Text = @"Retry", Origin = Anchor.Centre, - Anchor = Anchor.Centre + Anchor = Anchor.Centre, + Action = Retry }, new PauseButton { Text = @"Quit", Origin = Anchor.Centre, Anchor = Anchor.Centre, - Position = new Vector2(0, 200) + Position = new Vector2(0, 200), + Action = Quit } }; } protected override void PopIn() { - this.FadeTo(1, 100, EasingTypes.In); + this.FadeTo(1, 100, EasingTypes.In); + paused = true; } protected override void PopOut() { - this.FadeTo(0, 100, EasingTypes.In); + this.FadeTo(0, 100, EasingTypes.In); + paused = false; } protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) @@ -83,25 +85,25 @@ namespace osu.Game.Overlays.Pause private void Pause() { - paused = true; Show(); OnPause?.Invoke(); } private void Play() { - paused = false; Hide(); OnPlay?.Invoke(); } private void Retry() - { + { + Hide(); OnRetry?.Invoke(); } private void Quit() - { + { + Hide(); OnQuit?.Invoke(); } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 61e9e66036..e7afe49881 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -102,6 +102,8 @@ namespace osu.Game.Screens.Play pauseOverlay = new PauseOverlay(); pauseOverlay.OnPause += onPause; pauseOverlay.OnPlay += onPlay; + pauseOverlay.OnRetry += onRetry; + pauseOverlay.OnQuit += onQuit; hitRenderer = ruleset.CreateHitRendererWith(beatmap.HitObjects); @@ -185,6 +187,16 @@ namespace osu.Game.Screens.Play sourceClock.Start(); } + private void onRetry() + { + + } + + private void onQuit() + { + Exit(); + } + protected override void OnEntering(GameMode last) { base.OnEntering(last); From 81de5a2097e80f309b39eeb201e6b1e7242bf9e2 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 27 Jan 2017 06:36:43 -0400 Subject: [PATCH 04/40] Made the pause overlay be at -1 depth so it renders on top of everything(used to allow circles to draw on top) --- osu.Game/Overlays/Pause/PauseOverlay.cs | 3 ++- osu.Game/Screens/Play/Player.cs | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Pause/PauseOverlay.cs b/osu.Game/Overlays/Pause/PauseOverlay.cs index 78679fac26..4a76fb1eb8 100644 --- a/osu.Game/Overlays/Pause/PauseOverlay.cs +++ b/osu.Game/Overlays/Pause/PauseOverlay.cs @@ -110,7 +110,8 @@ namespace osu.Game.Overlays.Pause public PauseOverlay() { RelativeSizeAxes = Axes.Both; - AutoSizeAxes = Axes.Both; + AutoSizeAxes = Axes.Both; + Depth = -1; } } } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index e7afe49881..8baa942b74 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -177,7 +177,6 @@ namespace osu.Game.Screens.Play private void onPause() { scoreOverlay.KeyCounter.IsCounting = false; - sourceClock.Stop(); } From 3ed88ea04369b939240259f79f7033485183366e Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 27 Jan 2017 07:11:22 -0400 Subject: [PATCH 05/40] Added PauseOverlay.TogglePaused, renamed OnPlay and similar to OnResume, made Pause and Play public, added proper testing for the visual test(pause button instead of auto-pause, logging actions), made PauseOverlay's fade duration a constant instead of statically typed --- .../Tests/TestCasePauseOverlay.cs | 20 ++++++++++++-- osu.Game/Overlays/Pause/PauseOverlay.cs | 26 ++++++++++++------- osu.Game/Screens/Play/Player.cs | 4 +-- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs index 78064791c1..48388b855c 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs @@ -1,11 +1,14 @@ using System; using OpenTK.Graphics; +using osu.Framework.Logging; using osu.Framework.Graphics; using osu.Game.Overlays.Pause; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Colour; using osu.Framework.GameModes.Testing; +using osu.Framework.Graphics.UserInterface; + namespace osu.Desktop.VisualTests.Tests { class TestCasePauseOverlay : TestCase @@ -27,7 +30,20 @@ namespace osu.Desktop.VisualTests.Tests }); Add(pauseOverlay = new PauseOverlay()); - pauseOverlay.ToggleVisibility(); - } + Add(new Button + { Text = @"Pause", + Anchor = Anchor.TopLeft, + Origin = Anchor.TopLeft, + Width = 100, + Height = 50, + Colour = Color4.Black, + Action = (() => pauseOverlay.Pause()) + }); + + pauseOverlay.OnPause += (() => Logger.Log(@"Pause")); + pauseOverlay.OnResume += (() => Logger.Log(@"Resume")); + pauseOverlay.OnRetry += (() => Logger.Log(@"Retry")); + pauseOverlay.OnQuit += (() => Logger.Log(@"Quit")); + } } } diff --git a/osu.Game/Overlays/Pause/PauseOverlay.cs b/osu.Game/Overlays/Pause/PauseOverlay.cs index 4a76fb1eb8..e64e9a85b8 100644 --- a/osu.Game/Overlays/Pause/PauseOverlay.cs +++ b/osu.Game/Overlays/Pause/PauseOverlay.cs @@ -16,9 +16,10 @@ namespace osu.Game.Overlays.Pause public class PauseOverlay : OverlayContainer { private bool paused = false; + private int fadeDuration = 100; public event Action OnPause; - public event Action OnPlay; + public event Action OnResume; public event Action OnRetry; public event Action OnQuit; @@ -39,7 +40,7 @@ namespace osu.Game.Overlays.Pause Origin = Anchor.Centre, Anchor = Anchor.Centre, Position = new Vector2(0, -200), - Action = Play + Action = Resume }, new PauseButton { @@ -61,13 +62,13 @@ namespace osu.Game.Overlays.Pause protected override void PopIn() { - this.FadeTo(1, 100, EasingTypes.In); + this.FadeTo(1, fadeDuration, EasingTypes.In); paused = true; } protected override void PopOut() { - this.FadeTo(0, 100, EasingTypes.In); + this.FadeTo(0, fadeDuration, EasingTypes.In); paused = false; } @@ -76,23 +77,28 @@ namespace osu.Game.Overlays.Pause switch (args.Key) { case Key.Escape: - paused = !paused; - (paused ? (Action)Pause : Play)?.Invoke(); + TogglePaused(); return true; } return base.OnKeyDown(state, args); } - private void Pause() + public void Pause() { Show(); OnPause?.Invoke(); } - private void Play() + public void Resume() { - Hide(); - OnPlay?.Invoke(); + Hide(); + OnResume?.Invoke(); + } + + public void TogglePaused() + { + ToggleVisibility(); + (paused ? (Action)Pause : Resume)?.Invoke(); } private void Retry() diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 8baa942b74..b06c3c6648 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -101,7 +101,7 @@ namespace osu.Game.Screens.Play pauseOverlay = new PauseOverlay(); pauseOverlay.OnPause += onPause; - pauseOverlay.OnPlay += onPlay; + pauseOverlay.OnResume += onResume; pauseOverlay.OnRetry += onRetry; pauseOverlay.OnQuit += onQuit; @@ -180,7 +180,7 @@ namespace osu.Game.Screens.Play sourceClock.Stop(); } - private void onPlay() + private void onResume() { scoreOverlay.KeyCounter.IsCounting = true; sourceClock.Start(); From 811cf4b04e42696efe9cb4857f9eda7fff3ce3b8 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 27 Jan 2017 07:12:20 -0400 Subject: [PATCH 06/40] Added newline, thanks Xamarin --- osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs index 48388b855c..93dfc6cd72 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs @@ -31,7 +31,8 @@ namespace osu.Desktop.VisualTests.Tests Add(pauseOverlay = new PauseOverlay()); Add(new Button - { Text = @"Pause", + { + Text = @"Pause", Anchor = Anchor.TopLeft, Origin = Anchor.TopLeft, Width = 100, From 8c6d9bdf2e78e3a8c90ab8e3c880fac628332002 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 27 Jan 2017 08:03:32 -0400 Subject: [PATCH 07/40] Added commas to the end of UI creation to match how the rest of the project does, moved PauseButton audio loading to PauseOverlay, much more reliable(still using placeholder assets), made it so the player can't spam pause, cools down to one second --- .../Tests/TestCasePauseOverlay.cs | 2 +- osu.Game/Overlays/Pause/PauseButton.cs | 14 +--- osu.Game/Overlays/Pause/PauseOverlay.cs | 81 +++++++++++++------ 3 files changed, 59 insertions(+), 38 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs index 93dfc6cd72..c1f81810ab 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs @@ -38,7 +38,7 @@ namespace osu.Desktop.VisualTests.Tests Width = 100, Height = 50, Colour = Color4.Black, - Action = (() => pauseOverlay.Pause()) + Action = (() => pauseOverlay.Pause()), }); pauseOverlay.OnPause += (() => Logger.Log(@"Pause")); diff --git a/osu.Game/Overlays/Pause/PauseButton.cs b/osu.Game/Overlays/Pause/PauseButton.cs index c7f35dcaaa..ddf2d49c97 100644 --- a/osu.Game/Overlays/Pause/PauseButton.cs +++ b/osu.Game/Overlays/Pause/PauseButton.cs @@ -2,8 +2,6 @@ using OpenTK.Graphics; using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.Transformations; -using osu.Framework.Allocation; -using osu.Framework.Audio; using osu.Framework.Audio.Sample; namespace osu.Game.Overlays.Pause @@ -14,16 +12,8 @@ namespace osu.Game.Overlays.Pause private float width = 300; private float expandedWidth = 350; - private AudioSample sampleClick; - private AudioSample sampleHover; - - [BackgroundDependencyLoader] - private void load(AudioManager audio) - { - // Placeholder till the actual samples are added to osu-resources - sampleClick = audio.Sample.Get(@"Menu/menuhit"); - sampleHover = audio.Sample.Get(@"Menu/menuclick"); - } + public AudioSample sampleClick; + public AudioSample sampleHover; protected override bool OnMouseDown(Framework.Input.InputState state, Framework.Graphics.MouseDownEventArgs args) { diff --git a/osu.Game/Overlays/Pause/PauseOverlay.cs b/osu.Game/Overlays/Pause/PauseOverlay.cs index e64e9a85b8..ecdf48c4ff 100644 --- a/osu.Game/Overlays/Pause/PauseOverlay.cs +++ b/osu.Game/Overlays/Pause/PauseOverlay.cs @@ -3,6 +3,7 @@ using OpenTK; using OpenTK.Input; using OpenTK.Graphics; using osu.Game.Graphics; +using osu.Framework.Audio; using osu.Framework.Input; using osu.Framework.Allocation; using osu.Framework.Graphics; @@ -15,17 +16,28 @@ namespace osu.Game.Overlays.Pause { public class PauseOverlay : OverlayContainer { - private bool paused = false; - private int fadeDuration = 100; - public event Action OnPause; public event Action OnResume; public event Action OnRetry; public event Action OnQuit; + public bool isPaused = false; + + private int fadeDuration = 100; + private double pauseDisableTime = 1000; + private double lastActionTime = -1000; + + private PauseButton resumeButton; + private PauseButton retryButton; + private PauseButton quitButton; + [BackgroundDependencyLoader] - private void load(OsuColour colours) - { + private void load(AudioManager audio, OsuColour colours) + { + var sampleHover = audio.Sample.Get(@"Menu/menuclick"); + var sampleBack = audio.Sample.Get(@"Menu/menuback"); + var samplePlayClick = audio.Sample.Get(@"Menu/menu-play-click"); + Children = new Drawable[] { new Box @@ -34,42 +46,51 @@ namespace osu.Game.Overlays.Pause Colour = Color4.Black, Alpha = 0.6f, }, - new PauseButton - { + resumeButton = new PauseButton + { Text = @"Resume", Origin = Anchor.Centre, Anchor = Anchor.Centre, Position = new Vector2(0, -200), - Action = Resume + Action = Resume, }, - new PauseButton + retryButton = new PauseButton { Text = @"Retry", Origin = Anchor.Centre, Anchor = Anchor.Centre, - Action = Retry + Action = Retry, }, - new PauseButton + quitButton = new PauseButton { Text = @"Quit", Origin = Anchor.Centre, Anchor = Anchor.Centre, Position = new Vector2(0, 200), - Action = Quit - } - }; + Action = Quit, + }, + }; + + resumeButton.sampleHover = sampleHover; + resumeButton.sampleClick = sampleBack; + + retryButton.sampleHover = sampleHover; + retryButton.sampleClick = samplePlayClick; + + quitButton.sampleHover = sampleHover; + quitButton.sampleClick = sampleBack; } protected override void PopIn() { - this.FadeTo(1, fadeDuration, EasingTypes.In); - paused = true; + FadeTo(1, fadeDuration, EasingTypes.In); + isPaused = true; } protected override void PopOut() { - this.FadeTo(0, fadeDuration, EasingTypes.In); - paused = false; + FadeTo(0, fadeDuration, EasingTypes.In); + isPaused = false; } protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) @@ -84,21 +105,31 @@ namespace osu.Game.Overlays.Pause } public void Pause() - { - Show(); - OnPause?.Invoke(); + { + // Only allow pausing once a second + if (Time.Current >= (lastActionTime + pauseDisableTime)) + { + lastActionTime = Time.Current; + Show(); + OnPause?.Invoke(); + } + else + { + isPaused = false; + } } public void Resume() - { + { + lastActionTime = Time.Current; Hide(); OnResume?.Invoke(); } public void TogglePaused() - { - ToggleVisibility(); - (paused ? (Action)Pause : Resume)?.Invoke(); + { + isPaused = !isPaused; + (isPaused ? (Action)Pause : Resume)?.Invoke(); } private void Retry() From e1151205439bad621b42e4dc038615cb59aa75b6 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 27 Jan 2017 08:13:39 -0400 Subject: [PATCH 08/40] Renamed pauseDisableTime to pauseCooldown --- osu.Game/Overlays/Pause/PauseOverlay.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Pause/PauseOverlay.cs b/osu.Game/Overlays/Pause/PauseOverlay.cs index ecdf48c4ff..5697308f2b 100644 --- a/osu.Game/Overlays/Pause/PauseOverlay.cs +++ b/osu.Game/Overlays/Pause/PauseOverlay.cs @@ -24,7 +24,7 @@ namespace osu.Game.Overlays.Pause public bool isPaused = false; private int fadeDuration = 100; - private double pauseDisableTime = 1000; + private double pauseCooldown = 1000; private double lastActionTime = -1000; private PauseButton resumeButton; @@ -106,8 +106,7 @@ namespace osu.Game.Overlays.Pause public void Pause() { - // Only allow pausing once a second - if (Time.Current >= (lastActionTime + pauseDisableTime)) + if (Time.Current >= (lastActionTime + pauseCooldown)) { lastActionTime = Time.Current; Show(); From 490feac030b8f601bb5828b640e778aaaea75884 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 27 Jan 2017 14:18:57 -0400 Subject: [PATCH 09/40] Working on design --- osu.Game/Overlays/Pause/PauseButton.cs | 216 +++++++++++++++++++++--- osu.Game/Overlays/Pause/PauseOverlay.cs | 177 +++++++++++-------- 2 files changed, 301 insertions(+), 92 deletions(-) diff --git a/osu.Game/Overlays/Pause/PauseButton.cs b/osu.Game/Overlays/Pause/PauseButton.cs index ddf2d49c97..eabf56192a 100644 --- a/osu.Game/Overlays/Pause/PauseButton.cs +++ b/osu.Game/Overlays/Pause/PauseButton.cs @@ -1,45 +1,217 @@ using OpenTK; using OpenTK.Graphics; -using osu.Framework.Graphics.UserInterface; +using osu.Framework.Allocation; +using osu.Game.Graphics; +using osu.Framework.Graphics; using osu.Framework.Graphics.Transformations; +using osu.Framework.Graphics.Colour; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Containers; +using osu.Framework.Audio; using osu.Framework.Audio.Sample; +using osu.Game.Graphics.Backgrounds; -namespace osu.Game.Overlays.Pause -{ - public class PauseButton : Button +namespace osu.Game.Overlays.Pause +{ + public class PauseButton : ClickableContainer { - private float height = 100; - private float width = 300; - private float expandedWidth = 350; + private float height = 70; + private float colourWidth = 0.8f; + private float colourExpandedWidth = 0.9f; + private float colourExpandTime = 500; + private float shear = 0.2f; + private float glowGradientEndAlpha = 0f; - public AudioSample sampleClick; - public AudioSample sampleHover; + private Color4 buttonColour; + private Color4 backgroundColour = OsuColour.Gray(34); - protected override bool OnMouseDown(Framework.Input.InputState state, Framework.Graphics.MouseDownEventArgs args) + private AudioSample sampleClick; + private AudioSample sampleHover; + + public PauseButtonType Type; + + public string Text + { + get + { + switch (Type) + { + case PauseButtonType.Resume: + return "Continue"; + + case PauseButtonType.Retry: + return "Retry"; + + case PauseButtonType.Quit: + return "Quit to Main Menu"; + + default: + return "Unknown"; + } + } + } + + private Container backgroundContainer; + private Container colourContainer; + private Container glowContainer; + private SpriteText spriteText; + + public override bool Contains(Vector2 screenSpacePos) => backgroundContainer.Contains(screenSpacePos); + + protected override bool OnMouseUp(Framework.Input.InputState state, MouseUpEventArgs args) { sampleClick?.Play(); - return true; } protected override bool OnHover(Framework.Input.InputState state) { + colourContainer.ResizeTo(new Vector2(colourExpandedWidth, 1f), colourExpandTime, EasingTypes.OutElastic); + glowContainer.FadeTo(1f, colourExpandTime, EasingTypes.Out); sampleHover?.Play(); - ResizeTo(new Vector2(expandedWidth, height), 500, EasingTypes.OutElastic); - return true; } protected override void OnHoverLost(Framework.Input.InputState state) { - ResizeTo(new Vector2(width, height), 500, EasingTypes.OutElastic); + colourContainer.ResizeTo(new Vector2(colourWidth, 1f), colourExpandTime, EasingTypes.OutElastic); + glowContainer.FadeTo(0f, colourExpandTime, EasingTypes.Out); } - - public PauseButton() + + [BackgroundDependencyLoader] + private void load(AudioManager audio, OsuColour colours) { - Size = new Vector2(width, height); - Colour = Color4.Black; - Shear = new Vector2(0.1f, 0); - } - } -} + switch (Type) + { + case PauseButtonType.Resume: + buttonColour = colours.Green; + sampleClick = audio.Sample.Get(@"Menu/menuback"); + break; + + case PauseButtonType.Retry: + buttonColour = colours.YellowDark; + sampleClick = audio.Sample.Get(@"Menu/menu-play-click"); + break; + + case PauseButtonType.Quit: + // For whatever reason the red from the mockup is not in the osu! palette + buttonColour = new Color4(170, 27, 39, 255); + sampleClick = audio.Sample.Get(@"Menu/menuback"); + break; + } + + sampleHover = audio.Sample.Get(@"Menu/menuclick"); + + Add(new Drawable[] + { + backgroundContainer = new Container + { + RelativeSizeAxes = Axes.Both, + Width = 1f, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = backgroundColour, + }, + } + }, + glowContainer = new Container + { + RelativeSizeAxes = Axes.Both, + Width = 1f, + Alpha = 0f, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Origin = Anchor.TopLeft, + Anchor = Anchor.TopLeft, + Width = 0.125f, + ColourInfo = ColourInfo.GradientHorizontal(new Color4(buttonColour.R, buttonColour.G, buttonColour.B, glowGradientEndAlpha), buttonColour), + }, + new Box + { + RelativeSizeAxes = Axes.Both, + Origin = Anchor.TopRight, + Anchor = Anchor.TopRight, + Width = 0.125f, + ColourInfo = ColourInfo.GradientHorizontal(buttonColour, new Color4(buttonColour.R, buttonColour.G, buttonColour.B, glowGradientEndAlpha)), + }, + } + }, + new Container + { + RelativeSizeAxes = Axes.X, + Height = height, + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Masking = true, + Children = new Drawable[] + { + colourContainer = new Container + { + RelativeSizeAxes = Axes.Both, + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Width = colourWidth, + Masking = true, + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Shadow, + Colour = Color4.Black.Opacity(0.2f), + Radius = 5, + Offset = new Vector2(0, 5), + }, + Colour = buttonColour, + Shear = new Vector2(shear, 0), + Children = new Drawable[] + { + new Box + { + EdgeSmoothness = new Vector2(2, 0), + RelativeSizeAxes = Axes.Both, + }, + new Triangles + { + Masking = true, + BlendingMode = BlendingMode.Additive, + RelativeSizeAxes = Axes.Both, + TriangleScale = 4, + Alpha = 0.05f, + Shear = new Vector2(-shear, 0), + }, + } + }, + } + }, + spriteText = new SpriteText + { + Text = Text, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + TextSize = 25, + Font = "Exo2.0-Bold", + Shadow = true, + ShadowColour = new Color4(0, 0, 0, 0.1f), + Colour = Color4.White, + }, + }); + } + + public PauseButton() + { + Height = height; + RelativeSizeAxes = Axes.X; + } + } + + public enum PauseButtonType + { + Resume, + Retry, + Quit + } +} diff --git a/osu.Game/Overlays/Pause/PauseOverlay.cs b/osu.Game/Overlays/Pause/PauseOverlay.cs index 5697308f2b..bbf424773e 100644 --- a/osu.Game/Overlays/Pause/PauseOverlay.cs +++ b/osu.Game/Overlays/Pause/PauseOverlay.cs @@ -10,7 +10,8 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Transformations; - +using osu.Game.Graphics.Backgrounds; +using osu.Game.Screens.Menu; namespace osu.Game.Overlays.Pause { @@ -25,71 +26,107 @@ namespace osu.Game.Overlays.Pause private int fadeDuration = 100; private double pauseCooldown = 1000; - private double lastActionTime = -1000; - - private PauseButton resumeButton; - private PauseButton retryButton; - private PauseButton quitButton; + private double lastActionTime = 0; [BackgroundDependencyLoader] - private void load(AudioManager audio, OsuColour colours) - { - var sampleHover = audio.Sample.Get(@"Menu/menuclick"); - var sampleBack = audio.Sample.Get(@"Menu/menuback"); - var samplePlayClick = audio.Sample.Get(@"Menu/menu-play-click"); - + private void load(OsuColour colours) + { Children = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both, Colour = Color4.Black, - Alpha = 0.6f, + Alpha = 0.75f, }, - resumeButton = new PauseButton + new SpriteText { - Text = @"Resume", + Text = @"paused", + Origin = Anchor.BottomCentre, + Anchor = Anchor.Centre, + Position = new Vector2(0, -175), + Font = @"Exo2.0-Medium", + Spacing = new Vector2(5, 0), + TextSize = 30, + Colour = colours.Yellow, + Shadow = true, + ShadowColour = new Color4(0, 0, 0, 0.25f), + }, + new SpriteText + { + Text = @"you're not going to do what i think you're going to do, ain't ya?", + Origin = Anchor.BottomCentre, + Anchor = Anchor.Centre, + Width = 100, + Position = new Vector2(0, -125), + Shadow = true, + ShadowColour = new Color4(0, 0, 0, 0.25f), + }, + new SpriteText + { + Text = @"You've retried 0 times in this session", + Origin = Anchor.TopCentre, + Anchor = Anchor.Centre, + Width = 100, + Position = new Vector2(0, 175), + Shadow = true, + ShadowColour = new Color4(0, 0, 0, 0.25f), + TextSize = 18, + }, + new FlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, Origin = Anchor.Centre, Anchor = Anchor.Centre, - Position = new Vector2(0, -200), - Action = Resume, - }, - retryButton = new PauseButton - { - Text = @"Retry", - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Action = Retry, - }, - quitButton = new PauseButton - { - Text = @"Quit", - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Position = new Vector2(0, 200), - Action = Quit, + Position = new Vector2(0, 25), + Masking = true, + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Shadow, + Colour = new Color4(0, 0, 0, 150), + Radius = 50, + Offset = new Vector2(0, 0), + }, + + Children = new Drawable[] + { + new PauseButton + { + Type = PauseButtonType.Resume, + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + Action = Resume, + }, + new PauseButton + { + Type = PauseButtonType.Retry, + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + Action = Retry, + }, + new PauseButton + { + Type = PauseButtonType.Quit, + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + Action = Quit, + }, + new Button(@"solo", @"freeplay", FontAwesome.fa_user, new Color4(102, 68, 204, 255), () => OnPause?.Invoke(), 300, Key.P), + } }, - }; - - resumeButton.sampleHover = sampleHover; - resumeButton.sampleClick = sampleBack; - - retryButton.sampleHover = sampleHover; - retryButton.sampleClick = samplePlayClick; - - quitButton.sampleHover = sampleHover; - quitButton.sampleClick = sampleBack; + }; } protected override void PopIn() { - FadeTo(1, fadeDuration, EasingTypes.In); + FadeTo(1, fadeDuration, EasingTypes.In); isPaused = true; } protected override void PopOut() { - FadeTo(0, fadeDuration, EasingTypes.In); + FadeTo(0, fadeDuration, EasingTypes.In); isPaused = false; } @@ -105,48 +142,48 @@ namespace osu.Game.Overlays.Pause } public void Pause() - { + { if (Time.Current >= (lastActionTime + pauseCooldown)) - { - lastActionTime = Time.Current; - Show(); - OnPause?.Invoke(); - } - else { - isPaused = false; + lastActionTime = Time.Current; + Show(); + OnPause?.Invoke(); + } + else + { + isPaused = false; } } public void Resume() - { + { lastActionTime = Time.Current; - Hide(); + Hide(); OnResume?.Invoke(); - } - - public void TogglePaused() - { + } + + public void TogglePaused() + { isPaused = !isPaused; - (isPaused ? (Action)Pause : Resume)?.Invoke(); - } - - private void Retry() - { + (isPaused ? (Action)Pause : Resume)?.Invoke(); + } + + private void Retry() + { Hide(); - OnRetry?.Invoke(); - } - - private void Quit() - { + OnRetry?.Invoke(); + } + + private void Quit() + { Hide(); - OnQuit?.Invoke(); + OnQuit?.Invoke(); } public PauseOverlay() { RelativeSizeAxes = Axes.Both; - AutoSizeAxes = Axes.Both; + AutoSizeAxes = Axes.Both; Depth = -1; } } From 601a5ed39ce1f56f4c6f78bff20be2625e8bf433 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 27 Jan 2017 14:29:51 -0400 Subject: [PATCH 10/40] Reverted Player to upstream --- osu.Game/Screens/Play/Player.cs | 46 +-------------------------------- 1 file changed, 1 insertion(+), 45 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index b06c3c6648..751f03f1f8 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -15,7 +15,6 @@ using osu.Game.Modes; using osu.Game.Modes.Objects; using osu.Game.Modes.Objects.Drawables; using osu.Game.Screens.Backgrounds; -using osu.Game.Overlays.Pause; using OpenTK.Input; using MouseState = osu.Framework.Input.MouseState; using OpenTK; @@ -49,9 +48,6 @@ namespace osu.Game.Screens.Play private HitRenderer hitRenderer; private Bindable dimLevel; - private PauseOverlay pauseOverlay; - private ScoreOverlay scoreOverlay; - [BackgroundDependencyLoader] private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuGameBase game, OsuConfigManager config) { @@ -96,15 +92,9 @@ namespace osu.Game.Screens.Play ruleset = Ruleset.GetRuleset(usablePlayMode); - scoreOverlay = ruleset.CreateScoreOverlay(); + var scoreOverlay = ruleset.CreateScoreOverlay(); scoreOverlay.BindProcessor(scoreProcessor = ruleset.CreateScoreProcessor(beatmap.HitObjects.Count)); - pauseOverlay = new PauseOverlay(); - pauseOverlay.OnPause += onPause; - pauseOverlay.OnResume += onResume; - pauseOverlay.OnRetry += onRetry; - pauseOverlay.OnQuit += onQuit; - hitRenderer = ruleset.CreateHitRendererWith(beatmap.HitObjects); //bind HitRenderer to ScoreProcessor and ourselves (for a pass situation) @@ -129,7 +119,6 @@ namespace osu.Game.Screens.Play } }, scoreOverlay, - pauseOverlay }; } @@ -174,28 +163,6 @@ namespace osu.Game.Screens.Play }); } - private void onPause() - { - scoreOverlay.KeyCounter.IsCounting = false; - sourceClock.Stop(); - } - - private void onResume() - { - scoreOverlay.KeyCounter.IsCounting = true; - sourceClock.Start(); - } - - private void onRetry() - { - - } - - private void onQuit() - { - Exit(); - } - protected override void OnEntering(GameMode last) { base.OnEntering(last); @@ -214,17 +181,6 @@ namespace osu.Game.Screens.Play return base.OnExiting(next); } - protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) - { - if (args.Key != Key.Escape) - { - return base.OnKeyDown(state, args); - } - else { - return pauseOverlay.TriggerKeyDown(state, args); - } - } - private void dimChanged(object sender, EventArgs e) { Background?.FadeTo((100f - dimLevel) / 100, 800); From feba3f35babbd6aefe5e0282b485783aa9573f37 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 27 Jan 2017 15:28:39 -0400 Subject: [PATCH 11/40] Changed the roles of PauseOverlay and player in pausing, PauseOverlay is now only the UI portion and doesn't do things like actually pause the game, and only calls actions and hides itself, whereas Player actually pauses the game and brings up the pause overlay in the first place --- .../Tests/TestCasePauseOverlay.cs | 9 +- osu.Game/Overlays/Pause/PauseOverlay.cs | 85 ++++++------------- osu.Game/Screens/Play/Player.cs | 63 +++++++++++++- 3 files changed, 89 insertions(+), 68 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs index c1f81810ab..be1f9d57d7 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs @@ -38,13 +38,8 @@ namespace osu.Desktop.VisualTests.Tests Width = 100, Height = 50, Colour = Color4.Black, - Action = (() => pauseOverlay.Pause()), - }); - - pauseOverlay.OnPause += (() => Logger.Log(@"Pause")); - pauseOverlay.OnResume += (() => Logger.Log(@"Resume")); - pauseOverlay.OnRetry += (() => Logger.Log(@"Retry")); - pauseOverlay.OnQuit += (() => Logger.Log(@"Quit")); + Action = (() => pauseOverlay.Show()), + }); } } } diff --git a/osu.Game/Overlays/Pause/PauseOverlay.cs b/osu.Game/Overlays/Pause/PauseOverlay.cs index bbf424773e..1590b8b726 100644 --- a/osu.Game/Overlays/Pause/PauseOverlay.cs +++ b/osu.Game/Overlays/Pause/PauseOverlay.cs @@ -3,30 +3,24 @@ using OpenTK; using OpenTK.Input; using OpenTK.Graphics; using osu.Game.Graphics; -using osu.Framework.Audio; +using osu.Game.Screens.Menu; +using osu.Game.Screens.Play; 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.Game.Graphics.Backgrounds; -using osu.Game.Screens.Menu; namespace osu.Game.Overlays.Pause { public class PauseOverlay : OverlayContainer { - public event Action OnPause; - public event Action OnResume; - public event Action OnRetry; - public event Action OnQuit; - - public bool isPaused = false; - private int fadeDuration = 100; - private double pauseCooldown = 1000; - private double lastActionTime = 0; + + public Action OnResume; + public Action OnRetry; + public Action OnQuit; [BackgroundDependencyLoader] private void load(OsuColour colours) @@ -96,23 +90,34 @@ namespace osu.Game.Overlays.Pause Type = PauseButtonType.Resume, Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, - Action = Resume, + Action = (delegate + { + Hide(); + OnResume?.Invoke(); + }), }, new PauseButton { Type = PauseButtonType.Retry, Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, - Action = Retry, + Action = (delegate + { + Hide(); + OnRetry?.Invoke(); + }), }, new PauseButton { Type = PauseButtonType.Quit, Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, - Action = Quit, - }, - new Button(@"solo", @"freeplay", FontAwesome.fa_user, new Color4(102, 68, 204, 255), () => OnPause?.Invoke(), 300, Key.P), + Action = (delegate + { + Hide(); + OnQuit?.Invoke(); + }), + }, } }, }; @@ -121,65 +126,25 @@ namespace osu.Game.Overlays.Pause protected override void PopIn() { FadeTo(1, fadeDuration, EasingTypes.In); - isPaused = true; } protected override void PopOut() { FadeTo(0, fadeDuration, EasingTypes.In); - isPaused = false; } protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { switch (args.Key) { - case Key.Escape: - TogglePaused(); + case Key.Escape: + Hide(); + OnResume?.Invoke(); return true; } return base.OnKeyDown(state, args); } - public void Pause() - { - if (Time.Current >= (lastActionTime + pauseCooldown)) - { - lastActionTime = Time.Current; - Show(); - OnPause?.Invoke(); - } - else - { - isPaused = false; - } - } - - public void Resume() - { - lastActionTime = Time.Current; - Hide(); - OnResume?.Invoke(); - } - - public void TogglePaused() - { - isPaused = !isPaused; - (isPaused ? (Action)Pause : Resume)?.Invoke(); - } - - private void Retry() - { - Hide(); - OnRetry?.Invoke(); - } - - private void Quit() - { - Hide(); - OnQuit?.Invoke(); - } - public PauseOverlay() { RelativeSizeAxes = Axes.Both; diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 751f03f1f8..82cff73508 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -22,6 +22,7 @@ using osu.Framework.GameModes; using osu.Game.Modes.UI; using osu.Game.Screens.Ranking; using osu.Game.Configuration; +using osu.Game.Overlays.Pause; using osu.Framework.Configuration; using System; using OpenTK.Graphics; @@ -40,6 +41,11 @@ namespace osu.Game.Screens.Play public PlayMode PreferredPlayMode; + public bool isPaused; + + private double pauseCooldown = 1000; + private double lastActionTime = 0; + private IAdjustableClock sourceClock; private Ruleset ruleset; @@ -48,6 +54,9 @@ namespace osu.Game.Screens.Play private HitRenderer hitRenderer; private Bindable dimLevel; + private ScoreOverlay scoreOverlay; + private PauseOverlay pauseOverlay; + [BackgroundDependencyLoader] private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuGameBase game, OsuConfigManager config) { @@ -92,9 +101,14 @@ namespace osu.Game.Screens.Play ruleset = Ruleset.GetRuleset(usablePlayMode); - var scoreOverlay = ruleset.CreateScoreOverlay(); + scoreOverlay = ruleset.CreateScoreOverlay(); scoreOverlay.BindProcessor(scoreProcessor = ruleset.CreateScoreProcessor(beatmap.HitObjects.Count)); + pauseOverlay = new PauseOverlay(); + pauseOverlay.OnResume = Resume; + //pauseOverlay.OnRetry = Retry; Add when retrying is implemented + pauseOverlay.OnQuit = Exit; + hitRenderer = ruleset.CreateHitRendererWith(beatmap.HitObjects); //bind HitRenderer to ScoreProcessor and ourselves (for a pass situation) @@ -119,9 +133,41 @@ namespace osu.Game.Screens.Play } }, scoreOverlay, + pauseOverlay }; } + public void Pause() + { + if (Time.Current >= (lastActionTime + pauseCooldown)) + { + lastActionTime = Time.Current; + isPaused = true; + scoreOverlay.KeyCounter.IsCounting = false; + pauseOverlay.Show(); + sourceClock.Stop(); + } + else + { + isPaused = false; + } + } + + public void Resume() + { + lastActionTime = Time.Current; + isPaused = false; + scoreOverlay.KeyCounter.IsCounting = true; + pauseOverlay.Hide(); + sourceClock.Start(); + } + + public void TogglePaused() + { + isPaused = !isPaused; + (isPaused ? (Action)Pause : Resume)?.Invoke(); + } + protected override void LoadComplete() { base.LoadComplete(); @@ -181,6 +227,21 @@ namespace osu.Game.Screens.Play return base.OnExiting(next); } + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + switch (args.Key) + { + case Key.Escape: + if (!isPaused) + { + Pause(); + return true; + } + else { return false; } + } + return base.OnKeyDown(state, args); + } + private void dimChanged(object sender, EventArgs e) { Background?.FadeTo((100f - dimLevel) / 100, 800); From 582599a8de42aa568220d49156f8b35d69e622b3 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 28 Jan 2017 16:55:42 -0400 Subject: [PATCH 12/40] Made PauseButton more visually responsive, added force option to Player.Pause, added very basic implementation of the progress bar --- osu.Game/Overlays/Pause/PauseButton.cs | 15 ++- osu.Game/Overlays/Pause/PauseOverlay.cs | 34 +++-- osu.Game/Overlays/Pause/PauseProgressBar.cs | 141 ++++++++++++++++++++ osu.Game/Screens/Play/Player.cs | 15 ++- osu.Game/osu.Game.csproj | 1 + 5 files changed, 187 insertions(+), 19 deletions(-) create mode 100644 osu.Game/Overlays/Pause/PauseProgressBar.cs 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 @@ + From 6b57456681b82e7d47f061e5bff3578d40ebd43c Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 28 Jan 2017 20:30:37 -0400 Subject: [PATCH 13/40] Removed depth setting from PauseOverlay, removed shadow offset on PauseButton color(why was that even there?), fixed the triangles on PauseButton not masking to the sheared container, made PauseButton call it's action on MouseUp instead of MouseDown to match stable --- osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs | 2 +- osu.Game/Overlays/Pause/PauseButton.cs | 9 +-------- osu.Game/Overlays/Pause/PauseOverlay.cs | 4 ++-- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs index be1f9d57d7..8b48779666 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs @@ -28,7 +28,7 @@ namespace osu.Desktop.VisualTests.Tests ColourInfo = ColourInfo.GradientVertical(Color4.Gray, Color4.WhiteSmoke), RelativeSizeAxes = Framework.Graphics.Axes.Both, }); - Add(pauseOverlay = new PauseOverlay()); + Add(pauseOverlay = new PauseOverlay { Depth = -1 }); Add(new Button { diff --git a/osu.Game/Overlays/Pause/PauseButton.cs b/osu.Game/Overlays/Pause/PauseButton.cs index 956cb31109..49c4e472d5 100644 --- a/osu.Game/Overlays/Pause/PauseButton.cs +++ b/osu.Game/Overlays/Pause/PauseButton.cs @@ -59,15 +59,10 @@ namespace osu.Game.Overlays.Pause 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(); + Action?.Invoke(); return true; } @@ -170,7 +165,6 @@ namespace osu.Game.Overlays.Pause Type = EdgeEffectType.Shadow, Colour = Color4.Black.Opacity(0.2f), Radius = 5, - Offset = new Vector2(0, 5), }, Colour = buttonColour, Shear = new Vector2(shear, 0), @@ -183,7 +177,6 @@ namespace osu.Game.Overlays.Pause }, new Triangles { - Masking = true, BlendingMode = BlendingMode.Additive, RelativeSizeAxes = Axes.Both, TriangleScale = 4, diff --git a/osu.Game/Overlays/Pause/PauseOverlay.cs b/osu.Game/Overlays/Pause/PauseOverlay.cs index 2fa4239749..ffa8955d46 100644 --- a/osu.Game/Overlays/Pause/PauseOverlay.cs +++ b/osu.Game/Overlays/Pause/PauseOverlay.cs @@ -20,7 +20,7 @@ namespace osu.Game.Overlays.Pause public Action OnRetry; public Action OnQuit; - private SpriteText retryCounter; private PauseProgressBar progressBar; + private SpriteText retryCounter; [BackgroundDependencyLoader] @@ -76,7 +76,7 @@ namespace osu.Game.Overlays.Pause ShadowColour = new Color4(0, 0, 0, 0.25f), TextSize = 18, }, - progressBar = new PauseProgressBar + new PauseProgressBar { Origin = Anchor.BottomCentre, Anchor = Anchor.BottomCentre, From d4216eb5398f2b815e79639b9491ee21cae8c0d2 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 28 Jan 2017 20:45:10 -0400 Subject: [PATCH 14/40] Made resume not call until double the time of the fade animation --- osu.Game/Overlays/Pause/PauseOverlay.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Pause/PauseOverlay.cs b/osu.Game/Overlays/Pause/PauseOverlay.cs index ffa8955d46..93c3d8509d 100644 --- a/osu.Game/Overlays/Pause/PauseOverlay.cs +++ b/osu.Game/Overlays/Pause/PauseOverlay.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Transformations; +using System.Threading.Tasks; namespace osu.Game.Overlays.Pause { @@ -107,7 +108,7 @@ namespace osu.Game.Overlays.Pause Action = (delegate { Hide(); - OnResume?.Invoke(); + Task.Delay(fadeDuration * 2).ContinueWith(t=> OnResume?.Invoke()); }), }, new PauseButton @@ -154,7 +155,7 @@ namespace osu.Game.Overlays.Pause case Key.Escape: if (State == Visibility.Hidden) return false; Hide(); - OnResume?.Invoke(); + Task.Delay(fadeDuration * 2).ContinueWith(t => OnResume?.Invoke()); return true; } return base.OnKeyDown(state, args); From d0a22bfdd41313910d8171bd01661bbe0ee04b6b Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 28 Jan 2017 20:56:23 -0400 Subject: [PATCH 15/40] Added PauseOverlay.SetRetries for updating the retry indicator --- osu.Game/Overlays/Pause/PauseOverlay.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Pause/PauseOverlay.cs b/osu.Game/Overlays/Pause/PauseOverlay.cs index 93c3d8509d..f7cf7861ad 100644 --- a/osu.Game/Overlays/Pause/PauseOverlay.cs +++ b/osu.Game/Overlays/Pause/PauseOverlay.cs @@ -68,7 +68,6 @@ namespace osu.Game.Overlays.Pause }, retryCounter = new SpriteText { - Text = @"You've retried 0 times in this session", Origin = Anchor.TopCentre, Anchor = Anchor.Centre, Width = 100, @@ -108,7 +107,7 @@ namespace osu.Game.Overlays.Pause Action = (delegate { Hide(); - Task.Delay(fadeDuration * 2).ContinueWith(t=> OnResume?.Invoke()); + Task.Delay(fadeDuration * 2).ContinueWith(task => OnResume?.Invoke()); }), }, new PauseButton @@ -135,7 +134,17 @@ namespace osu.Game.Overlays.Pause }, } }, - }; + }; + + SetRetries(0); + } + + public void SetRetries(int count) + { + if (retryCounter != null) + // "You've retried 1,065 times in this session" + // "You've retried 1 time in this session" + retryCounter.Text = $"You've retried {String.Format("{0:n0}", count)} time{(count == 1) ? "" : "s"} in this session"; } protected override void PopIn() @@ -155,7 +164,7 @@ namespace osu.Game.Overlays.Pause case Key.Escape: if (State == Visibility.Hidden) return false; Hide(); - Task.Delay(fadeDuration * 2).ContinueWith(t => OnResume?.Invoke()); + Task.Delay(fadeDuration * 2).ContinueWith(task => OnResume?.Invoke()); return true; } return base.OnKeyDown(state, args); From c75b234b1a31b2fa64893c600ced712634bb6b2a Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 28 Jan 2017 21:50:06 -0400 Subject: [PATCH 16/40] Adjusted the fade time of the pause overlay, put a fill behind the colour of PauseButton to fix an issue where the background gray is visible when the pause overlay is fading out --- osu.Game/Overlays/Pause/PauseButton.cs | 32 +++++++++++++++---------- osu.Game/Overlays/Pause/PauseOverlay.cs | 2 +- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/osu.Game/Overlays/Pause/PauseButton.cs b/osu.Game/Overlays/Pause/PauseButton.cs index 49c4e472d5..eeb24b969b 100644 --- a/osu.Game/Overlays/Pause/PauseButton.cs +++ b/osu.Game/Overlays/Pause/PauseButton.cs @@ -115,8 +115,8 @@ namespace osu.Game.Overlays.Pause new Box { RelativeSizeAxes = Axes.Both, - Colour = backgroundColour, - }, + Colour = backgroundColour + } } }, glowContainer = new Container @@ -132,7 +132,15 @@ namespace osu.Game.Overlays.Pause Origin = Anchor.TopLeft, Anchor = Anchor.TopLeft, Width = 0.125f, - ColourInfo = ColourInfo.GradientHorizontal(new Color4(buttonColour.R, buttonColour.G, buttonColour.B, glowGradientEndAlpha), buttonColour), + ColourInfo = ColourInfo.GradientHorizontal(new Color4(buttonColour.R, buttonColour.G, buttonColour.B, glowGradientEndAlpha), buttonColour) + }, + new Box + { + RelativeSizeAxes = Axes.Both, + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Width = 0.75f, + Colour = buttonColour }, new Box { @@ -140,8 +148,8 @@ namespace osu.Game.Overlays.Pause Origin = Anchor.TopRight, Anchor = Anchor.TopRight, Width = 0.125f, - ColourInfo = ColourInfo.GradientHorizontal(buttonColour, new Color4(buttonColour.R, buttonColour.G, buttonColour.B, glowGradientEndAlpha)), - }, + ColourInfo = ColourInfo.GradientHorizontal(buttonColour, new Color4(buttonColour.R, buttonColour.G, buttonColour.B, glowGradientEndAlpha)) + } } }, new Container @@ -164,7 +172,7 @@ namespace osu.Game.Overlays.Pause { Type = EdgeEffectType.Shadow, Colour = Color4.Black.Opacity(0.2f), - Radius = 5, + Radius = 5 }, Colour = buttonColour, Shear = new Vector2(shear, 0), @@ -173,7 +181,7 @@ namespace osu.Game.Overlays.Pause new Box { EdgeSmoothness = new Vector2(2, 0), - RelativeSizeAxes = Axes.Both, + RelativeSizeAxes = Axes.Both }, new Triangles { @@ -181,10 +189,10 @@ namespace osu.Game.Overlays.Pause RelativeSizeAxes = Axes.Both, TriangleScale = 4, Alpha = 0.05f, - Shear = new Vector2(-shear, 0), - }, + Shear = new Vector2(-shear, 0) + } } - }, + } } }, new SpriteText @@ -196,8 +204,8 @@ namespace osu.Game.Overlays.Pause Font = "Exo2.0-Bold", Shadow = true, ShadowColour = new Color4(0, 0, 0, 0.1f), - Colour = Color4.White, - }, + Colour = Color4.White + } }); } diff --git a/osu.Game/Overlays/Pause/PauseOverlay.cs b/osu.Game/Overlays/Pause/PauseOverlay.cs index f7cf7861ad..2e91604e04 100644 --- a/osu.Game/Overlays/Pause/PauseOverlay.cs +++ b/osu.Game/Overlays/Pause/PauseOverlay.cs @@ -15,7 +15,7 @@ namespace osu.Game.Overlays.Pause { public class PauseOverlay : OverlayContainer { - private int fadeDuration = 100; + private int fadeDuration = 200; public Action OnResume; public Action OnRetry; From 28967cf77ab776f14ec6ad47b592575f49bb4424 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sun, 29 Jan 2017 05:04:48 -0400 Subject: [PATCH 17/40] Renamed Player.isPaused to IsPaused, did a small patch suggested for how the player can click through the pause menu onto the Playfield(only partially works, upstream changes need to be made for full functionality), made Retry default to Resume until retrying is implemented, minor cleanups --- osu.Game/Overlays/Pause/PauseButton.cs | 5 ++--- osu.Game/Overlays/Pause/PauseOverlay.cs | 15 +++++---------- osu.Game/Screens/Play/Player.cs | 22 +++++++++++++--------- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/osu.Game/Overlays/Pause/PauseButton.cs b/osu.Game/Overlays/Pause/PauseButton.cs index eeb24b969b..9914caf37d 100644 --- a/osu.Game/Overlays/Pause/PauseButton.cs +++ b/osu.Game/Overlays/Pause/PauseButton.cs @@ -21,7 +21,6 @@ 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); @@ -60,7 +59,7 @@ namespace osu.Game.Overlays.Pause protected override bool OnMouseDown(Framework.Input.InputState state, MouseDownEventArgs args) { - colourContainer.ResizeTo(new Vector2(1.1f, 1f), pressExpandTime, EasingTypes.In); + colourContainer.ResizeTo(new Vector2(1.1f, 1f), 200, EasingTypes.In); sampleClick?.Play(); Action?.Invoke(); return true; @@ -204,7 +203,7 @@ namespace osu.Game.Overlays.Pause Font = "Exo2.0-Bold", Shadow = true, ShadowColour = new Color4(0, 0, 0, 0.1f), - Colour = Color4.White + Colour = Color4.White, } }); } diff --git a/osu.Game/Overlays/Pause/PauseOverlay.cs b/osu.Game/Overlays/Pause/PauseOverlay.cs index 2e91604e04..3d345eb404 100644 --- a/osu.Game/Overlays/Pause/PauseOverlay.cs +++ b/osu.Game/Overlays/Pause/PauseOverlay.cs @@ -23,13 +23,15 @@ namespace osu.Game.Overlays.Pause private SpriteText retryCounter; + public override bool Contains(Vector2 screenSpacePos) => true; + [BackgroundDependencyLoader] private void load(OsuColour colours) { Children = new Drawable[] { - new ClickableContainer + new Container { RelativeSizeAxes = Axes.Both, @@ -147,15 +149,8 @@ namespace osu.Game.Overlays.Pause retryCounter.Text = $"You've retried {String.Format("{0:n0}", count)} time{(count == 1) ? "" : "s"} in this session"; } - protected override void PopIn() - { - FadeTo(1, fadeDuration, EasingTypes.In); - } - - protected override void PopOut() - { - FadeTo(0, fadeDuration, EasingTypes.In); - } + protected override void PopIn() => FadeIn(fadeDuration, EasingTypes.In); + protected override void PopOut() => FadeOut(fadeDuration, EasingTypes.In); protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index e1ef040307..02a5f93a36 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -41,7 +41,7 @@ namespace osu.Game.Screens.Play public PlayMode PreferredPlayMode; - public bool isPaused; + public bool IsPaused; private double pauseCooldown = 1000; private double lastActionTime = 0; @@ -56,6 +56,7 @@ namespace osu.Game.Screens.Play private ScoreOverlay scoreOverlay; private PauseOverlay pauseOverlay; + private PlayerInputManager playerInputManager; [BackgroundDependencyLoader] private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuGameBase game, OsuConfigManager config) @@ -123,7 +124,7 @@ namespace osu.Game.Screens.Play Children = new Drawable[] { - new PlayerInputManager(game.Host) + playerInputManager = new PlayerInputManager(game.Host) { Clock = new InterpolatingFramedClock(sourceClock), PassThrough = false, @@ -142,35 +143,38 @@ namespace osu.Game.Screens.Play if (Time.Current >= (lastActionTime + pauseCooldown) || force) { lastActionTime = Time.Current; - isPaused = true; + playerInputManager.PassThrough = true; scoreOverlay.KeyCounter.IsCounting = false; pauseOverlay.Show(); sourceClock.Stop(); + IsPaused = true; } else { - isPaused = false; + IsPaused = false; } } public void Resume() { lastActionTime = Time.Current; - isPaused = false; + playerInputManager.PassThrough = false; scoreOverlay.KeyCounter.IsCounting = true; pauseOverlay.Hide(); sourceClock.Start(); + IsPaused = false; } public void TogglePaused() { - isPaused = !isPaused; - if (isPaused) Pause(); else Resume(); + IsPaused = !IsPaused; + if (IsPaused) Pause(); else Resume(); } public void Restart() { // TODO: Implement retrying + if (IsPaused) Resume(); } protected override void LoadComplete() @@ -237,12 +241,12 @@ namespace osu.Game.Screens.Play switch (args.Key) { case Key.Escape: - if (!isPaused) + if (!IsPaused) { Pause(); return true; } - else { return false; } + return false; } return base.OnKeyDown(state, args); } From d70cbd37dd779f907dbefd89d2062c7b1669a938 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 30 Jan 2017 04:08:14 -0400 Subject: [PATCH 18/40] Made the pause progress graph it's own class, to be implemented, made it so the user couldn't double click the pause buttons and made it so the action wasn't called a second time when the mouse button was released, made PopIn and PopOut in PauseOverlay one line each, made Player.IsPaused a public getter with a private getter/setter, implemented restarting in Player --- .../Tests/TestCasePauseOverlay.cs | 46 +++++++++++++---- osu.Game/Overlays/Pause/PauseButton.cs | 28 ++++++++-- osu.Game/Overlays/Pause/PauseOverlay.cs | 32 ++++++------ osu.Game/Overlays/Pause/PauseProgressBar.cs | 20 +++++--- osu.Game/Overlays/Pause/PauseProgressGraph.cs | 28 ++++++++++ osu.Game/Screens/Play/Player.cs | 51 +++++++++++++++---- osu.Game/osu.Game.csproj | 1 + 7 files changed, 157 insertions(+), 49 deletions(-) create mode 100644 osu.Game/Overlays/Pause/PauseProgressGraph.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs index 8b48779666..e311074124 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs @@ -18,6 +18,7 @@ namespace osu.Desktop.VisualTests.Tests public override string Description => @"Tests the pause overlay"; private PauseOverlay pauseOverlay; + private int retryCount; public override void Reset() { @@ -26,19 +27,46 @@ namespace osu.Desktop.VisualTests.Tests Add(new Box { ColourInfo = ColourInfo.GradientVertical(Color4.Gray, Color4.WhiteSmoke), - RelativeSizeAxes = Framework.Graphics.Axes.Both, + RelativeSizeAxes = Framework.Graphics.Axes.Both }); - Add(pauseOverlay = new PauseOverlay { Depth = -1 }); - Add(new Button + Add(pauseOverlay = new PauseOverlay { Depth = -1 }); + pauseOverlay.OnResume += (() => Logger.Log(@"Resume")); + pauseOverlay.OnRetry += (() => Logger.Log(@"Retry")); + pauseOverlay.OnQuit += (() => Logger.Log(@"Quit")); + + Add(new FlowContainer { - Text = @"Pause", - Anchor = Anchor.TopLeft, + RelativeSizeAxes = Axes.Both, Origin = Anchor.TopLeft, - Width = 100, - Height = 50, - Colour = Color4.Black, - Action = (() => pauseOverlay.Show()), + Anchor = Anchor.TopLeft, + Direction = FlowDirection.VerticalOnly, + Children = new Drawable[] + { + new Button + { + Text = @"Pause", + Anchor = Anchor.TopLeft, + Origin = Anchor.TopLeft, + Width = 100, + Height = 50, + Colour = Color4.Black, + Action = (() => pauseOverlay.Show()) + }, + new Button + { + Text = @"Add Retry", + Anchor = Anchor.TopLeft, + Origin = Anchor.TopLeft, + Width = 100, + Height = 50, + Colour = Color4.Black, + Action = (delegate { + retryCount++; + pauseOverlay.SetRetries(retryCount); + }), + } + } }); } } diff --git a/osu.Game/Overlays/Pause/PauseButton.cs b/osu.Game/Overlays/Pause/PauseButton.cs index 9914caf37d..d4a12101d2 100644 --- a/osu.Game/Overlays/Pause/PauseButton.cs +++ b/osu.Game/Overlays/Pause/PauseButton.cs @@ -1,7 +1,7 @@ -using OpenTK; +using System; +using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; -using osu.Game.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Transformations; using osu.Framework.Graphics.Colour; @@ -9,6 +9,7 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Containers; using osu.Framework.Audio; using osu.Framework.Audio.Sample; +using osu.Game.Graphics; using osu.Game.Graphics.Backgrounds; namespace osu.Game.Overlays.Pause @@ -55,16 +56,28 @@ namespace osu.Game.Overlays.Pause private Container colourContainer; private Container glowContainer; + private bool didClick; + public override bool Contains(Vector2 screenSpacePos) => backgroundContainer.Contains(screenSpacePos); protected override bool OnMouseDown(Framework.Input.InputState state, MouseDownEventArgs args) { - colourContainer.ResizeTo(new Vector2(1.1f, 1f), 200, EasingTypes.In); + didClick = true; + colourContainer.ResizeTo(new Vector2(1.5f, 1f), 200, EasingTypes.In); sampleClick?.Play(); Action?.Invoke(); + + Delay(200); + Schedule(delegate { + colourContainer.ResizeTo(new Vector2(colourWidth, 1f), 0, EasingTypes.None); + glowContainer.Alpha = 0; + }); + return true; } + protected override bool OnClick(Framework.Input.InputState state) => false; + protected override bool OnHover(Framework.Input.InputState state) { colourContainer.ResizeTo(new Vector2(colourExpandedWidth, 1f), colourExpandTime, EasingTypes.OutElastic); @@ -75,8 +88,13 @@ 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 / 2, EasingTypes.Out); + if (!didClick) + { + colourContainer.ResizeTo(new Vector2(colourWidth, 1f), colourExpandTime, EasingTypes.OutElastic); + glowContainer.FadeTo(0f, colourExpandTime / 2, EasingTypes.Out); + } + + didClick = false; } [BackgroundDependencyLoader] diff --git a/osu.Game/Overlays/Pause/PauseOverlay.cs b/osu.Game/Overlays/Pause/PauseOverlay.cs index 3d345eb404..728dc9e8de 100644 --- a/osu.Game/Overlays/Pause/PauseOverlay.cs +++ b/osu.Game/Overlays/Pause/PauseOverlay.cs @@ -24,7 +24,23 @@ namespace osu.Game.Overlays.Pause private SpriteText retryCounter; public override bool Contains(Vector2 screenSpacePos) => true; + public override bool HandleInput => State == Visibility.Visible; + protected override void PopIn() => FadeIn(fadeDuration, EasingTypes.In); + protected override void PopOut() => FadeOut(fadeDuration, EasingTypes.In); + + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + switch (args.Key) + { + case Key.Escape: + if (State == Visibility.Hidden) return false; + Hide(); + Task.Delay(fadeDuration * 2).ContinueWith(task => OnResume?.Invoke()); + return true; + } + return base.OnKeyDown(state, args); + } [BackgroundDependencyLoader] private void load(OsuColour colours) @@ -149,22 +165,6 @@ namespace osu.Game.Overlays.Pause retryCounter.Text = $"You've retried {String.Format("{0:n0}", count)} time{(count == 1) ? "" : "s"} in this session"; } - protected override void PopIn() => FadeIn(fadeDuration, EasingTypes.In); - protected override void PopOut() => FadeOut(fadeDuration, EasingTypes.In); - - protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) - { - switch (args.Key) - { - case Key.Escape: - if (State == Visibility.Hidden) return false; - Hide(); - Task.Delay(fadeDuration * 2).ContinueWith(task => OnResume?.Invoke()); - return true; - } - return base.OnKeyDown(state, args); - } - public PauseOverlay() { RelativeSizeAxes = Axes.Both; diff --git a/osu.Game/Overlays/Pause/PauseProgressBar.cs b/osu.Game/Overlays/Pause/PauseProgressBar.cs index 2c48bf8689..f3b404a4c0 100644 --- a/osu.Game/Overlays/Pause/PauseProgressBar.cs +++ b/osu.Game/Overlays/Pause/PauseProgressBar.cs @@ -1,15 +1,8 @@ -using System; -using OpenTK; -using OpenTK.Input; -using OpenTK.Graphics; -using osu.Game.Graphics; -using osu.Framework.Input; +using OpenTK.Graphics; 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; @@ -43,6 +36,17 @@ namespace osu.Game.Overlays.Pause Children = new Drawable[] { + new PauseProgressGraph + { + RelativeSizeAxes = Axes.X, + Origin = Anchor.BottomCentre, + Anchor = Anchor.BottomCentre, + Height = 35, + Margin = new MarginPadding + { + Bottom = 5 + } + }, new Container { Origin = Anchor.BottomRight, diff --git a/osu.Game/Overlays/Pause/PauseProgressGraph.cs b/osu.Game/Overlays/Pause/PauseProgressGraph.cs new file mode 100644 index 0000000000..08667c94c7 --- /dev/null +++ b/osu.Game/Overlays/Pause/PauseProgressGraph.cs @@ -0,0 +1,28 @@ +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Containers; +using osu.Game.Beatmaps; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Configuration; + +namespace osu.Game.Overlays.Pause +{ + public class PauseProgressGraph : FlowContainer + { + private WorkingBeatmap current; + + [BackgroundDependencyLoader] + private void load(OsuGameBase osuGame) + { + current = osuGame.Beatmap.Value; + } + + public PauseProgressGraph() + { + // TODO: Implement the pause progress graph + } + } +} diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 02a5f93a36..9b4c151e3c 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -41,10 +41,19 @@ namespace osu.Game.Screens.Play public PlayMode PreferredPlayMode; - public bool IsPaused; + private bool isPaused; + public bool IsPaused + { + get + { + return isPaused; + } + } + + public int RestartCount; private double pauseCooldown = 1000; - private double lastActionTime = 0; + private double lastPauseActionTime = 0; private IAdjustableClock sourceClock; @@ -140,41 +149,57 @@ namespace osu.Game.Screens.Play public void Pause(bool force = false) { - if (Time.Current >= (lastActionTime + pauseCooldown) || force) + if (Time.Current >= (lastPauseActionTime + pauseCooldown) || force) { - lastActionTime = Time.Current; + lastPauseActionTime = Time.Current; playerInputManager.PassThrough = true; scoreOverlay.KeyCounter.IsCounting = false; + pauseOverlay.SetRetries(RestartCount); pauseOverlay.Show(); sourceClock.Stop(); - IsPaused = true; + isPaused = true; } else { - IsPaused = false; + isPaused = false; } } public void Resume() { - lastActionTime = Time.Current; + lastPauseActionTime = Time.Current; playerInputManager.PassThrough = false; scoreOverlay.KeyCounter.IsCounting = true; pauseOverlay.Hide(); sourceClock.Start(); - IsPaused = false; + isPaused = false; } public void TogglePaused() { - IsPaused = !IsPaused; + isPaused = !IsPaused; if (IsPaused) Pause(); else Resume(); } public void Restart() { - // TODO: Implement retrying - if (IsPaused) Resume(); + sourceClock.Stop(); // If the clock is not stopped and Restart is called alot of lag will happen until the game is relaunched + + var newPlayer = new Player(); + + newPlayer.Preload(Game, delegate + { + RestartCount++; + newPlayer.RestartCount = RestartCount; + Exit(); + + if (!(last?.Push(newPlayer) ?? false)) + { + // Error(?) + } + + Dispose(); + }); } protected override void LoadComplete() @@ -218,6 +243,8 @@ namespace osu.Game.Screens.Play }); } + private GameMode last; + protected override void OnEntering(GameMode last) { base.OnEntering(last); @@ -227,6 +254,8 @@ namespace osu.Game.Screens.Play Content.Alpha = 0; dimLevel.ValueChanged += dimChanged; + + this.last = last; } protected override bool OnExiting(GameMode next) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index cf0fc50373..f143afc498 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -239,6 +239,7 @@ + From f8cbc35f8e74cf111446188df8233662fa8efdb5 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 30 Jan 2017 04:43:06 -0400 Subject: [PATCH 19/40] Small cleanups --- .../Tests/TestCasePauseOverlay.cs | 83 ++++++++++--------- osu.Game/Overlays/Pause/PauseButton.cs | 28 +++---- osu.Game/Overlays/Pause/PauseOverlay.cs | 9 +- 3 files changed, 64 insertions(+), 56 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs index e311074124..81fbb84620 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs @@ -24,50 +24,55 @@ namespace osu.Desktop.VisualTests.Tests { base.Reset(); - Add(new Box + Children = new Drawable[] { - ColourInfo = ColourInfo.GradientVertical(Color4.Gray, Color4.WhiteSmoke), - RelativeSizeAxes = Framework.Graphics.Axes.Both - }); + new Box + { + ColourInfo = ColourInfo.GradientVertical(Color4.Gray, Color4.WhiteSmoke), + RelativeSizeAxes = Framework.Graphics.Axes.Both + }, + pauseOverlay = new PauseOverlay + { + Depth = -1 + }, + new FlowContainer + { + RelativeSizeAxes = Axes.Both, + Origin = Anchor.TopLeft, + Anchor = Anchor.TopLeft, + Direction = FlowDirection.VerticalOnly, + Children = new Drawable[] + { + new Button + { + Text = @"Pause", + Anchor = Anchor.TopLeft, + Origin = Anchor.TopLeft, + Width = 100, + Height = 50, + Colour = Color4.Black, + Action = (() => pauseOverlay.Show()) + }, + new Button + { + Text = @"Add Retry", + Anchor = Anchor.TopLeft, + Origin = Anchor.TopLeft, + Width = 100, + Height = 50, + Colour = Color4.Black, + Action = (delegate { + retryCount++; + pauseOverlay.SetRetries(retryCount); + }), + } + } + } + }; - Add(pauseOverlay = new PauseOverlay { Depth = -1 }); pauseOverlay.OnResume += (() => Logger.Log(@"Resume")); pauseOverlay.OnRetry += (() => Logger.Log(@"Retry")); pauseOverlay.OnQuit += (() => Logger.Log(@"Quit")); - - Add(new FlowContainer - { - RelativeSizeAxes = Axes.Both, - Origin = Anchor.TopLeft, - Anchor = Anchor.TopLeft, - Direction = FlowDirection.VerticalOnly, - Children = new Drawable[] - { - new Button - { - Text = @"Pause", - Anchor = Anchor.TopLeft, - Origin = Anchor.TopLeft, - Width = 100, - Height = 50, - Colour = Color4.Black, - Action = (() => pauseOverlay.Show()) - }, - new Button - { - Text = @"Add Retry", - Anchor = Anchor.TopLeft, - Origin = Anchor.TopLeft, - Width = 100, - Height = 50, - Colour = Color4.Black, - Action = (delegate { - retryCount++; - pauseOverlay.SetRetries(retryCount); - }), - } - } - }); } } } diff --git a/osu.Game/Overlays/Pause/PauseButton.cs b/osu.Game/Overlays/Pause/PauseButton.cs index d4a12101d2..7d277a5ac5 100644 --- a/osu.Game/Overlays/Pause/PauseButton.cs +++ b/osu.Game/Overlays/Pause/PauseButton.cs @@ -16,12 +16,10 @@ namespace osu.Game.Overlays.Pause { public class PauseButton : ClickableContainer { - private float height = 70; - private float colourWidth = 0.8f; - private float colourExpandedWidth = 0.9f; - private float colourExpandTime = 500; - private float shear = 0.2f; - private float glowGradientEndAlpha = 0f; + private const float colourWidth = 0.8f; + private const float colourExpandedWidth = 0.9f; + private const float colourExpandTime = 500; + private Vector2 colourShear = new Vector2(0.2f, 0); private Color4 buttonColour; private Color4 backgroundColour = OsuColour.Gray(34); @@ -56,7 +54,7 @@ namespace osu.Game.Overlays.Pause private Container colourContainer; private Container glowContainer; - private bool didClick; + private bool didClick; // Used for making sure that the OnMouseDown animation can call instead of OnHoverLost's public override bool Contains(Vector2 screenSpacePos) => backgroundContainer.Contains(screenSpacePos); @@ -113,7 +111,7 @@ namespace osu.Game.Overlays.Pause break; case PauseButtonType.Quit: - // For whatever reason the red from the mockup is not in the osu! palette + // The red from the design isn't in the palette so it's used directly buttonColour = new Color4(170, 27, 39, 255); sampleClick = audio.Sample.Get(@"Menu/menuback"); break; @@ -149,7 +147,7 @@ namespace osu.Game.Overlays.Pause Origin = Anchor.TopLeft, Anchor = Anchor.TopLeft, Width = 0.125f, - ColourInfo = ColourInfo.GradientHorizontal(new Color4(buttonColour.R, buttonColour.G, buttonColour.B, glowGradientEndAlpha), buttonColour) + ColourInfo = ColourInfo.GradientHorizontal(new Color4(buttonColour.R, buttonColour.G, buttonColour.B, 0f), buttonColour) }, new Box { @@ -165,14 +163,13 @@ namespace osu.Game.Overlays.Pause Origin = Anchor.TopRight, Anchor = Anchor.TopRight, Width = 0.125f, - ColourInfo = ColourInfo.GradientHorizontal(buttonColour, new Color4(buttonColour.R, buttonColour.G, buttonColour.B, glowGradientEndAlpha)) + ColourInfo = ColourInfo.GradientHorizontal(buttonColour, new Color4(buttonColour.R, buttonColour.G, buttonColour.B, 0f)) } } }, new Container { - RelativeSizeAxes = Axes.X, - Height = height, + RelativeSizeAxes = Axes.Both, Origin = Anchor.Centre, Anchor = Anchor.Centre, Masking = true, @@ -192,7 +189,7 @@ namespace osu.Game.Overlays.Pause Radius = 5 }, Colour = buttonColour, - Shear = new Vector2(shear, 0), + Shear = colourShear, Children = new Drawable[] { new Box @@ -206,7 +203,7 @@ namespace osu.Game.Overlays.Pause RelativeSizeAxes = Axes.Both, TriangleScale = 4, Alpha = 0.05f, - Shear = new Vector2(-shear, 0) + Shear = -colourShear } } } @@ -228,8 +225,7 @@ namespace osu.Game.Overlays.Pause public PauseButton() { - Height = height; - RelativeSizeAxes = Axes.X; + } } diff --git a/osu.Game/Overlays/Pause/PauseOverlay.cs b/osu.Game/Overlays/Pause/PauseOverlay.cs index 728dc9e8de..7a3867766f 100644 --- a/osu.Game/Overlays/Pause/PauseOverlay.cs +++ b/osu.Game/Overlays/Pause/PauseOverlay.cs @@ -15,7 +15,8 @@ namespace osu.Game.Overlays.Pause { public class PauseOverlay : OverlayContainer { - private int fadeDuration = 200; + private const int fadeDuration = 200; + private const int buttonHeight = 70; public Action OnResume; public Action OnRetry; @@ -120,8 +121,10 @@ namespace osu.Game.Overlays.Pause new PauseButton { Type = PauseButtonType.Resume, + RelativeSizeAxes = Axes.X, Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, + Height = buttonHeight, Action = (delegate { Hide(); @@ -131,8 +134,10 @@ namespace osu.Game.Overlays.Pause new PauseButton { Type = PauseButtonType.Retry, + RelativeSizeAxes = Axes.X, Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, + Height = buttonHeight, Action = (delegate { Hide(); @@ -142,8 +147,10 @@ namespace osu.Game.Overlays.Pause new PauseButton { Type = PauseButtonType.Quit, + RelativeSizeAxes = Axes.X, Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, + Height = buttonHeight, Action = (delegate { Hide(); From 62282076c76c7db9768dc65652fb0ddcbc166e2d Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 30 Jan 2017 05:04:57 -0400 Subject: [PATCH 20/40] Changes on PauseButton to match design closer --- osu.Game/Overlays/Pause/PauseButton.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/Pause/PauseButton.cs b/osu.Game/Overlays/Pause/PauseButton.cs index 7d277a5ac5..6d0371ef27 100644 --- a/osu.Game/Overlays/Pause/PauseButton.cs +++ b/osu.Game/Overlays/Pause/PauseButton.cs @@ -50,9 +50,9 @@ namespace osu.Game.Overlays.Pause } } - private Container backgroundContainer; - private Container colourContainer; - private Container glowContainer; + private Container backgroundContainer, colourContainer, glowContainer; + + private SpriteText spriteText; private bool didClick; // Used for making sure that the OnMouseDown animation can call instead of OnHoverLost's @@ -68,6 +68,7 @@ namespace osu.Game.Overlays.Pause Delay(200); Schedule(delegate { colourContainer.ResizeTo(new Vector2(colourWidth, 1f), 0, EasingTypes.None); + spriteText.Spacing = Vector2.Zero; glowContainer.Alpha = 0; }); @@ -79,6 +80,7 @@ namespace osu.Game.Overlays.Pause protected override bool OnHover(Framework.Input.InputState state) { colourContainer.ResizeTo(new Vector2(colourExpandedWidth, 1f), colourExpandTime, EasingTypes.OutElastic); + spriteText.TransformSpacingTo(new Vector2(3f, 0f), colourExpandTime, EasingTypes.OutElastic); glowContainer.FadeTo(1f, colourExpandTime / 2, EasingTypes.Out); sampleHover?.Play(); return true; @@ -89,6 +91,7 @@ namespace osu.Game.Overlays.Pause if (!didClick) { colourContainer.ResizeTo(new Vector2(colourWidth, 1f), colourExpandTime, EasingTypes.OutElastic); + spriteText.TransformSpacingTo(Vector2.Zero, colourExpandTime, EasingTypes.OutElastic); glowContainer.FadeTo(0f, colourExpandTime / 2, EasingTypes.Out); } @@ -209,12 +212,12 @@ namespace osu.Game.Overlays.Pause } } }, - new SpriteText + spriteText = new SpriteText { Text = Text, Anchor = Anchor.Centre, Origin = Anchor.Centre, - TextSize = 25, + TextSize = 28, Font = "Exo2.0-Bold", Shadow = true, ShadowColour = new Color4(0, 0, 0, 0.1f), From 015832f242dbc58a8f34245329124d00935c1bb5 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 30 Jan 2017 06:14:28 -0400 Subject: [PATCH 21/40] Changed PauseOverlay to layout with FlowContainers and not positioning, made the retry counter in PauseOverlay have the number bolded, made it so if the player presses escape before the clock is started in Player then Exit is called instead of Pause --- osu.Game/Overlays/Pause/PauseOverlay.cs | 239 ++++++++++++++---------- osu.Game/Screens/Play/Player.cs | 12 +- 2 files changed, 144 insertions(+), 107 deletions(-) diff --git a/osu.Game/Overlays/Pause/PauseOverlay.cs b/osu.Game/Overlays/Pause/PauseOverlay.cs index 7a3867766f..d240020d20 100644 --- a/osu.Game/Overlays/Pause/PauseOverlay.cs +++ b/osu.Game/Overlays/Pause/PauseOverlay.cs @@ -22,7 +22,7 @@ namespace osu.Game.Overlays.Pause public Action OnRetry; public Action OnQuit; - private SpriteText retryCounter; + private FlowContainer retryCounterContainer; public override bool Contains(Vector2 screenSpacePos) => true; public override bool HandleInput => State == Visibility.Visible; @@ -48,116 +48,121 @@ namespace osu.Game.Overlays.Pause { Children = new Drawable[] { - new Container + new Box { RelativeSizeAxes = Axes.Both, - + Colour = Color4.Black, + Alpha = 0.75f, + }, + new FlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FlowDirection.VerticalOnly, + Spacing = new Vector2(0f, 50f), + Origin = Anchor.Centre, + Anchor = Anchor.Centre, Children = new Drawable[] { - new Box + new FlowContainer { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black, - Alpha = 0.75f, - } + AutoSizeAxes = Axes.Both, + Direction = FlowDirection.VerticalOnly, + Spacing = new Vector2(0f, 20f), + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + Children = new Drawable[] + { + new SpriteText + { + Text = @"paused", + 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 SpriteText + { + Text = @"you're not going to do what i think you're going to do, ain't ya?", + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + Shadow = true, + ShadowColour = new Color4(0, 0, 0, 0.25f), + }, + } + }, + new FlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Masking = true, + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Shadow, + Colour = new Color4(0, 0, 0, 150), + Radius = 50, + Offset = new Vector2(0, 0), + }, + Children = new Drawable[] + { + new PauseButton + { + Type = PauseButtonType.Resume, + RelativeSizeAxes = Axes.X, + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + Height = buttonHeight, + Action = (delegate + { + Hide(); + Task.Delay(fadeDuration * 2).ContinueWith(task => OnResume?.Invoke()); + }), + }, + new PauseButton + { + Type = PauseButtonType.Retry, + RelativeSizeAxes = Axes.X, + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + Height = buttonHeight, + Action = (delegate + { + Hide(); + OnRetry?.Invoke(); + }), + }, + new PauseButton + { + Type = PauseButtonType.Quit, + RelativeSizeAxes = Axes.X, + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + Height = buttonHeight, + Action = (delegate + { + Hide(); + OnQuit?.Invoke(); + }), + }, + } + }, + retryCounterContainer = new FlowContainer + { + AutoSizeAxes = Axes.Both, + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + }, } }, - new SpriteText - { - Text = @"paused", - Origin = Anchor.BottomCentre, - Anchor = Anchor.Centre, - Position = new Vector2(0, -175), - Font = @"Exo2.0-Medium", - Spacing = new Vector2(5, 0), - TextSize = 30, - Colour = colours.Yellow, - Shadow = true, - ShadowColour = new Color4(0, 0, 0, 0.25f), - }, - new SpriteText - { - Text = @"you're not going to do what i think you're going to do, ain't ya?", - Origin = Anchor.BottomCentre, - Anchor = Anchor.Centre, - Width = 100, - Position = new Vector2(0, -125), - Shadow = true, - ShadowColour = new Color4(0, 0, 0, 0.25f), - }, - retryCounter = new SpriteText - { - Origin = Anchor.TopCentre, - Anchor = Anchor.Centre, - Width = 100, - Position = new Vector2(0, 175), - Shadow = true, - ShadowColour = new Color4(0, 0, 0, 0.25f), - TextSize = 18, - }, new PauseProgressBar { Origin = Anchor.BottomCentre, Anchor = Anchor.BottomCentre, Width = 1f, - }, - new FlowContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Position = new Vector2(0, 25), - Masking = true, - EdgeEffect = new EdgeEffect - { - Type = EdgeEffectType.Shadow, - Colour = new Color4(0, 0, 0, 150), - Radius = 50, - Offset = new Vector2(0, 0), - }, - Children = new Drawable[] - { - new PauseButton - { - Type = PauseButtonType.Resume, - RelativeSizeAxes = Axes.X, - Origin = Anchor.TopCentre, - Anchor = Anchor.TopCentre, - Height = buttonHeight, - Action = (delegate - { - Hide(); - Task.Delay(fadeDuration * 2).ContinueWith(task => OnResume?.Invoke()); - }), - }, - new PauseButton - { - Type = PauseButtonType.Retry, - RelativeSizeAxes = Axes.X, - Origin = Anchor.TopCentre, - Anchor = Anchor.TopCentre, - Height = buttonHeight, - Action = (delegate - { - Hide(); - OnRetry?.Invoke(); - }), - }, - new PauseButton - { - Type = PauseButtonType.Quit, - RelativeSizeAxes = Axes.X, - Origin = Anchor.TopCentre, - Anchor = Anchor.TopCentre, - Height = buttonHeight, - Action = (delegate - { - Hide(); - OnQuit?.Invoke(); - }), - }, - } }, }; @@ -166,16 +171,46 @@ namespace osu.Game.Overlays.Pause public void SetRetries(int count) { - if (retryCounter != null) + if (retryCounterContainer != null) + { // "You've retried 1,065 times in this session" // "You've retried 1 time in this session" - retryCounter.Text = $"You've retried {String.Format("{0:n0}", count)} time{(count == 1) ? "" : "s"} 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 + } + }; + } } public PauseOverlay() { RelativeSizeAxes = Axes.Both; - AutoSizeAxes = Axes.Both; } } } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 9b4c151e3c..191fb62dde 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -55,6 +55,8 @@ namespace osu.Game.Screens.Play private double pauseCooldown = 1000; private double lastPauseActionTime = 0; + private bool clockWasStarted = false; + private IAdjustableClock sourceClock; private Ruleset ruleset; @@ -183,14 +185,13 @@ namespace osu.Game.Screens.Play public void Restart() { - sourceClock.Stop(); // If the clock is not stopped and Restart is called alot of lag will happen until the game is relaunched + sourceClock.Stop(); // If the clock is running and Restart is called the game will lag until relaunch var newPlayer = new Player(); newPlayer.Preload(Game, delegate { - RestartCount++; - newPlayer.RestartCount = RestartCount; + newPlayer.RestartCount = RestartCount + 1; Exit(); if (!(last?.Push(newPlayer) ?? false)) @@ -214,6 +215,7 @@ namespace osu.Game.Screens.Play Schedule(() => { sourceClock.Start(); + clockWasStarted = true; }); } @@ -270,12 +272,12 @@ namespace osu.Game.Screens.Play switch (args.Key) { case Key.Escape: - if (!IsPaused) + if (!IsPaused && clockWasStarted) // For if the user presses escape quickly when entering the map { Pause(); return true; } - return false; + break; } return base.OnKeyDown(state, args); } From ad33ae9431e34d688830e6bc6506a120d0f05bf6 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 30 Jan 2017 06:24:44 -0400 Subject: [PATCH 22/40] Removed unnecessary change --- osu.Game/Screens/Play/Player.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 191fb62dde..cb3e2e489b 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -252,7 +252,7 @@ namespace osu.Game.Screens.Play base.OnEntering(last); (Background as BackgroundModeBeatmap)?.BlurTo(Vector2.Zero, 1000); - Background?.FadeTo((100f - dimLevel) / 100, 1000); + Background?.FadeTo((100f- dimLevel)/100, 1000); Content.Alpha = 0; dimLevel.ValueChanged += dimChanged; From dcb02eff65372036cffdf3efac1487b771051993 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 30 Jan 2017 07:19:14 -0400 Subject: [PATCH 23/40] Cleared out PauseProgressGraph --- osu.Game/Overlays/Pause/PauseProgressGraph.cs | 21 +++---------------- 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/osu.Game/Overlays/Pause/PauseProgressGraph.cs b/osu.Game/Overlays/Pause/PauseProgressGraph.cs index 08667c94c7..bc8b377824 100644 --- a/osu.Game/Overlays/Pause/PauseProgressGraph.cs +++ b/osu.Game/Overlays/Pause/PauseProgressGraph.cs @@ -1,25 +1,10 @@ -using OpenTK; -using OpenTK.Graphics; -using osu.Framework.Allocation; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Containers; -using osu.Game.Beatmaps; -using osu.Framework.Graphics.Primitives; -using osu.Framework.Configuration; +using osu.Framework.Graphics.Containers; namespace osu.Game.Overlays.Pause { - public class PauseProgressGraph : FlowContainer + public class PauseProgressGraph : Container { - private WorkingBeatmap current; - - [BackgroundDependencyLoader] - private void load(OsuGameBase osuGame) - { - current = osuGame.Beatmap.Value; - } - + public PauseProgressGraph() { // TODO: Implement the pause progress graph From ed3ed8251f23e01cfe99721086d8c7971c07e821 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 30 Jan 2017 08:04:39 -0400 Subject: [PATCH 24/40] Made styling PauseButtons public, Resume/Retry/Quit buttons changed to subclasses --- osu.Game/Overlays/Pause/PauseButton.cs | 97 ++++++++----------------- osu.Game/Overlays/Pause/PauseOverlay.cs | 9 +-- osu.Game/Overlays/Pause/QuitButton.cs | 23 ++++++ osu.Game/Overlays/Pause/ResumeButton.cs | 22 ++++++ osu.Game/Overlays/Pause/RetryButton.cs | 22 ++++++ osu.Game/osu.Game.csproj | 3 + 6 files changed, 105 insertions(+), 71 deletions(-) create mode 100644 osu.Game/Overlays/Pause/QuitButton.cs create mode 100644 osu.Game/Overlays/Pause/ResumeButton.cs create mode 100644 osu.Game/Overlays/Pause/RetryButton.cs diff --git a/osu.Game/Overlays/Pause/PauseButton.cs b/osu.Game/Overlays/Pause/PauseButton.cs index 6d0371ef27..10c5487db9 100644 --- a/osu.Game/Overlays/Pause/PauseButton.cs +++ b/osu.Game/Overlays/Pause/PauseButton.cs @@ -1,13 +1,10 @@ -using System; -using OpenTK; +using OpenTK; using OpenTK.Graphics; -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Transformations; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Containers; -using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Game.Graphics; using osu.Game.Graphics.Backgrounds; @@ -21,37 +18,41 @@ namespace osu.Game.Overlays.Pause private const float colourExpandTime = 500; private Vector2 colourShear = new Vector2(0.2f, 0); - private Color4 buttonColour; private Color4 backgroundColour = OsuColour.Gray(34); - private AudioSample sampleClick; - private AudioSample sampleHover; - - public PauseButtonType Type; + private Color4 buttonColour; + public Color4 ButtonColour + { + get + { + return buttonColour; + } + set + { + buttonColour = value; + if (colourContainer == null) return; + colourContainer.Colour = ButtonColour; + } + } + private string text; public string Text { get { - switch (Type) - { - case PauseButtonType.Resume: - return "Continue"; - - case PauseButtonType.Retry: - return "Retry"; - - case PauseButtonType.Quit: - return "Quit to Main Menu"; - - default: - return "Unknown"; - } + return text; + } + set + { + text = value; + if (spriteText == null) return; + spriteText.Text = Text; } } - private Container backgroundContainer, colourContainer, glowContainer; + public AudioSample SampleClick, SampleHover; + private Container backgroundContainer, colourContainer, glowContainer; private SpriteText spriteText; private bool didClick; // Used for making sure that the OnMouseDown animation can call instead of OnHoverLost's @@ -62,7 +63,7 @@ namespace osu.Game.Overlays.Pause { didClick = true; colourContainer.ResizeTo(new Vector2(1.5f, 1f), 200, EasingTypes.In); - sampleClick?.Play(); + SampleClick?.Play(); Action?.Invoke(); Delay(200); @@ -82,7 +83,7 @@ namespace osu.Game.Overlays.Pause colourContainer.ResizeTo(new Vector2(colourExpandedWidth, 1f), colourExpandTime, EasingTypes.OutElastic); spriteText.TransformSpacingTo(new Vector2(3f, 0f), colourExpandTime, EasingTypes.OutElastic); glowContainer.FadeTo(1f, colourExpandTime / 2, EasingTypes.Out); - sampleHover?.Play(); + SampleHover?.Play(); return true; } @@ -98,30 +99,8 @@ namespace osu.Game.Overlays.Pause didClick = false; } - [BackgroundDependencyLoader] - private void load(AudioManager audio, OsuColour colours) + public PauseButton() { - switch (Type) - { - case PauseButtonType.Resume: - buttonColour = colours.Green; - sampleClick = audio.Sample.Get(@"Menu/menuback"); - break; - - case PauseButtonType.Retry: - buttonColour = colours.YellowDark; - sampleClick = audio.Sample.Get(@"Menu/menu-play-click"); - break; - - case PauseButtonType.Quit: - // The red from the design isn't in the palette so it's used directly - buttonColour = new Color4(170, 27, 39, 255); - sampleClick = audio.Sample.Get(@"Menu/menuback"); - break; - } - - sampleHover = audio.Sample.Get(@"Menu/menuclick"); - Add(new Drawable[] { backgroundContainer = new Container @@ -150,7 +129,7 @@ namespace osu.Game.Overlays.Pause Origin = Anchor.TopLeft, Anchor = Anchor.TopLeft, Width = 0.125f, - ColourInfo = ColourInfo.GradientHorizontal(new Color4(buttonColour.R, buttonColour.G, buttonColour.B, 0f), buttonColour) + ColourInfo = ColourInfo.GradientHorizontal(new Color4(ButtonColour.R, ButtonColour.G, ButtonColour.B, 0f), ButtonColour) }, new Box { @@ -158,7 +137,7 @@ namespace osu.Game.Overlays.Pause Origin = Anchor.Centre, Anchor = Anchor.Centre, Width = 0.75f, - Colour = buttonColour + Colour = ButtonColour }, new Box { @@ -166,7 +145,7 @@ namespace osu.Game.Overlays.Pause Origin = Anchor.TopRight, Anchor = Anchor.TopRight, Width = 0.125f, - ColourInfo = ColourInfo.GradientHorizontal(buttonColour, new Color4(buttonColour.R, buttonColour.G, buttonColour.B, 0f)) + ColourInfo = ColourInfo.GradientHorizontal(ButtonColour, new Color4(ButtonColour.R, ButtonColour.G, ButtonColour.B, 0f)) } } }, @@ -191,7 +170,7 @@ namespace osu.Game.Overlays.Pause Colour = Color4.Black.Opacity(0.2f), Radius = 5 }, - Colour = buttonColour, + Colour = ButtonColour, Shear = colourShear, Children = new Drawable[] { @@ -225,17 +204,5 @@ namespace osu.Game.Overlays.Pause } }); } - - public PauseButton() - { - - } - } - - public enum PauseButtonType - { - Resume, - Retry, - Quit } } diff --git a/osu.Game/Overlays/Pause/PauseOverlay.cs b/osu.Game/Overlays/Pause/PauseOverlay.cs index d240020d20..8993360cd7 100644 --- a/osu.Game/Overlays/Pause/PauseOverlay.cs +++ b/osu.Game/Overlays/Pause/PauseOverlay.cs @@ -109,9 +109,8 @@ namespace osu.Game.Overlays.Pause }, Children = new Drawable[] { - new PauseButton + new ResumeButton { - Type = PauseButtonType.Resume, RelativeSizeAxes = Axes.X, Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, @@ -122,9 +121,8 @@ namespace osu.Game.Overlays.Pause Task.Delay(fadeDuration * 2).ContinueWith(task => OnResume?.Invoke()); }), }, - new PauseButton + new RetryButton { - Type = PauseButtonType.Retry, RelativeSizeAxes = Axes.X, Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, @@ -135,9 +133,8 @@ namespace osu.Game.Overlays.Pause OnRetry?.Invoke(); }), }, - new PauseButton + new QuitButton { - Type = PauseButtonType.Quit, RelativeSizeAxes = Axes.X, Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, diff --git a/osu.Game/Overlays/Pause/QuitButton.cs b/osu.Game/Overlays/Pause/QuitButton.cs new file mode 100644 index 0000000000..05d6171d2e --- /dev/null +++ b/osu.Game/Overlays/Pause/QuitButton.cs @@ -0,0 +1,23 @@ +using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Game.Graphics; + +namespace osu.Game.Overlays.Pause +{ + public class QuitButton : PauseButton + { + [BackgroundDependencyLoader] + private void load(AudioManager audio, OsuColour colours) + { + 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/Overlays/Pause/ResumeButton.cs b/osu.Game/Overlays/Pause/ResumeButton.cs new file mode 100644 index 0000000000..216a852993 --- /dev/null +++ b/osu.Game/Overlays/Pause/ResumeButton.cs @@ -0,0 +1,22 @@ +using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Game.Graphics; + +namespace osu.Game.Overlays.Pause +{ + public class ResumeButton : PauseButton + { + [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/Overlays/Pause/RetryButton.cs b/osu.Game/Overlays/Pause/RetryButton.cs new file mode 100644 index 0000000000..12378ca43b --- /dev/null +++ b/osu.Game/Overlays/Pause/RetryButton.cs @@ -0,0 +1,22 @@ +using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Game.Graphics; + +namespace osu.Game.Overlays.Pause +{ + public class RetryButton : PauseButton + { + [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"; + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index f143afc498..fa2ccfa0d5 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -240,6 +240,9 @@ + + + From 8f6a6143d6e6f64f524399ca96b9ddf81caaa011 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 30 Jan 2017 08:07:37 -0400 Subject: [PATCH 25/40] Removed excess parenthesis --- osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs index 81fbb84620..171c77dd66 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs @@ -51,7 +51,7 @@ namespace osu.Desktop.VisualTests.Tests Width = 100, Height = 50, Colour = Color4.Black, - Action = (() => pauseOverlay.Show()) + Action = () => pauseOverlay.Show() }, new Button { @@ -70,9 +70,9 @@ namespace osu.Desktop.VisualTests.Tests } }; - pauseOverlay.OnResume += (() => Logger.Log(@"Resume")); - pauseOverlay.OnRetry += (() => Logger.Log(@"Retry")); - pauseOverlay.OnQuit += (() => Logger.Log(@"Quit")); + pauseOverlay.OnResume += () => Logger.Log(@"Resume"); + pauseOverlay.OnRetry += () => Logger.Log(@"Retry"); + pauseOverlay.OnQuit += () => Logger.Log(@"Quit"); } } } From 9ab49247b2b01f4a7f2d13d1422d83dbca075c86 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 30 Jan 2017 08:08:38 -0400 Subject: [PATCH 26/40] Forgot one --- osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs index 171c77dd66..b958f75fe6 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs @@ -61,10 +61,10 @@ namespace osu.Desktop.VisualTests.Tests Width = 100, Height = 50, Colour = Color4.Black, - Action = (delegate { + Action = delegate { retryCount++; pauseOverlay.SetRetries(retryCount); - }), + }, } } } From dbb9078e3047d563fa69d8bf43d552e3e3179eb4 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 30 Jan 2017 08:19:44 -0400 Subject: [PATCH 27/40] Fixed glow on PauseButton not updating --- osu.Game/Overlays/Pause/PauseButton.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Pause/PauseButton.cs b/osu.Game/Overlays/Pause/PauseButton.cs index 10c5487db9..3ccbedc6f0 100644 --- a/osu.Game/Overlays/Pause/PauseButton.cs +++ b/osu.Game/Overlays/Pause/PauseButton.cs @@ -32,6 +32,7 @@ namespace osu.Game.Overlays.Pause buttonColour = value; if (colourContainer == null) return; colourContainer.Colour = ButtonColour; + reapplyGlow(); } } @@ -53,6 +54,7 @@ namespace osu.Game.Overlays.Pause public AudioSample SampleClick, SampleHover; private Container backgroundContainer, colourContainer, glowContainer; + private Box leftGlow, centerGlow, rightGlow; private SpriteText spriteText; private bool didClick; // Used for making sure that the OnMouseDown animation can call instead of OnHoverLost's @@ -99,6 +101,14 @@ namespace osu.Game.Overlays.Pause didClick = false; } + private void reapplyGlow() + { + 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)); + } + public PauseButton() { Add(new Drawable[] @@ -123,7 +133,7 @@ namespace osu.Game.Overlays.Pause Alpha = 0f, Children = new Drawable[] { - new Box + leftGlow = new Box { RelativeSizeAxes = Axes.Both, Origin = Anchor.TopLeft, @@ -131,7 +141,7 @@ namespace osu.Game.Overlays.Pause Width = 0.125f, ColourInfo = ColourInfo.GradientHorizontal(new Color4(ButtonColour.R, ButtonColour.G, ButtonColour.B, 0f), ButtonColour) }, - new Box + centerGlow = new Box { RelativeSizeAxes = Axes.Both, Origin = Anchor.Centre, @@ -139,7 +149,7 @@ namespace osu.Game.Overlays.Pause Width = 0.75f, Colour = ButtonColour }, - new Box + rightGlow = new Box { RelativeSizeAxes = Axes.Both, Origin = Anchor.TopRight, @@ -203,6 +213,8 @@ namespace osu.Game.Overlays.Pause Colour = Color4.White, } }); + + reapplyGlow(); } } } From af8294f02c43ee2ae0a29ee2ec1a7016e94f6554 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 30 Jan 2017 08:45:10 -0400 Subject: [PATCH 28/40] Renamed/removed various private constants --- osu.Game/Overlays/Pause/PauseButton.cs | 36 +++++++++--------- osu.Game/Overlays/Pause/PauseOverlay.cs | 41 +++++++++++---------- osu.Game/Overlays/Pause/PauseProgressBar.cs | 18 +++++---- 3 files changed, 49 insertions(+), 46 deletions(-) diff --git a/osu.Game/Overlays/Pause/PauseButton.cs b/osu.Game/Overlays/Pause/PauseButton.cs index 3ccbedc6f0..1826162697 100644 --- a/osu.Game/Overlays/Pause/PauseButton.cs +++ b/osu.Game/Overlays/Pause/PauseButton.cs @@ -13,10 +13,10 @@ namespace osu.Game.Overlays.Pause { public class PauseButton : ClickableContainer { - private const float colourWidth = 0.8f; - private const float colourExpandedWidth = 0.9f; - private const float colourExpandTime = 500; - private Vector2 colourShear = new Vector2(0.2f, 0); + private const float hoverWidth = 0.9f; + private const float hoverDuration = 500; + private const float glowFadeDuration = 250; + private const float clickDuration = 200; private Color4 backgroundColour = OsuColour.Gray(34); @@ -57,20 +57,20 @@ namespace osu.Game.Overlays.Pause private Box leftGlow, centerGlow, rightGlow; private SpriteText spriteText; - private bool didClick; // Used for making sure that the OnMouseDown animation can call instead of OnHoverLost's + private bool didClick; // Used for making sure that the OnMouseDown animation can call instead of OnHoverLost's when clicking public override bool Contains(Vector2 screenSpacePos) => backgroundContainer.Contains(screenSpacePos); protected override bool OnMouseDown(Framework.Input.InputState state, MouseDownEventArgs args) { didClick = true; - colourContainer.ResizeTo(new Vector2(1.5f, 1f), 200, EasingTypes.In); + colourContainer.ResizeTo(new Vector2(1.5f, 1f), clickDuration, EasingTypes.In); SampleClick?.Play(); Action?.Invoke(); - Delay(200); + Delay(clickDuration); Schedule(delegate { - colourContainer.ResizeTo(new Vector2(colourWidth, 1f), 0, EasingTypes.None); + colourContainer.ResizeTo(new Vector2(0.8f, 1f), 0, EasingTypes.None); spriteText.Spacing = Vector2.Zero; glowContainer.Alpha = 0; }); @@ -82,9 +82,9 @@ namespace osu.Game.Overlays.Pause protected override bool OnHover(Framework.Input.InputState state) { - colourContainer.ResizeTo(new Vector2(colourExpandedWidth, 1f), colourExpandTime, EasingTypes.OutElastic); - spriteText.TransformSpacingTo(new Vector2(3f, 0f), colourExpandTime, EasingTypes.OutElastic); - glowContainer.FadeTo(1f, colourExpandTime / 2, EasingTypes.Out); + colourContainer.ResizeTo(new Vector2(hoverWidth, 1f), hoverDuration, EasingTypes.OutElastic); + spriteText.TransformSpacingTo(new Vector2(3f, 0f), hoverDuration, EasingTypes.OutElastic); + glowContainer.FadeOut(glowFadeDuration, EasingTypes.Out); SampleHover?.Play(); return true; } @@ -93,9 +93,9 @@ namespace osu.Game.Overlays.Pause { if (!didClick) { - colourContainer.ResizeTo(new Vector2(colourWidth, 1f), colourExpandTime, EasingTypes.OutElastic); - spriteText.TransformSpacingTo(Vector2.Zero, colourExpandTime, EasingTypes.OutElastic); - glowContainer.FadeTo(0f, colourExpandTime / 2, EasingTypes.Out); + colourContainer.ResizeTo(new Vector2(0.8f, 1f), hoverDuration, EasingTypes.OutElastic); + spriteText.TransformSpacingTo(Vector2.Zero, hoverDuration, EasingTypes.OutElastic); + glowContainer.FadeOut(glowFadeDuration, EasingTypes.Out); } didClick = false; @@ -172,7 +172,7 @@ namespace osu.Game.Overlays.Pause RelativeSizeAxes = Axes.Both, Origin = Anchor.Centre, Anchor = Anchor.Centre, - Width = colourWidth, + Width = 0.8f, Masking = true, EdgeEffect = new EdgeEffect { @@ -181,7 +181,7 @@ namespace osu.Game.Overlays.Pause Radius = 5 }, Colour = ButtonColour, - Shear = colourShear, + Shear = new Vector2(0.2f, 0), Children = new Drawable[] { new Box @@ -195,7 +195,7 @@ namespace osu.Game.Overlays.Pause RelativeSizeAxes = Axes.Both, TriangleScale = 4, Alpha = 0.05f, - Shear = -colourShear + Shear = new Vector2(-0.2f, 0) } } } @@ -210,7 +210,7 @@ namespace osu.Game.Overlays.Pause Font = "Exo2.0-Bold", Shadow = true, ShadowColour = new Color4(0, 0, 0, 0.1f), - Colour = Color4.White, + Colour = Color4.White } }); diff --git a/osu.Game/Overlays/Pause/PauseOverlay.cs b/osu.Game/Overlays/Pause/PauseOverlay.cs index 8993360cd7..3055f032d5 100644 --- a/osu.Game/Overlays/Pause/PauseOverlay.cs +++ b/osu.Game/Overlays/Pause/PauseOverlay.cs @@ -15,8 +15,9 @@ namespace osu.Game.Overlays.Pause { public class PauseOverlay : OverlayContainer { - private const int fadeDuration = 200; + private const int transitionDuration = 200; private const int buttonHeight = 70; + private const float backgroundAlpha = 0.75f; public Action OnResume; public Action OnRetry; @@ -27,8 +28,8 @@ namespace osu.Game.Overlays.Pause public override bool Contains(Vector2 screenSpacePos) => true; public override bool HandleInput => State == Visibility.Visible; - protected override void PopIn() => FadeIn(fadeDuration, EasingTypes.In); - protected override void PopOut() => FadeOut(fadeDuration, EasingTypes.In); + protected override void PopIn() => FadeIn(transitionDuration, EasingTypes.In); + protected override void PopOut() => FadeOut(transitionDuration, EasingTypes.In); protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { @@ -37,7 +38,7 @@ namespace osu.Game.Overlays.Pause case Key.Escape: if (State == Visibility.Hidden) return false; Hide(); - Task.Delay(fadeDuration * 2).ContinueWith(task => OnResume?.Invoke()); + Task.Delay(transitionDuration * 2).ContinueWith(task => OnResume?.Invoke()); return true; } return base.OnKeyDown(state, args); @@ -52,7 +53,7 @@ namespace osu.Game.Overlays.Pause { RelativeSizeAxes = Axes.Both, Colour = Color4.Black, - Alpha = 0.75f, + Alpha = backgroundAlpha, }, new FlowContainer { @@ -83,7 +84,7 @@ namespace osu.Game.Overlays.Pause TextSize = 30, Colour = colours.Yellow, Shadow = true, - ShadowColour = new Color4(0, 0, 0, 0.25f), + ShadowColour = new Color4(0, 0, 0, 0.25f) }, new SpriteText { @@ -91,8 +92,8 @@ namespace osu.Game.Overlays.Pause Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, Shadow = true, - ShadowColour = new Color4(0, 0, 0, 0.25f), - }, + ShadowColour = new Color4(0, 0, 0, 0.25f) + } } }, new FlowContainer @@ -115,11 +116,11 @@ namespace osu.Game.Overlays.Pause Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, Height = buttonHeight, - Action = (delegate + Action = delegate { Hide(); - Task.Delay(fadeDuration * 2).ContinueWith(task => OnResume?.Invoke()); - }), + Task.Delay(transitionDuration * 2).ContinueWith(task => OnResume?.Invoke()); + } }, new RetryButton { @@ -127,11 +128,11 @@ namespace osu.Game.Overlays.Pause Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, Height = buttonHeight, - Action = (delegate + Action = delegate { Hide(); OnRetry?.Invoke(); - }), + } }, new QuitButton { @@ -139,28 +140,28 @@ namespace osu.Game.Overlays.Pause Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, Height = buttonHeight, - Action = (delegate + Action = delegate { Hide(); OnQuit?.Invoke(); - }), - }, + } + } } }, retryCounterContainer = new FlowContainer { AutoSizeAxes = Axes.Both, Origin = Anchor.TopCentre, - Anchor = Anchor.TopCentre, - }, + Anchor = Anchor.TopCentre + } } }, new PauseProgressBar { Origin = Anchor.BottomCentre, Anchor = Anchor.BottomCentre, - Width = 1f, - }, + Width = 1f + } }; SetRetries(0); diff --git a/osu.Game/Overlays/Pause/PauseProgressBar.cs b/osu.Game/Overlays/Pause/PauseProgressBar.cs index f3b404a4c0..28824cb7ea 100644 --- a/osu.Game/Overlays/Pause/PauseProgressBar.cs +++ b/osu.Game/Overlays/Pause/PauseProgressBar.cs @@ -10,6 +10,9 @@ namespace osu.Game.Overlays.Pause { public class PauseProgressBar : Container { + private Color4 fillColour = new Color4(221, 255, 255, 255); + private Color4 glowColour = new Color4(221, 255, 255, 150); + private Container fill; private WorkingBeatmap current; @@ -53,14 +56,13 @@ namespace osu.Game.Overlays.Pause 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, + Colour = Color4.Black, + Alpha = 0.5f } } }, @@ -91,18 +93,18 @@ namespace osu.Game.Overlays.Pause EdgeEffect = new EdgeEffect { Type = EdgeEffectType.Glow, - Colour = new Color4(130, 204, 255, 150), - Radius = 5, + Colour = glowColour, + Radius = 5 }, Children = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both, - Colour = new Color4(221, 255, 255, 255), + Colour = fillColour } } - }, + } } }, new Container @@ -116,7 +118,7 @@ namespace osu.Game.Overlays.Pause new Box { RelativeSizeAxes = Axes.Both, - Colour = Color4.White, + Colour = Color4.White }, new Container { From 740f6e5595b7890846da1eb0995ef9373e6f7a9e Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 30 Jan 2017 09:06:26 -0400 Subject: [PATCH 29/40] Moved delaying resuming to Player --- osu.Game/Overlays/Pause/PauseOverlay.cs | 4 ++-- osu.Game/Screens/Play/Player.cs | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Pause/PauseOverlay.cs b/osu.Game/Overlays/Pause/PauseOverlay.cs index 3055f032d5..e05be76927 100644 --- a/osu.Game/Overlays/Pause/PauseOverlay.cs +++ b/osu.Game/Overlays/Pause/PauseOverlay.cs @@ -38,7 +38,7 @@ namespace osu.Game.Overlays.Pause case Key.Escape: if (State == Visibility.Hidden) return false; Hide(); - Task.Delay(transitionDuration * 2).ContinueWith(task => OnResume?.Invoke()); + OnResume?.Invoke(); return true; } return base.OnKeyDown(state, args); @@ -119,7 +119,7 @@ namespace osu.Game.Overlays.Pause Action = delegate { Hide(); - Task.Delay(transitionDuration * 2).ContinueWith(task => OnResume?.Invoke()); + OnResume?.Invoke(); } }, new RetryButton diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index cb3e2e489b..931764c2be 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -117,7 +117,14 @@ namespace osu.Game.Screens.Play scoreOverlay.BindProcessor(scoreProcessor = ruleset.CreateScoreProcessor(beatmap.HitObjects.Count)); pauseOverlay = new PauseOverlay { Depth = -1 }; - pauseOverlay.OnResume = Resume; + pauseOverlay.OnResume = delegate + { + Delay(400); + Schedule(() => + { + Resume(); + }); + }; pauseOverlay.OnRetry = Restart; pauseOverlay.OnQuit = Exit; From 2f2f0ed9a306085b77c043813e60746926955281 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 30 Jan 2017 09:26:24 -0400 Subject: [PATCH 30/40] Fixed an issue with PauseButton's glow not fading in --- osu.Game/Overlays/Pause/PauseButton.cs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/osu.Game/Overlays/Pause/PauseButton.cs b/osu.Game/Overlays/Pause/PauseButton.cs index 1826162697..342697026a 100644 --- a/osu.Game/Overlays/Pause/PauseButton.cs +++ b/osu.Game/Overlays/Pause/PauseButton.cs @@ -30,9 +30,9 @@ namespace osu.Game.Overlays.Pause set { buttonColour = value; + reapplyGlow(); if (colourContainer == null) return; colourContainer.Colour = ButtonColour; - reapplyGlow(); } } @@ -84,7 +84,7 @@ namespace osu.Game.Overlays.Pause { colourContainer.ResizeTo(new Vector2(hoverWidth, 1f), hoverDuration, EasingTypes.OutElastic); spriteText.TransformSpacingTo(new Vector2(3f, 0f), hoverDuration, EasingTypes.OutElastic); - glowContainer.FadeOut(glowFadeDuration, EasingTypes.Out); + glowContainer.FadeIn(glowFadeDuration, EasingTypes.Out); SampleHover?.Play(); return true; } @@ -111,7 +111,7 @@ namespace osu.Game.Overlays.Pause public PauseButton() { - Add(new Drawable[] + Children = new Drawable[] { backgroundContainer = new Container { @@ -138,24 +138,21 @@ namespace osu.Game.Overlays.Pause RelativeSizeAxes = Axes.Both, Origin = Anchor.TopLeft, Anchor = Anchor.TopLeft, - Width = 0.125f, - ColourInfo = ColourInfo.GradientHorizontal(new Color4(ButtonColour.R, ButtonColour.G, ButtonColour.B, 0f), ButtonColour) + Width = 0.125f }, centerGlow = new Box { RelativeSizeAxes = Axes.Both, Origin = Anchor.Centre, Anchor = Anchor.Centre, - Width = 0.75f, - Colour = ButtonColour + Width = 0.75f }, rightGlow = new Box { RelativeSizeAxes = Axes.Both, Origin = Anchor.TopRight, Anchor = Anchor.TopRight, - Width = 0.125f, - ColourInfo = ColourInfo.GradientHorizontal(ButtonColour, new Color4(ButtonColour.R, ButtonColour.G, ButtonColour.B, 0f)) + Width = 0.125f } } }, @@ -212,7 +209,7 @@ namespace osu.Game.Overlays.Pause ShadowColour = new Color4(0, 0, 0, 0.1f), Colour = Color4.White } - }); + }; reapplyGlow(); } From c642660896db227d6e26b2f8dcce5ac60e628403 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 30 Jan 2017 16:15:56 -0400 Subject: [PATCH 31/40] Made TestCasePauseOverlay.retryCount reset on Retry, fixed an issue with PauseButton where if the user moved the cursor in/out very fast and clicked than the glow wouldn't fade out --- osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs index b958f75fe6..fc549d3b10 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs @@ -73,6 +73,7 @@ namespace osu.Desktop.VisualTests.Tests pauseOverlay.OnResume += () => Logger.Log(@"Resume"); pauseOverlay.OnRetry += () => Logger.Log(@"Retry"); pauseOverlay.OnQuit += () => Logger.Log(@"Quit"); + retryCount = 0; } } } From 9d4a14074f5c78387b2a725b839d6951ea119917 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 30 Jan 2017 16:18:11 -0400 Subject: [PATCH 32/40] Woops forgot to add PauseButton --- osu.Game/Overlays/Pause/PauseButton.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Pause/PauseButton.cs b/osu.Game/Overlays/Pause/PauseButton.cs index 342697026a..16f52f4b20 100644 --- a/osu.Game/Overlays/Pause/PauseButton.cs +++ b/osu.Game/Overlays/Pause/PauseButton.cs @@ -72,7 +72,7 @@ namespace osu.Game.Overlays.Pause Schedule(delegate { colourContainer.ResizeTo(new Vector2(0.8f, 1f), 0, EasingTypes.None); spriteText.Spacing = Vector2.Zero; - glowContainer.Alpha = 0; + glowContainer.FadeOut(); }); return true; From fe09bab78fd66a68b289fbabaf4e2f315f0006a7 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 30 Jan 2017 16:18:34 -0400 Subject: [PATCH 33/40] Removed empty ctor in PauseProgressGraph --- osu.Game/Overlays/Pause/PauseProgressGraph.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/osu.Game/Overlays/Pause/PauseProgressGraph.cs b/osu.Game/Overlays/Pause/PauseProgressGraph.cs index bc8b377824..fab9f37923 100644 --- a/osu.Game/Overlays/Pause/PauseProgressGraph.cs +++ b/osu.Game/Overlays/Pause/PauseProgressGraph.cs @@ -4,10 +4,6 @@ namespace osu.Game.Overlays.Pause { public class PauseProgressGraph : Container { - - public PauseProgressGraph() - { - // TODO: Implement the pause progress graph - } + // TODO: Implement the pause progress graph } } From bf54ae86eac0d9598a25b54941064ddc9bc0590d Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 31 Jan 2017 08:07:05 -0400 Subject: [PATCH 34/40] Added flash when clicking a PauseButton --- osu.Game/Overlays/Pause/PauseButton.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/osu.Game/Overlays/Pause/PauseButton.cs b/osu.Game/Overlays/Pause/PauseButton.cs index 16f52f4b20..0696dba452 100644 --- a/osu.Game/Overlays/Pause/PauseButton.cs +++ b/osu.Game/Overlays/Pause/PauseButton.cs @@ -65,6 +65,7 @@ namespace osu.Game.Overlays.Pause { didClick = true; colourContainer.ResizeTo(new Vector2(1.5f, 1f), clickDuration, EasingTypes.In); + flash(); SampleClick?.Play(); Action?.Invoke(); @@ -101,6 +102,22 @@ namespace osu.Game.Overlays.Pause didClick = false; } + private void flash() + { + var flash = new Box + { + RelativeSizeAxes = Axes.Both + }; + + colourContainer.Add(flash); + + flash.Colour = ButtonColour; + flash.BlendingMode = BlendingMode.Additive; + flash.Alpha = 0.3f; + flash.FadeOutFromOne(clickDuration); + flash.Expire(); + } + private void reapplyGlow() { if (leftGlow == null || centerGlow == null || rightGlow == null) return; From ecaa88a0d2fab1ef663052ecb2eca98874643e13 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 31 Jan 2017 08:42:14 -0400 Subject: [PATCH 35/40] Changed TestCasePauseOverlay to use AddButton and removed background gradient(not needed) --- .../Tests/TestCasePauseOverlay.cs | 52 +++---------------- 1 file changed, 7 insertions(+), 45 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs index fc549d3b10..2a66783b2a 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs @@ -24,51 +24,13 @@ namespace osu.Desktop.VisualTests.Tests { base.Reset(); - Children = new Drawable[] - { - new Box - { - ColourInfo = ColourInfo.GradientVertical(Color4.Gray, Color4.WhiteSmoke), - RelativeSizeAxes = Framework.Graphics.Axes.Both - }, - pauseOverlay = new PauseOverlay - { - Depth = -1 - }, - new FlowContainer - { - RelativeSizeAxes = Axes.Both, - Origin = Anchor.TopLeft, - Anchor = Anchor.TopLeft, - Direction = FlowDirection.VerticalOnly, - Children = new Drawable[] - { - new Button - { - Text = @"Pause", - Anchor = Anchor.TopLeft, - Origin = Anchor.TopLeft, - Width = 100, - Height = 50, - Colour = Color4.Black, - Action = () => pauseOverlay.Show() - }, - new Button - { - Text = @"Add Retry", - Anchor = Anchor.TopLeft, - Origin = Anchor.TopLeft, - Width = 100, - Height = 50, - Colour = Color4.Black, - Action = delegate { - retryCount++; - pauseOverlay.SetRetries(retryCount); - }, - } - } - } - }; + Add(pauseOverlay = new PauseOverlay { Depth = -1 }); + AddButton("Pause", pauseOverlay.Show); + AddButton("Add Retry", delegate + { + retryCount++; + pauseOverlay.SetRetries(retryCount); + }); pauseOverlay.OnResume += () => Logger.Log(@"Resume"); pauseOverlay.OnRetry += () => Logger.Log(@"Retry"); From 91a5d0b3cf45958677401baca77b58c87a229100 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 31 Jan 2017 09:17:47 -0400 Subject: [PATCH 36/40] Made requested changes --- .../Tests/TestCasePauseOverlay.cs | 2 +- osu.Game/Overlays/Pause/PauseButton.cs | 7 +- osu.Game/Overlays/Pause/PauseOverlay.cs | 122 +++++++++--------- osu.Game/Screens/Play/Player.cs | 2 +- 4 files changed, 65 insertions(+), 68 deletions(-) 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 @@ namespace osu.Desktop.VisualTests.Tests 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 @@ namespace osu.Game.Overlays.Pause set { buttonColour = value; - reapplyGlow(); + updateGlow(); if (colourContainer == null) return; colourContainer.Colour = ButtonColour; } @@ -118,9 +118,8 @@ namespace osu.Game.Overlays.Pause 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 @@ namespace osu.Game.Overlays.Pause } }; - 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 @@ namespace osu.Game.Overlays.Pause { RelativeSizeAxes = Axes.Both, Colour = Color4.Black, - Alpha = backgroundAlpha, + Alpha = background_alpha, }, new FlowContainer { @@ -88,7 +124,7 @@ namespace osu.Game.Overlays.Pause }, 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 @@ namespace osu.Game.Overlays.Pause 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 @@ namespace osu.Game.Overlays.Pause 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 @@ namespace osu.Game.Overlays.Pause RelativeSizeAxes = Axes.X, Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, - Height = buttonHeight, + Height = button_height, Action = delegate { Hide(); @@ -164,47 +195,14 @@ namespace osu.Game.Overlays.Pause } }; - 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 @@ namespace osu.Game.Screens.Play lastPauseActionTime = Time.Current; playerInputManager.PassThrough = true; scoreOverlay.KeyCounter.IsCounting = false; - pauseOverlay.SetRetries(RestartCount); + pauseOverlay.Retries = RestartCount; pauseOverlay.Show(); sourceClock.Stop(); isPaused = true; From bcd41a2c8fcc110a0f823ca82f9ed43e6bf09155 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 31 Jan 2017 20:28:50 -0400 Subject: [PATCH 37/40] Moved pause overlay action setting to the initialiser in Player, moved pause overlay displaying be handled in OnExiting instead of OnKeyDown, removed clockWasStarted and used sourceClock.IsRunning instead --- osu.Game/Screens/Play/Player.cs | 55 ++++++++++++--------------------- 1 file changed, 19 insertions(+), 36 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 106a419b7d..2cd0995c16 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -55,8 +55,6 @@ namespace osu.Game.Screens.Play private double pauseCooldown = 1000; private double lastPauseActionTime = 0; - private bool clockWasStarted = false; - private IAdjustableClock sourceClock; private Ruleset ruleset; @@ -116,17 +114,16 @@ namespace osu.Game.Screens.Play scoreOverlay = ruleset.CreateScoreOverlay(); scoreOverlay.BindProcessor(scoreProcessor = ruleset.CreateScoreProcessor(beatmap.HitObjects.Count)); - pauseOverlay = new PauseOverlay { Depth = -1 }; - pauseOverlay.OnResume = delegate + pauseOverlay = new PauseOverlay { - Delay(400); - Schedule(() => - { - Resume(); - }); + Depth = -1, + OnResume = delegate { + Delay(400); + Schedule(Resume); + }, + OnRetry = Restart, + OnQuit = Exit }; - pauseOverlay.OnRetry = Restart; - pauseOverlay.OnQuit = Exit; hitRenderer = ruleset.CreateHitRendererWith(beatmap.HitObjects); @@ -199,14 +196,12 @@ namespace osu.Game.Screens.Play newPlayer.Preload(Game, delegate { newPlayer.RestartCount = RestartCount + 1; - Exit(); + ValidForResume = false; - if (!(last?.Push(newPlayer) ?? false)) + if (!Push(newPlayer)) { // Error(?) } - - Dispose(); }); } @@ -222,7 +217,6 @@ namespace osu.Game.Screens.Play Schedule(() => { sourceClock.Start(); - clockWasStarted = true; }); } @@ -252,8 +246,6 @@ namespace osu.Game.Screens.Play }); } - private GameMode last; - protected override void OnEntering(GameMode last) { base.OnEntering(last); @@ -263,30 +255,21 @@ namespace osu.Game.Screens.Play Content.Alpha = 0; dimLevel.ValueChanged += dimChanged; - - this.last = last; } protected override bool OnExiting(GameMode next) { - dimLevel.ValueChanged -= dimChanged; - Background?.FadeTo(1f, 200); - return base.OnExiting(next); - } - - protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) - { - switch (args.Key) + if (!IsPaused && sourceClock.IsRunning) // For if the user presses escape quickly when entering the map { - case Key.Escape: - if (!IsPaused && clockWasStarted) // For if the user presses escape quickly when entering the map - { - Pause(); - return true; - } - break; + Pause(); + return true; + } + else + { + dimLevel.ValueChanged -= dimChanged; + Background?.FadeTo(1f, 200); + return base.OnExiting(next); } - return base.OnKeyDown(state, args); } private void dimChanged(object sender, EventArgs e) From 13da75f149c65e4d350b643e5709d8b02ea7a7fb Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 31 Jan 2017 20:44:59 -0400 Subject: [PATCH 38/40] Fixed a bug where the user can double press escape to exit the song --- osu.Game/Screens/Play/Player.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 2cd0995c16..570524187a 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -55,6 +55,14 @@ namespace osu.Game.Screens.Play private double pauseCooldown = 1000; private double lastPauseActionTime = 0; + private bool canPause + { + get + { + return Time.Current >= (lastPauseActionTime + pauseCooldown); + } + } + private IAdjustableClock sourceClock; private Ruleset ruleset; @@ -155,7 +163,7 @@ namespace osu.Game.Screens.Play public void Pause(bool force = false) { - if (Time.Current >= (lastPauseActionTime + pauseCooldown) || force) + if (canPause || force) { lastPauseActionTime = Time.Current; playerInputManager.PassThrough = true; @@ -259,6 +267,8 @@ namespace osu.Game.Screens.Play protected override bool OnExiting(GameMode next) { + if (!canPause) return true; + if (!IsPaused && sourceClock.IsRunning) // For if the user presses escape quickly when entering the map { Pause(); From 2c12568a0d6a7260bde78afb0e19ac361153517b Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 31 Jan 2017 20:51:26 -0400 Subject: [PATCH 39/40] Moved TestCasePauseOverlay's PauseOverlay action setting to the initialiser --- osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs index 31184d04e9..dbcd1b93af 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs @@ -24,7 +24,13 @@ namespace osu.Desktop.VisualTests.Tests { base.Reset(); - Add(pauseOverlay = new PauseOverlay { Depth = -1 }); + Add(pauseOverlay = new PauseOverlay + { + Depth = -1, + OnResume = () => Logger.Log(@"Resume"), + OnRetry = () => Logger.Log(@"Retry"), + OnQuit = () => Logger.Log(@"Quit") + }); AddButton("Pause", pauseOverlay.Show); AddButton("Add Retry", delegate { @@ -32,9 +38,6 @@ namespace osu.Desktop.VisualTests.Tests pauseOverlay.Retries = retryCount; }); - pauseOverlay.OnResume += () => Logger.Log(@"Resume"); - pauseOverlay.OnRetry += () => Logger.Log(@"Retry"); - pauseOverlay.OnQuit += () => Logger.Log(@"Quit"); retryCount = 0; } } From c92418e000d8070f69f49befef34a1df04ee3873 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 31 Jan 2017 21:02:58 -0400 Subject: [PATCH 40/40] Made Player.canPause one line --- osu.Game/Screens/Play/Player.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 570524187a..4fb0d4dfab 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -55,13 +55,7 @@ namespace osu.Game.Screens.Play private double pauseCooldown = 1000; private double lastPauseActionTime = 0; - private bool canPause - { - get - { - return Time.Current >= (lastPauseActionTime + pauseCooldown); - } - } + private bool canPause => Time.Current >= (lastPauseActionTime + pauseCooldown); private IAdjustableClock sourceClock;