From fea6389f693947dd22d8f4bda9ecc30c33278cdc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 22 Jul 2020 12:41:06 +0900 Subject: [PATCH 1/3] Hide HUD elements during break time by default --- .../Visual/Gameplay/TestSceneHUDOverlay.cs | 8 ++-- osu.Game/Configuration/HUDVisibilityMode.cs | 17 ++++++++ osu.Game/Configuration/OsuConfigManager.cs | 4 +- .../Sections/Gameplay/GeneralSettings.cs | 6 +-- osu.Game/Screens/Play/HUDOverlay.cs | 42 +++++++++++++++---- osu.Game/Screens/Play/Player.cs | 1 + 6 files changed, 60 insertions(+), 18 deletions(-) create mode 100644 osu.Game/Configuration/HUDVisibilityMode.cs diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs index c192a7b0e0..e84e3cc930 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs @@ -65,17 +65,17 @@ namespace osu.Game.Tests.Visual.Gameplay [Test] public void TestExternalHideDoesntAffectConfig() { - bool originalConfigValue = false; + HUDVisibilityMode originalConfigValue = HUDVisibilityMode.DuringGameplay; createNew(); - AddStep("get original config value", () => originalConfigValue = config.Get(OsuSetting.ShowInterface)); + AddStep("get original config value", () => originalConfigValue = config.Get(OsuSetting.HUDVisibilityMode)); AddStep("set showhud false", () => hudOverlay.ShowHud.Value = false); - AddAssert("config unchanged", () => originalConfigValue == config.Get(OsuSetting.ShowInterface)); + AddAssert("config unchanged", () => originalConfigValue == config.Get(OsuSetting.HUDVisibilityMode)); AddStep("set showhud true", () => hudOverlay.ShowHud.Value = true); - AddAssert("config unchanged", () => originalConfigValue == config.Get(OsuSetting.ShowInterface)); + AddAssert("config unchanged", () => originalConfigValue == config.Get(OsuSetting.HUDVisibilityMode)); } [Test] diff --git a/osu.Game/Configuration/HUDVisibilityMode.cs b/osu.Game/Configuration/HUDVisibilityMode.cs new file mode 100644 index 0000000000..2b133b1bcf --- /dev/null +++ b/osu.Game/Configuration/HUDVisibilityMode.cs @@ -0,0 +1,17 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.ComponentModel; + +namespace osu.Game.Configuration +{ + public enum HUDVisibilityMode + { + Never, + + [Description("Hide during breaks")] + DuringGameplay, + + Always + } +} diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 268328272c..3ce71e8549 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -85,7 +85,7 @@ namespace osu.Game.Configuration Set(OsuSetting.HitLighting, true); - Set(OsuSetting.ShowInterface, true); + Set(OsuSetting.HUDVisibilityMode, HUDVisibilityMode.DuringGameplay); Set(OsuSetting.ShowProgressGraph, true); Set(OsuSetting.ShowHealthDisplayWhenCantFail, true); Set(OsuSetting.FadePlayfieldWhenHealthLow, true); @@ -184,7 +184,7 @@ namespace osu.Game.Configuration AlwaysPlayFirstComboBreak, ScoreMeter, FloatingComments, - ShowInterface, + HUDVisibilityMode, ShowProgressGraph, ShowHealthDisplayWhenCantFail, FadePlayfieldWhenHealthLow, diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs index 93a02ea0e4..af71c4f4e8 100644 --- a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs @@ -36,10 +36,10 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay LabelText = "Lighten playfield during breaks", Bindable = config.GetBindable(OsuSetting.LightenDuringBreaks) }, - new SettingsCheckbox + new SettingsEnumDropdown { - LabelText = "Show score overlay", - Bindable = config.GetBindable(OsuSetting.ShowInterface) + LabelText = "Score overlay (HUD) mode", + Bindable = config.GetBindable(OsuSetting.HUDVisibilityMode) }, new SettingsCheckbox { diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs index f09745cf71..ef1f80e0d5 100644 --- a/osu.Game/Screens/Play/HUDOverlay.cs +++ b/osu.Game/Screens/Play/HUDOverlay.cs @@ -51,7 +51,7 @@ namespace osu.Game.Screens.Play /// public Bindable ShowHud { get; } = new BindableBool(); - private Bindable configShowHud; + private Bindable configVisibilityMode; private readonly Container visibilityContainer; @@ -63,6 +63,8 @@ namespace osu.Game.Screens.Play private readonly Container topScoreContainer; + internal readonly IBindable IsBreakTime = new Bindable(); + private IEnumerable hideTargets => new Drawable[] { visibilityContainer, KeyCounter }; public HUDOverlay(ScoreProcessor scoreProcessor, HealthProcessor healthProcessor, DrawableRuleset drawableRuleset, IReadOnlyList mods) @@ -139,9 +141,9 @@ namespace osu.Game.Screens.Play ModDisplay.Current.Value = mods; - configShowHud = config.GetBindable(OsuSetting.ShowInterface); + configVisibilityMode = config.GetBindable(OsuSetting.HUDVisibilityMode); - if (!configShowHud.Value && !hasShownNotificationOnce) + if (configVisibilityMode.Value == HUDVisibilityMode.Never && !hasShownNotificationOnce) { hasShownNotificationOnce = true; @@ -177,15 +179,33 @@ namespace osu.Game.Screens.Play } }, true); - configShowHud.BindValueChanged(visible => - { - if (!ShowHud.Disabled) - ShowHud.Value = visible.NewValue; - }, true); + IsBreakTime.BindValueChanged(_ => updateVisibility()); + configVisibilityMode.BindValueChanged(_ => updateVisibility(), true); replayLoaded.BindValueChanged(replayLoadedValueChanged, true); } + private void updateVisibility() + { + if (ShowHud.Disabled) + return; + + switch (configVisibilityMode.Value) + { + case HUDVisibilityMode.Never: + ShowHud.Value = false; + break; + + case HUDVisibilityMode.DuringGameplay: + ShowHud.Value = replayLoaded.Value || !IsBreakTime.Value; + break; + + case HUDVisibilityMode.Always: + ShowHud.Value = true; + break; + } + } + private void replayLoadedValueChanged(ValueChangedEvent e) { PlayerSettingsOverlay.ReplayLoaded = e.NewValue; @@ -202,6 +222,8 @@ namespace osu.Game.Screens.Play ModDisplay.Delay(2000).FadeOut(200); KeyCounter.Margin = new MarginPadding(10); } + + updateVisibility(); } protected virtual void BindDrawableRuleset(DrawableRuleset drawableRuleset) @@ -222,7 +244,9 @@ namespace osu.Game.Screens.Play switch (e.Key) { case Key.Tab: - configShowHud.Value = !configShowHud.Value; + configVisibilityMode.Value = configVisibilityMode.Value != HUDVisibilityMode.Never + ? HUDVisibilityMode.Never + : HUDVisibilityMode.DuringGameplay; return true; } } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 541275cf55..50b2d5a021 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -612,6 +612,7 @@ namespace osu.Game.Screens.Play // bind component bindables. Background.IsBreakTime.BindTo(breakTracker.IsBreakTime); + HUDOverlay.IsBreakTime.BindTo(breakTracker.IsBreakTime); DimmableStoryboard.IsBreakTime.BindTo(breakTracker.IsBreakTime); Background.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground); From 024009e1749aee8c7a147c1ac2645080b88b25f1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 20 Oct 2020 14:19:15 +0900 Subject: [PATCH 2/3] Change default to "always visible" --- osu.Game/Configuration/OsuConfigManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index e95f8b571a..7d601c0cb9 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -90,7 +90,7 @@ namespace osu.Game.Configuration Set(OsuSetting.HitLighting, true); - Set(OsuSetting.HUDVisibilityMode, HUDVisibilityMode.DuringGameplay); + Set(OsuSetting.HUDVisibilityMode, HUDVisibilityMode.Always); Set(OsuSetting.ShowProgressGraph, true); Set(OsuSetting.ShowHealthDisplayWhenCantFail, true); Set(OsuSetting.FadePlayfieldWhenHealthLow, true); From 4f8a755518d45ba9d4c40b717e0729cb8ebbac82 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 20 Oct 2020 14:20:44 +0900 Subject: [PATCH 3/3] Add "hide during gameplay" mode --- osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs | 2 +- osu.Game/Configuration/HUDVisibilityMode.cs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs index 55d6b38b66..6ec673704c 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs @@ -89,7 +89,7 @@ namespace osu.Game.Tests.Visual.Gameplay [Test] public void TestExternalHideDoesntAffectConfig() { - HUDVisibilityMode originalConfigValue = HUDVisibilityMode.DuringGameplay; + HUDVisibilityMode originalConfigValue = HUDVisibilityMode.HideDuringBreaks; createNew(); diff --git a/osu.Game/Configuration/HUDVisibilityMode.cs b/osu.Game/Configuration/HUDVisibilityMode.cs index 2b133b1bcf..b0b55dd811 100644 --- a/osu.Game/Configuration/HUDVisibilityMode.cs +++ b/osu.Game/Configuration/HUDVisibilityMode.cs @@ -9,8 +9,11 @@ namespace osu.Game.Configuration { Never, + [Description("Hide during gameplay")] + HideDuringGameplay, + [Description("Hide during breaks")] - DuringGameplay, + HideDuringBreaks, Always }