From c34ef42f0071a0bec598fd0b27d13f0a5bd3b729 Mon Sep 17 00:00:00 2001 From: TocoToucan Date: Fri, 20 Apr 2018 12:50:19 +0300 Subject: [PATCH 01/58] 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/58] 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/58] 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/58] 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/58] 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/58] 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/58] 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/58] 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/58] 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/58] 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/58] 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/58] 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/58] 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 d87ac5a1cbb0afb35979f3f1a150eddef7bafb44 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 10 May 2018 22:12:25 -0300 Subject: [PATCH 14/58] Create the drawable hierarchy for DrawableRoom in load. --- osu.Game/Screens/Multiplayer/DrawableRoom.cs | 49 +++++++++----------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/osu.Game/Screens/Multiplayer/DrawableRoom.cs b/osu.Game/Screens/Multiplayer/DrawableRoom.cs index d53100526f..b9f464ff78 100644 --- a/osu.Game/Screens/Multiplayer/DrawableRoom.cs +++ b/osu.Game/Screens/Multiplayer/DrawableRoom.cs @@ -29,11 +29,10 @@ namespace osu.Game.Screens.Multiplayer private const float cover_width = 145; private readonly Box sideStrip; - private readonly Container coverContainer; - private readonly OsuSpriteText name, status, beatmapTitle, beatmapDash, beatmapArtist; - private readonly FillFlowContainer beatmapInfoFlow; - private readonly ParticipantInfo participantInfo; - private readonly ModeTypeInfo modeTypeInfo; + private Container coverContainer; + private OsuSpriteText name, status, beatmapTitle, beatmapDash, beatmapArtist; + private ParticipantInfo participantInfo; + private ModeTypeInfo modeTypeInfo; private readonly Bindable nameBind = new Bindable(); private readonly Bindable hostBind = new Bindable(); @@ -62,6 +61,19 @@ namespace osu.Game.Screens.Multiplayer Radius = 5, }; + sideStrip = new Box + { + RelativeSizeAxes = Axes.Y, + Width = side_strip_width, + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours, LocalisationEngine localisation) + { + this.localisation = localisation; + this.colours = colours; + Children = new Drawable[] { new Box @@ -69,11 +81,7 @@ namespace osu.Game.Screens.Multiplayer RelativeSizeAxes = Axes.Both, Colour = OsuColour.FromHex(@"212121"), }, - sideStrip = new Box - { - RelativeSizeAxes = Axes.Y, - Width = side_strip_width, - }, + sideStrip, new Container { Width = cover_width, @@ -133,10 +141,11 @@ namespace osu.Game.Screens.Multiplayer TextSize = 14, Font = @"Exo2.0-Bold", }, - beatmapInfoFlow = new FillFlowContainer + new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, + Colour = colours.Gray9, Direction = FillDirection.Horizontal, Children = new[] { @@ -170,7 +179,9 @@ namespace osu.Game.Screens.Multiplayer nameBind.ValueChanged += displayName; hostBind.ValueChanged += displayUser; + statusBind.ValueChanged += displayStatus; typeBind.ValueChanged += displayGameType; + beatmapBind.ValueChanged += displayBeatmap; participantsBind.ValueChanged += displayParticipants; nameBind.BindTo(Room.Name); @@ -181,22 +192,6 @@ namespace osu.Game.Screens.Multiplayer participantsBind.BindTo(Room.Participants); } - [BackgroundDependencyLoader] - private void load(OsuColour colours, LocalisationEngine localisation) - { - this.localisation = localisation; - this.colours = colours; - - beatmapInfoFlow.Colour = colours.Gray9; - - //binded here instead of ctor because dependencies are needed - statusBind.ValueChanged += displayStatus; - beatmapBind.ValueChanged += displayBeatmap; - - statusBind.TriggerChange(); - beatmapBind.TriggerChange(); - } - private void displayName(string value) { name.Text = value; From ec53927d8e77730bd0cc6c820d6287f004018180 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 10 May 2018 22:48:07 -0300 Subject: [PATCH 15/58] Add selection to DrawableRoom. --- osu.Game.Tests/Visual/TestCaseDrawableRoom.cs | 3 + .../Graphics/UserInterface/SelectionState.cs | 11 + osu.Game/Rulesets/Edit/HitObjectMask.cs | 7 +- osu.Game/Screens/Multiplayer/DrawableRoom.cs | 364 +++++++++--------- 4 files changed, 206 insertions(+), 179 deletions(-) create mode 100644 osu.Game/Graphics/UserInterface/SelectionState.cs diff --git a/osu.Game.Tests/Visual/TestCaseDrawableRoom.cs b/osu.Game.Tests/Visual/TestCaseDrawableRoom.cs index 25f8ba06c4..65e782b828 100644 --- a/osu.Game.Tests/Visual/TestCaseDrawableRoom.cs +++ b/osu.Game.Tests/Visual/TestCaseDrawableRoom.cs @@ -6,6 +6,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps; +using osu.Game.Graphics.UserInterface; using osu.Game.Online.Multiplayer; using osu.Game.Rulesets; using osu.Game.Screens.Multiplayer; @@ -111,6 +112,7 @@ namespace osu.Game.Tests.Visual } }); + AddStep(@"select", () => first.State = SelectionState.Selected); AddStep(@"change title", () => first.Room.Name.Value = @"I Changed Name"); AddStep(@"change host", () => first.Room.Host.Value = new User { Username = @"DrabWeb", Id = 6946022, Country = new Country { FlagName = @"CA" } }); AddStep(@"change status", () => first.Room.Status.Value = new RoomStatusPlaying()); @@ -121,6 +123,7 @@ namespace osu.Game.Tests.Visual new User { Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 1254 } } }, new User { Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 123189 } } }, }); + AddStep(@"deselect", () => first.State = SelectionState.NotSelected); } [BackgroundDependencyLoader] diff --git a/osu.Game/Graphics/UserInterface/SelectionState.cs b/osu.Game/Graphics/UserInterface/SelectionState.cs new file mode 100644 index 0000000000..079ae343eb --- /dev/null +++ b/osu.Game/Graphics/UserInterface/SelectionState.cs @@ -0,0 +1,11 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Graphics.UserInterface +{ + public enum SelectionState + { + NotSelected, + Selected + } +} diff --git a/osu.Game/Rulesets/Edit/HitObjectMask.cs b/osu.Game/Rulesets/Edit/HitObjectMask.cs index ad7c27ad80..61fb700dd3 100644 --- a/osu.Game/Rulesets/Edit/HitObjectMask.cs +++ b/osu.Game/Rulesets/Edit/HitObjectMask.cs @@ -6,6 +6,7 @@ using osu.Framework; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Input; +using osu.Game.Graphics.UserInterface; using osu.Game.Rulesets.Objects.Drawables; using OpenTK; @@ -137,10 +138,4 @@ namespace osu.Game.Rulesets.Edit /// public virtual Quad SelectionQuad => ScreenSpaceDrawQuad; } - - public enum SelectionState - { - NotSelected, - Selected - } } diff --git a/osu.Game/Screens/Multiplayer/DrawableRoom.cs b/osu.Game/Screens/Multiplayer/DrawableRoom.cs index b9f464ff78..16eb93d3f0 100644 --- a/osu.Game/Screens/Multiplayer/DrawableRoom.cs +++ b/osu.Game/Screens/Multiplayer/DrawableRoom.cs @@ -1,6 +1,8 @@ // 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; using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; @@ -15,24 +17,23 @@ using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; using osu.Game.Online.Multiplayer; using osu.Game.Users; namespace osu.Game.Screens.Multiplayer { - public class DrawableRoom : OsuClickableContainer + public class DrawableRoom : OsuClickableContainer, IStateful { + private const float corner_radius = 5; + private const float selection_border_width = 4; private const float transition_duration = 100; private const float content_padding = 10; private const float height = 100; private const float side_strip_width = 5; private const float cover_width = 145; - private readonly Box sideStrip; - private Container coverContainer; - private OsuSpriteText name, status, beatmapTitle, beatmapDash, beatmapArtist; - private ParticipantInfo participantInfo; - private ModeTypeInfo modeTypeInfo; + private readonly Box selectionBox; private readonly Bindable nameBind = new Bindable(); private readonly Bindable hostBind = new Bindable(); @@ -41,148 +42,227 @@ namespace osu.Game.Screens.Multiplayer private readonly Bindable beatmapBind = new Bindable(); private readonly Bindable participantsBind = new Bindable(); - private OsuColour colours; - private LocalisationEngine localisation; - public readonly Room Room; + private SelectionState state; + + public SelectionState State + { + get { return state; } + set + { + if (value == state) return; + state = value; + + if (state == SelectionState.Selected) + selectionBox.FadeIn(transition_duration); + else + selectionBox.FadeOut(transition_duration); + + StateChanged?.Invoke(State); + } + } + + public event Action StateChanged; + public DrawableRoom(Room room) { Room = room; RelativeSizeAxes = Axes.X; - Height = height; - CornerRadius = 5; + Height = height + selection_border_width * 2; + CornerRadius = corner_radius + selection_border_width / 2; Masking = true; - EdgeEffect = new EdgeEffectParameters - { - Type = EdgeEffectType.Shadow, - Colour = Color4.Black.Opacity(40), - Radius = 5, - }; - sideStrip = new Box + // create selectionBox here so State can be set before being loaded + selectionBox = new Box { - RelativeSizeAxes = Axes.Y, - Width = side_strip_width, + RelativeSizeAxes = Axes.Both, + Alpha = 0f, }; } [BackgroundDependencyLoader] private void load(OsuColour colours, LocalisationEngine localisation) { - this.localisation = localisation; - this.colours = colours; + Box sideStrip; + Container coverContainer; + OsuSpriteText name, status, beatmapTitle, beatmapDash, beatmapArtist; + ParticipantInfo participantInfo; + ModeTypeInfo modeTypeInfo; Children = new Drawable[] { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.FromHex(@"212121"), - }, - sideStrip, - new Container - { - Width = cover_width, - RelativeSizeAxes = Axes.Y, - Masking = true, - Margin = new MarginPadding { Left = side_strip_width }, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black, - }, - coverContainer = new Container - { - RelativeSizeAxes = Axes.Both, - }, - }, - }, + selectionBox, new Container { RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding + Padding = new MarginPadding(selection_border_width), + Child = new Container { - Vertical = content_padding, - Left = side_strip_width + cover_width + content_padding, - Right = content_padding, - }, - Children = new Drawable[] - { - new FillFlowContainer + RelativeSizeAxes = Axes.Both, + Masking = true, + CornerRadius = corner_radius, + EdgeEffect = new EdgeEffectParameters { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - Spacing = new Vector2(5f), - Children = new Drawable[] + Type = EdgeEffectType.Shadow, + Colour = Color4.Black.Opacity(40), + Radius = 5, + }, + Children = new Drawable[] + { + new Box { - name = new OsuSpriteText - { - TextSize = 18, - }, - participantInfo = new ParticipantInfo(), + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.FromHex(@"212121"), }, - }, - new FillFlowContainer - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - Children = new Drawable[] + sideStrip = new Box { - status = new OsuSpriteText + RelativeSizeAxes = Axes.Y, + Width = side_strip_width, + }, + new Container + { + Width = cover_width, + RelativeSizeAxes = Axes.Y, + Masking = true, + Margin = new MarginPadding { Left = side_strip_width }, + Children = new Drawable[] { - TextSize = 14, - Font = @"Exo2.0-Bold", - }, - new FillFlowContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Colour = colours.Gray9, - Direction = FillDirection.Horizontal, - Children = new[] + new Box { - beatmapTitle = new OsuSpriteText - { - TextSize = 14, - Font = @"Exo2.0-BoldItalic", - }, - beatmapDash = new OsuSpriteText - { - TextSize = 14, - Font = @"Exo2.0-BoldItalic", - }, - beatmapArtist = new OsuSpriteText - { - TextSize = 14, - Font = @"Exo2.0-RegularItalic", - }, + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + }, + coverContainer = new Container + { + RelativeSizeAxes = Axes.Both, + }, + }, + }, + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding + { + Vertical = content_padding, + Left = side_strip_width + cover_width + content_padding, + Right = content_padding, + }, + Children = new Drawable[] + { + new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Spacing = new Vector2(5f), + Children = new Drawable[] + { + name = new OsuSpriteText + { + TextSize = 18, + }, + participantInfo = new ParticipantInfo(), + }, + }, + new FillFlowContainer + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + status = new OsuSpriteText + { + TextSize = 14, + Font = @"Exo2.0-Bold", + }, + new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Colour = colours.Gray9, + Direction = FillDirection.Horizontal, + Children = new[] + { + beatmapTitle = new OsuSpriteText + { + TextSize = 14, + Font = @"Exo2.0-BoldItalic", + }, + beatmapDash = new OsuSpriteText + { + TextSize = 14, + Font = @"Exo2.0-BoldItalic", + }, + beatmapArtist = new OsuSpriteText + { + TextSize = 14, + Font = @"Exo2.0-RegularItalic", + }, + }, + }, + }, + }, + modeTypeInfo = new ModeTypeInfo + { + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, }, }, }, - }, - modeTypeInfo = new ModeTypeInfo - { - Anchor = Anchor.BottomRight, - Origin = Anchor.BottomRight, }, }, }, }; - nameBind.ValueChanged += displayName; - hostBind.ValueChanged += displayUser; - statusBind.ValueChanged += displayStatus; - typeBind.ValueChanged += displayGameType; - beatmapBind.ValueChanged += displayBeatmap; - participantsBind.ValueChanged += displayParticipants; + nameBind.ValueChanged += n => name.Text = n; + hostBind.ValueChanged += h => participantInfo.Host = h; + typeBind.ValueChanged += m => modeTypeInfo.Type = m; + participantsBind.ValueChanged += p => participantInfo.Participants = p; + + statusBind.ValueChanged += s => + { + status.Text = s.Message; + + foreach (Drawable d in new Drawable[] { selectionBox, sideStrip, status }) + d.FadeColour(s.GetAppropriateColour(colours), 100); + }; + + beatmapBind.ValueChanged += b => + { + modeTypeInfo.Beatmap = b; + + if (b != null) + { + coverContainer.FadeIn(transition_duration); + + LoadComponentAsync(new BeatmapSetCover(b.BeatmapSet) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + FillMode = FillMode.Fill, + OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out), + }, coverContainer.Add); + + beatmapTitle.Current = localisation.GetUnicodePreference(b.Metadata.TitleUnicode, b.Metadata.Title); + beatmapDash.Text = @" - "; + beatmapArtist.Current = localisation.GetUnicodePreference(b.Metadata.ArtistUnicode, b.Metadata.Artist); + } + else + { + coverContainer.FadeOut(transition_duration); + + beatmapTitle.Current = null; + beatmapArtist.Current = null; + + beatmapTitle.Text = "Changing map"; + beatmapDash.Text = beatmapArtist.Text = string.Empty; + } + }; nameBind.BindTo(Room.Name); hostBind.BindTo(Room.Host); @@ -191,67 +271,5 @@ namespace osu.Game.Screens.Multiplayer beatmapBind.BindTo(Room.Beatmap); participantsBind.BindTo(Room.Participants); } - - private void displayName(string value) - { - name.Text = value; - } - - private void displayUser(User value) - { - participantInfo.Host = value; - } - - private void displayStatus(RoomStatus value) - { - if (value == null) return; - status.Text = value.Message; - - foreach (Drawable d in new Drawable[] { sideStrip, status }) - d.FadeColour(value.GetAppropriateColour(colours), 100); - } - - private void displayGameType(GameType value) - { - modeTypeInfo.Type = value; - } - - private void displayBeatmap(BeatmapInfo value) - { - modeTypeInfo.Beatmap = value; - - if (value != null) - { - coverContainer.FadeIn(transition_duration); - - LoadComponentAsync(new BeatmapSetCover(value.BeatmapSet) - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - FillMode = FillMode.Fill, - OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out), - }, - coverContainer.Add); - - beatmapTitle.Current = localisation.GetUnicodePreference(value.Metadata.TitleUnicode, value.Metadata.Title); - beatmapDash.Text = @" - "; - beatmapArtist.Current = localisation.GetUnicodePreference(value.Metadata.ArtistUnicode, value.Metadata.Artist); - } - else - { - coverContainer.FadeOut(transition_duration); - - beatmapTitle.Current = null; - beatmapArtist.Current = null; - - beatmapTitle.Text = "Changing map"; - beatmapDash.Text = beatmapArtist.Text = string.Empty; - } - } - - private void displayParticipants(User[] value) - { - participantInfo.Participants = value; - } } } From a241ff1c051447338442ae9e30d3b2b402182b0d Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 10 May 2018 22:50:03 -0300 Subject: [PATCH 16/58] Cleanup. --- osu.Game/Screens/Multiplayer/DrawableRoom.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Multiplayer/DrawableRoom.cs b/osu.Game/Screens/Multiplayer/DrawableRoom.cs index 16eb93d3f0..a67ead74a1 100644 --- a/osu.Game/Screens/Multiplayer/DrawableRoom.cs +++ b/osu.Game/Screens/Multiplayer/DrawableRoom.cs @@ -45,7 +45,6 @@ namespace osu.Game.Screens.Multiplayer public readonly Room Room; private SelectionState state; - public SelectionState State { get { return state; } From 41de02fc78e08513e9588a6d02090044155ed32f Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 11 May 2018 13:43:53 -0300 Subject: [PATCH 17/58] Make DrawableRooms select when they are clicked. --- osu.Game/Screens/Multi/Components/DrawableRoom.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Screens/Multi/Components/DrawableRoom.cs b/osu.Game/Screens/Multi/Components/DrawableRoom.cs index f3ce3dcd8e..994b0e886b 100644 --- a/osu.Game/Screens/Multi/Components/DrawableRoom.cs +++ b/osu.Game/Screens/Multi/Components/DrawableRoom.cs @@ -9,6 +9,7 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Framework.Input; using osu.Framework.Localisation; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; @@ -79,6 +80,8 @@ namespace osu.Game.Screens.Multi.Components RelativeSizeAxes = Axes.Both, Alpha = 0f, }; + + Action += () => State = SelectionState.Selected; } [BackgroundDependencyLoader] From 937ff50a5a4269431973066233d776fc16ace442 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 11 May 2018 13:56:27 -0300 Subject: [PATCH 18/58] Remove unused using. --- osu.Game/Screens/Multi/Components/DrawableRoom.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Multi/Components/DrawableRoom.cs b/osu.Game/Screens/Multi/Components/DrawableRoom.cs index 994b0e886b..88a253d719 100644 --- a/osu.Game/Screens/Multi/Components/DrawableRoom.cs +++ b/osu.Game/Screens/Multi/Components/DrawableRoom.cs @@ -9,7 +9,6 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Framework.Input; using osu.Framework.Localisation; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; From 8a5bd27c2018e0ae4f980e77aea891f70b1ce562 Mon Sep 17 00:00:00 2001 From: ocboogie Date: Sat, 12 May 2018 16:30:29 -0700 Subject: [PATCH 19/58] 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 20/58] 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 21/58] 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 22/58] 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 23/58] 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 4b2b2086df821b5889892abe9bae3775f55a2a5e Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 19 May 2018 01:26:39 -0300 Subject: [PATCH 24/58] Create drawable hierarchy for RoomInspector in load, remove display* methods. --- .../Screens/Multi/Components/RoomInspector.cs | 191 ++++++++---------- 1 file changed, 85 insertions(+), 106 deletions(-) diff --git a/osu.Game/Screens/Multi/Components/RoomInspector.cs b/osu.Game/Screens/Multi/Components/RoomInspector.cs index 92910e8301..b103624dfb 100644 --- a/osu.Game/Screens/Multi/Components/RoomInspector.cs +++ b/osu.Game/Screens/Multi/Components/RoomInspector.cs @@ -28,14 +28,6 @@ namespace osu.Game.Screens.Multi.Components private readonly MarginPadding contentPadding = new MarginPadding { Horizontal = 20, Vertical = 10 }; private const float transition_duration = 100; - private readonly Box statusStrip; - private readonly Container coverContainer; - private readonly FillFlowContainer topFlow, participantsFlow; - private readonly ModeTypeInfo modeTypeInfo; - private readonly OsuSpriteText participants, participantsSlash, maxParticipants, name, status, beatmapTitle, beatmapDash, beatmapArtist, beatmapAuthor; - private readonly ParticipantInfo participantInfo; - private readonly ScrollContainer participantsScroll; - private readonly Bindable nameBind = new Bindable(); private readonly Bindable hostBind = new Bindable(); private readonly Bindable statusBind = new Bindable(); @@ -44,11 +36,10 @@ namespace osu.Game.Screens.Multi.Components private readonly Bindable maxParticipantsBind = new Bindable(); private readonly Bindable participantsBind = new Bindable(); - private OsuColour colours; - private LocalisationEngine localisation; + private FillFlowContainer topFlow; + private ScrollContainer participantsScroll; private Room room; - public Room Room { get { return room; } @@ -71,6 +62,17 @@ namespace osu.Game.Screens.Multi.Components { Width = 520; RelativeSizeAxes = Axes.Y; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours, LocalisationEngine localisation) + { + Box statusStrip; + Container coverContainer; + FillFlowContainer participantsFlow; + ModeTypeInfo modeTypeInfo; + OsuSpriteText participants, participantsSlash, maxParticipants, name, status, beatmapTitle, beatmapDash, beatmapArtist, beatmapAuthor; + ParticipantInfo participantInfo; Children = new Drawable[] { @@ -229,6 +231,7 @@ namespace osu.Game.Screens.Multi.Components Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, TextSize = 14, + Colour = colours.Gray9, }, }, }, @@ -269,27 +272,83 @@ namespace osu.Game.Screens.Multi.Components }, }; - nameBind.ValueChanged += displayName; - hostBind.ValueChanged += displayUser; - typeBind.ValueChanged += displayGameType; - maxParticipantsBind.ValueChanged += displayMaxParticipants; - participantsBind.ValueChanged += displayParticipants; - } + nameBind.ValueChanged += n => name.Text = n; + hostBind.ValueChanged += h => participantInfo.Host = h; + typeBind.ValueChanged += t => modeTypeInfo.Type = t; - [BackgroundDependencyLoader] - private void load(OsuColour colours, LocalisationEngine localisation) - { - this.localisation = localisation; - this.colours = colours; + statusBind.ValueChanged += s => + { + status.Text = s.Message; - beatmapAuthor.Colour = colours.Gray9; + foreach (Drawable d in new Drawable[] { statusStrip, status }) + d.FadeColour(s.GetAppropriateColour(colours), transition_duration); + }; - //binded here instead of ctor because dependencies are needed - statusBind.ValueChanged += displayStatus; - beatmapBind.ValueChanged += displayBeatmap; + beatmapBind.ValueChanged += b => + { + modeTypeInfo.Beatmap = b; + if (b != null) + { + coverContainer.FadeIn(transition_duration); + + LoadComponentAsync(new BeatmapSetCover(b.BeatmapSet) + { + RelativeSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + FillMode = FillMode.Fill, + OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out), + }, + coverContainer.Add); + + beatmapTitle.Current = localisation.GetUnicodePreference(b.Metadata.TitleUnicode, b.Metadata.Title); + beatmapDash.Text = @" - "; + beatmapArtist.Current = localisation.GetUnicodePreference(b.Metadata.ArtistUnicode, b.Metadata.Artist); + beatmapAuthor.Text = $"mapped by {b.Metadata.Author}"; + } + else + { + coverContainer.FadeOut(transition_duration); + + beatmapTitle.Current = null; + beatmapArtist.Current = null; + + beatmapTitle.Text = "Changing map"; + beatmapDash.Text = beatmapArtist.Text = beatmapAuthor.Text = string.Empty; + } + }; + + maxParticipantsBind.ValueChanged += m => + { + if (m == null) + { + participantsSlash.FadeOut(transition_duration); + maxParticipants.FadeOut(transition_duration); + } + else + { + participantsSlash.FadeIn(transition_duration); + maxParticipants.FadeIn(transition_duration); + maxParticipants.Text = m.ToString(); + } + }; + + participantsBind.ValueChanged += p => + { + participants.Text = p.Length.ToString(); + participantInfo.Participants = p; + participantsFlow.ChildrenEnumerable = p.Select(u => new UserTile(u)); + }; + + // trigger incase a room was set before we were loaded + nameBind.TriggerChange(); + hostBind.TriggerChange(); statusBind.TriggerChange(); + typeBind.TriggerChange(); beatmapBind.TriggerChange(); + maxParticipantsBind.TriggerChange(); + participantsBind.TriggerChange(); } protected override void UpdateAfterChildren() @@ -299,86 +358,6 @@ namespace osu.Game.Screens.Multi.Components participantsScroll.Height = DrawHeight - topFlow.DrawHeight; } - private void displayName(string value) - { - name.Text = value; - } - - private void displayUser(User value) - { - participantInfo.Host = value; - } - - private void displayStatus(RoomStatus value) - { - status.Text = value.Message; - - foreach (Drawable d in new Drawable[] { statusStrip, status }) - d.FadeColour(value.GetAppropriateColour(colours), transition_duration); - } - - private void displayGameType(GameType value) - { - modeTypeInfo.Type = value; - } - - private void displayBeatmap(BeatmapInfo value) - { - modeTypeInfo.Beatmap = value; - - if (value != null) - { - coverContainer.FadeIn(transition_duration); - - LoadComponentAsync(new BeatmapSetCover(value.BeatmapSet) - { - RelativeSizeAxes = Axes.Both, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - FillMode = FillMode.Fill, - OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out), - }, - coverContainer.Add); - - beatmapTitle.Current = localisation.GetUnicodePreference(value.Metadata.TitleUnicode, value.Metadata.Title); - beatmapDash.Text = @" - "; - beatmapArtist.Current = localisation.GetUnicodePreference(value.Metadata.ArtistUnicode, value.Metadata.Artist); - beatmapAuthor.Text = $"mapped by {value.Metadata.Author}"; - } - else - { - coverContainer.FadeOut(transition_duration); - - beatmapTitle.Current = null; - beatmapArtist.Current = null; - - beatmapTitle.Text = "Changing map"; - beatmapDash.Text = beatmapArtist.Text = beatmapAuthor.Text = string.Empty; - } - } - - private void displayMaxParticipants(int? value) - { - if (value == null) - { - participantsSlash.FadeOut(transition_duration); - maxParticipants.FadeOut(transition_duration); - } - else - { - participantsSlash.FadeIn(transition_duration); - maxParticipants.FadeIn(transition_duration); - maxParticipants.Text = value.ToString(); - } - } - - private void displayParticipants(User[] value) - { - participants.Text = value.Length.ToString(); - participantInfo.Participants = value; - participantsFlow.ChildrenEnumerable = value.Select(u => new UserTile(u)); - } - private class UserTile : Container, IHasTooltip { private readonly User user; From ad878003f7ef6a83cb88d7e98a3d45f1d4f0aeb2 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 19 May 2018 02:23:09 -0300 Subject: [PATCH 25/58] Add null room support to RoomInspector. --- .../Visual/TestCaseRoomInspector.cs | 8 +- .../Screens/Multi/Components/RoomInspector.cs | 116 ++++++++++++------ 2 files changed, 81 insertions(+), 43 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseRoomInspector.cs b/osu.Game.Tests/Visual/TestCaseRoomInspector.cs index cb1425ca69..48756c907b 100644 --- a/osu.Game.Tests/Visual/TestCaseRoomInspector.cs +++ b/osu.Game.Tests/Visual/TestCaseRoomInspector.cs @@ -21,7 +21,7 @@ namespace osu.Game.Tests.Visual { base.LoadComplete(); - var room = new Room + Room room = new Room { Name = { Value = @"My Awesome Room" }, Host = { Value = new User { Username = @"flyte", Id = 3103765, Country = new Country { FlagName = @"JP" } } }, @@ -71,9 +71,11 @@ namespace osu.Game.Tests.Visual { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Room = room, }); + AddStep(@"set room", () => inspector.Room = room); + AddStep(@"null room", () => inspector.Room = null); + AddStep(@"set room", () => inspector.Room = room); AddStep(@"change title", () => room.Name.Value = @"A Better Room Than The Above"); AddStep(@"change host", () => room.Host.Value = new User { Username = @"DrabWeb", Id = 6946022, Country = new Country { FlagName = @"CA" } }); AddStep(@"change status", () => room.Status.Value = new RoomStatusPlaying()); @@ -88,7 +90,7 @@ namespace osu.Game.Tests.Visual AddStep(@"change room", () => { - var newRoom = new Room + Room newRoom = new Room { Name = { Value = @"My New, Better Than Ever Room" }, Host = { Value = new User { Username = @"Angelsim", Id = 1777162, Country = new Country { FlagName = @"KR" } } }, diff --git a/osu.Game/Screens/Multi/Components/RoomInspector.cs b/osu.Game/Screens/Multi/Components/RoomInspector.cs index b103624dfb..b3a6d90e39 100644 --- a/osu.Game/Screens/Multi/Components/RoomInspector.cs +++ b/osu.Game/Screens/Multi/Components/RoomInspector.cs @@ -5,6 +5,7 @@ using System.Linq; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; @@ -25,9 +26,9 @@ namespace osu.Game.Screens.Multi.Components { public class RoomInspector : Container { - private readonly MarginPadding contentPadding = new MarginPadding { Horizontal = 20, Vertical = 10 }; private const float transition_duration = 100; + private readonly MarginPadding contentPadding = new MarginPadding { Horizontal = 20, Vertical = 10 }; private readonly Bindable nameBind = new Bindable(); private readonly Bindable hostBind = new Bindable(); private readonly Bindable statusBind = new Bindable(); @@ -36,8 +37,13 @@ namespace osu.Game.Screens.Multi.Components private readonly Bindable maxParticipantsBind = new Bindable(); private readonly Bindable participantsBind = new Bindable(); - private FillFlowContainer topFlow; + private OsuColour colours; + private Box statusStrip; + private Container coverContainer; + private FillFlowContainer topFlow, participantsFlow, participantNumbersFlow, infoPanelFlow; + private OsuSpriteText name, status; private ScrollContainer participantsScroll; + private ParticipantInfo participantInfo; private Room room; public Room Room @@ -48,13 +54,26 @@ namespace osu.Game.Screens.Multi.Components if (value == room) return; room = value; - nameBind.BindTo(Room.Name); - hostBind.BindTo(Room.Host); - statusBind.BindTo(Room.Status); - typeBind.BindTo(Room.Type); - beatmapBind.BindTo(Room.Beatmap); - maxParticipantsBind.BindTo(Room.MaxParticipants); - participantsBind.BindTo(Room.Participants); + nameBind.UnbindBindings(); + hostBind.UnbindBindings(); + statusBind.UnbindBindings(); + typeBind.UnbindBindings(); + beatmapBind.UnbindBindings(); + maxParticipantsBind.UnbindBindings(); + participantsBind.UnbindBindings(); + + if (Room != null) + { + nameBind.BindTo(Room.Name); + hostBind.BindTo(Room.Host); + statusBind.BindTo(Room.Status); + typeBind.BindTo(Room.Type); + beatmapBind.BindTo(Room.Beatmap); + maxParticipantsBind.BindTo(Room.MaxParticipants); + participantsBind.BindTo(Room.Participants); + } + + updateState(); } } @@ -67,12 +86,10 @@ namespace osu.Game.Screens.Multi.Components [BackgroundDependencyLoader] private void load(OsuColour colours, LocalisationEngine localisation) { - Box statusStrip; - Container coverContainer; - FillFlowContainer participantsFlow; + this.colours = colours; + ModeTypeInfo modeTypeInfo; - OsuSpriteText participants, participantsSlash, maxParticipants, name, status, beatmapTitle, beatmapDash, beatmapArtist, beatmapAuthor; - ParticipantInfo participantInfo; + OsuSpriteText participants, participantsSlash, maxParticipants, beatmapTitle, beatmapDash, beatmapArtist, beatmapAuthor; Children = new Drawable[] { @@ -122,7 +139,7 @@ namespace osu.Game.Screens.Multi.Components Padding = new MarginPadding(20), Children = new Drawable[] { - new FillFlowContainer + participantNumbersFlow = new FillFlowContainer { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, @@ -180,6 +197,7 @@ namespace osu.Game.Screens.Multi.Components RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, + LayoutDuration = transition_duration, Padding = contentPadding, Spacing = new Vector2(0f, 5f), Children = new Drawable[] @@ -189,7 +207,7 @@ namespace osu.Game.Screens.Multi.Components TextSize = 14, Font = @"Exo2.0-Bold", }, - new FillFlowContainer + infoPanelFlow = new FillFlowContainer { AutoSizeAxes = Axes.X, Height = 30, @@ -275,14 +293,7 @@ namespace osu.Game.Screens.Multi.Components nameBind.ValueChanged += n => name.Text = n; hostBind.ValueChanged += h => participantInfo.Host = h; typeBind.ValueChanged += t => modeTypeInfo.Type = t; - - statusBind.ValueChanged += s => - { - status.Text = s.Message; - - foreach (Drawable d in new Drawable[] { statusStrip, status }) - d.FadeColour(s.GetAppropriateColour(colours), transition_duration); - }; + statusBind.ValueChanged += displayStatus; beatmapBind.ValueChanged += b => { @@ -293,14 +304,13 @@ namespace osu.Game.Screens.Multi.Components coverContainer.FadeIn(transition_duration); LoadComponentAsync(new BeatmapSetCover(b.BeatmapSet) - { - RelativeSizeAxes = Axes.Both, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - FillMode = FillMode.Fill, - OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out), - }, - coverContainer.Add); + { + RelativeSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + FillMode = FillMode.Fill, + OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out), + }, coverContainer.Add); beatmapTitle.Current = localisation.GetUnicodePreference(b.Metadata.TitleUnicode, b.Metadata.Title); beatmapDash.Text = @" - "; @@ -341,14 +351,7 @@ namespace osu.Game.Screens.Multi.Components participantsFlow.ChildrenEnumerable = p.Select(u => new UserTile(u)); }; - // trigger incase a room was set before we were loaded - nameBind.TriggerChange(); - hostBind.TriggerChange(); - statusBind.TriggerChange(); - typeBind.TriggerChange(); - beatmapBind.TriggerChange(); - maxParticipantsBind.TriggerChange(); - participantsBind.TriggerChange(); + updateState(); } protected override void UpdateAfterChildren() @@ -358,6 +361,33 @@ namespace osu.Game.Screens.Multi.Components participantsScroll.Height = DrawHeight - topFlow.DrawHeight; } + private void displayStatus(RoomStatus s) + { + status.Text = s.Message; + + foreach (Drawable d in new Drawable[] { statusStrip, status }) + d.FadeColour(s.GetAppropriateColour(colours), transition_duration); + } + + private void updateState() + { + if (Room == null) + { + foreach (Drawable d in new Drawable[] { coverContainer, participantsFlow, participantNumbersFlow, infoPanelFlow, name, participantInfo }) + d.FadeOut(transition_duration); + + displayStatus(new RoomStatusNoneSelected()); + } + else + { + foreach (Drawable d in new Drawable[] { participantsFlow, participantNumbersFlow, infoPanelFlow, name, participantInfo }) + d.FadeIn(transition_duration); + + statusBind.TriggerChange(); + beatmapBind.TriggerChange(); + } + } + private class UserTile : Container, IHasTooltip { private readonly User user; @@ -386,5 +416,11 @@ namespace osu.Game.Screens.Multi.Components }; } } + + private class RoomStatusNoneSelected : RoomStatus + { + public override string Message => @"No Room Selected"; + public override Color4 GetAppropriateColour(OsuColour colours) => colours.Gray8; + } } } From 136c57b824d477e3af4370681e987358ed35b5b6 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 19 May 2018 02:27:33 -0300 Subject: [PATCH 26/58] Don't set size in ctor. --- osu.Game.Tests/Visual/TestCaseRoomInspector.cs | 2 ++ osu.Game/Screens/Multi/Components/RoomInspector.cs | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseRoomInspector.cs b/osu.Game.Tests/Visual/TestCaseRoomInspector.cs index 48756c907b..06b9c4a6f9 100644 --- a/osu.Game.Tests/Visual/TestCaseRoomInspector.cs +++ b/osu.Game.Tests/Visual/TestCaseRoomInspector.cs @@ -71,6 +71,8 @@ namespace osu.Game.Tests.Visual { Anchor = Anchor.Centre, Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Width = 0.5f, }); AddStep(@"set room", () => inspector.Room = room); diff --git a/osu.Game/Screens/Multi/Components/RoomInspector.cs b/osu.Game/Screens/Multi/Components/RoomInspector.cs index b3a6d90e39..3de1611b77 100644 --- a/osu.Game/Screens/Multi/Components/RoomInspector.cs +++ b/osu.Game/Screens/Multi/Components/RoomInspector.cs @@ -79,8 +79,6 @@ namespace osu.Game.Screens.Multi.Components public RoomInspector() { - Width = 520; - RelativeSizeAxes = Axes.Y; } [BackgroundDependencyLoader] From 9cd0ec366e2d003e1f6c1923f414010a7208a821 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 19 May 2018 02:51:51 -0300 Subject: [PATCH 27/58] Cleanup. --- .../Screens/Multi/Components/RoomInspector.cs | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/osu.Game/Screens/Multi/Components/RoomInspector.cs b/osu.Game/Screens/Multi/Components/RoomInspector.cs index 3de1611b77..ea12b5dbde 100644 --- a/osu.Game/Screens/Multi/Components/RoomInspector.cs +++ b/osu.Game/Screens/Multi/Components/RoomInspector.cs @@ -5,7 +5,6 @@ using System.Linq; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; -using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; @@ -77,10 +76,6 @@ namespace osu.Game.Screens.Multi.Components } } - public RoomInspector() - { - } - [BackgroundDependencyLoader] private void load(OsuColour colours, LocalisationEngine localisation) { @@ -363,23 +358,31 @@ namespace osu.Game.Screens.Multi.Components { status.Text = s.Message; - foreach (Drawable d in new Drawable[] { statusStrip, status }) - d.FadeColour(s.GetAppropriateColour(colours), transition_duration); + Color4 c = s.GetAppropriateColour(colours); + statusStrip.FadeColour(c, transition_duration); + status.FadeColour(c, transition_duration); } private void updateState() { if (Room == null) { - foreach (Drawable d in new Drawable[] { coverContainer, participantsFlow, participantNumbersFlow, infoPanelFlow, name, participantInfo }) - d.FadeOut(transition_duration); + coverContainer.FadeOut(transition_duration); + participantsFlow.FadeOut(transition_duration); + participantNumbersFlow.FadeOut(transition_duration); + infoPanelFlow.FadeOut(transition_duration); + name.FadeOut(transition_duration); + participantInfo.FadeOut(transition_duration); displayStatus(new RoomStatusNoneSelected()); } else { - foreach (Drawable d in new Drawable[] { participantsFlow, participantNumbersFlow, infoPanelFlow, name, participantInfo }) - d.FadeIn(transition_duration); + participantsFlow.FadeIn(transition_duration); + participantNumbersFlow.FadeIn(transition_duration); + infoPanelFlow.FadeIn(transition_duration); + name.FadeIn(transition_duration); + participantInfo.FadeIn(transition_duration); statusBind.TriggerChange(); beatmapBind.TriggerChange(); From 4d528c4e6703da6e93418e59f3d11db2b13e8031 Mon Sep 17 00:00:00 2001 From: Aergwyn Date: Sun, 20 May 2018 10:57:15 +0200 Subject: [PATCH 28/58] 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 aaca7e92b483f847fb8605f203088e76909effb3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 21 May 2018 03:56:59 +0900 Subject: [PATCH 29/58] Avoid excessive property lookups --- .../Screens/Multi/Components/RoomInspector.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/osu.Game/Screens/Multi/Components/RoomInspector.cs b/osu.Game/Screens/Multi/Components/RoomInspector.cs index ea12b5dbde..3bd054b042 100644 --- a/osu.Game/Screens/Multi/Components/RoomInspector.cs +++ b/osu.Game/Screens/Multi/Components/RoomInspector.cs @@ -61,15 +61,15 @@ namespace osu.Game.Screens.Multi.Components maxParticipantsBind.UnbindBindings(); participantsBind.UnbindBindings(); - if (Room != null) + if (room != null) { - nameBind.BindTo(Room.Name); - hostBind.BindTo(Room.Host); - statusBind.BindTo(Room.Status); - typeBind.BindTo(Room.Type); - beatmapBind.BindTo(Room.Beatmap); - maxParticipantsBind.BindTo(Room.MaxParticipants); - participantsBind.BindTo(Room.Participants); + nameBind.BindTo(room.Name); + hostBind.BindTo(room.Host); + statusBind.BindTo(room.Status); + typeBind.BindTo(room.Type); + beatmapBind.BindTo(room.Beatmap); + maxParticipantsBind.BindTo(room.MaxParticipants); + participantsBind.BindTo(room.Participants); } updateState(); From 46c6c1d07e6edd0dc778d22a9ecf4e87c686a0dd Mon Sep 17 00:00:00 2001 From: Joehu Date: Sun, 20 May 2018 20:25:39 -0700 Subject: [PATCH 30/58] Allow drag clicking footer and filter on song select --- osu.Game/Screens/Select/FilterControl.cs | 2 -- osu.Game/Screens/Select/Footer.cs | 2 -- 2 files changed, 4 deletions(-) diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index ee458a13a4..f9f3db3827 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -190,7 +190,5 @@ namespace osu.Game.Screens.Select protected override bool OnMouseMove(InputState state) => true; protected override bool OnClick(InputState state) => true; - - protected override bool OnDragStart(InputState state) => true; } } diff --git a/osu.Game/Screens/Select/Footer.cs b/osu.Game/Screens/Select/Footer.cs index 363249ab63..8f07e0a763 100644 --- a/osu.Game/Screens/Select/Footer.cs +++ b/osu.Game/Screens/Select/Footer.cs @@ -141,7 +141,5 @@ namespace osu.Game.Screens.Select protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true; protected override bool OnClick(InputState state) => true; - - protected override bool OnDragStart(InputState state) => true; } } From 42519e3723e5abcde81c0c04005dae38a657aeb8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 21 May 2018 14:45:44 +0900 Subject: [PATCH 31/58] 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 32/58] 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 33/58] 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 34/58] 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 35/58] 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 36/58] 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 37/58] 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 38/58] 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 39/58] 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 40/58] 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 41/58] 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 42/58] 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 43/58] 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 44/58] 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 45/58] 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 46/58] 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 47/58] 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 48/58] 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 49/58] 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 50/58] 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 51/58] 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 52/58] 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 53/58] 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 54/58] 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(); From 76fbc656a18587d3299c04b858a91b155c79eb99 Mon Sep 17 00:00:00 2001 From: Aergwyn Date: Tue, 22 May 2018 17:53:36 +0200 Subject: [PATCH 55/58] fix disclaimer allowing notifications --- osu.Game/Screens/Menu/Disclaimer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Screens/Menu/Disclaimer.cs b/osu.Game/Screens/Menu/Disclaimer.cs index 9a671cf780..b8cb7f2a4a 100644 --- a/osu.Game/Screens/Menu/Disclaimer.cs +++ b/osu.Game/Screens/Menu/Disclaimer.cs @@ -19,6 +19,7 @@ namespace osu.Game.Screens.Menu private Color4 iconColour; protected override bool HideOverlaysOnEnter => true; + protected override bool AllowOpeningOverlays => false; public override bool CursorVisible => false; From f894d73501d813d1999fb39d73bd193257b4f611 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 23 May 2018 14:36:09 +0900 Subject: [PATCH 56/58] Fix possible MusicController nullref --- osu.Game/Overlays/Music/PlaylistList.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Music/PlaylistList.cs b/osu.Game/Overlays/Music/PlaylistList.cs index 8c8ff89420..966f09975d 100644 --- a/osu.Game/Overlays/Music/PlaylistList.cs +++ b/osu.Game/Overlays/Music/PlaylistList.cs @@ -101,7 +101,7 @@ namespace osu.Game.Overlays.Music private void updateSelectedSet() { foreach (PlaylistItem s in items.Children) - s.Selected = s.BeatmapSetInfo.ID == beatmapBacking.Value.BeatmapSetInfo.ID; + s.Selected = s.BeatmapSetInfo.ID == beatmapBacking.Value?.BeatmapSetInfo?.ID; } public string SearchTerm From 0c0f86fe26ec1785b67d52d50d9ad4fa9d62c8d7 Mon Sep 17 00:00:00 2001 From: Aergwyn Date: Wed, 23 May 2018 16:23:03 +0200 Subject: [PATCH 57/58] fix incorrect default values keeping overlays in wrong state --- osu.Game/Screens/OsuScreen.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 4b1562291b..a188b7aa64 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -37,14 +37,14 @@ namespace osu.Game.Screens /// /// Whether overlays should be hidden when this screen is entered or resumed. /// - protected virtual bool HideOverlaysOnEnter => hideOverlaysOnEnter; + protected virtual bool HideOverlaysOnEnter => false; private readonly BindableBool allowOpeningOverlays = new BindableBool(); /// /// Whether overlays should be able to be opened while this screen is active. /// - protected virtual bool AllowOpeningOverlays => allowOpeningOverlays; + protected virtual bool AllowOpeningOverlays => true; /// /// Whether this allows the cursor to be displayed. From 568d4882c681b187d80e4bba3b99d0b00abeaaae Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 25 May 2018 11:00:56 +0900 Subject: [PATCH 58/58] Remove unnecessary null coalesce --- osu.Game/Overlays/Music/PlaylistList.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Music/PlaylistList.cs b/osu.Game/Overlays/Music/PlaylistList.cs index 966f09975d..d4bc8c5b27 100644 --- a/osu.Game/Overlays/Music/PlaylistList.cs +++ b/osu.Game/Overlays/Music/PlaylistList.cs @@ -101,7 +101,7 @@ namespace osu.Game.Overlays.Music private void updateSelectedSet() { foreach (PlaylistItem s in items.Children) - s.Selected = s.BeatmapSetInfo.ID == beatmapBacking.Value?.BeatmapSetInfo?.ID; + s.Selected = s.BeatmapSetInfo.ID == beatmapBacking.Value.BeatmapSetInfo?.ID; } public string SearchTerm