diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs index 5887cc2435..7ce6153ba5 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs @@ -30,8 +30,8 @@ namespace osu.Game.Tests.Visual.Gameplay AddAssert("showhud is set", () => hudOverlay.ShowHud.Value); AddAssert("hidetarget is visible", () => hideTarget.IsPresent); + AddAssert("key counter flow is visible", () => hudOverlay.KeyCounter.KeyFlow.IsPresent); AddAssert("pause button is visible", () => hudOverlay.HoldToQuit.IsPresent); - AddAssert("key counter flow is hidden", () => !hudOverlay.KeyCounter.KeyFlow.IsPresent); } [Test] @@ -45,19 +45,17 @@ namespace osu.Game.Tests.Visual.Gameplay } [Test] - public void TestChangeVisibilityExternally() + public void TestHideExternally() { createNew(); AddStep("set showhud false", () => hudOverlay.ShowHud.Value = false); + AddUntilStep("hidetarget is hidden", () => !hideTarget.IsPresent); - AddAssert("key counter flow is hidden", () => !hudOverlay.KeyCounter.KeyFlow.IsPresent); AddAssert("pause button is still visible", () => hudOverlay.HoldToQuit.IsPresent); - AddStep("set showhud false", () => hudOverlay.ShowHud.Value = true); - AddUntilStep("hidetarget is visible", () => hideTarget.IsPresent); - AddAssert("key counter flow is still hidden", () => !hudOverlay.KeyCounter.KeyFlow.IsPresent); - AddAssert("pause button is still visible", () => hudOverlay.HoldToQuit.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] @@ -84,7 +82,11 @@ namespace osu.Game.Tests.Visual.Gameplay createNew(); AddStep("save keycounter visible value", () => keyCounterVisibleValue = config.Get(OsuSetting.KeyOverlay)); - AddStep("set keycounter visible false", () => config.Set(OsuSetting.KeyOverlay, false)); + AddStep("set keycounter visible false", () => + { + config.Set(OsuSetting.KeyOverlay, false); + hudOverlay.KeyCounter.Visible.Value = false; + }); AddStep("set showhud false", () => hudOverlay.ShowHud.Value = false); AddUntilStep("hidetarget is hidden", () => !hideTarget.IsPresent); diff --git a/osu.Game/Screens/Play/KeyCounterDisplay.cs b/osu.Game/Screens/Play/KeyCounterDisplay.cs index 4c4fcea879..5584bdc359 100644 --- a/osu.Game/Screens/Play/KeyCounterDisplay.cs +++ b/osu.Game/Screens/Play/KeyCounterDisplay.cs @@ -19,13 +19,8 @@ namespace osu.Game.Screens.Play private const int duration = 100; private const double key_fade_time = 80; - /// - /// Whether to always show key counter regardless of any other condition. - /// This is bound to configuration setting bindable. - /// - private readonly Bindable alwaysShow = new Bindable(); - - public readonly Bindable HasReplayLoaded = new BindableBool(); + public readonly Bindable Visible = new Bindable(true); + private readonly Bindable configVisibility = new Bindable(); protected readonly FillFlowContainer KeyFlow; @@ -56,15 +51,15 @@ namespace osu.Game.Screens.Play [BackgroundDependencyLoader] private void load(OsuConfigManager config) { - config.BindWith(OsuSetting.KeyOverlay, alwaysShow); + config.BindWith(OsuSetting.KeyOverlay, configVisibility); } protected override void LoadComplete() { base.LoadComplete(); - HasReplayLoaded.BindValueChanged(_ => updateVisibility()); - alwaysShow.BindValueChanged(_ => updateVisibility(), true); + Visible.BindValueChanged(_ => updateVisibility()); + configVisibility.BindValueChanged(_ => updateVisibility(), true); } private bool isCounting = true; @@ -116,7 +111,7 @@ namespace osu.Game.Screens.Play private void updateVisibility() => // Isolate changing visibility of the key counters from fading this component. - KeyFlow.FadeTo(HasReplayLoaded.Value || alwaysShow.Value ? 1 : 0, duration); + KeyFlow.FadeTo(AlwaysVisible.Value || configVisibility.Value ? 1 : 0, duration); public override bool HandleNonPositionalInput => receptor == null; public override bool HandlePositionalInput => receptor == null; diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 02fc5f81d5..7228e22382 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -219,7 +219,7 @@ namespace osu.Game.Screens.Play IsPaused = { BindTarget = GameplayClockContainer.IsPaused } }, PlayerSettingsOverlay = { PlaybackSettings = { UserPlaybackRate = { BindTarget = GameplayClockContainer.UserPlaybackRate } } }, - KeyCounter = { HasReplayLoaded = { BindTarget = DrawableRuleset.HasReplayLoaded } }, + KeyCounter = { Visible = { BindTarget = DrawableRuleset.HasReplayLoaded } }, RequestSeek = GameplayClockContainer.Seek, Anchor = Anchor.Centre, Origin = Anchor.Centre