Hide HUD elements during break time by default

This commit is contained in:
Dean Herbert
2020-07-22 12:41:06 +09:00
parent 557daadd4a
commit fea6389f69
6 changed files with 60 additions and 18 deletions

View File

@ -65,17 +65,17 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test] [Test]
public void TestExternalHideDoesntAffectConfig() public void TestExternalHideDoesntAffectConfig()
{ {
bool originalConfigValue = false; HUDVisibilityMode originalConfigValue = HUDVisibilityMode.DuringGameplay;
createNew(); createNew();
AddStep("get original config value", () => originalConfigValue = config.Get<bool>(OsuSetting.ShowInterface)); AddStep("get original config value", () => originalConfigValue = config.Get<HUDVisibilityMode>(OsuSetting.HUDVisibilityMode));
AddStep("set showhud false", () => hudOverlay.ShowHud.Value = false); AddStep("set showhud false", () => hudOverlay.ShowHud.Value = false);
AddAssert("config unchanged", () => originalConfigValue == config.Get<bool>(OsuSetting.ShowInterface)); AddAssert("config unchanged", () => originalConfigValue == config.Get<HUDVisibilityMode>(OsuSetting.HUDVisibilityMode));
AddStep("set showhud true", () => hudOverlay.ShowHud.Value = true); AddStep("set showhud true", () => hudOverlay.ShowHud.Value = true);
AddAssert("config unchanged", () => originalConfigValue == config.Get<bool>(OsuSetting.ShowInterface)); AddAssert("config unchanged", () => originalConfigValue == config.Get<HUDVisibilityMode>(OsuSetting.HUDVisibilityMode));
} }
[Test] [Test]

View File

@ -0,0 +1,17 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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
}
}

View File

@ -85,7 +85,7 @@ namespace osu.Game.Configuration
Set(OsuSetting.HitLighting, true); Set(OsuSetting.HitLighting, true);
Set(OsuSetting.ShowInterface, true); Set(OsuSetting.HUDVisibilityMode, HUDVisibilityMode.DuringGameplay);
Set(OsuSetting.ShowProgressGraph, true); Set(OsuSetting.ShowProgressGraph, true);
Set(OsuSetting.ShowHealthDisplayWhenCantFail, true); Set(OsuSetting.ShowHealthDisplayWhenCantFail, true);
Set(OsuSetting.FadePlayfieldWhenHealthLow, true); Set(OsuSetting.FadePlayfieldWhenHealthLow, true);
@ -184,7 +184,7 @@ namespace osu.Game.Configuration
AlwaysPlayFirstComboBreak, AlwaysPlayFirstComboBreak,
ScoreMeter, ScoreMeter,
FloatingComments, FloatingComments,
ShowInterface, HUDVisibilityMode,
ShowProgressGraph, ShowProgressGraph,
ShowHealthDisplayWhenCantFail, ShowHealthDisplayWhenCantFail,
FadePlayfieldWhenHealthLow, FadePlayfieldWhenHealthLow,

View File

