1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 03:02:53 +08:00

Merge pull request #1754 from ColdVolcano/background-blur

Add setting to adjust background blur level during gameplay
This commit is contained in:
Dean Herbert 2018-01-10 13:50:08 +09:00 committed by GitHub
commit fe7ce26b84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 26 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

@ -4,6 +4,7 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Framework.Graphics.Transforms;
using OpenTK; using OpenTK;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Backgrounds;
@ -19,10 +20,7 @@ namespace osu.Game.Screens.Backgrounds
public WorkingBeatmap Beatmap public WorkingBeatmap Beatmap
{ {
get get { return beatmap; }
{
return beatmap;
}
set set
{ {
if (beatmap == value && beatmap != null) if (beatmap == value && beatmap != null)
@ -56,11 +54,8 @@ namespace osu.Game.Screens.Backgrounds
Beatmap = beatmap; Beatmap = beatmap;
} }
public void BlurTo(Vector2 sigma, double duration, Easing easing = Easing.None) public TransformSequence<Background> BlurTo(Vector2 sigma, double duration, Easing easing = Easing.None)
{ => background?.BlurTo(blurTarget = sigma, duration, easing);
background?.BlurTo(sigma, duration, easing);
blurTarget = sigma;
}
public override bool Equals(BackgroundScreen other) public override bool Equals(BackgroundScreen other)
{ {

View File

@ -24,10 +24,10 @@ using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Ranking; using osu.Game.Screens.Ranking;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Screens.Play.BreaksOverlay; using osu.Game.Screens.Play.BreaksOverlay;
using osu.Game.Storyboards.Drawables; using osu.Game.Storyboards.Drawables;
using OpenTK.Graphics;
namespace osu.Game.Screens.Play namespace osu.Game.Screens.Play
{ {
@ -67,6 +67,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;
@ -90,6 +91,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);
@ -316,10 +318,9 @@ namespace osu.Game.Screens.Play
if (!loadedSuccessfully) if (!loadedSuccessfully)
return; return;
(Background as BackgroundScreenBeatmap)?.BlurTo(Vector2.Zero, 1000, Easing.OutQuint); dimLevel.ValueChanged += _ => updateBackgroundElements();
blurLevel.ValueChanged += _ => updateBackgroundElements();
dimLevel.ValueChanged += dimLevel_ValueChanged; showStoryboard.ValueChanged += _ => updateBackgroundElements();
showStoryboard.ValueChanged += showStoryboard_ValueChanged;
updateBackgroundElements(); updateBackgroundElements();
Content.Alpha = 0; Content.Alpha = 0;
@ -375,14 +376,12 @@ namespace osu.Game.Screens.Play
return true; return true;
} }
private void dimLevel_ValueChanged(double newValue)
=> updateBackgroundElements();
private void showStoryboard_ValueChanged(bool newValue)
=> updateBackgroundElements();
private void updateBackgroundElements() private void updateBackgroundElements()
{ {
if (!IsCurrentScreen) return;
const float duration = 800;
var opacity = 1 - (float)dimLevel; var opacity = 1 - (float)dimLevel;
if (showStoryboard && storyboard == null) if (showStoryboard && storyboard == null)
@ -391,17 +390,17 @@ namespace osu.Game.Screens.Play
var beatmap = Beatmap.Value; var beatmap = Beatmap.Value;
var storyboardVisible = showStoryboard && beatmap.Storyboard.HasDrawable; var storyboardVisible = showStoryboard && beatmap.Storyboard.HasDrawable;
storyboardContainer.FadeColour(new Color4(opacity, opacity, opacity, 1), 800); storyboardContainer
storyboardContainer.FadeTo(storyboardVisible && opacity > 0 ? 1 : 0); .FadeColour(OsuColour.Gray(opacity), duration, Easing.OutQuint)
.FadeTo(storyboardVisible && opacity > 0 ? 1 : 0, duration, Easing.OutQuint);
Background?.FadeTo(!storyboardVisible || beatmap.Background == null ? opacity : 0, 800, Easing.OutQuint); (Background as BackgroundScreenBeatmap)?
.BlurTo(new Vector2((float)blurLevel.Value * 25), duration, Easing.OutQuint)?
.FadeTo(!storyboardVisible || beatmap.Background == null ? opacity : 0, duration, Easing.OutQuint);
} }
private void fadeOut() private void fadeOut()
{ {
dimLevel.ValueChanged -= dimLevel_ValueChanged;
showStoryboard.ValueChanged -= showStoryboard_ValueChanged;
const float fade_out_duration = 250; const float fade_out_duration = 250;
RulesetContainer?.FadeOut(fade_out_duration); RulesetContainer?.FadeOut(fade_out_duration);