1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-21 03:02:54 +08:00

Add blur to background in Player

This commit is contained in:
ColdVolcano 2017-12-25 19:11:49 -06:00
parent 367090155c
commit 044e4d0acd
3 changed files with 21 additions and 7 deletions

View File

@ -65,6 +65,7 @@ namespace osu.Game.Configuration
// Gameplay // Gameplay
Set(OsuSetting.DimLevel, 0.3, 0, 1, 0.01); Set(OsuSetting.DimLevel, 0.3, 0, 1, 0.01);
Set(OsuSetting.BlurLevel, 0, 0, 1, 0.01);
Set(OsuSetting.ShowInterface, true); Set(OsuSetting.ShowInterface, true);
Set(OsuSetting.KeyOverlay, false); Set(OsuSetting.KeyOverlay, false);
@ -90,6 +91,7 @@ namespace osu.Game.Configuration
GameplayCursorSize, GameplayCursorSize,
AutoCursorSize, AutoCursorSize,
DimLevel, DimLevel,
BlurLevel,
ShowStoryboard, ShowStoryboard,
KeyOverlay, KeyOverlay,
FloatingComments, FloatingComments,

View File

@ -22,6 +22,12 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
Bindable = config.GetBindable<double>(OsuSetting.DimLevel), Bindable = config.GetBindable<double>(OsuSetting.DimLevel),
KeyboardStep = 0.1f KeyboardStep = 0.1f
}, },
new SettingsSlider<double>
{
LabelText = "Background blur",
Bindable = config.GetBindable<double>(OsuSetting.BlurLevel),
KeyboardStep = 0.1f
},
new SettingsCheckbox new SettingsCheckbox
{ {
LabelText = "Show score overlay", LabelText = "Show score overlay",

View File

@ -65,6 +65,7 @@ namespace osu.Game.Screens.Play
#region User Settings #region User Settings
private Bindable<double> dimLevel; private Bindable<double> dimLevel;
private Bindable<double> blurLevel;
private Bindable<bool> showStoryboard; private Bindable<bool> showStoryboard;
private Bindable<bool> mouseWheelDisabled; private Bindable<bool> mouseWheelDisabled;
private Bindable<double> userAudioOffset; private Bindable<double> userAudioOffset;
@ -74,7 +75,7 @@ namespace osu.Game.Screens.Play
#endregion #endregion
private BreakOverlay breakOverlay; private BreakOverlay breakOverlay;
private Container storyboardContainer; private BufferedContainer storyboardContainer;
private DrawableStoryboard storyboard; private DrawableStoryboard storyboard;
private HUDOverlay hudOverlay; private HUDOverlay hudOverlay;
@ -88,6 +89,7 @@ namespace osu.Game.Screens.Play
this.api = api; this.api = api;
dimLevel = config.GetBindable<double>(OsuSetting.DimLevel); dimLevel = config.GetBindable<double>(OsuSetting.DimLevel);
blurLevel = config.GetBindable<double>(OsuSetting.BlurLevel);
showStoryboard = config.GetBindable<bool>(OsuSetting.ShowStoryboard); showStoryboard = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
mouseWheelDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableWheel); mouseWheelDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableWheel);
@ -147,7 +149,7 @@ namespace osu.Game.Screens.Play
Children = new Drawable[] Children = new Drawable[]
{ {
storyboardContainer = new Container storyboardContainer = new BufferedContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Clock = offsetClock, Clock = offsetClock,
@ -309,9 +311,9 @@ namespace osu.Game.Screens.Play
if (!loadedSuccessfully) if (!loadedSuccessfully)
return; return;
(Background as BackgroundScreenBeatmap)?.BlurTo(Vector2.Zero, 1000, Easing.OutQuint); dimLevel.ValueChanged += backgroundLevel_ValueChanged;
blurLevel.ValueChanged += backgroundLevel_ValueChanged;
dimLevel.ValueChanged += dimLevel_ValueChanged;
showStoryboard.ValueChanged += showStoryboard_ValueChanged; showStoryboard.ValueChanged += showStoryboard_ValueChanged;
updateBackgroundElements(); updateBackgroundElements();
@ -368,7 +370,7 @@ namespace osu.Game.Screens.Play
return true; return true;
} }
private void dimLevel_ValueChanged(double newValue) private void backgroundLevel_ValueChanged(double newValue)
=> updateBackgroundElements(); => updateBackgroundElements();
private void showStoryboard_ValueChanged(bool newValue) private void showStoryboard_ValueChanged(bool newValue)
@ -377,6 +379,7 @@ namespace osu.Game.Screens.Play
private void updateBackgroundElements() private void updateBackgroundElements()
{ {
var opacity = 1 - (float)dimLevel; var opacity = 1 - (float)dimLevel;
var blur = new Vector2((float)blurLevel.Value * 25);
if (showStoryboard && storyboard == null) if (showStoryboard && storyboard == null)
initializeStoryboard(true); initializeStoryboard(true);
@ -385,14 +388,17 @@ namespace osu.Game.Screens.Play
var storyboardVisible = showStoryboard && beatmap.Storyboard.HasDrawable; var storyboardVisible = showStoryboard && beatmap.Storyboard.HasDrawable;
storyboardContainer.FadeColour(new Color4(opacity, opacity, opacity, 1), 800); storyboardContainer.FadeColour(new Color4(opacity, opacity, opacity, 1), 800);
storyboardContainer.FadeTo(storyboardVisible && opacity > 0 ? 1 : 0); storyboardContainer.FadeTo(storyboardVisible && opacity > 0 ? 1 : 0, 800, Easing.OutQuint);
storyboardContainer.BlurTo(blur, 800, Easing.OutQuint);
Background?.FadeTo(!storyboardVisible || beatmap.Background == null ? opacity : 0, 800, Easing.OutQuint); Background?.FadeTo(!storyboardVisible || beatmap.Background == null ? opacity : 0, 800, Easing.OutQuint);
(Background as BackgroundScreenBeatmap)?.BlurTo(blur, 800, Easing.OutQuint);
} }
private void fadeOut() private void fadeOut()
{ {
dimLevel.ValueChanged -= dimLevel_ValueChanged; dimLevel.ValueChanged -= backgroundLevel_ValueChanged;
blurLevel.ValueChanged -= backgroundLevel_ValueChanged;
showStoryboard.ValueChanged -= showStoryboard_ValueChanged; showStoryboard.ValueChanged -= showStoryboard_ValueChanged;
const float fade_out_duration = 250; const float fade_out_duration = 250;