From c34ef42f0071a0bec598fd0b27d13f0a5bd3b729 Mon Sep 17 00:00:00 2001 From: TocoToucan Date: Fri, 20 Apr 2018 12:50:19 +0300 Subject: [PATCH 01/43] Add 'End replay' button --- osu.Game/Screens/Play/Player.cs | 2 ++ osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index ec7c1a1009..84021fe8d4 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -218,6 +218,8 @@ namespace osu.Game.Screens.Play } }; + hudOverlay.PlayerSettingsOverlay.PlaybackSettings.EndReplayButton.Action = Exit; + if (ShowStoryboard) initializeStoryboard(false); diff --git a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs index 13e403e899..3303ebaf97 100644 --- a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs +++ b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs @@ -6,6 +6,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Timing; using osu.Game.Graphics.Sprites; +using osu.Game.Overlays.Settings; namespace osu.Game.Screens.Play.PlayerSettings { @@ -18,6 +19,7 @@ namespace osu.Game.Screens.Play.PlayerSettings public IAdjustableClock AdjustableClock { set; get; } private readonly PlayerSliderBar sliderbar; + public readonly SettingsButton EndReplayButton; public PlaybackSettings() { @@ -55,6 +57,10 @@ namespace osu.Game.Screens.Play.PlayerSettings MaxValue = 2, Precision = 0.1, }, + }, + EndReplayButton = new SettingsButton + { + Text = "End replay" } }; From 633c775306c928088e40da8db602b7fa23f1384f Mon Sep 17 00:00:00 2001 From: TocoToucan Date: Sat, 21 Apr 2018 18:24:31 +0300 Subject: [PATCH 02/43] Initial HoldToQuit commit --- osu.Game/Screens/Play/HUD/HoldToQuit.cs | 118 ++++++++++++++++++++++++ osu.Game/Screens/Play/HUDOverlay.cs | 9 ++ 2 files changed, 127 insertions(+) create mode 100644 osu.Game/Screens/Play/HUD/HoldToQuit.cs diff --git a/osu.Game/Screens/Play/HUD/HoldToQuit.cs b/osu.Game/Screens/Play/HUD/HoldToQuit.cs new file mode 100644 index 0000000000..55cbff4d86 --- /dev/null +++ b/osu.Game/Screens/Play/HUD/HoldToQuit.cs @@ -0,0 +1,118 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Threading; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.UserInterface; +using osu.Framework.Input; +using osu.Framework.Threading; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using OpenTK; + +namespace osu.Game.Screens.Play.HUD +{ + public class HoldToQuit : Container + { + private readonly OsuSpriteText text; + private readonly HoldToQuitButton button; + + public HoldToQuit() + { + Children = new Drawable[] + { + text = new OsuSpriteText + { + Text = "Hold to Quit", + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft + }, + button = new HoldToQuitButton(text) + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight + } + }; + AutoSizeAxes = Axes.Both; + } + + private class HoldToQuitButton : CircularContainer + { + private readonly OsuSpriteText text; + private SpriteIcon icon; + private CircularProgress progress; + + private Action exitAction; + private readonly Scheduler scheduler; + private ScheduledDelegate scheduledExitAction; + + private const int fade_duration = 200; + + public HoldToQuitButton(OsuSpriteText text) + { + this.text = text; + scheduler = new Scheduler(); + + // TODO provide action + exitAction = () => Thread.Sleep(1); + } + + private void hideText() => scheduler.AddDelayed(() => text.FadeOut(fade_duration), 5000); + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + Masking = true; + Size = new Vector2(60); + AddRange(new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = colours.Gray1, + Alpha = 0.8f, + }, + icon = new SpriteIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(15), + Icon = FontAwesome.fa_close + }, + progress = new CircularProgress { RelativeSizeAxes = Axes.Both, InnerRadius = 0.1f, Current = { Value = 1 } } + }); + progress.Hide(); + hideText(); + } + + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) + { + icon.ScaleTo(1.5f); + text.FadeIn(fade_duration); + progress.FadeIn(1000); + scheduledExitAction = scheduler.AddDelayed(exitAction, 1000); + return base.OnMouseDown(state, args); + } + + protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) + { + icon.ScaleTo(1f); + hideText(); + if (scheduledExitAction != null && !scheduledExitAction.Completed) + scheduledExitAction.Cancel(); + progress.FadeOut(fade_duration); + return base.OnMouseUp(state, args); + } + + protected override void Update() + { + scheduler.Update(); + base.Update(); + } + } + } +} diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs index 36d8bb75c0..c2471c967e 100644 --- a/osu.Game/Screens/Play/HUDOverlay.cs +++ b/osu.Game/Screens/Play/HUDOverlay.cs @@ -34,6 +34,7 @@ namespace osu.Game.Screens.Play public readonly HealthDisplay HealthDisplay; public readonly SongProgress Progress; public readonly ModDisplay ModDisplay; + public readonly HoldToQuit HoldToQuit; public readonly PlayerSettingsOverlay PlayerSettingsOverlay; private Bindable showHud; @@ -57,6 +58,7 @@ namespace osu.Game.Screens.Play AccuracyCounter = CreateAccuracyCounter(), HealthDisplay = CreateHealthDisplay(), Progress = CreateProgress(), + HoldToQuit = CreateHoldToQuit(), ModDisplay = CreateModsContainer(), PlayerSettingsOverlay = CreatePlayerSettingsOverlay() } @@ -205,6 +207,13 @@ namespace osu.Game.Screens.Play RelativeSizeAxes = Axes.X, }; + protected virtual HoldToQuit CreateHoldToQuit() => new HoldToQuit + { + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + Margin = new MarginPadding { Bottom = Progress.Size.Y * 1.25f, Right = 5 } + }; + protected virtual ModDisplay CreateModsContainer() => new ModDisplay { Anchor = Anchor.TopRight, From 3b621db460cdf6226559eb6a25b6f6443635c935 Mon Sep 17 00:00:00 2001 From: TocoToucan Date: Sat, 21 Apr 2018 19:25:21 +0300 Subject: [PATCH 03/43] Implement CircularProgress filling --- osu.Game/Screens/Play/HUD/HoldToQuit.cs | 29 +++++++++++++++++-------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/HoldToQuit.cs b/osu.Game/Screens/Play/HUD/HoldToQuit.cs index 55cbff4d86..59569aacbd 100644 --- a/osu.Game/Screens/Play/HUD/HoldToQuit.cs +++ b/osu.Game/Screens/Play/HUD/HoldToQuit.cs @@ -10,6 +10,7 @@ using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input; using osu.Framework.Threading; +using osu.Framework.Timing; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using OpenTK; @@ -47,22 +48,24 @@ namespace osu.Game.Screens.Play.HUD private CircularProgress progress; private Action exitAction; - private readonly Scheduler scheduler; private ScheduledDelegate scheduledExitAction; + private readonly Scheduler scheduler; + private readonly StopwatchClock stopwatchClock; + private const int fade_duration = 200; + private const int text_display_time = 5000; public HoldToQuitButton(OsuSpriteText text) { this.text = text; scheduler = new Scheduler(); + stopwatchClock = new StopwatchClock(); // TODO provide action exitAction = () => Thread.Sleep(1); } - private void hideText() => scheduler.AddDelayed(() => text.FadeOut(fade_duration), 5000); - [BackgroundDependencyLoader] private void load(OsuColour colours) { @@ -83,34 +86,42 @@ namespace osu.Game.Screens.Play.HUD Size = new Vector2(15), Icon = FontAwesome.fa_close }, - progress = new CircularProgress { RelativeSizeAxes = Axes.Both, InnerRadius = 0.1f, Current = { Value = 1 } } + progress = new CircularProgress { RelativeSizeAxes = Axes.Both, InnerRadius = 0.1f } }); - progress.Hide(); - hideText(); + scheduler.AddDelayed(() => text.FadeOut(fade_duration), text_display_time); } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) { icon.ScaleTo(1.5f); text.FadeIn(fade_duration); - progress.FadeIn(1000); + stopwatchClock.Restart(); scheduledExitAction = scheduler.AddDelayed(exitAction, 1000); + return base.OnMouseDown(state, args); } protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) { icon.ScaleTo(1f); - hideText(); + scheduler.AddDelayed(() => text.FadeOut(fade_duration), text_display_time); + stopwatchClock.Stop(); if (scheduledExitAction != null && !scheduledExitAction.Completed) scheduledExitAction.Cancel(); - progress.FadeOut(fade_duration); + progress.Current.SetDefault(); + return base.OnMouseUp(state, args); } protected override void Update() { scheduler.Update(); + if (stopwatchClock.IsRunning) + { + var clampedTime = MathHelper.Clamp(stopwatchClock.CurrentTime, 0, 1000); + progress.Current.Value = clampedTime / 1000; + } + base.Update(); } } From 21454d1f10848a38c71c16e77695c5a0f241dc93 Mon Sep 17 00:00:00 2001 From: TocoToucan Date: Sat, 21 Apr 2018 19:27:17 +0300 Subject: [PATCH 04/43] Revert "Add 'End replay' button" This reverts commit c34ef42f0071a0bec598fd0b27d13f0a5bd3b729. --- osu.Game/Screens/Play/Player.cs | 2 -- osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs | 6 ------ 2 files changed, 8 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 84021fe8d4..ec7c1a1009 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -218,8 +218,6 @@ namespace osu.Game.Screens.Play } }; - hudOverlay.PlayerSettingsOverlay.PlaybackSettings.EndReplayButton.Action = Exit; - if (ShowStoryboard) initializeStoryboard(false); diff --git a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs index 3303ebaf97..13e403e899 100644 --- a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs +++ b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs @@ -6,7 +6,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Timing; using osu.Game.Graphics.Sprites; -using osu.Game.Overlays.Settings; namespace osu.Game.Screens.Play.PlayerSettings { @@ -19,7 +18,6 @@ namespace osu.Game.Screens.Play.PlayerSettings public IAdjustableClock AdjustableClock { set; get; } private readonly PlayerSliderBar sliderbar; - public readonly SettingsButton EndReplayButton; public PlaybackSettings() { @@ -57,10 +55,6 @@ namespace osu.Game.Screens.Play.PlayerSettings MaxValue = 2, Precision = 0.1, }, - }, - EndReplayButton = new SettingsButton - { - Text = "End replay" } }; From e6d7136a9206153a0132961efe8c2adb9bbcca1d Mon Sep 17 00:00:00 2001 From: TocoToucan Date: Sat, 21 Apr 2018 20:21:09 +0300 Subject: [PATCH 05/43] Fix HoldToQuit appearance and set HoldToQuitButton.ExitAction --- osu.Game/Screens/Play/HUD/HoldToQuit.cs | 23 +++++++++-------------- osu.Game/Screens/Play/Player.cs | 2 ++ 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/HoldToQuit.cs b/osu.Game/Screens/Play/HUD/HoldToQuit.cs index 59569aacbd..f4848ff730 100644 --- a/osu.Game/Screens/Play/HUD/HoldToQuit.cs +++ b/osu.Game/Screens/Play/HUD/HoldToQuit.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Threading; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -17,37 +16,36 @@ using OpenTK; namespace osu.Game.Screens.Play.HUD { - public class HoldToQuit : Container + public class HoldToQuit : FillFlowContainer { private readonly OsuSpriteText text; - private readonly HoldToQuitButton button; + public readonly HoldToQuitButton Button; public HoldToQuit() { + Direction = FillDirection.Horizontal; + Spacing = new Vector2(20, 0); Children = new Drawable[] { text = new OsuSpriteText { Text = "Hold to Quit", + Font = @"Exo2.0-Bold", Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft }, - button = new HoldToQuitButton(text) - { - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight - } + Button = new HoldToQuitButton(text) }; AutoSizeAxes = Axes.Both; } - private class HoldToQuitButton : CircularContainer + public class HoldToQuitButton : CircularContainer { private readonly OsuSpriteText text; private SpriteIcon icon; private CircularProgress progress; - private Action exitAction; + public Action ExitAction { get; set; } private ScheduledDelegate scheduledExitAction; private readonly Scheduler scheduler; @@ -61,9 +59,6 @@ namespace osu.Game.Screens.Play.HUD this.text = text; scheduler = new Scheduler(); stopwatchClock = new StopwatchClock(); - - // TODO provide action - exitAction = () => Thread.Sleep(1); } [BackgroundDependencyLoader] @@ -96,7 +91,7 @@ namespace osu.Game.Screens.Play.HUD icon.ScaleTo(1.5f); text.FadeIn(fade_duration); stopwatchClock.Restart(); - scheduledExitAction = scheduler.AddDelayed(exitAction, 1000); + scheduledExitAction = scheduler.AddDelayed(ExitAction, 1000); return base.OnMouseDown(state, args); } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index ec7c1a1009..6c5e10c836 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -218,6 +218,8 @@ namespace osu.Game.Screens.Play } }; + hudOverlay.HoldToQuit.Button.ExitAction = Exit; + if (ShowStoryboard) initializeStoryboard(false); From 630980255ed479d391f6860bc89f762633917a70 Mon Sep 17 00:00:00 2001 From: TocoToucan Date: Sat, 21 Apr 2018 20:35:24 +0300 Subject: [PATCH 06/43] Convert HoldToQuit.text to local variable --- osu.Game/Screens/Play/HUD/HoldToQuit.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/HUD/HoldToQuit.cs b/osu.Game/Screens/Play/HUD/HoldToQuit.cs index f4848ff730..3f14582d50 100644 --- a/osu.Game/Screens/Play/HUD/HoldToQuit.cs +++ b/osu.Game/Screens/Play/HUD/HoldToQuit.cs @@ -18,11 +18,11 @@ namespace osu.Game.Screens.Play.HUD { public class HoldToQuit : FillFlowContainer { - private readonly OsuSpriteText text; public readonly HoldToQuitButton Button; public HoldToQuit() { + OsuSpriteText text; Direction = FillDirection.Horizontal; Spacing = new Vector2(20, 0); Children = new Drawable[] From b3cf381c5d3b883be24df2db2b8210e38e8b348c Mon Sep 17 00:00:00 2001 From: TocoToucan Date: Sat, 28 Apr 2018 19:24:49 +0300 Subject: [PATCH 07/43] Add TestCaseHoldToQuit --- osu.Game.Tests/Visual/TestCaseHoldToQuit.cs | 56 +++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 osu.Game.Tests/Visual/TestCaseHoldToQuit.cs diff --git a/osu.Game.Tests/Visual/TestCaseHoldToQuit.cs b/osu.Game.Tests/Visual/TestCaseHoldToQuit.cs new file mode 100644 index 0000000000..d7f024d905 --- /dev/null +++ b/osu.Game.Tests/Visual/TestCaseHoldToQuit.cs @@ -0,0 +1,56 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Linq; +using NUnit.Framework; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Game.Screens.Play.HUD; + +namespace osu.Game.Tests.Visual +{ + [Description("'Hold to Quit' UI element")] + public class TestCaseHoldToQuit : OsuTestCase + { + private bool exitAction; + + public TestCaseHoldToQuit() + { + HoldToQuit holdToQuit; + Add(holdToQuit = new HoldToQuit + { + Origin = Anchor.BottomRight, + Anchor = Anchor.BottomRight, + }); + holdToQuit.Button.ExitAction = () => exitAction = true; + + var text = holdToQuit.Children.OfType().Single(); + + AddStep("Text fade in", () => + { + exitAction = false; + holdToQuit.Button.TriggerOnMouseDown(); + holdToQuit.Button.TriggerOnMouseUp(); + }); + + AddUntilStep(() => text.IsPresent && !exitAction, "Text visible"); + + AddStep("Text fade out", () => + { + exitAction = false; + holdToQuit.Button.TriggerOnMouseDown(); + holdToQuit.Button.TriggerOnMouseUp(); + }); + + AddUntilStep(() => !text.IsPresent && !exitAction, "Text is not visible"); + + AddStep("Trigger exit action", () => + { + exitAction = false; + holdToQuit.Button.TriggerOnMouseDown(); + }); + + AddUntilStep(() => exitAction, $"{nameof(holdToQuit.Button.ExitAction)} was triggered"); + } + } +} From c78c5195f352dcb5bc657cf0e29f66cf61e6a369 Mon Sep 17 00:00:00 2001 From: TocoToucan Date: Sat, 28 Apr 2018 20:43:41 +0300 Subject: [PATCH 08/43] HoldToQuitButton cleanup --- osu.Game/Screens/Play/HUD/HoldToQuit.cs | 38 ++++--------------------- 1 file changed, 6 insertions(+), 32 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/HoldToQuit.cs b/osu.Game/Screens/Play/HUD/HoldToQuit.cs index 3f14582d50..59338f8cdc 100644 --- a/osu.Game/Screens/Play/HUD/HoldToQuit.cs +++ b/osu.Game/Screens/Play/HUD/HoldToQuit.cs @@ -8,8 +8,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input; -using osu.Framework.Threading; -using osu.Framework.Timing; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using OpenTK; @@ -46,20 +44,12 @@ namespace osu.Game.Screens.Play.HUD private CircularProgress progress; public Action ExitAction { get; set; } - private ScheduledDelegate scheduledExitAction; - - private readonly Scheduler scheduler; - private readonly StopwatchClock stopwatchClock; private const int fade_duration = 200; + private const int progress_duration = 1000; private const int text_display_time = 5000; - public HoldToQuitButton(OsuSpriteText text) - { - this.text = text; - scheduler = new Scheduler(); - stopwatchClock = new StopwatchClock(); - } + public HoldToQuitButton(OsuSpriteText text) => this.text = text; [BackgroundDependencyLoader] private void load(OsuColour colours) @@ -83,15 +73,14 @@ namespace osu.Game.Screens.Play.HUD }, progress = new CircularProgress { RelativeSizeAxes = Axes.Both, InnerRadius = 0.1f } }); - scheduler.AddDelayed(() => text.FadeOut(fade_duration), text_display_time); + Scheduler.AddDelayed(() => text.FadeOut(fade_duration), text_display_time); } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) { icon.ScaleTo(1.5f); text.FadeIn(fade_duration); - stopwatchClock.Restart(); - scheduledExitAction = scheduler.AddDelayed(ExitAction, 1000); + progress.FillTo(1, progress_duration).OnComplete(cp => ExitAction()); return base.OnMouseDown(state, args); } @@ -99,26 +88,11 @@ namespace osu.Game.Screens.Play.HUD protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) { icon.ScaleTo(1f); - scheduler.AddDelayed(() => text.FadeOut(fade_duration), text_display_time); - stopwatchClock.Stop(); - if (scheduledExitAction != null && !scheduledExitAction.Completed) - scheduledExitAction.Cancel(); - progress.Current.SetDefault(); + Scheduler.AddDelayed(() => text.FadeOut(fade_duration), text_display_time); + progress.FillTo(0, progress_duration / 4).OnComplete(cp => progress.Current.SetDefault()); return base.OnMouseUp(state, args); } - - protected override void Update() - { - scheduler.Update(); - if (stopwatchClock.IsRunning) - { - var clampedTime = MathHelper.Clamp(stopwatchClock.CurrentTime, 0, 1000); - progress.Current.Value = clampedTime / 1000; - } - - base.Update(); - } } } } From 3b84ce7c9f4317cf4a3f3d4e8011385579d6ec1f Mon Sep 17 00:00:00 2001 From: TocoToucan Date: Tue, 1 May 2018 03:56:01 +0300 Subject: [PATCH 09/43] Remove redundant test step --- osu.Game.Tests/Visual/TestCaseHoldToQuit.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseHoldToQuit.cs b/osu.Game.Tests/Visual/TestCaseHoldToQuit.cs index d7f024d905..04ea4249e5 100644 --- a/osu.Game.Tests/Visual/TestCaseHoldToQuit.cs +++ b/osu.Game.Tests/Visual/TestCaseHoldToQuit.cs @@ -26,7 +26,7 @@ namespace osu.Game.Tests.Visual var text = holdToQuit.Children.OfType().Single(); - AddStep("Text fade in", () => + AddStep("Trigger text fade in/out", () => { exitAction = false; holdToQuit.Button.TriggerOnMouseDown(); @@ -34,14 +34,6 @@ namespace osu.Game.Tests.Visual }); AddUntilStep(() => text.IsPresent && !exitAction, "Text visible"); - - AddStep("Text fade out", () => - { - exitAction = false; - holdToQuit.Button.TriggerOnMouseDown(); - holdToQuit.Button.TriggerOnMouseUp(); - }); - AddUntilStep(() => !text.IsPresent && !exitAction, "Text is not visible"); AddStep("Trigger exit action", () => From f8630115d68b7dd610638ab037c8e69282043d00 Mon Sep 17 00:00:00 2001 From: Roman Kapustin Date: Thu, 3 May 2018 23:29:58 +0300 Subject: [PATCH 10/43] Do not expose HoldToQuit.HoldToQuitButton --- osu.Game.Tests/Visual/TestCaseHoldToQuit.cs | 10 +++++----- osu.Game/Screens/Play/HUD/HoldToQuit.cs | 9 +++++++-- osu.Game/Screens/Play/Player.cs | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseHoldToQuit.cs b/osu.Game.Tests/Visual/TestCaseHoldToQuit.cs index 04ea4249e5..a9b391cd79 100644 --- a/osu.Game.Tests/Visual/TestCaseHoldToQuit.cs +++ b/osu.Game.Tests/Visual/TestCaseHoldToQuit.cs @@ -22,15 +22,15 @@ namespace osu.Game.Tests.Visual Origin = Anchor.BottomRight, Anchor = Anchor.BottomRight, }); - holdToQuit.Button.ExitAction = () => exitAction = true; + holdToQuit.ExitAction = () => exitAction = true; var text = holdToQuit.Children.OfType().Single(); AddStep("Trigger text fade in/out", () => { exitAction = false; - holdToQuit.Button.TriggerOnMouseDown(); - holdToQuit.Button.TriggerOnMouseUp(); + holdToQuit.TriggerOnMouseDown(); + holdToQuit.TriggerOnMouseUp(); }); AddUntilStep(() => text.IsPresent && !exitAction, "Text visible"); @@ -39,10 +39,10 @@ namespace osu.Game.Tests.Visual AddStep("Trigger exit action", () => { exitAction = false; - holdToQuit.Button.TriggerOnMouseDown(); + holdToQuit.TriggerOnMouseDown(); }); - AddUntilStep(() => exitAction, $"{nameof(holdToQuit.Button.ExitAction)} was triggered"); + AddUntilStep(() => exitAction, $"{nameof(holdToQuit.ExitAction)} was triggered"); } } } diff --git a/osu.Game/Screens/Play/HUD/HoldToQuit.cs b/osu.Game/Screens/Play/HUD/HoldToQuit.cs index 59338f8cdc..ee67dd35f8 100644 --- a/osu.Game/Screens/Play/HUD/HoldToQuit.cs +++ b/osu.Game/Screens/Play/HUD/HoldToQuit.cs @@ -16,7 +16,12 @@ namespace osu.Game.Screens.Play.HUD { public class HoldToQuit : FillFlowContainer { - public readonly HoldToQuitButton Button; + private readonly HoldToQuitButton button; + public Action ExitAction + { + get => button.ExitAction; + set => button.ExitAction = value; + } public HoldToQuit() { @@ -32,7 +37,7 @@ namespace osu.Game.Screens.Play.HUD Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft }, - Button = new HoldToQuitButton(text) + button = new HoldToQuitButton(text) }; AutoSizeAxes = Axes.Both; } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 836730e3f3..540950a853 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -216,7 +216,7 @@ namespace osu.Game.Screens.Play } }; - hudOverlay.HoldToQuit.Button.ExitAction = Exit; + hudOverlay.HoldToQuit.ExitAction = Exit; if (ShowStoryboard) initializeStoryboard(false); From 39db1e8cbb9ba539838e1ac4b117e1611cf04063 Mon Sep 17 00:00:00 2001 From: Roman Kapustin Date: Thu, 3 May 2018 23:50:30 +0300 Subject: [PATCH 11/43] Rename HoldToQuit to QuitButton --- osu.Game.Tests/Visual/TestCaseHoldToQuit.cs | 4 ++-- .../Play/HUD/{HoldToQuit.cs => QuitButton.cs} | 12 ++++++------ osu.Game/Screens/Play/HUDOverlay.cs | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) rename osu.Game/Screens/Play/HUD/{HoldToQuit.cs => QuitButton.cs} (91%) diff --git a/osu.Game.Tests/Visual/TestCaseHoldToQuit.cs b/osu.Game.Tests/Visual/TestCaseHoldToQuit.cs index a9b391cd79..9a2228c23c 100644 --- a/osu.Game.Tests/Visual/TestCaseHoldToQuit.cs +++ b/osu.Game.Tests/Visual/TestCaseHoldToQuit.cs @@ -16,8 +16,8 @@ namespace osu.Game.Tests.Visual public TestCaseHoldToQuit() { - HoldToQuit holdToQuit; - Add(holdToQuit = new HoldToQuit + QuitButton holdToQuit; + Add(holdToQuit = new QuitButton { Origin = Anchor.BottomRight, Anchor = Anchor.BottomRight, diff --git a/osu.Game/Screens/Play/HUD/HoldToQuit.cs b/osu.Game/Screens/Play/HUD/QuitButton.cs similarity index 91% rename from osu.Game/Screens/Play/HUD/HoldToQuit.cs rename to osu.Game/Screens/Play/HUD/QuitButton.cs index ee67dd35f8..aa6dc388ac 100644 --- a/osu.Game/Screens/Play/HUD/HoldToQuit.cs +++ b/osu.Game/Screens/Play/HUD/QuitButton.cs @@ -14,16 +14,16 @@ using OpenTK; namespace osu.Game.Screens.Play.HUD { - public class HoldToQuit : FillFlowContainer + public class QuitButton : FillFlowContainer { - private readonly HoldToQuitButton button; + private readonly Button button; public Action ExitAction { get => button.ExitAction; set => button.ExitAction = value; } - public HoldToQuit() + public QuitButton() { OsuSpriteText text; Direction = FillDirection.Horizontal; @@ -37,12 +37,12 @@ namespace osu.Game.Screens.Play.HUD Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft }, - button = new HoldToQuitButton(text) + button = new Button(text) }; AutoSizeAxes = Axes.Both; } - public class HoldToQuitButton : CircularContainer + private class Button : CircularContainer { private readonly OsuSpriteText text; private SpriteIcon icon; @@ -54,7 +54,7 @@ namespace osu.Game.Screens.Play.HUD private const int progress_duration = 1000; private const int text_display_time = 5000; - public HoldToQuitButton(OsuSpriteText text) => this.text = text; + public Button(OsuSpriteText text) => this.text = text; [BackgroundDependencyLoader] private void load(OsuColour colours) diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs index c2471c967e..cba5c94266 100644 --- a/osu.Game/Screens/Play/HUDOverlay.cs +++ b/osu.Game/Screens/Play/HUDOverlay.cs @@ -34,7 +34,7 @@ namespace osu.Game.Screens.Play public readonly HealthDisplay HealthDisplay; public readonly SongProgress Progress; public readonly ModDisplay ModDisplay; - public readonly HoldToQuit HoldToQuit; + public readonly QuitButton HoldToQuit; public readonly PlayerSettingsOverlay PlayerSettingsOverlay; private Bindable showHud; @@ -58,7 +58,7 @@ namespace osu.Game.Screens.Play AccuracyCounter = CreateAccuracyCounter(), HealthDisplay = CreateHealthDisplay(), Progress = CreateProgress(), - HoldToQuit = CreateHoldToQuit(), + HoldToQuit = CreateQuitButton(), ModDisplay = CreateModsContainer(), PlayerSettingsOverlay = CreatePlayerSettingsOverlay() } @@ -207,11 +207,11 @@ namespace osu.Game.Screens.Play RelativeSizeAxes = Axes.X, }; - protected virtual HoldToQuit CreateHoldToQuit() => new HoldToQuit + protected virtual QuitButton CreateQuitButton() => new QuitButton { Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight, - Margin = new MarginPadding { Bottom = Progress.Size.Y * 1.25f, Right = 5 } + Position = new Vector2(-5, -70) }; protected virtual ModDisplay CreateModsContainer() => new ModDisplay From b0e556d83fd1367fc4156516c026255b26f5cac2 Mon Sep 17 00:00:00 2001 From: Roman Kapustin Date: Fri, 4 May 2018 00:01:00 +0300 Subject: [PATCH 12/43] Actualize QuitButton visual test --- ...aseHoldToQuit.cs => TestCaseQuitButton.cs} | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) rename osu.Game.Tests/Visual/{TestCaseHoldToQuit.cs => TestCaseQuitButton.cs} (60%) diff --git a/osu.Game.Tests/Visual/TestCaseHoldToQuit.cs b/osu.Game.Tests/Visual/TestCaseQuitButton.cs similarity index 60% rename from osu.Game.Tests/Visual/TestCaseHoldToQuit.cs rename to osu.Game.Tests/Visual/TestCaseQuitButton.cs index 9a2228c23c..545a8ff57b 100644 --- a/osu.Game.Tests/Visual/TestCaseHoldToQuit.cs +++ b/osu.Game.Tests/Visual/TestCaseQuitButton.cs @@ -4,33 +4,36 @@ using System.Linq; using NUnit.Framework; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Game.Screens.Play.HUD; namespace osu.Game.Tests.Visual { [Description("'Hold to Quit' UI element")] - public class TestCaseHoldToQuit : OsuTestCase + public class TestCaseQuitButton : OsuTestCase { + private readonly QuitButton quitButton; + private Drawable innerButton => quitButton.Children.Single(child => child is CircularContainer); private bool exitAction; - public TestCaseHoldToQuit() + public TestCaseQuitButton() { - QuitButton holdToQuit; - Add(holdToQuit = new QuitButton + Add(quitButton = new QuitButton { Origin = Anchor.BottomRight, Anchor = Anchor.BottomRight, }); - holdToQuit.ExitAction = () => exitAction = true; + quitButton.ExitAction = () => exitAction = true; - var text = holdToQuit.Children.OfType().Single(); + var text = quitButton.Children.OfType().Single(); AddStep("Trigger text fade in/out", () => { exitAction = false; - holdToQuit.TriggerOnMouseDown(); - holdToQuit.TriggerOnMouseUp(); + + innerButton.TriggerOnMouseDown(); + innerButton.TriggerOnMouseUp(); }); AddUntilStep(() => text.IsPresent && !exitAction, "Text visible"); @@ -39,10 +42,10 @@ namespace osu.Game.Tests.Visual AddStep("Trigger exit action", () => { exitAction = false; - holdToQuit.TriggerOnMouseDown(); + innerButton.TriggerOnMouseDown(); }); - AddUntilStep(() => exitAction, $"{nameof(holdToQuit.ExitAction)} was triggered"); + AddUntilStep(() => exitAction, $"{nameof(quitButton.ExitAction)} was triggered"); } } } From 86430da6d6a2321c588872a11a6c77c8da68d623 Mon Sep 17 00:00:00 2001 From: Roman Kapustin Date: Thu, 10 May 2018 21:08:02 +0300 Subject: [PATCH 13/43] Update CircularProgress.FillTo calls --- osu.Game/Screens/Play/HUD/QuitButton.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/QuitButton.cs b/osu.Game/Screens/Play/HUD/QuitButton.cs index aa6dc388ac..276bffb0a4 100644 --- a/osu.Game/Screens/Play/HUD/QuitButton.cs +++ b/osu.Game/Screens/Play/HUD/QuitButton.cs @@ -17,6 +17,7 @@ namespace osu.Game.Screens.Play.HUD public class QuitButton : FillFlowContainer { private readonly Button button; + public Action ExitAction { get => button.ExitAction; @@ -85,7 +86,7 @@ namespace osu.Game.Screens.Play.HUD { icon.ScaleTo(1.5f); text.FadeIn(fade_duration); - progress.FillTo(1, progress_duration).OnComplete(cp => ExitAction()); + progress.FillTo(progress.Current, 1, progress_duration).OnComplete(cp => ExitAction()); return base.OnMouseDown(state, args); } @@ -94,7 +95,7 @@ namespace osu.Game.Screens.Play.HUD { icon.ScaleTo(1f); Scheduler.AddDelayed(() => text.FadeOut(fade_duration), text_display_time); - progress.FillTo(0, progress_duration / 4).OnComplete(cp => progress.Current.SetDefault()); + progress.FillTo(progress.Current, 0, progress_duration / 4).OnComplete(cp => progress.Current.SetDefault()); return base.OnMouseUp(state, args); } From 8a5bd27c2018e0ae4f980e77aea891f70b1ce562 Mon Sep 17 00:00:00 2001 From: ocboogie Date: Sat, 12 May 2018 16:30:29 -0700 Subject: [PATCH 14/43] Add global key bindings for changing current ruleset --- .../Overlays/Toolbar/ToolbarModeSelector.cs | 49 ++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs index 1da51e4a5a..4855c004c4 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs @@ -1,11 +1,14 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using System.Linq; +using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Caching; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Input.Bindings; using OpenTK; using OpenTK.Graphics; using osu.Framework.Configuration; @@ -14,7 +17,7 @@ using osu.Game.Rulesets; namespace osu.Game.Overlays.Toolbar { - public class ToolbarModeSelector : Container + public class ToolbarModeSelector : KeyBindingContainer { private const float padding = 10; @@ -22,6 +25,7 @@ namespace osu.Game.Overlays.Toolbar private readonly Drawable modeButtonLine; private ToolbarModeButton activeButton; + private int rulesetCount; private readonly Bindable ruleset = new Bindable(); public ToolbarModeSelector() @@ -64,9 +68,50 @@ namespace osu.Game.Overlays.Toolbar }; } + public override IEnumerable DefaultKeyBindings + { + get + { + var keybinds = new List(); + for (int i = 0; i < Math.Min(rulesetCount, 10); i++) + { + InputKey numberKey; + if (i == 9) + numberKey = InputKey.Number0; + else + numberKey = (InputKey)i + 110; + + keybinds.Add(new osu.Framework.Input.Bindings.KeyBinding(new[] { InputKey.Control, numberKey }, i)); + } + return keybinds; + } + } + + private class RulesetSwitcherInputHandler : Container, IKeyBindingHandler + { + private Bindable ruleset; + private RulesetStore rulesets; + + public RulesetSwitcherInputHandler(Bindable ruleset, RulesetStore rulesets) + { + this.ruleset = ruleset; + this.rulesets = rulesets; + } + + public bool OnPressed(int action) + { + ruleset.Value = rulesets.GetRuleset(action); + + return true; + } + + public bool OnReleased(int action) => false; + } + [BackgroundDependencyLoader(true)] private void load(RulesetStore rulesets, OsuGame game) { + this.rulesetCount = rulesets.AvailableRulesets.Count(); foreach (var r in rulesets.AvailableRulesets) { modeButtons.Add(new ToolbarModeButton @@ -85,6 +130,8 @@ namespace osu.Game.Overlays.Toolbar ruleset.BindTo(game.Ruleset); else ruleset.Value = rulesets.AvailableRulesets.FirstOrDefault(); + + Add(new RulesetSwitcherInputHandler(ruleset, rulesets)); } public override bool HandleKeyboardInput => !ruleset.Disabled && base.HandleKeyboardInput; From 26f06a9ae1612e19bdc372873fd17ed84f70179e Mon Sep 17 00:00:00 2001 From: ocboogie Date: Sat, 12 May 2018 17:25:15 -0700 Subject: [PATCH 15/43] Resolve linting issues in ToolbarModeSelector.cs --- osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs index 4855c004c4..889cf8885e 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs @@ -89,8 +89,8 @@ namespace osu.Game.Overlays.Toolbar private class RulesetSwitcherInputHandler : Container, IKeyBindingHandler { - private Bindable ruleset; - private RulesetStore rulesets; + private readonly Bindable ruleset; + private readonly RulesetStore rulesets; public RulesetSwitcherInputHandler(Bindable ruleset, RulesetStore rulesets) { @@ -111,7 +111,7 @@ namespace osu.Game.Overlays.Toolbar [BackgroundDependencyLoader(true)] private void load(RulesetStore rulesets, OsuGame game) { - this.rulesetCount = rulesets.AvailableRulesets.Count(); + rulesetCount = rulesets.AvailableRulesets.Count(); foreach (var r in rulesets.AvailableRulesets) { modeButtons.Add(new ToolbarModeButton From 327c7432be72ab79e882a6dc9d8e0c51d310d485 Mon Sep 17 00:00:00 2001 From: ocboogie Date: Sun, 13 May 2018 19:33:52 -0700 Subject: [PATCH 16/43] Use OnKeyDown instead of a IKeyBindingHandler --- .../Overlays/Toolbar/ToolbarModeSelector.cs | 66 ++++++------------- 1 file changed, 21 insertions(+), 45 deletions(-) diff --git a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs index 889cf8885e..7286cf3f1c 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs @@ -4,12 +4,14 @@ using System; using System.Linq; using System.Collections.Generic; +using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Caching; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Input.Bindings; +using osu.Framework.Input; using OpenTK; +using OpenTK.Input; using OpenTK.Graphics; using osu.Framework.Configuration; using osu.Framework.Graphics.Shapes; @@ -17,7 +19,7 @@ using osu.Game.Rulesets; namespace osu.Game.Overlays.Toolbar { - public class ToolbarModeSelector : KeyBindingContainer + public class ToolbarModeSelector : Container { private const float padding = 10; @@ -25,7 +27,7 @@ namespace osu.Game.Overlays.Toolbar private readonly Drawable modeButtonLine; private ToolbarModeButton activeButton; - private int rulesetCount; + private RulesetStore rulesets; private readonly Bindable ruleset = new Bindable(); public ToolbarModeSelector() @@ -68,50 +70,10 @@ namespace osu.Game.Overlays.Toolbar }; } - public override IEnumerable DefaultKeyBindings - { - get - { - var keybinds = new List(); - for (int i = 0; i < Math.Min(rulesetCount, 10); i++) - { - InputKey numberKey; - if (i == 9) - numberKey = InputKey.Number0; - else - numberKey = (InputKey)i + 110; - - keybinds.Add(new osu.Framework.Input.Bindings.KeyBinding(new[] { InputKey.Control, numberKey }, i)); - } - return keybinds; - } - } - - private class RulesetSwitcherInputHandler : Container, IKeyBindingHandler - { - private readonly Bindable ruleset; - private readonly RulesetStore rulesets; - - public RulesetSwitcherInputHandler(Bindable ruleset, RulesetStore rulesets) - { - this.ruleset = ruleset; - this.rulesets = rulesets; - } - - public bool OnPressed(int action) - { - ruleset.Value = rulesets.GetRuleset(action); - - return true; - } - - public bool OnReleased(int action) => false; - } - [BackgroundDependencyLoader(true)] private void load(RulesetStore rulesets, OsuGame game) { - rulesetCount = rulesets.AvailableRulesets.Count(); + this.rulesets = rulesets; foreach (var r in rulesets.AvailableRulesets) { modeButtons.Add(new ToolbarModeButton @@ -130,8 +92,22 @@ namespace osu.Game.Overlays.Toolbar ruleset.BindTo(game.Ruleset); else ruleset.Value = rulesets.AvailableRulesets.FirstOrDefault(); + } - Add(new RulesetSwitcherInputHandler(ruleset, rulesets)); + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + base.OnKeyDown(state, args); + if (!state.Keyboard.ControlPressed || args.Repeat || (int)args.Key < 109 || (int)args.Key > 118) { + return false; + } + + RulesetInfo targetRuleset = rulesets.GetRuleset(args.Key == Key.Number0 ? 9 : (int)args.Key - 110); + if (targetRuleset == null || targetRuleset == ruleset.Value) { + return false; + } + + ruleset.Value = targetRuleset; + return true; } public override bool HandleKeyboardInput => !ruleset.Disabled && base.HandleKeyboardInput; From ebd9d1a0376becee8ee0f71e93cca67daf9799e7 Mon Sep 17 00:00:00 2001 From: ocboogie Date: Sun, 13 May 2018 19:43:26 -0700 Subject: [PATCH 17/43] Resolve linting issues in ToolbarModeSelector.cs --- osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs index 7286cf3f1c..eeaa15d58a 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs @@ -1,10 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using System.Linq; -using System.Collections.Generic; -using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Caching; using osu.Framework.Graphics; From 67db5391729cb62a3461eb3eb448152dc9bc1580 Mon Sep 17 00:00:00 2001 From: Aergwyn Date: Fri, 18 May 2018 07:57:12 +0200 Subject: [PATCH 18/43] prevent Overlays from showing in intro/outro sequences --- .../Graphics/Containers/OsuFocusedOverlayContainer.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs index f657c0cae5..c26adc8a3d 100644 --- a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs +++ b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs @@ -7,6 +7,7 @@ using osu.Framework.Audio.Sample; using osu.Framework.Graphics.Containers; using osu.Framework.Input; using OpenTK; +using osu.Framework.Configuration; namespace osu.Game.Graphics.Containers { @@ -15,13 +16,17 @@ namespace osu.Game.Graphics.Containers private SampleChannel samplePopIn; private SampleChannel samplePopOut; + protected BindableBool ShowOverlays = new BindableBool(); + [BackgroundDependencyLoader] - private void load(AudioManager audio) + private void load(OsuGame osuGame, AudioManager audio) { samplePopIn = audio.Sample.Get(@"UI/overlay-pop-in"); samplePopOut = audio.Sample.Get(@"UI/overlay-pop-out"); StateChanged += onStateChanged; + + ShowOverlays.BindTo(osuGame.ShowOverlays); } /// @@ -46,6 +51,9 @@ namespace osu.Game.Graphics.Containers private void onStateChanged(Visibility visibility) { + if (!ShowOverlays) + State = Visibility.Hidden; + switch (visibility) { case Visibility.Visible: From 4d528c4e6703da6e93418e59f3d11db2b13e8031 Mon Sep 17 00:00:00 2001 From: Aergwyn Date: Sun, 20 May 2018 10:57:15 +0200 Subject: [PATCH 19/43] fix VisualTests and Samples still playing --- .../Graphics/Containers/OsuFocusedOverlayContainer.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs index c26adc8a3d..1005794742 100644 --- a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs +++ b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs @@ -16,9 +16,9 @@ namespace osu.Game.Graphics.Containers private SampleChannel samplePopIn; private SampleChannel samplePopOut; - protected BindableBool ShowOverlays = new BindableBool(); + protected BindableBool ShowOverlays = new BindableBool(true); - [BackgroundDependencyLoader] + [BackgroundDependencyLoader(true)] private void load(OsuGame osuGame, AudioManager audio) { samplePopIn = audio.Sample.Get(@"UI/overlay-pop-in"); @@ -26,7 +26,8 @@ namespace osu.Game.Graphics.Containers StateChanged += onStateChanged; - ShowOverlays.BindTo(osuGame.ShowOverlays); + if (osuGame != null) + ShowOverlays.BindTo(osuGame.ShowOverlays); } /// @@ -52,7 +53,10 @@ namespace osu.Game.Graphics.Containers private void onStateChanged(Visibility visibility) { if (!ShowOverlays) + { State = Visibility.Hidden; + return; + } switch (visibility) { From 42519e3723e5abcde81c0c04005dae38a657aeb8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 21 May 2018 14:45:44 +0900 Subject: [PATCH 20/43] Rewrite code for clarity This also uses the AvailableRulesets list rather than private IDs --- .../Overlays/Toolbar/ToolbarModeSelector.cs | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs index eeaa15d58a..3078c44844 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs @@ -76,15 +76,13 @@ namespace osu.Game.Overlays.Toolbar modeButtons.Add(new ToolbarModeButton { Ruleset = r, - Action = delegate - { - ruleset.Value = r; - } + Action = delegate { ruleset.Value = r; } }); } ruleset.ValueChanged += rulesetChanged; ruleset.DisabledChanged += disabledChanged; + if (game != null) ruleset.BindTo(game.Ruleset); else @@ -94,17 +92,18 @@ namespace osu.Game.Overlays.Toolbar protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { base.OnKeyDown(state, args); - if (!state.Keyboard.ControlPressed || args.Repeat || (int)args.Key < 109 || (int)args.Key > 118) { - return false; + + if (state.Keyboard.ControlPressed && !args.Repeat && args.Key >= Key.Number1 && args.Key <= Key.Number9) + { + int requested = args.Key - Key.Number1; + + RulesetInfo found = rulesets.AvailableRulesets.Skip(requested).FirstOrDefault(); + if (found != null) + ruleset.Value = found; + return true; } - RulesetInfo targetRuleset = rulesets.GetRuleset(args.Key == Key.Number0 ? 9 : (int)args.Key - 110); - if (targetRuleset == null || targetRuleset == ruleset.Value) { - return false; - } - - ruleset.Value = targetRuleset; - return true; + return false; } public override bool HandleKeyboardInput => !ruleset.Disabled && base.HandleKeyboardInput; From 1482bca147a7e152bd109eaf8094ac16d39ffb51 Mon Sep 17 00:00:00 2001 From: Aergwyn Date: Mon, 21 May 2018 09:42:29 +0200 Subject: [PATCH 21/43] Rename for better understanding ShowOverlays -> AllowOverlays ShowOverlaysOnEnter -> HideOverlaysOnEnter --- .../Containers/OsuFocusedOverlayContainer.cs | 33 +++++++++---------- osu.Game/OsuGame.cs | 6 ++-- osu.Game/Screens/Edit/Editor.cs | 2 +- osu.Game/Screens/Loader.cs | 2 +- osu.Game/Screens/Menu/ButtonSystem.cs | 10 +++--- osu.Game/Screens/Menu/Disclaimer.cs | 2 +- osu.Game/Screens/Menu/Intro.cs | 2 +- osu.Game/Screens/Menu/MainMenu.cs | 2 +- osu.Game/Screens/OsuScreen.cs | 10 +++--- osu.Game/Screens/Play/Player.cs | 2 +- osu.Game/Screens/Play/PlayerLoader.cs | 6 ++-- osu.Game/Screens/Tournament/Drawings.cs | 2 +- 12 files changed, 40 insertions(+), 39 deletions(-) diff --git a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs index 1005794742..9c36eb8c18 100644 --- a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs +++ b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs @@ -16,18 +16,18 @@ namespace osu.Game.Graphics.Containers private SampleChannel samplePopIn; private SampleChannel samplePopOut; - protected BindableBool ShowOverlays = new BindableBool(true); + protected BindableBool AllowOverlays = new BindableBool(true); [BackgroundDependencyLoader(true)] private void load(OsuGame osuGame, AudioManager audio) { + if (osuGame != null) + AllowOverlays.BindTo(osuGame.AllowOverlays); + samplePopIn = audio.Sample.Get(@"UI/overlay-pop-in"); samplePopOut = audio.Sample.Get(@"UI/overlay-pop-out"); StateChanged += onStateChanged; - - if (osuGame != null) - ShowOverlays.BindTo(osuGame.ShowOverlays); } /// @@ -52,21 +52,20 @@ namespace osu.Game.Graphics.Containers private void onStateChanged(Visibility visibility) { - if (!ShowOverlays) + if (AllowOverlays) { + switch (visibility) + { + case Visibility.Visible: + samplePopIn?.Play(); + break; + case Visibility.Hidden: + samplePopOut?.Play(); + break; + } + } + else State = Visibility.Hidden; - return; - } - - switch (visibility) - { - case Visibility.Visible: - samplePopIn?.Play(); - break; - case Visibility.Hidden: - samplePopOut?.Play(); - break; - } } } } diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index fe5ca4f278..b3da2831cd 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -77,7 +77,7 @@ namespace osu.Game public float ToolbarOffset => Toolbar.Position.Y + Toolbar.DrawHeight; - public readonly BindableBool ShowOverlays = new BindableBool(); + public readonly BindableBool AllowOverlays = new BindableBool(); private OsuScreen screenStack; @@ -367,9 +367,9 @@ namespace osu.Game settings.StateChanged += _ => updateScreenOffset(); notifications.StateChanged += _ => updateScreenOffset(); - notifications.Enabled.BindTo(ShowOverlays); + notifications.Enabled.BindTo(AllowOverlays); - ShowOverlays.ValueChanged += show => + AllowOverlays.ValueChanged += show => { //central game screen change logic. if (!show) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index e4eaee76fc..8049ea2738 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -26,7 +26,7 @@ namespace osu.Game.Screens.Edit { protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4"); - public override bool ShowOverlaysOnEnter => false; + public override bool HideOverlaysOnEnter => true; public override bool AllowBeatmapRulesetChange => false; private Box bottomBackground; diff --git a/osu.Game/Screens/Loader.cs b/osu.Game/Screens/Loader.cs index 555c497d92..e49fb08087 100644 --- a/osu.Game/Screens/Loader.cs +++ b/osu.Game/Screens/Loader.cs @@ -17,7 +17,7 @@ namespace osu.Game.Screens { private bool showDisclaimer; - public override bool ShowOverlaysOnEnter => false; + public override bool HideOverlaysOnEnter => true; protected override bool AllowBackButton => false; diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 997002327a..9ca1a1ce19 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -27,7 +27,7 @@ namespace osu.Game.Screens.Menu { public event Action StateChanged; - private readonly BindableBool showOverlays = new BindableBool(); + private readonly BindableBool allowOverlays = new BindableBool(); public Action OnEdit; public Action OnExit; @@ -135,7 +135,9 @@ namespace osu.Game.Screens.Menu [BackgroundDependencyLoader(true)] private void load(AudioManager audio, OsuGame game) { - if (game != null) showOverlays.BindTo(game.ShowOverlays); + if (game != null) + allowOverlays.BindTo(game.AllowOverlays); + sampleBack = audio.Sample.Get(@"Menu/button-back-select"); } @@ -322,7 +324,7 @@ namespace osu.Game.Screens.Menu logoDelayedAction = Scheduler.AddDelayed(() => { - showOverlays.Value = false; + allowOverlays.Value = false; logo.ClearTransforms(targetMember: nameof(Position)); logo.RelativePositionAxes = Axes.Both; @@ -351,7 +353,7 @@ namespace osu.Game.Screens.Menu logoTracking = true; logo.Impact(); - showOverlays.Value = true; + allowOverlays.Value = true; }, 200); break; default: diff --git a/osu.Game/Screens/Menu/Disclaimer.cs b/osu.Game/Screens/Menu/Disclaimer.cs index 5af634b02d..bd32792f3f 100644 --- a/osu.Game/Screens/Menu/Disclaimer.cs +++ b/osu.Game/Screens/Menu/Disclaimer.cs @@ -18,7 +18,7 @@ namespace osu.Game.Screens.Menu private readonly SpriteIcon icon; private Color4 iconColour; - public override bool ShowOverlaysOnEnter => false; + public override bool HideOverlaysOnEnter => true; public override bool CursorVisible => false; public Disclaimer() diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index 4de76e530a..019f0432f6 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -31,7 +31,7 @@ namespace osu.Game.Screens.Menu private SampleChannel welcome; private SampleChannel seeya; - public override bool ShowOverlaysOnEnter => false; + public override bool HideOverlaysOnEnter => true; public override bool CursorVisible => false; protected override BackgroundScreen CreateBackground() => new BackgroundScreenEmpty(); diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index 3b519c5259..0dd05fa0ad 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -24,7 +24,7 @@ namespace osu.Game.Screens.Menu { private readonly ButtonSystem buttons; - public override bool ShowOverlaysOnEnter => buttons.State != MenuState.Initial; + public override bool HideOverlaysOnEnter => buttons.State == MenuState.Initial; protected override bool AllowBackButton => buttons.State != MenuState.Initial; diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 24945ea347..f94087869a 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -32,12 +32,12 @@ namespace osu.Game.Screens /// protected virtual BackgroundScreen CreateBackground() => null; - protected BindableBool ShowOverlays = new BindableBool(); + protected BindableBool AllowOverlays = new BindableBool(); /// - /// Whether overlays should be shown when this screen is entered or resumed. + /// Whether overlays should be hidden when this screen is entered or resumed. /// - public virtual bool ShowOverlaysOnEnter => true; + public virtual bool HideOverlaysOnEnter => false; /// /// Whether this allows the cursor to be displayed. @@ -88,7 +88,7 @@ namespace osu.Game.Screens if (osuGame != null) { Ruleset.BindTo(osuGame.Ruleset); - ShowOverlays.BindTo(osuGame.ShowOverlays); + AllowOverlays.BindTo(osuGame.AllowOverlays); } sampleExit = audio.Sample.Get(@"UI/screen-back"); @@ -220,7 +220,7 @@ namespace osu.Game.Screens if (backgroundParallaxContainer != null) backgroundParallaxContainer.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT * BackgroundParallaxAmount; - ShowOverlays.Value = ShowOverlaysOnEnter; + AllowOverlays.Value = !HideOverlaysOnEnter; } private void onExitingLogo() diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 46919e25e1..44112609f8 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -35,7 +35,7 @@ namespace osu.Game.Screens.Play { protected override float BackgroundParallaxAmount => 0.1f; - public override bool ShowOverlaysOnEnter => false; + public override bool HideOverlaysOnEnter => true; public Action RestartRequested; diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 56fbd7b6e7..fcb2a19c58 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -25,8 +25,8 @@ namespace osu.Game.Screens.Play private BeatmapMetadataDisplay info; - private bool showOverlays = true; - public override bool ShowOverlaysOnEnter => showOverlays; + private bool allowOverlays = true; + public override bool HideOverlaysOnEnter => !allowOverlays; private Task loadTask; @@ -36,7 +36,7 @@ namespace osu.Game.Screens.Play player.RestartRequested = () => { - showOverlays = false; + allowOverlays = false; ValidForResume = true; }; } diff --git a/osu.Game/Screens/Tournament/Drawings.cs b/osu.Game/Screens/Tournament/Drawings.cs index 1ef0b6cca0..ca806ce73e 100644 --- a/osu.Game/Screens/Tournament/Drawings.cs +++ b/osu.Game/Screens/Tournament/Drawings.cs @@ -29,7 +29,7 @@ namespace osu.Game.Screens.Tournament { private const string results_filename = "drawings_results.txt"; - public override bool ShowOverlaysOnEnter => false; + public override bool HideOverlaysOnEnter => true; protected override BackgroundScreen CreateBackground() => new BackgroundScreenDefault(); From b7e3ea348b15e8cdae2e3963f9b8ee4a405e7ea1 Mon Sep 17 00:00:00 2001 From: Aergwyn Date: Mon, 21 May 2018 15:53:50 +0200 Subject: [PATCH 22/43] expose two Bindables with split logic instead of one with mixed logic --- .../Containers/OsuFocusedOverlayContainer.cs | 6 +++--- osu.Game/OsuGame.cs | 9 +++++---- osu.Game/Screens/Edit/Editor.cs | 2 +- osu.Game/Screens/Loader.cs | 2 +- osu.Game/Screens/Menu/ButtonSystem.cs | 13 ++++++++----- osu.Game/Screens/Menu/Disclaimer.cs | 3 ++- osu.Game/Screens/Menu/Intro.cs | 4 +++- osu.Game/Screens/Menu/MainMenu.cs | 3 ++- osu.Game/Screens/OsuScreen.cs | 17 +++++++++++++---- osu.Game/Screens/Play/Player.cs | 2 +- osu.Game/Screens/Play/PlayerLoader.cs | 6 +++--- osu.Game/Screens/Tournament/Drawings.cs | 2 +- 12 files changed, 43 insertions(+), 26 deletions(-) diff --git a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs index 9c36eb8c18..11a2034a8f 100644 --- a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs +++ b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs @@ -16,13 +16,13 @@ namespace osu.Game.Graphics.Containers private SampleChannel samplePopIn; private SampleChannel samplePopOut; - protected BindableBool AllowOverlays = new BindableBool(true); + private readonly BindableBool allowOpeningOverlays = new BindableBool(true); [BackgroundDependencyLoader(true)] private void load(OsuGame osuGame, AudioManager audio) { if (osuGame != null) - AllowOverlays.BindTo(osuGame.AllowOverlays); + allowOpeningOverlays.BindTo(osuGame.AllowOpeningOverlays); samplePopIn = audio.Sample.Get(@"UI/overlay-pop-in"); samplePopOut = audio.Sample.Get(@"UI/overlay-pop-out"); @@ -52,7 +52,7 @@ namespace osu.Game.Graphics.Containers private void onStateChanged(Visibility visibility) { - if (AllowOverlays) + if (allowOpeningOverlays) { switch (visibility) { diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index b3da2831cd..ec93b1ae46 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -77,7 +77,8 @@ namespace osu.Game public float ToolbarOffset => Toolbar.Position.Y + Toolbar.DrawHeight; - public readonly BindableBool AllowOverlays = new BindableBool(); + public readonly BindableBool HideOverlaysOnEnter = new BindableBool(); + public readonly BindableBool AllowOpeningOverlays = new BindableBool(true); private OsuScreen screenStack; @@ -367,12 +368,12 @@ namespace osu.Game settings.StateChanged += _ => updateScreenOffset(); notifications.StateChanged += _ => updateScreenOffset(); - notifications.Enabled.BindTo(AllowOverlays); + notifications.Enabled.BindTo(AllowOpeningOverlays); - AllowOverlays.ValueChanged += show => + HideOverlaysOnEnter.ValueChanged += hide => { //central game screen change logic. - if (!show) + if (hide) { hideAllOverlays(); musicController.State = Visibility.Hidden; diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 8049ea2738..b657fe5597 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -26,7 +26,7 @@ namespace osu.Game.Screens.Edit { protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4"); - public override bool HideOverlaysOnEnter => true; + protected override bool HideOverlaysOnEnter => true; public override bool AllowBeatmapRulesetChange => false; private Box bottomBackground; diff --git a/osu.Game/Screens/Loader.cs b/osu.Game/Screens/Loader.cs index e49fb08087..fb5c5ca84b 100644 --- a/osu.Game/Screens/Loader.cs +++ b/osu.Game/Screens/Loader.cs @@ -17,7 +17,7 @@ namespace osu.Game.Screens { private bool showDisclaimer; - public override bool HideOverlaysOnEnter => true; + protected override bool HideOverlaysOnEnter => true; protected override bool AllowBackButton => false; diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 9ca1a1ce19..d1d388ae1f 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -27,7 +27,8 @@ namespace osu.Game.Screens.Menu { public event Action StateChanged; - private readonly BindableBool allowOverlays = new BindableBool(); + private readonly BindableBool hideOverlaysOnEnter = new BindableBool(); + private readonly BindableBool allowOpeningOverlays = new BindableBool(); public Action OnEdit; public Action OnExit; @@ -136,7 +137,10 @@ namespace osu.Game.Screens.Menu private void load(AudioManager audio, OsuGame game) { if (game != null) - allowOverlays.BindTo(game.AllowOverlays); + { + hideOverlaysOnEnter.BindTo(game.HideOverlaysOnEnter); + allowOpeningOverlays.BindTo(game.AllowOpeningOverlays); + } sampleBack = audio.Sample.Get(@"Menu/button-back-select"); } @@ -324,8 +328,6 @@ namespace osu.Game.Screens.Menu logoDelayedAction = Scheduler.AddDelayed(() => { - allowOverlays.Value = false; - logo.ClearTransforms(targetMember: nameof(Position)); logo.RelativePositionAxes = Axes.Both; @@ -353,7 +355,8 @@ namespace osu.Game.Screens.Menu logoTracking = true; logo.Impact(); - allowOverlays.Value = true; + hideOverlaysOnEnter.Value = false; + allowOpeningOverlays.Value = true; }, 200); break; default: diff --git a/osu.Game/Screens/Menu/Disclaimer.cs b/osu.Game/Screens/Menu/Disclaimer.cs index bd32792f3f..9a671cf780 100644 --- a/osu.Game/Screens/Menu/Disclaimer.cs +++ b/osu.Game/Screens/Menu/Disclaimer.cs @@ -18,7 +18,8 @@ namespace osu.Game.Screens.Menu private readonly SpriteIcon icon; private Color4 iconColour; - public override bool HideOverlaysOnEnter => true; + protected override bool HideOverlaysOnEnter => true; + public override bool CursorVisible => false; public Disclaimer() diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index 019f0432f6..c174e2d470 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -31,7 +31,9 @@ namespace osu.Game.Screens.Menu private SampleChannel welcome; private SampleChannel seeya; - public override bool HideOverlaysOnEnter => true; + protected override bool HideOverlaysOnEnter => true; + protected override bool AllowOpeningOverlays => false; + public override bool CursorVisible => false; protected override BackgroundScreen CreateBackground() => new BackgroundScreenEmpty(); diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index 0dd05fa0ad..d5f3b11467 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -24,7 +24,8 @@ namespace osu.Game.Screens.Menu { private readonly ButtonSystem buttons; - public override bool HideOverlaysOnEnter => buttons.State == MenuState.Initial; + protected override bool HideOverlaysOnEnter => buttons.State == MenuState.Initial; + protected override bool AllowOpeningOverlays => buttons.State != MenuState.Initial; protected override bool AllowBackButton => buttons.State != MenuState.Initial; diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index f94087869a..4b1562291b 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -32,12 +32,19 @@ namespace osu.Game.Screens /// protected virtual BackgroundScreen CreateBackground() => null; - protected BindableBool AllowOverlays = new BindableBool(); + private readonly BindableBool hideOverlaysOnEnter = new BindableBool(); /// /// Whether overlays should be hidden when this screen is entered or resumed. /// - public virtual bool HideOverlaysOnEnter => false; + protected virtual bool HideOverlaysOnEnter => hideOverlaysOnEnter; + + private readonly BindableBool allowOpeningOverlays = new BindableBool(); + + /// + /// Whether overlays should be able to be opened while this screen is active. + /// + protected virtual bool AllowOpeningOverlays => allowOpeningOverlays; /// /// Whether this allows the cursor to be displayed. @@ -88,7 +95,8 @@ namespace osu.Game.Screens if (osuGame != null) { Ruleset.BindTo(osuGame.Ruleset); - AllowOverlays.BindTo(osuGame.AllowOverlays); + hideOverlaysOnEnter.BindTo(osuGame.HideOverlaysOnEnter); + allowOpeningOverlays.BindTo(osuGame.AllowOpeningOverlays); } sampleExit = audio.Sample.Get(@"UI/screen-back"); @@ -220,7 +228,8 @@ namespace osu.Game.Screens if (backgroundParallaxContainer != null) backgroundParallaxContainer.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT * BackgroundParallaxAmount; - AllowOverlays.Value = !HideOverlaysOnEnter; + hideOverlaysOnEnter.Value = HideOverlaysOnEnter; + allowOpeningOverlays.Value = AllowOpeningOverlays; } private void onExitingLogo() diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 44112609f8..ec7a99145e 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -35,7 +35,7 @@ namespace osu.Game.Screens.Play { protected override float BackgroundParallaxAmount => 0.1f; - public override bool HideOverlaysOnEnter => true; + protected override bool HideOverlaysOnEnter => true; public Action RestartRequested; diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index fcb2a19c58..734837a4f1 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -25,8 +25,8 @@ namespace osu.Game.Screens.Play private BeatmapMetadataDisplay info; - private bool allowOverlays = true; - public override bool HideOverlaysOnEnter => !allowOverlays; + private bool hideOverlays; + protected override bool HideOverlaysOnEnter => hideOverlays; private Task loadTask; @@ -36,7 +36,7 @@ namespace osu.Game.Screens.Play player.RestartRequested = () => { - allowOverlays = false; + hideOverlays = true; ValidForResume = true; }; } diff --git a/osu.Game/Screens/Tournament/Drawings.cs b/osu.Game/Screens/Tournament/Drawings.cs index ca806ce73e..29301899d5 100644 --- a/osu.Game/Screens/Tournament/Drawings.cs +++ b/osu.Game/Screens/Tournament/Drawings.cs @@ -29,7 +29,7 @@ namespace osu.Game.Screens.Tournament { private const string results_filename = "drawings_results.txt"; - public override bool HideOverlaysOnEnter => true; + protected override bool HideOverlaysOnEnter => true; protected override BackgroundScreen CreateBackground() => new BackgroundScreenDefault(); From d109522bf790bc9e111ff54df5d8b247199f09d5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 21 May 2018 23:09:00 +0900 Subject: [PATCH 23/43] Fix escape not working to go backwards in menus before finally exiting the game Resolves #2596. --- osu.Game/Screens/Menu/ButtonSystem.cs | 29 +++++++++++++++++---------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 997002327a..98c1cfbf07 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -148,6 +148,8 @@ namespace osu.Game.Screens.Menu case Key.Space: logo?.TriggerOnClick(state); return true; + case Key.Escape: + return goBack(); } return false; @@ -158,17 +160,22 @@ namespace osu.Game.Screens.Menu switch (action) { case GlobalAction.Back: - switch (State) - { - case MenuState.TopLevel: - State = MenuState.Initial; - return true; - case MenuState.Play: - backButton.TriggerOnClick(); - return true; - default: - return false; - } + return goBack(); + default: + return false; + } + } + + private bool goBack() + { + switch (State) + { + case MenuState.TopLevel: + State = MenuState.Initial; + return true; + case MenuState.Play: + backButton.TriggerOnClick(); + return true; default: return false; } From 3d9d40448ded833eb6ecaf960b047817ca3db5ed Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 22 May 2018 00:01:40 +0900 Subject: [PATCH 24/43] Fix incorrect syntax --- osu.Game/Screens/Play/HUD/QuitButton.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/QuitButton.cs b/osu.Game/Screens/Play/HUD/QuitButton.cs index 276bffb0a4..db24400f30 100644 --- a/osu.Game/Screens/Play/HUD/QuitButton.cs +++ b/osu.Game/Screens/Play/HUD/QuitButton.cs @@ -86,7 +86,7 @@ namespace osu.Game.Screens.Play.HUD { icon.ScaleTo(1.5f); text.FadeIn(fade_duration); - progress.FillTo(progress.Current, 1, progress_duration).OnComplete(cp => ExitAction()); + progress.FillTo(1, progress_duration).OnComplete(cp => ExitAction()); return base.OnMouseDown(state, args); } @@ -95,7 +95,7 @@ namespace osu.Game.Screens.Play.HUD { icon.ScaleTo(1f); Scheduler.AddDelayed(() => text.FadeOut(fade_duration), text_display_time); - progress.FillTo(progress.Current, 0, progress_duration / 4).OnComplete(cp => progress.Current.SetDefault()); + progress.FillTo(0, progress_duration / 4f).OnComplete(cp => progress.Current.SetDefault()); return base.OnMouseUp(state, args); } From d5afccd610f268096c6fe968213d71ec97fb3aa1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 22 May 2018 00:02:03 +0900 Subject: [PATCH 25/43] Make hint text display briefly at initial display, then on hover --- osu.Game/Screens/Play/HUD/QuitButton.cs | 35 ++++++++++++++++++------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/QuitButton.cs b/osu.Game/Screens/Play/HUD/QuitButton.cs index db24400f30..61925108ae 100644 --- a/osu.Game/Screens/Play/HUD/QuitButton.cs +++ b/osu.Game/Screens/Play/HUD/QuitButton.cs @@ -16,6 +16,8 @@ namespace osu.Game.Screens.Play.HUD { public class QuitButton : FillFlowContainer { + public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => button.ReceiveMouseInputAt(screenSpacePos); + private readonly Button button; public Action ExitAction @@ -24,28 +26,47 @@ namespace osu.Game.Screens.Play.HUD set => button.ExitAction = value; } + OsuSpriteText text; + public QuitButton() { - OsuSpriteText text; Direction = FillDirection.Horizontal; Spacing = new Vector2(20, 0); + Margin = new MarginPadding(10); Children = new Drawable[] { text = new OsuSpriteText { - Text = "Hold to Quit", + Text = "hold to quit", Font = @"Exo2.0-Bold", Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft }, - button = new Button(text) + button = new Button() }; AutoSizeAxes = Axes.Both; } + protected override void LoadComplete() + { + text.FadeInFromZero(500, Easing.OutQuint).Delay(1500).FadeOut(500, Easing.OutQuint); + base.LoadComplete(); + } + + protected override bool OnHover(InputState state) + { + text.FadeIn(500, Easing.OutQuint); + return base.OnHover(state); + } + + protected override void OnHoverLost(InputState state) + { + text.FadeOut(500, Easing.OutQuint); + base.OnHoverLost(state); + } + private class Button : CircularContainer { - private readonly OsuSpriteText text; private SpriteIcon icon; private CircularProgress progress; @@ -53,9 +74,6 @@ namespace osu.Game.Screens.Play.HUD private const int fade_duration = 200; private const int progress_duration = 1000; - private const int text_display_time = 5000; - - public Button(OsuSpriteText text) => this.text = text; [BackgroundDependencyLoader] private void load(OsuColour colours) @@ -79,13 +97,11 @@ namespace osu.Game.Screens.Play.HUD }, progress = new CircularProgress { RelativeSizeAxes = Axes.Both, InnerRadius = 0.1f } }); - Scheduler.AddDelayed(() => text.FadeOut(fade_duration), text_display_time); } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) { icon.ScaleTo(1.5f); - text.FadeIn(fade_duration); progress.FillTo(1, progress_duration).OnComplete(cp => ExitAction()); return base.OnMouseDown(state, args); @@ -94,7 +110,6 @@ namespace osu.Game.Screens.Play.HUD protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) { icon.ScaleTo(1f); - Scheduler.AddDelayed(() => text.FadeOut(fade_duration), text_display_time); progress.FillTo(0, progress_duration / 4f).OnComplete(cp => progress.Current.SetDefault()); return base.OnMouseUp(state, args); From cee8d21542713dd2e3eadc3983d9c611ddf7dd21 Mon Sep 17 00:00:00 2001 From: Aergwyn Date: Mon, 21 May 2018 17:24:57 +0200 Subject: [PATCH 26/43] hide overlays when going back to initial menu state --- osu.Game/Screens/Menu/ButtonSystem.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index d1d388ae1f..2e757c256e 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -328,6 +328,9 @@ namespace osu.Game.Screens.Menu logoDelayedAction = Scheduler.AddDelayed(() => { + hideOverlaysOnEnter.Value = true; + allowOpeningOverlays.Value = false; + logo.ClearTransforms(targetMember: nameof(Position)); logo.RelativePositionAxes = Axes.Both; @@ -355,6 +358,7 @@ namespace osu.Game.Screens.Menu logoTracking = true; logo.Impact(); + hideOverlaysOnEnter.Value = false; allowOpeningOverlays.Value = true; }, 200); From f9c162dee95617e22cd8666cc35d3fe03b6941a0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 22 May 2018 00:49:33 +0900 Subject: [PATCH 27/43] Adjust design and feel --- osu.Game/Screens/Play/HUD/QuitButton.cs | 58 +++++++++++++++++++++---- 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/QuitButton.cs b/osu.Game/Screens/Play/HUD/QuitButton.cs index 61925108ae..939966f0e5 100644 --- a/osu.Game/Screens/Play/HUD/QuitButton.cs +++ b/osu.Game/Screens/Play/HUD/QuitButton.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input; +using osu.Framework.MathUtils; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using OpenTK; @@ -26,7 +27,7 @@ namespace osu.Game.Screens.Play.HUD set => button.ExitAction = value; } - OsuSpriteText text; + private readonly OsuSpriteText text; public QuitButton() { @@ -65,15 +66,32 @@ namespace osu.Game.Screens.Play.HUD base.OnHoverLost(state); } + protected override void Update() + { + base.Update(); + + float adjust = Vector2.Distance(GetContainingInputManager().CurrentState.Mouse.NativeState.Position, button.ScreenSpaceDrawQuad.Centre) / 200; + double elapsed = MathHelper.Clamp(Clock.ElapsedFrameTime, 0, 1000); + + bool stayVisible = text.Alpha > 0 || button.Progress > 0 || IsHovered; + + Alpha = stayVisible ? 1 : Interpolation.ValueAt(elapsed, Alpha, MathHelper.Clamp(1 - adjust, 0.04f, 1), 0, 200, Easing.OutQuint); + } + private class Button : CircularContainer { private SpriteIcon icon; private CircularProgress progress; + private Circle innerCircle; + + private bool triggered; public Action ExitAction { get; set; } + public double Progress => progress.Current.Value; + private const int fade_duration = 200; - private const int progress_duration = 1000; + private const int progress_duration = 600; [BackgroundDependencyLoader] private void load(OsuColour colours) @@ -86,31 +104,55 @@ namespace osu.Game.Screens.Play.HUD { RelativeSizeAxes = Axes.Both, Colour = colours.Gray1, - Alpha = 0.8f, + Alpha = 0.5f, + }, + progress = new CircularProgress + { + RelativeSizeAxes = Axes.Both, + InnerRadius = 1 + }, + innerCircle = new Circle + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Colour = colours.Gray1, + Size = new Vector2(0.9f), }, icon = new SpriteIcon { + Shadow = false, Anchor = Anchor.Centre, Origin = Anchor.Centre, Size = new Vector2(15), Icon = FontAwesome.fa_close }, - progress = new CircularProgress { RelativeSizeAxes = Axes.Both, InnerRadius = 0.1f } }); } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) { - icon.ScaleTo(1.5f); - progress.FillTo(1, progress_duration).OnComplete(cp => ExitAction()); + if (state.Mouse.Buttons.Count > 1 || triggered) + return true; + + icon.ScaleTo(1.4f, progress_duration); + progress.FillTo(1, progress_duration, Easing.OutSine).OnComplete(_ => + { + innerCircle.ScaleTo(0, 100).Then().FadeOut().ScaleTo(1).FadeIn(500); + triggered = true; + ExitAction(); + }); return base.OnMouseDown(state, args); } protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) { - icon.ScaleTo(1f); - progress.FillTo(0, progress_duration / 4f).OnComplete(cp => progress.Current.SetDefault()); + if (state.Mouse.Buttons.Count > 0 || triggered) + return true; + + icon.ScaleTo(1, 800, Easing.OutElastic); + progress.FillTo(0, progress_duration, Easing.OutQuint).OnComplete(cp => progress.Current.SetDefault()); return base.OnMouseUp(state, args); } From ebda287e8186fea7c7ebf82ac9c1e70175bcd7b4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 22 May 2018 01:44:06 +0900 Subject: [PATCH 28/43] Share code with HoldToConfirm implementations elsewhere --- osu-framework | 2 +- osu.Game.Tests/Visual/TestCaseQuitButton.cs | 42 ++++--- .../Containers/HoldToCofirmContainer.cs | 52 ++++++++ osu.Game/Overlays/HoldToConfirmOverlay.cs | 33 +---- osu.Game/Screens/Play/HUD/QuitButton.cs | 116 ++++++++---------- osu.Game/Screens/Play/Player.cs | 2 +- 6 files changed, 135 insertions(+), 112 deletions(-) create mode 100644 osu.Game/Graphics/Containers/HoldToCofirmContainer.cs diff --git a/osu-framework b/osu-framework index fac688633b..b4d5c766f5 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit fac688633b8fcf34ae5d0514c26b03e217161eb4 +Subproject commit b4d5c766f5698540a7b1bbbae7290ac7dafc2813 diff --git a/osu.Game.Tests/Visual/TestCaseQuitButton.cs b/osu.Game.Tests/Visual/TestCaseQuitButton.cs index 545a8ff57b..f0f8d41074 100644 --- a/osu.Game.Tests/Visual/TestCaseQuitButton.cs +++ b/osu.Game.Tests/Visual/TestCaseQuitButton.cs @@ -3,49 +3,55 @@ using System.Linq; using NUnit.Framework; +using osu.Framework.Allocation; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Game.Screens.Play.HUD; +using OpenTK; +using OpenTK.Input; namespace osu.Game.Tests.Visual { [Description("'Hold to Quit' UI element")] - public class TestCaseQuitButton : OsuTestCase + public class TestCaseQuitButton : ManualInputManagerTestCase { - private readonly QuitButton quitButton; - private Drawable innerButton => quitButton.Children.Single(child => child is CircularContainer); private bool exitAction; - public TestCaseQuitButton() + [BackgroundDependencyLoader] + private void load() { + QuitButton quitButton; + Add(quitButton = new QuitButton { Origin = Anchor.BottomRight, Anchor = Anchor.BottomRight, - }); - quitButton.ExitAction = () => exitAction = true; - - var text = quitButton.Children.OfType().Single(); - - AddStep("Trigger text fade in/out", () => - { - exitAction = false; - - innerButton.TriggerOnMouseDown(); - innerButton.TriggerOnMouseUp(); + Action = () => exitAction = true }); + var text = quitButton.Children.OfType().First(); + + // initial display AddUntilStep(() => text.IsPresent && !exitAction, "Text visible"); AddUntilStep(() => !text.IsPresent && !exitAction, "Text is not visible"); + AddStep("Trigger text fade in", () => InputManager.MoveMouseTo(quitButton)); + AddUntilStep(() => text.IsPresent && !exitAction, "Text visible"); + AddStep("Trigger text fade out", () => InputManager.MoveMouseTo(Vector2.One)); + AddUntilStep(() => !text.IsPresent && !exitAction, "Text is not visible"); + AddStep("Trigger exit action", () => { exitAction = false; - innerButton.TriggerOnMouseDown(); + InputManager.MoveMouseTo(quitButton); + InputManager.ButtonDown(MouseButton.Left); }); - AddUntilStep(() => exitAction, $"{nameof(quitButton.ExitAction)} was triggered"); + AddStep("Early release", () => InputManager.ButtonUp(MouseButton.Left)); + AddAssert("action not triggered", () => !exitAction); + + AddStep("Trigger exit action", () => InputManager.ButtonDown(MouseButton.Left)); + AddUntilStep(() => exitAction, $"{nameof(quitButton.Action)} was triggered"); } } } diff --git a/osu.Game/Graphics/Containers/HoldToCofirmContainer.cs b/osu.Game/Graphics/Containers/HoldToCofirmContainer.cs new file mode 100644 index 0000000000..eb2b2ca51b --- /dev/null +++ b/osu.Game/Graphics/Containers/HoldToCofirmContainer.cs @@ -0,0 +1,52 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; + +namespace osu.Game.Graphics.Containers +{ + public abstract class HoldToCofirmContainer : Container + { + public Action Action; + + private const int activate_delay = 400; + private const int fadeout_delay = 200; + + private bool fired; + private bool confirming; + + /// + /// Whether the overlay should be allowed to return from a fired state. + /// + protected virtual bool AllowMultipleFires => false; + + public Bindable Progress = new BindableDouble(); + + protected void BeginConfirm() + { + if (confirming || !AllowMultipleFires && fired) return; + + confirming = true; + + this.TransformBindableTo(Progress, 1, activate_delay * (1 - Progress.Value), Easing.Out).OnComplete(_ => Confirm()); + } + + protected virtual void Confirm() + { + Action?.Invoke(); + fired = true; + } + + protected void AbortConfirm() + { + if (!AllowMultipleFires && fired) return; + + confirming = false; + + this.TransformBindableTo(Progress, 0, fadeout_delay, Easing.Out); + } + } +} diff --git a/osu.Game/Overlays/HoldToConfirmOverlay.cs b/osu.Game/Overlays/HoldToConfirmOverlay.cs index a0e4bf1a39..afd3e2016f 100644 --- a/osu.Game/Overlays/HoldToConfirmOverlay.cs +++ b/osu.Game/Overlays/HoldToConfirmOverlay.cs @@ -1,11 +1,10 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using osu.Framework.Allocation; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics.Containers; using OpenTK.Graphics; namespace osu.Game.Overlays @@ -14,22 +13,10 @@ namespace osu.Game.Overlays /// An overlay which will display a black screen that dims over a period before confirming an exit action. /// Action is BYO (derived class will need to call and from a user event). /// - public abstract class HoldToConfirmOverlay : Container + public abstract class HoldToConfirmOverlay : HoldToCofirmContainer { - public Action Action; - private Box overlay; - private const int activate_delay = 400; - private const int fadeout_delay = 200; - - private bool fired; - - /// - /// Whether the overlay should be allowed to return from a fired state. - /// - protected virtual bool AllowMultipleFires => false; - [BackgroundDependencyLoader] private void load() { @@ -45,22 +32,8 @@ namespace osu.Game.Overlays RelativeSizeAxes = Axes.Both, } }; - } - protected void BeginConfirm() - { - if (!AllowMultipleFires && fired) return; - overlay.FadeIn(activate_delay * (1 - overlay.Alpha), Easing.Out).OnComplete(_ => - { - Action?.Invoke(); - fired = true; - }); - } - - protected void AbortConfirm() - { - if (!AllowMultipleFires && fired) return; - overlay.FadeOut(fadeout_delay, Easing.Out); + Progress.ValueChanged += v => overlay.Alpha = (float)v; } } } diff --git a/osu.Game/Screens/Play/HUD/QuitButton.cs b/osu.Game/Screens/Play/HUD/QuitButton.cs index 939966f0e5..867558ad93 100644 --- a/osu.Game/Screens/Play/HUD/QuitButton.cs +++ b/osu.Game/Screens/Play/HUD/QuitButton.cs @@ -10,6 +10,7 @@ using osu.Framework.Graphics.UserInterface; using osu.Framework.Input; using osu.Framework.MathUtils; using osu.Game.Graphics; +using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using OpenTK; @@ -21,10 +22,9 @@ namespace osu.Game.Screens.Play.HUD private readonly Button button; - public Action ExitAction + public Action Action { - get => button.ExitAction; - set => button.ExitAction = value; + set => button.Action = value; } private readonly OsuSpriteText text; @@ -73,88 +73,80 @@ namespace osu.Game.Screens.Play.HUD float adjust = Vector2.Distance(GetContainingInputManager().CurrentState.Mouse.NativeState.Position, button.ScreenSpaceDrawQuad.Centre) / 200; double elapsed = MathHelper.Clamp(Clock.ElapsedFrameTime, 0, 1000); - bool stayVisible = text.Alpha > 0 || button.Progress > 0 || IsHovered; + bool stayVisible = text.Alpha > 0 || button.Progress.Value > 0 || IsHovered; Alpha = stayVisible ? 1 : Interpolation.ValueAt(elapsed, Alpha, MathHelper.Clamp(1 - adjust, 0.04f, 1), 0, 200, Easing.OutQuint); } - private class Button : CircularContainer + private class Button : HoldToCofirmContainer { private SpriteIcon icon; private CircularProgress progress; private Circle innerCircle; - private bool triggered; - - public Action ExitAction { get; set; } - - public double Progress => progress.Current.Value; - - private const int fade_duration = 200; - private const int progress_duration = 600; - [BackgroundDependencyLoader] private void load(OsuColour colours) { - Masking = true; Size = new Vector2(60); - AddRange(new Drawable[] + + Child = new CircularContainer { - new Box + Masking = true, + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] { - RelativeSizeAxes = Axes.Both, - Colour = colours.Gray1, - Alpha = 0.5f, - }, - progress = new CircularProgress - { - RelativeSizeAxes = Axes.Both, - InnerRadius = 1 - }, - innerCircle = new Circle - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - Colour = colours.Gray1, - Size = new Vector2(0.9f), - }, - icon = new SpriteIcon - { - Shadow = false, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Size = new Vector2(15), - Icon = FontAwesome.fa_close - }, - }); + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = colours.Gray1, + Alpha = 0.5f, + }, + progress = new CircularProgress + { + RelativeSizeAxes = Axes.Both, + InnerRadius = 1 + }, + innerCircle = new Circle + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Colour = colours.Gray1, + Size = new Vector2(0.9f), + }, + icon = new SpriteIcon + { + Shadow = false, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(15), + Icon = FontAwesome.fa_close + }, + } + }; + + Progress.BindTo(progress.Current); + Progress.ValueChanged += v => icon.Scale = new Vector2(1 + (float)v * 0.4f); + } + + protected override void Confirm() + { + base.Confirm(); + innerCircle.ScaleTo(0, 100).Then().FadeOut().ScaleTo(1).FadeIn(500); } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) { - if (state.Mouse.Buttons.Count > 1 || triggered) - return true; - - icon.ScaleTo(1.4f, progress_duration); - progress.FillTo(1, progress_duration, Easing.OutSine).OnComplete(_ => - { - innerCircle.ScaleTo(0, 100).Then().FadeOut().ScaleTo(1).FadeIn(500); - triggered = true; - ExitAction(); - }); - - return base.OnMouseDown(state, args); + if (state.Mouse.Buttons.Count == 1) + BeginConfirm(); + return true; } protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) { - if (state.Mouse.Buttons.Count > 0 || triggered) - return true; - - icon.ScaleTo(1, 800, Easing.OutElastic); - progress.FillTo(0, progress_duration, Easing.OutQuint).OnComplete(cp => progress.Current.SetDefault()); - - return base.OnMouseUp(state, args); + if (state.Mouse.Buttons.Count == 0) + AbortConfirm(); + return true; } } } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 5fb3fb778c..37176aa327 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -219,7 +219,7 @@ namespace osu.Game.Screens.Play } }; - hudOverlay.HoldToQuit.ExitAction = Exit; + hudOverlay.HoldToQuit.Action = Exit; if (ShowStoryboard) initializeStoryboard(false); From 946a75ddb273bd84a71b1f3bce73dfed9dea7fe8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 22 May 2018 02:05:08 +0900 Subject: [PATCH 29/43] Block hover to use UI cursor instead of gameplay cursor --- osu.Game/Screens/Play/HUD/QuitButton.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/HUD/QuitButton.cs b/osu.Game/Screens/Play/HUD/QuitButton.cs index 867558ad93..1533f6a9af 100644 --- a/osu.Game/Screens/Play/HUD/QuitButton.cs +++ b/osu.Game/Screens/Play/HUD/QuitButton.cs @@ -57,7 +57,7 @@ namespace osu.Game.Screens.Play.HUD protected override bool OnHover(InputState state) { text.FadeIn(500, Easing.OutQuint); - return base.OnHover(state); + return true; } protected override void OnHoverLost(InputState state) From 156d7fb25a15458e23fa8458a717fd33a856c359 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 22 May 2018 02:08:21 +0900 Subject: [PATCH 30/43] Change depth of HUD Yes, this is intentional. --- 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 37176aa327..0150d76251 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -183,6 +183,7 @@ namespace osu.Game.Screens.Play ProcessCustomClock = false, Breaks = beatmap.Breaks }, + RulesetContainer.Cursor?.CreateProxy() ?? new Container(), hudOverlay = new HUDOverlay(scoreProcessor, RulesetContainer, working, offsetClock, adjustableClock) { Clock = Clock, // hud overlay doesn't want to use the audio clock directly @@ -190,7 +191,6 @@ namespace osu.Game.Screens.Play Anchor = Anchor.Centre, Origin = Anchor.Centre }, - RulesetContainer.Cursor?.CreateProxy() ?? new Container(), new SkipOverlay(firstObjectTime) { Clock = Clock, // skip button doesn't want to use the audio clock directly From 323aa189b63269329f5f32db31893859bf90e1ac Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 22 May 2018 02:08:44 +0900 Subject: [PATCH 31/43] Make on-confirmation animation more robust --- osu.Game/Screens/Play/HUD/QuitButton.cs | 31 +++++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/QuitButton.cs b/osu.Game/Screens/Play/HUD/QuitButton.cs index 1533f6a9af..d6060e01a3 100644 --- a/osu.Game/Screens/Play/HUD/QuitButton.cs +++ b/osu.Game/Screens/Play/HUD/QuitButton.cs @@ -81,9 +81,11 @@ namespace osu.Game.Screens.Play.HUD private class Button : HoldToCofirmContainer { private SpriteIcon icon; - private CircularProgress progress; + private CircularProgress circularProgress; private Circle innerCircle; + protected override bool AllowMultipleFires => true; + [BackgroundDependencyLoader] private void load(OsuColour colours) { @@ -101,7 +103,7 @@ namespace osu.Game.Screens.Play.HUD Colour = colours.Gray1, Alpha = 0.5f, }, - progress = new CircularProgress + circularProgress = new CircularProgress { RelativeSizeAxes = Axes.Both, InnerRadius = 1 @@ -125,19 +127,38 @@ namespace osu.Game.Screens.Play.HUD } }; - Progress.BindTo(progress.Current); + bind(); + } + + private void bind() + { + circularProgress.Current.BindTo(Progress); Progress.ValueChanged += v => icon.Scale = new Vector2(1 + (float)v * 0.4f); } + private bool pendingAnimation; + protected override void Confirm() { base.Confirm(); - innerCircle.ScaleTo(0, 100).Then().FadeOut().ScaleTo(1).FadeIn(500); + + // temporarily unbind as to not look weird during flash animation. + Progress.UnbindAll(); + pendingAnimation = true; + + innerCircle.ScaleTo(0, 100) + .Then().FadeOut().ScaleTo(1).FadeIn(500) + .OnComplete(a => circularProgress.FadeOut(100).OnComplete(_ => + { + bind(); + circularProgress.FadeIn(); + pendingAnimation = false; + })); } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) { - if (state.Mouse.Buttons.Count == 1) + if (!pendingAnimation && state.Mouse.Buttons.Count == 1) BeginConfirm(); return true; } From 5a892e4d082fa8042b053d2a870bd851226198af Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 22 May 2018 02:09:52 +0900 Subject: [PATCH 32/43] This quit button don't quit --- osu.Game/Screens/Play/HUD/QuitButton.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/HUD/QuitButton.cs b/osu.Game/Screens/Play/HUD/QuitButton.cs index d6060e01a3..e829d26aab 100644 --- a/osu.Game/Screens/Play/HUD/QuitButton.cs +++ b/osu.Game/Screens/Play/HUD/QuitButton.cs @@ -38,7 +38,7 @@ namespace osu.Game.Screens.Play.HUD { text = new OsuSpriteText { - Text = "hold to quit", + Text = "hold for menu", Font = @"Exo2.0-Bold", Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft From 2ce2bd9788aabec4ca0db917a057c710f1ba9719 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 22 May 2018 15:58:00 +0900 Subject: [PATCH 33/43] Add comment for pendingAnimation --- osu.Game/Screens/Play/HUD/QuitButton.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Screens/Play/HUD/QuitButton.cs b/osu.Game/Screens/Play/HUD/QuitButton.cs index e829d26aab..a26e0a2aae 100644 --- a/osu.Game/Screens/Play/HUD/QuitButton.cs +++ b/osu.Game/Screens/Play/HUD/QuitButton.cs @@ -144,6 +144,8 @@ namespace osu.Game.Screens.Play.HUD // temporarily unbind as to not look weird during flash animation. Progress.UnbindAll(); + + // avoid starting a new confirm call until we finish animating. pendingAnimation = true; innerCircle.ScaleTo(0, 100) From ef55c3c1971de6e7ed8e329223673c9bd11d701c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 22 May 2018 15:58:17 +0900 Subject: [PATCH 34/43] Fix icon scale not resetting due to no implicit triggering --- osu.Game/Screens/Play/HUD/QuitButton.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Screens/Play/HUD/QuitButton.cs b/osu.Game/Screens/Play/HUD/QuitButton.cs index a26e0a2aae..defaf002b8 100644 --- a/osu.Game/Screens/Play/HUD/QuitButton.cs +++ b/osu.Game/Screens/Play/HUD/QuitButton.cs @@ -133,7 +133,9 @@ namespace osu.Game.Screens.Play.HUD private void bind() { circularProgress.Current.BindTo(Progress); + Progress.ValueChanged += v => icon.Scale = new Vector2(1 + (float)v * 0.4f); + Progress.TriggerChange(); } private bool pendingAnimation; From 58ae54574701520ce54cbc8065f254549a02c233 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 22 May 2018 15:59:53 +0900 Subject: [PATCH 35/43] innerCircle -> overlayCircle --- osu.Game/Screens/Play/HUD/QuitButton.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/QuitButton.cs b/osu.Game/Screens/Play/HUD/QuitButton.cs index defaf002b8..2ee1b97136 100644 --- a/osu.Game/Screens/Play/HUD/QuitButton.cs +++ b/osu.Game/Screens/Play/HUD/QuitButton.cs @@ -82,7 +82,7 @@ namespace osu.Game.Screens.Play.HUD { private SpriteIcon icon; private CircularProgress circularProgress; - private Circle innerCircle; + private Circle overlayCircle; protected override bool AllowMultipleFires => true; @@ -108,7 +108,7 @@ namespace osu.Game.Screens.Play.HUD RelativeSizeAxes = Axes.Both, InnerRadius = 1 }, - innerCircle = new Circle + overlayCircle = new Circle { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -150,7 +150,7 @@ namespace osu.Game.Screens.Play.HUD // avoid starting a new confirm call until we finish animating. pendingAnimation = true; - innerCircle.ScaleTo(0, 100) + overlayCircle.ScaleTo(0, 100) .Then().FadeOut().ScaleTo(1).FadeIn(500) .OnComplete(a => circularProgress.FadeOut(100).OnComplete(_ => { From 8fbda9d57ea02add62558f60571a5e00f1442620 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 22 May 2018 16:04:07 +0900 Subject: [PATCH 36/43] Improve comment --- osu.Game/Screens/Play/HUD/QuitButton.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/HUD/QuitButton.cs b/osu.Game/Screens/Play/HUD/QuitButton.cs index 2ee1b97136..bbd6075332 100644 --- a/osu.Game/Screens/Play/HUD/QuitButton.cs +++ b/osu.Game/Screens/Play/HUD/QuitButton.cs @@ -144,7 +144,7 @@ namespace osu.Game.Screens.Play.HUD { base.Confirm(); - // temporarily unbind as to not look weird during flash animation. + // temporarily unbind as to not look weird if releasing during confirm animation (can see the unwind of progress). Progress.UnbindAll(); // avoid starting a new confirm call until we finish animating. From 5f8eb6d8231cd2ab53f8d2031d372606406720eb Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 22 May 2018 16:04:36 +0900 Subject: [PATCH 37/43] Fix class name --- .../{HoldToCofirmContainer.cs => HoldToConfirmContainer.cs} | 2 +- osu.Game/Overlays/HoldToConfirmOverlay.cs | 2 +- osu.Game/Screens/Play/HUD/QuitButton.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename osu.Game/Graphics/Containers/{HoldToCofirmContainer.cs => HoldToConfirmContainer.cs} (95%) diff --git a/osu.Game/Graphics/Containers/HoldToCofirmContainer.cs b/osu.Game/Graphics/Containers/HoldToConfirmContainer.cs similarity index 95% rename from osu.Game/Graphics/Containers/HoldToCofirmContainer.cs rename to osu.Game/Graphics/Containers/HoldToConfirmContainer.cs index eb2b2ca51b..adfc258f61 100644 --- a/osu.Game/Graphics/Containers/HoldToCofirmContainer.cs +++ b/osu.Game/Graphics/Containers/HoldToConfirmContainer.cs @@ -8,7 +8,7 @@ using osu.Framework.Graphics.Containers; namespace osu.Game.Graphics.Containers { - public abstract class HoldToCofirmContainer : Container + public abstract class HoldToConfirmContainer : Container { public Action Action; diff --git a/osu.Game/Overlays/HoldToConfirmOverlay.cs b/osu.Game/Overlays/HoldToConfirmOverlay.cs index afd3e2016f..7e2f6f5891 100644 --- a/osu.Game/Overlays/HoldToConfirmOverlay.cs +++ b/osu.Game/Overlays/HoldToConfirmOverlay.cs @@ -13,7 +13,7 @@ namespace osu.Game.Overlays /// An overlay which will display a black screen that dims over a period before confirming an exit action. /// Action is BYO (derived class will need to call and from a user event). /// - public abstract class HoldToConfirmOverlay : HoldToCofirmContainer + public abstract class HoldToConfirmOverlay : HoldToConfirmContainer { private Box overlay; diff --git a/osu.Game/Screens/Play/HUD/QuitButton.cs b/osu.Game/Screens/Play/HUD/QuitButton.cs index bbd6075332..924c8d35ee 100644 --- a/osu.Game/Screens/Play/HUD/QuitButton.cs +++ b/osu.Game/Screens/Play/HUD/QuitButton.cs @@ -78,7 +78,7 @@ namespace osu.Game.Screens.Play.HUD Alpha = stayVisible ? 1 : Interpolation.ValueAt(elapsed, Alpha, MathHelper.Clamp(1 - adjust, 0.04f, 1), 0, 200, Easing.OutQuint); } - private class Button : HoldToCofirmContainer + private class Button : HoldToConfirmContainer { private SpriteIcon icon; private CircularProgress circularProgress; From babb7d5158d860123b00bb76c58d0a0d395df8c0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 22 May 2018 16:23:05 +0900 Subject: [PATCH 38/43] Fix white ring flash when holding button post-confirmation --- osu.Game/Screens/Play/HUD/QuitButton.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/QuitButton.cs b/osu.Game/Screens/Play/HUD/QuitButton.cs index 924c8d35ee..9f59d4164f 100644 --- a/osu.Game/Screens/Play/HUD/QuitButton.cs +++ b/osu.Game/Screens/Play/HUD/QuitButton.cs @@ -151,13 +151,16 @@ namespace osu.Game.Screens.Play.HUD pendingAnimation = true; overlayCircle.ScaleTo(0, 100) - .Then().FadeOut().ScaleTo(1).FadeIn(500) - .OnComplete(a => circularProgress.FadeOut(100).OnComplete(_ => - { - bind(); - circularProgress.FadeIn(); - pendingAnimation = false; - })); + .Then().FadeOut().ScaleTo(1).FadeIn(500) + .OnComplete(a => circularProgress.FadeOut(100).OnComplete(_ => + { + Progress.Value = 0; + + bind(); + + circularProgress.FadeIn(); + pendingAnimation = false; + })); } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) From 7b770d03c5b99a83434e636dc37ae08f71abb41b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 22 May 2018 16:26:11 +0900 Subject: [PATCH 39/43] Use OnMouseMove instead of Update logic --- osu.Game/Screens/Play/HUD/QuitButton.cs | 47 ++++++++++++++++--------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/QuitButton.cs b/osu.Game/Screens/Play/HUD/QuitButton.cs index 9f59d4164f..8c59427edb 100644 --- a/osu.Game/Screens/Play/HUD/QuitButton.cs +++ b/osu.Game/Screens/Play/HUD/QuitButton.cs @@ -18,7 +18,7 @@ namespace osu.Game.Screens.Play.HUD { public class QuitButton : FillFlowContainer { - public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => button.ReceiveMouseInputAt(screenSpacePos); + public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true; private readonly Button button; @@ -43,7 +43,11 @@ namespace osu.Game.Screens.Play.HUD Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft }, - button = new Button() + button = new Button + { + HoverGained = () => text.FadeIn(500, Easing.OutQuint), + HoverLost = () => text.FadeOut(500, Easing.OutQuint) + } }; AutoSizeAxes = Axes.Both; } @@ -54,28 +58,24 @@ namespace osu.Game.Screens.Play.HUD base.LoadComplete(); } - protected override bool OnHover(InputState state) - { - text.FadeIn(500, Easing.OutQuint); - return true; - } + private float positionalAdjust; - protected override void OnHoverLost(InputState state) + protected override bool OnMouseMove(InputState state) { - text.FadeOut(500, Easing.OutQuint); - base.OnHoverLost(state); + positionalAdjust = Vector2.Distance(state.Mouse.NativeState.Position, button.ScreenSpaceDrawQuad.Centre) / 200; + return base.OnMouseMove(state); } protected override void Update() { base.Update(); - float adjust = Vector2.Distance(GetContainingInputManager().CurrentState.Mouse.NativeState.Position, button.ScreenSpaceDrawQuad.Centre) / 200; - double elapsed = MathHelper.Clamp(Clock.ElapsedFrameTime, 0, 1000); - - bool stayVisible = text.Alpha > 0 || button.Progress.Value > 0 || IsHovered; - - Alpha = stayVisible ? 1 : Interpolation.ValueAt(elapsed, Alpha, MathHelper.Clamp(1 - adjust, 0.04f, 1), 0, 200, Easing.OutQuint); + if (text.Alpha > 0 || button.Progress.Value > 0 || button.IsHovered) + Alpha = 1; + else + Alpha = Interpolation.ValueAt( + MathHelper.Clamp(Clock.ElapsedFrameTime, 0, 1000), + Alpha, MathHelper.Clamp(1 - positionalAdjust, 0.04f, 1), 0, 200, Easing.OutQuint); } private class Button : HoldToConfirmContainer @@ -86,6 +86,9 @@ namespace osu.Game.Screens.Play.HUD protected override bool AllowMultipleFires => true; + public Action HoverGained; + public Action HoverLost; + [BackgroundDependencyLoader] private void load(OsuColour colours) { @@ -163,6 +166,18 @@ namespace osu.Game.Screens.Play.HUD })); } + protected override bool OnHover(InputState state) + { + HoverGained?.Invoke(); + return true; + } + + protected override void OnHoverLost(InputState state) + { + HoverLost?.Invoke(); + base.OnHoverLost(state); + } + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) { if (!pendingAnimation && state.Mouse.Buttons.Count == 1) From 436067c01f52c8a3f91c48637d86caef65f936d4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 22 May 2018 16:44:37 +0900 Subject: [PATCH 40/43] Handle scale back in a nicer way --- osu.Game/Screens/Play/HUD/QuitButton.cs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/QuitButton.cs b/osu.Game/Screens/Play/HUD/QuitButton.cs index 8c59427edb..43a24a3ba8 100644 --- a/osu.Game/Screens/Play/HUD/QuitButton.cs +++ b/osu.Game/Screens/Play/HUD/QuitButton.cs @@ -136,9 +136,7 @@ namespace osu.Game.Screens.Play.HUD private void bind() { circularProgress.Current.BindTo(Progress); - - Progress.ValueChanged += v => icon.Scale = new Vector2(1 + (float)v * 0.4f); - Progress.TriggerChange(); + Progress.ValueChanged += v => icon.Scale = new Vector2(1 + (float)v * 0.2f); } private bool pendingAnimation; @@ -155,15 +153,19 @@ namespace osu.Game.Screens.Play.HUD overlayCircle.ScaleTo(0, 100) .Then().FadeOut().ScaleTo(1).FadeIn(500) - .OnComplete(a => circularProgress.FadeOut(100).OnComplete(_ => + .OnComplete(a => { - Progress.Value = 0; + icon.ScaleTo(1, 100); + circularProgress.FadeOut(100).OnComplete(_ => + { + Progress.Value = 0; - bind(); + bind(); - circularProgress.FadeIn(); - pendingAnimation = false; - })); + circularProgress.FadeIn(); + pendingAnimation = false; + }); + }); } protected override bool OnHover(InputState state) From d43e4af8ea2136d0b1a0be3f6edb3c5ac9c502cb Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 22 May 2018 16:45:42 +0900 Subject: [PATCH 41/43] Fix overlap between quit button at key input overlay --- osu.Game/Screens/Play/HUDOverlay.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs index cba5c94266..f920b20649 100644 --- a/osu.Game/Screens/Play/HUDOverlay.cs +++ b/osu.Game/Screens/Play/HUDOverlay.cs @@ -52,15 +52,26 @@ namespace osu.Game.Screens.Play Children = new Drawable[] { - KeyCounter = CreateKeyCounter(), ComboCounter = CreateComboCounter(), ScoreCounter = CreateScoreCounter(), AccuracyCounter = CreateAccuracyCounter(), HealthDisplay = CreateHealthDisplay(), Progress = CreateProgress(), - HoldToQuit = CreateQuitButton(), ModDisplay = CreateModsContainer(), - PlayerSettingsOverlay = CreatePlayerSettingsOverlay() + PlayerSettingsOverlay = CreatePlayerSettingsOverlay(), + new FillFlowContainer + { + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + Position = -new Vector2(5, TwoLayerButton.SIZE_RETRACTED.Y), + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + KeyCounter = CreateKeyCounter(), + HoldToQuit = CreateQuitButton(), + } + } } }); @@ -189,7 +200,6 @@ namespace osu.Game.Screens.Play Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight, Margin = new MarginPadding(10), - Y = -TwoLayerButton.SIZE_RETRACTED.Y, }; protected virtual ScoreCounter CreateScoreCounter() => new ScoreCounter(6) @@ -211,7 +221,6 @@ namespace osu.Game.Screens.Play { Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight, - Position = new Vector2(-5, -70) }; protected virtual ModDisplay CreateModsContainer() => new ModDisplay From 39de807445eeb353a8843b93dfd6fc72c640ccd7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 22 May 2018 16:46:55 +0900 Subject: [PATCH 42/43] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index b4d5c766f5..eb076a3301 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit b4d5c766f5698540a7b1bbbae7290ac7dafc2813 +Subproject commit eb076a3301231eb73917073499051e49a9b12978 From 0e122468dba15da4f5932d224249b303cea07ea5 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 22 May 2018 18:06:40 +0900 Subject: [PATCH 43/43] Fix progress easing to 0 if aborting after confirmation --- osu.Game/Screens/Play/HUD/QuitButton.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/QuitButton.cs b/osu.Game/Screens/Play/HUD/QuitButton.cs index 43a24a3ba8..d0aa0dad92 100644 --- a/osu.Game/Screens/Play/HUD/QuitButton.cs +++ b/osu.Game/Screens/Play/HUD/QuitButton.cs @@ -151,6 +151,8 @@ namespace osu.Game.Screens.Play.HUD // avoid starting a new confirm call until we finish animating. pendingAnimation = true; + Progress.Value = 0; + overlayCircle.ScaleTo(0, 100) .Then().FadeOut().ScaleTo(1).FadeIn(500) .OnComplete(a => @@ -158,8 +160,6 @@ namespace osu.Game.Screens.Play.HUD icon.ScaleTo(1, 100); circularProgress.FadeOut(100).OnComplete(_ => { - Progress.Value = 0; - bind(); circularProgress.FadeIn();