mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 05:52:54 +08:00
Move user dimming logic into its own container
This commit is contained in:
parent
e174fa2d3e
commit
e2a312a663
1
.idea/.idea.osu/.idea/.name
Normal file
1
.idea/.idea.osu/.idea/.name
Normal file
@ -0,0 +1 @@
|
||||
osu
|
@ -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;
|
||||
|
||||
|
@ -0,0 +1,57 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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<double> DimLevel;
|
||||
protected float BackgroundOpacity => 1 - (float)DimLevel;
|
||||
private Container fadeContainer;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
DimLevel = config.GetBindable<double>(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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user