diff --git a/.idea/.idea.osu/.idea/.name b/.idea/.idea.osu/.idea/.name new file mode 100644 index 0000000000..21cb4db60e --- /dev/null +++ b/.idea/.idea.osu/.idea/.name @@ -0,0 +1 @@ +osu \ No newline at end of file diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index 8706cc6668..4fe0f0627e 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -2,18 +2,24 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; +using osu.Framework.Configuration; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Textures; +using osu.Framework.Screens; using osu.Game.Beatmaps; +using osu.Game.Configuration; +using osu.Game.Graphics; using osu.Game.Graphics.Backgrounds; +using osuTK; namespace osu.Game.Screens.Backgrounds { public class BackgroundScreenBeatmap : BlurrableBackgroundScreen { - private WorkingBeatmap beatmap; + protected WorkingBeatmap beatmap; - public WorkingBeatmap Beatmap + public virtual WorkingBeatmap Beatmap { get { return beatmap; } set @@ -37,13 +43,18 @@ namespace osu.Game.Screens.Backgrounds } b.Depth = newDepth; - AddInternal(Background = b); + AddBackground(Background = b); Background.BlurSigma = BlurTarget; })); }); } } + protected virtual void AddBackground(Drawable d) + { + AddInternal(d); + } + public BackgroundScreenBeatmap(WorkingBeatmap beatmap = null) { Beatmap = beatmap; @@ -57,7 +68,7 @@ namespace osu.Game.Screens.Backgrounds return base.Equals(other) && beatmap == otherBeatmapBackground.Beatmap; } - private class BeatmapBackground : Background + protected class BeatmapBackground : Background { private readonly WorkingBeatmap beatmap; diff --git a/osu.Game/Screens/Backgrounds/UserDimmableBackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/UserDimmableBackgroundScreenBeatmap.cs new file mode 100644 index 0000000000..2902626702 --- /dev/null +++ b/osu.Game/Screens/Backgrounds/UserDimmableBackgroundScreenBeatmap.cs @@ -0,0 +1,57 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Allocation; +using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Screens; +using osu.Game.Beatmaps; +using osu.Game.Configuration; +using osu.Game.Graphics; +using osuTK; + +namespace osu.Game.Screens.Backgrounds +{ + public class UserDimmableBackgroundScreenBeatmap : BackgroundScreenBeatmap + { + protected Bindable DimLevel; + protected float BackgroundOpacity => 1 - (float)DimLevel; + private Container fadeContainer; + + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + DimLevel = config.GetBindable(OsuSetting.DimLevel); + fadeContainer = new Container { RelativeSizeAxes = Axes.Both}; + } + + protected override void AddBackground(Drawable d) + { + fadeContainer.Child = d; + InternalChild = fadeContainer; + } + + public override void OnEntering(IScreen last) + { + base.OnEntering(last); + DimLevel.ValueChanged += _ => updateBackgroundDim(); + updateBackgroundDim(); + } + public override void OnResuming(IScreen last) + { + base.OnResuming(last); + updateBackgroundDim(); + } + + public UserDimmableBackgroundScreenBeatmap(WorkingBeatmap beatmap = null) + :base(beatmap) + { + } + + private void updateBackgroundDim() + { + fadeContainer?.FadeColour(OsuColour.Gray(BackgroundOpacity), 800, Easing.OutQuint); + } + } +} diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 71b7b77e5d..fa9b05cd73 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -29,6 +29,7 @@ using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; using osu.Game.Scoring; +using osu.Game.Screens.Backgrounds; using osu.Game.Screens.Ranking; using osu.Game.Skinning; using osu.Game.Storyboards.Drawables; diff --git a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs index 93ec7347c8..698fd7d98b 100644 --- a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs +++ b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs @@ -14,9 +14,9 @@ namespace osu.Game.Screens.Play { public abstract class ScreenWithBeatmapBackground : OsuScreen { - protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap.Value); + protected override BackgroundScreen CreateBackground() => new UserDimmableBackgroundScreenBeatmap(Beatmap.Value); - protected new BackgroundScreenBeatmap Background => base.Background as BackgroundScreenBeatmap; + protected new UserDimmableBackgroundScreenBeatmap Background => base.Background as UserDimmableBackgroundScreenBeatmap; public override bool AllowBeatmapRulesetChange => false; @@ -43,7 +43,6 @@ namespace osu.Game.Screens.Play public override void OnEntering(IScreen last) { base.OnEntering(last); - DimLevel.ValueChanged += _ => UpdateBackgroundElements(); BlurLevel.ValueChanged += _ => UpdateBackgroundElements(); ShowStoryboard.ValueChanged += _ => UpdateBackgroundElements(); InitializeBackgroundElements(); @@ -68,7 +67,6 @@ namespace osu.Game.Screens.Play { if (!this.IsCurrentScreen()) return; - Background?.FadeColour(OsuColour.Gray(BackgroundOpacity), BACKGROUND_FADE_DURATION, Easing.OutQuint); Background?.BlurTo(new Vector2((float)BlurLevel.Value * 25), BACKGROUND_FADE_DURATION, Easing.OutQuint); } }