mirror of
https://github.com/ppy/osu.git
synced 2025-02-16 18:32:56 +08:00
Implement VisualSettings autohiding
This commit is contained in:
parent
98851e4a78
commit
3ec93966a0
@ -1,6 +1,8 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// 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 @@ namespace osu.Game.Screens.Play.HUD
|
||||
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<double> dimSliderBar;
|
||||
private readonly ReplayCheckbox showStoryboardToggle;
|
||||
private readonly ReplayCheckbox mouseWheelDisabledToggle;
|
||||
@ -25,19 +44,18 @@ namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = "Background dim:"
|
||||
},
|
||||
dimSliderBar = new ReplaySliderBar<double>(),
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = "Toggles:"
|
||||
},
|
||||
showStoryboardToggle = new ReplayCheckbox {LabelText = "Storyboards" },
|
||||
mouseWheelDisabledToggle = new ReplayCheckbox { LabelText = "Disable mouse wheel" }
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = "Background dim:"
|
||||
},
|
||||
dimSliderBar = new ReplaySliderBar<double>(),
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = "Toggles:"
|
||||
},
|
||||
showStoryboardToggle = new ReplayCheckbox { LabelText = "Storyboards" },
|
||||
mouseWheelDisabledToggle = new ReplayCheckbox { LabelText = "Disable mouse wheel" }
|
||||
};
|
||||
ToggleContentVisibility();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -46,23 +64,34 @@ namespace osu.Game.Screens.Play.HUD
|
||||
dimSliderBar.Bindable = config.GetBindable<double>(OsuSetting.DimLevel);
|
||||
showStoryboardToggle.Bindable = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
|
||||
mouseWheelDisabledToggle.Bindable = config.GetBindable<bool>(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -103,8 +103,7 @@ namespace osu.Game.Screens.Play
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user