mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 18:52:55 +08:00
Hide HUD elements during break time by default
This commit is contained in:
parent
557daadd4a
commit
fea6389f69
@ -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<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]
|
||||
|
17
osu.Game/Configuration/HUDVisibilityMode.cs
Normal file
17
osu.Game/Configuration/HUDVisibilityMode.cs
Normal 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
|
||||
}
|
||||
}
|
@ -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,
|
||||
|
@ -36,10 +36,10 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
||||
LabelText = "Lighten playfield during breaks",
|
||||
Bindable = config.GetBindable<bool>(OsuSetting.LightenDuringBreaks)
|
||||
},
|
||||
new SettingsCheckbox
|
||||
new SettingsEnumDropdown<HUDVisibilityMode>
|
||||
{
|
||||
LabelText = "Show score overlay",
|
||||
Bindable = config.GetBindable<bool>(OsuSetting.ShowInterface)
|
||||
LabelText = "Score overlay (HUD) mode",
|
||||
Bindable = config.GetBindable<HUDVisibilityMode>(OsuSetting.HUDVisibilityMode)
|
||||
},
|
||||
new SettingsCheckbox
|
||||
{
|
||||
|
@ -51,7 +51,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;
|
||||
|
||||
@ -63,6 +63,8 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
private readonly Container topScoreContainer;
|
||||
|
||||
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)
|
||||
@ -139,9 +141,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;
|
||||
|
||||
@ -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<bool> 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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user