2018-01-10 07:24:51 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2018-01-12 05:37:28 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2018-01-10 07:24:51 +08:00
|
|
|
|
|
2018-01-12 04:39:23 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Diagnostics;
|
2018-01-10 07:24:51 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Timing;
|
|
|
|
|
using osu.Game.Configuration;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
|
2018-01-14 03:25:09 +08:00
|
|
|
|
namespace osu.Game.Screens.Play.PlayerSettings
|
2018-01-10 07:24:51 +08:00
|
|
|
|
{
|
2018-01-16 01:52:52 +08:00
|
|
|
|
public class VisualSettings : PlayerSettingsGroup
|
2018-01-10 07:24:51 +08:00
|
|
|
|
{
|
|
|
|
|
protected override string Title => "Visual settings";
|
2018-01-11 06:24:34 +08:00
|
|
|
|
|
|
|
|
|
public IAdjustableClock AudioClock { get; set; }
|
|
|
|
|
public FramedClock FramedClock { get; set; }
|
2018-01-10 07:24:51 +08:00
|
|
|
|
|
2018-01-12 04:39:23 +08:00
|
|
|
|
private bool autohide;
|
2018-01-12 05:37:28 +08:00
|
|
|
|
|
2018-01-12 04:39:23 +08:00
|
|
|
|
public bool Autohide
|
|
|
|
|
{
|
|
|
|
|
get => autohide;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
autohide = value;
|
|
|
|
|
if (autohide && hideStopWatch == null)
|
|
|
|
|
hideStopWatch = Stopwatch.StartNew();
|
|
|
|
|
else if (!autohide)
|
|
|
|
|
hideStopWatch = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-12 05:03:55 +08:00
|
|
|
|
private readonly TimeSpan hideTimeSpan = TimeSpan.FromSeconds(3);
|
2018-01-12 04:39:23 +08:00
|
|
|
|
private Stopwatch hideStopWatch;
|
|
|
|
|
|
2018-01-14 03:25:09 +08:00
|
|
|
|
private readonly PlayerSliderBar<double> dimSliderBar;
|
|
|
|
|
private readonly PlayerSliderBar<double> blurSliderBar;
|
|
|
|
|
private readonly PlayerCheckbox showStoryboardToggle;
|
|
|
|
|
private readonly PlayerCheckbox mouseWheelDisabledToggle;
|
2018-01-10 07:24:51 +08:00
|
|
|
|
|
|
|
|
|
public VisualSettings()
|
|
|
|
|
{
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2018-01-12 04:39:23 +08:00
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Text = "Background dim:"
|
|
|
|
|
},
|
2018-01-14 03:25:09 +08:00
|
|
|
|
dimSliderBar = new PlayerSliderBar<double>(),
|
2018-01-12 04:39:23 +08:00
|
|
|
|
new OsuSpriteText
|
2018-01-12 05:03:55 +08:00
|
|
|
|
{
|
|
|
|
|
Text = "Background blur:"
|
|
|
|
|
},
|
2018-01-14 03:25:09 +08:00
|
|
|
|
blurSliderBar = new PlayerSliderBar<double>(),
|
2018-01-12 05:03:55 +08:00
|
|
|
|
new OsuSpriteText
|
2018-01-12 04:39:23 +08:00
|
|
|
|
{
|
|
|
|
|
Text = "Toggles:"
|
|
|
|
|
},
|
2018-01-14 03:25:09 +08:00
|
|
|
|
showStoryboardToggle = new PlayerCheckbox { LabelText = "Storyboards" },
|
|
|
|
|
mouseWheelDisabledToggle = new PlayerCheckbox { LabelText = "Disable mouse wheel" }
|
2018-01-10 07:24:51 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuConfigManager config)
|
|
|
|
|
{
|
|
|
|
|
dimSliderBar.Bindable = config.GetBindable<double>(OsuSetting.DimLevel);
|
2018-01-12 05:03:55 +08:00
|
|
|
|
blurSliderBar.Bindable = config.GetBindable<double>(OsuSetting.BlurLevel);
|
2018-01-10 07:24:51 +08:00
|
|
|
|
showStoryboardToggle.Bindable = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
|
|
|
|
|
mouseWheelDisabledToggle.Bindable = config.GetBindable<bool>(OsuSetting.MouseDisableWheel);
|
2018-01-12 04:39:23 +08:00
|
|
|
|
|
|
|
|
|
ToggleContentVisibility();
|
2018-01-10 07:24:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void ToggleContentVisibility()
|
|
|
|
|
{
|
|
|
|
|
base.ToggleContentVisibility();
|
2018-01-12 04:39:23 +08:00
|
|
|
|
if (!Autohide)
|
|
|
|
|
return;
|
2018-01-10 07:24:51 +08:00
|
|
|
|
if (Expanded)
|
2018-01-11 06:24:34 +08:00
|
|
|
|
{
|
2018-01-12 04:39:23 +08:00
|
|
|
|
AudioClock.Stop();
|
|
|
|
|
FramedClock.ProcessSourceClockFrames = false;
|
|
|
|
|
hideStopWatch.Stop();
|
2018-01-11 06:24:34 +08:00
|
|
|
|
}
|
2018-01-10 07:24:51 +08:00
|
|
|
|
else
|
2018-01-11 06:24:34 +08:00
|
|
|
|
{
|
2018-01-12 04:39:23 +08:00
|
|
|
|
AudioClock.Start();
|
|
|
|
|
FramedClock.ProcessSourceClockFrames = true;
|
|
|
|
|
hideStopWatch.Start();
|
2018-01-11 06:24:34 +08:00
|
|
|
|
}
|
2018-01-10 07:24:51 +08:00
|
|
|
|
}
|
2018-01-12 04:39:23 +08:00
|
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
|
|
|
|
|
2018-01-12 05:03:55 +08:00
|
|
|
|
if (Autohide && IsPresent && hideStopWatch.Elapsed > hideTimeSpan) this.FadeOut(50);
|
2018-01-12 04:39:23 +08:00
|
|
|
|
}
|
2018-01-10 07:24:51 +08:00
|
|
|
|
}
|
|
|
|
|
}
|