@ -36,10 +36,10 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
LabelText = "Lighten playfield during breaks", LabelText = "Lighten playfield during breaks",
Bindable = config.GetBindable<bool>(OsuSetting.LightenDuringBreaks) Bindable = config.GetBindable<bool>(OsuSetting.LightenDuringBreaks)
}, },
new SettingsCheckbox new SettingsEnumDropdown<HUDVisibilityMode>
{ {
LabelText = "Show score overlay", LabelText = "Score overlay (HUD) mode",
Bindable = config.GetBindable<bool>(OsuSetting.ShowInterface) Bindable = config.GetBindable<HUDVisibilityMode>(OsuSetting.HUDVisibilityMode)
}, },
new SettingsCheckbox new SettingsCheckbox
{ {

View File

@ -51,7 +51,7 @@ namespace osu.Game.Screens.Play
/// </summary> /// </summary>
public Bindable<bool> ShowHud { get; } = new BindableBool(); public Bindable<bool> ShowHud { get; } = new BindableBool();
private Bindable<bool> configShowHud; private Bindable<HUDVisibilityMode> configVisibilityMode;
private readonly Container visibilityContainer; private readonly Container visibilityContainer;
@ -63,6 +63,8 @@ namespace osu.Game.Screens.Play
private readonly Container topScoreContainer; private readonly Container topScoreContainer;
internal readonly IBindable<bool> IsBreakTime = new Bindable<bool>();
private IEnumerable<Drawable> hideTargets => new Drawable[] { visibilityContainer, KeyCounter }; private IEnumerable<Drawable> hideTargets => new Drawable[] { visibilityContainer, KeyCounter };
public HUDOverlay(ScoreProcessor scoreProcessor, HealthProcessor healthProcessor, DrawableRuleset drawableRuleset, IReadOnlyList<Mod> mods) public HUDOverlay(ScoreProcessor scoreProcessor, HealthProcessor healthProcessor, DrawableRuleset drawableRuleset, IReadOnlyList<Mod> mods)
@ -139,9 +141,9 @@ namespace osu.Game.Screens.Play
ModDisplay.Current.Value = mods; ModDisplay.Current.Value = mods;
configShowHud = config.GetBindable<bool>(OsuSetting.ShowInterface); configVisibilityMode = config.GetBindable<HUDVisibilityMode>(OsuSetting.HUDVisibilityMode);
if (!configShowHud.Value && !hasShownNotificationOnce) if (configVisibilityMode.Value == HUDVisibilityMode.Never && !hasShownNotificationOnce)
{ {
hasShownNotificationOnce = true; hasShownNotificationOnce = true;
@ -177,15 +179,33 @@ namespace osu.Game.Screens.Play
} }
}, true); }, true);
configShowHud.BindValueChanged(visible => IsBreakTime.BindValueChanged(_ => updateVisibility());
{ configVisibilityMode.BindValueChanged(_ => updateVisibility(), true);
if (!ShowHud.Disabled)
ShowHud.Value = visible.NewValue;
}, true);
replayLoaded.BindValueChanged(replayLoadedValueChanged, 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<bool> e) private void replayLoadedValueChanged(ValueChangedEvent<bool> e)
{ {
PlayerSettingsOverlay.ReplayLoaded = e.NewValue; PlayerSettingsOverlay.ReplayLoaded = e.NewValue;
@ -202,6 +222,8 @@ namespace osu.Game.Screens.Play
ModDisplay.Delay(2000).FadeOut(200); ModDisplay.Delay(2000).FadeOut(200);
KeyCounter.Margin = new MarginPadding(10); KeyCounter.Margin = new MarginPadding(10);
} }
updateVisibility();
} }
protected virtual void BindDrawableRuleset(DrawableRuleset drawableRuleset) protected virtual void BindDrawableRuleset(DrawableRuleset drawableRuleset)
@ -222,7 +244,9 @@ namespace osu.Game.Screens.Play
switch (e.Key) switch (e.Key)
{ {
case Key.Tab: case Key.Tab:
configShowHud.Value = !configShowHud.Value; configVisibilityMode.Value = configVisibilityMode.Value != HUDVisibilityMode.Never
? HUDVisibilityMode.Never
: HUDVisibilityMode.DuringGameplay;
return true; return true;
} }
} }

View File

@ -612,6 +612,7 @@ namespace osu.Game.Screens.Play
// bind component bindables. // bind component bindables.
Background.IsBreakTime.BindTo(breakTracker.IsBreakTime); Background.IsBreakTime.BindTo(breakTracker.IsBreakTime);
HUDOverlay.IsBreakTime.BindTo(breakTracker.IsBreakTime);
DimmableStoryboard.IsBreakTime.BindTo(breakTracker.IsBreakTime); DimmableStoryboard.IsBreakTime.BindTo(breakTracker.IsBreakTime);
Background.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground); Background.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground);