diff --git a/osu.Game/Screens/Play/HUD/VisualSettings.cs b/osu.Game/Screens/Play/HUD/VisualSettings.cs index 068783df34..778978d26e 100644 --- a/osu.Game/Screens/Play/HUD/VisualSettings.cs +++ b/osu.Game/Screens/Play/HUD/VisualSettings.cs @@ -1,6 +1,8 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE +using System; +using System.Diagnostics; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Timing; @@ -17,6 +19,23 @@ public class VisualSettings : ReplayGroup public IAdjustableClock AudioClock { get; set; } public FramedClock FramedClock { get; set; } + private bool autohide; + public bool Autohide + { + get => autohide; + set + { + autohide = value; + if (autohide && hideStopWatch == null) + hideStopWatch = Stopwatch.StartNew(); + else if (!autohide) + hideStopWatch = null; + } + } + + private readonly TimeSpan hideTimeSpan = TimeSpan.FromSeconds(5); + private Stopwatch hideStopWatch; + private readonly ReplaySliderBar dimSliderBar; private readonly ReplayCheckbox showStoryboardToggle; private readonly ReplayCheckbox mouseWheelDisabledToggle; @@ -25,19 +44,18 @@ public VisualSettings() { Children = new Drawable[] { - new OsuSpriteText - { - Text = "Background dim:" - }, - dimSliderBar = new ReplaySliderBar(), - new OsuSpriteText - { - Text = "Toggles:" - }, - showStoryboardToggle = new ReplayCheckbox {LabelText = "Storyboards" }, - mouseWheelDisabledToggle = new ReplayCheckbox { LabelText = "Disable mouse wheel" } + new OsuSpriteText + { + Text = "Background dim:" + }, + dimSliderBar = new ReplaySliderBar(), + new OsuSpriteText + { + Text = "Toggles:" + }, + showStoryboardToggle = new ReplayCheckbox { LabelText = "Storyboards" }, + mouseWheelDisabledToggle = new ReplayCheckbox { LabelText = "Disable mouse wheel" } }; - ToggleContentVisibility(); } [BackgroundDependencyLoader] @@ -46,23 +64,34 @@ private void load(OsuConfigManager config) dimSliderBar.Bindable = config.GetBindable(OsuSetting.DimLevel); showStoryboardToggle.Bindable = config.GetBindable(OsuSetting.ShowStoryboard); mouseWheelDisabledToggle.Bindable = config.GetBindable(OsuSetting.MouseDisableWheel); + + ToggleContentVisibility(); } protected override void ToggleContentVisibility() { base.ToggleContentVisibility(); + if (!Autohide) + return; if (Expanded) { - AudioClock?.Stop(); - if (FramedClock != null) - FramedClock.ProcessSourceClockFrames = false; + AudioClock.Stop(); + FramedClock.ProcessSourceClockFrames = false; + hideStopWatch.Stop(); } else { - AudioClock?.Start(); - if (FramedClock != null) - FramedClock.ProcessSourceClockFrames = true; + AudioClock.Start(); + FramedClock.ProcessSourceClockFrames = true; + hideStopWatch.Start(); } } + + protected override void Update() + { + base.Update(); + + if (Autohide && IsPresent && hideStopWatch.Elapsed > hideTimeSpan) this.FadeOut(100); + } } } diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs index be37da04cd..f677734d04 100644 --- a/osu.Game/Screens/Play/HUDOverlay.cs +++ b/osu.Game/Screens/Play/HUDOverlay.cs @@ -103,8 +103,7 @@ public virtual void BindRulesetContainer(RulesetContainer rulesetContainer) if (!replayLoaded) { ReplaySettingsOverlay.PlaybackSettings.Hide(); - // TODO Hide VisualSettings correctly. At least, It shouldn't dissapear in expanded state. - //ReplaySettingsOverlay.VisualSettings.Delay(10000).FadeOut(200); + ReplaySettingsOverlay.VisualSettings.Autohide = true; ModDisplay.Delay(2000).FadeOut(200); } }