diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs index e34e87d8df..11064d0ffd 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs @@ -2,11 +2,10 @@ // See the LICENCE file in the repository root for full licence text. using System; -using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; -using osu.Framework.Bindables; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Game.Configuration; using osu.Game.Rulesets.Mods; using osu.Game.Screens.Play; @@ -31,7 +30,7 @@ namespace osu.Game.Tests.Visual.Gameplay AddAssert("showhud is set", () => hudOverlay.ShowHud.Value); AddAssert("hidetarget is visible", () => hideTarget.IsPresent); - AddAssert("key counters are visible", () => hudOverlay.KeyCounter.All(k => k.IsPresent)); + AddAssert("key counter flow is visible", () => hudOverlay.KeyCounter.KeyFlow.IsPresent); AddAssert("pause button is visible", () => hudOverlay.HoldToQuit.IsPresent); } @@ -55,8 +54,8 @@ namespace osu.Game.Tests.Visual.Gameplay AddUntilStep("hidetarget is hidden", () => !hideTarget.IsPresent); AddAssert("pause button is still visible", () => hudOverlay.HoldToQuit.IsPresent); - // Key counters should not be affected by this, only the key counter container will be hidden as checked above. - AddAssert("key counters not affected", () => hudOverlay.KeyCounter.All(k => k.IsPresent)); + // Key counter flow container should not be affected by this, only the key counter display will be hidden as checked above. + AddAssert("key counter flow not affected", () => hudOverlay.KeyCounter.KeyFlow.IsPresent); } [Test] @@ -88,11 +87,11 @@ namespace osu.Game.Tests.Visual.Gameplay AddStep("set showhud false", () => hudOverlay.ShowHud.Value = false); AddUntilStep("hidetarget is hidden", () => !hideTarget.IsPresent); - AddAssert("key counters hidden", () => hudOverlay.KeyCounter.All(k => !k.IsPresent)); + AddAssert("key counters hidden", () => !hudOverlay.KeyCounter.KeyFlow.IsPresent); AddStep("set showhud true", () => hudOverlay.ShowHud.Value = true); AddUntilStep("hidetarget is visible", () => hideTarget.IsPresent); - AddAssert("key counters still hidden", () => hudOverlay.KeyCounter.All(k => !k.IsPresent)); + AddAssert("key counters still hidden", () => !hudOverlay.KeyCounter.KeyFlow.IsPresent); } private void createNew(Action action = null) @@ -126,7 +125,7 @@ namespace osu.Game.Tests.Visual.Gameplay private class TestKeyCounterDisplay : KeyCounterDisplay { - public new Bindable ConfigVisibility => base.ConfigVisibility; + public new Container KeyFlow => base.KeyFlow; } } } diff --git a/osu.Game/Screens/Play/KeyCounterDisplay.cs b/osu.Game/Screens/Play/KeyCounterDisplay.cs index d7b4913d3c..b03f663371 100644 --- a/osu.Game/Screens/Play/KeyCounterDisplay.cs +++ b/osu.Game/Screens/Play/KeyCounterDisplay.cs @@ -5,7 +5,6 @@ using System; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; -using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input.Events; @@ -15,7 +14,7 @@ using osuTK.Graphics; namespace osu.Game.Screens.Play { - public class KeyCounterDisplay : FillFlowContainer + public class KeyCounterDisplay : Container { private const int duration = 100; private const double key_fade_time = 80; @@ -23,10 +22,19 @@ namespace osu.Game.Screens.Play public readonly Bindable Visible = new Bindable(true); protected readonly Bindable ConfigVisibility = new Bindable(); + protected readonly FillFlowContainer KeyFlow; + + protected override Container Content => KeyFlow; + public KeyCounterDisplay() { - Direction = FillDirection.Horizontal; AutoSizeAxes = Axes.Both; + + InternalChild = KeyFlow = new FillFlowContainer + { + Direction = FillDirection.Horizontal, + AutoSizeAxes = Axes.Both, + }; } public override void Add(KeyCounter key) @@ -102,8 +110,8 @@ namespace osu.Game.Screens.Play } private void updateVisibility() => - // Change visibility of all key counters internally to isolate from showing them by fading in this container. - Children.ForEach(k => k.FadeTo(Visible.Value || ConfigVisibility.Value ? 1 : 0, duration)); + // Isolate changing visibility of the key counters from fading this component. + KeyFlow.FadeTo(Visible.Value || alwaysShow.Value ? 1 : 0, duration); public override bool HandleNonPositionalInput => receptor == null; public override bool HandlePositionalInput => receptor == null;