1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 16:52:55 +08:00

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] [Test]
public void TestExternalHideDoesntAffectConfig() public void TestExternalHideDoesntAffectConfig()
{ {
bool originalConfigValue = false; HUDVisibilityMode originalConfigValue = HUDVisibilityMode.HideDuringBreaks;
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,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.HitLighting, true);
Set(OsuSetting.ShowInterface, true); Set(OsuSetting.HUDVisibilityMode, HUDVisibilityMode.Always);
Set(OsuSetting.ShowProgressGraph, true); Set(OsuSetting.ShowProgressGraph, true);
Set(OsuSetting.ShowHealthDisplayWhenCantFail, true); Set(OsuSetting.ShowHealthDisplayWhenCantFail, true);
Set(OsuSetting.FadePlayfieldWhenHealthLow, true); Set(OsuSetting.FadePlayfieldWhenHealthLow, true);
@ -190,7 +190,7 @@ namespace osu.Game.Configuration
AlwaysPlayFirstComboBreak, AlwaysPlayFirstComboBreak,
ScoreMeter, ScoreMeter,
FloatingComments, FloatingComments,
ShowInterface, HUDVisibilityMode,
ShowProgressGraph, ShowProgressGraph,
ShowHealthDisplayWhenCantFail, ShowHealthDisplayWhenCantFail,
FadePlayfieldWhenHealthLow, FadePlayfieldWhenHealthLow,

View File

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

View File

@ -52,7 +52,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;
@ -65,6 +65,8 @@ namespace osu.Game.Screens.Play
private readonly FillFlowContainer bottomRightElements; private readonly FillFlowContainer bottomRightElements;
private readonly FillFlowContainer topRightElements; private readonly FillFlowContainer topRightElements;
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)
@ -167,9 +169,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;
@ -192,11 +194,8 @@ namespace osu.Game.Screens.Play
ShowHealthbar.BindValueChanged(healthBar => HealthDisplay.FadeTo(healthBar.NewValue ? 1 : 0, FADE_DURATION, FADE_EASING), true); 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))); ShowHud.BindValueChanged(visible => hideTargets.ForEach(d => d.FadeTo(visible.NewValue ? 1 : 0, FADE_DURATION, FADE_EASING)));
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);
} }
@ -213,6 +212,33 @@ namespace osu.Game.Screens.Play
bottomRightElements.Y = -Progress.Height; 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) private void replayLoadedValueChanged(ValueChangedEvent<bool> e)
{ {
PlayerSettingsOverlay.ReplayLoaded = e.NewValue; PlayerSettingsOverlay.ReplayLoaded = e.NewValue;
@ -229,6 +255,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)
@ -249,7 +277,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.HideDuringGameplay;
return true; return true;
} }
} }

View File

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