Merge pull request #9643 from peppy/hide-hud-during-break-time

Add more display modes for HUD overlay (hide during gameplay / hide during break)
This commit is contained in:
Dan Balasescu 2020-10-20 16:11:12 +09:00 committed by GitHub
commit ca8492b3bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 69 additions and 18 deletions

View File

@ -89,17 +89,17 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test]
public void TestExternalHideDoesntAffectConfig()
{
bool originalConfigValue = false;
HUDVisibilityMode originalConfigValue = HUDVisibilityMode.HideDuringBreaks;
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);
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);
AddAssert("config unchanged", () => originalConfigValue == config.Get<bool>(OsuSetting.ShowInterface));
AddAssert("config unchanged", () => originalConfigValue == config.Get<HUDVisibilityMode>(OsuSetting.HUDVisibilityMode));
}
[Test]

View File

@ -0,0 +1,20 @@
// 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 gameplay")]
HideDuringGameplay,
[Description("Hide during breaks")]
HideDuringBreaks,
Always
}
}

View File

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

View File

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

View File

@ -52,7 +52,7 @@ namespace osu.Game.Screens.Play
/// </summary>
public Bindable<bool> ShowHud { get; } = new BindableBool();
private Bindable<bool> configShowHud;
private Bindable<HUDVisibilityMode> configVisibilityMode;
private readonly Container visibilityContainer;
@ -65,6 +65,8 @@ namespace osu.Game.Screens.Play
private readonly FillFlowContainer bottomRightElements;
private readonly FillFlowContainer topRightElements;
internal readonly IBindable<bool> IsBreakTime = new Bindable<bool>();
private IEnumerable<Drawable> hideTargets => new Drawable[] { visibilityContainer, KeyCounter };
public HUDOverlay(ScoreProcessor scoreProcessor, HealthProcessor healthProcessor, DrawableRuleset drawableRuleset, IReadOnlyList<Mod> mods)
@ -167,9 +169,9 @@ namespace osu.Game.Screens.Play
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;
@ -192,11 +194,8 @@ namespace osu.Game.Screens.Play
ShowHealthbar.BindValueChanged(healthBar => HealthDisplay.FadeTo(healthBar.NewValue ? 1 : 0, FADE_DURATION, FADE_EASING), true);
ShowHud.BindValueChanged(visible => hideTargets.ForEach(d => d.FadeTo(visible.NewValue ? 1 : 0, FADE_DURATION, FADE_EASING)));
configShowHud.BindValueChanged(visible =>
{
if (!ShowHud.Disabled)
ShowHud.Value = visible.NewValue;
}, true);
IsBreakTime.BindValueChanged(_ => updateVisibility());
configVisibilityMode.BindValueChanged(_ => updateVisibility(), true);
replayLoaded.BindValueChanged(replayLoadedValueChanged, true);
}
@ -213,6 +212,33 @@ namespace osu.Game.Screens.Play
bottomRightElements.Y = -Progress.Height;
}
private void updateVisibility()
{
if (ShowHud.Disabled)
return;
switch (configVisibilityMode.Value)
{
case HUDVisibilityMode.Never:
ShowHud.Value = false;
break;
case HUDVisibilityMode.HideDuringBreaks:
// always show during replay as we want the seek bar to be visible.
ShowHud.Value = replayLoaded.Value || !IsBreakTime.Value;
break;
case HUDVisibilityMode.HideDuringGameplay:
// always show during replay as we want the seek bar to be visible.
ShowHud.Value = replayLoaded.Value || IsBreakTime.Value;
break;
case HUDVisibilityMode.Always:
ShowHud.Value = true;
break;
}
}
private void replayLoadedValueChanged(ValueChangedEvent<bool> e)
{
PlayerSettingsOverlay.ReplayLoaded = e.NewValue;
@ -229,6 +255,8 @@ namespace osu.Game.Screens.Play
ModDisplay.Delay(2000).FadeOut(200);
KeyCounter.Margin = new MarginPadding(10);
}
updateVisibility();
}
protected virtual void BindDrawableRuleset(DrawableRuleset drawableRuleset)
@ -249,7 +277,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.HideDuringGameplay;
return true;
}
}

View File

@ -657,6 +657,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);