mirror of
https://github.com/ppy/osu.git
synced 2025-03-15 15:27:20 +08:00
Move all storyboard show logic into UserDimContainer
This commit is contained in:
parent
ad5e81f0cd
commit
0677194f46
@ -13,20 +13,42 @@ namespace osu.Game.Graphics.Containers
|
||||
public class UserDimContainer : Container
|
||||
{
|
||||
protected Bindable<double> DimLevel;
|
||||
|
||||
protected Bindable<bool> ShowStoryboard;
|
||||
public Bindable<bool> EnableUserDim = new Bindable<bool>();
|
||||
public Bindable<bool> StoryboardReplacesBackground = new Bindable<bool>();
|
||||
|
||||
private readonly bool isStoryboard;
|
||||
|
||||
private const float BACKGROUND_FADE_DURATION = 800;
|
||||
|
||||
public UserDimContainer(bool isStoryboard = false)
|
||||
{
|
||||
this.isStoryboard = isStoryboard;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
DimLevel = config.GetBindable<double>(OsuSetting.DimLevel);
|
||||
ShowStoryboard = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
|
||||
EnableUserDim.ValueChanged += _ => updateBackgroundDim();
|
||||
DimLevel.ValueChanged += _ => updateBackgroundDim();
|
||||
ShowStoryboard.ValueChanged += _ => updateBackgroundDim();
|
||||
}
|
||||
|
||||
private void updateBackgroundDim()
|
||||
{
|
||||
this.FadeColour(EnableUserDim ? OsuColour.Gray(1 - (float)DimLevel) : Color4.White, 800, Easing.OutQuint);
|
||||
if (isStoryboard)
|
||||
{
|
||||
this.FadeTo(!ShowStoryboard || DimLevel == 1 ? 0 : 1, BACKGROUND_FADE_DURATION, Easing.OutQuint);
|
||||
}
|
||||
else
|
||||
{
|
||||
// The background needs to be hidden in the case of it being replaced
|
||||
this.FadeTo(ShowStoryboard && StoryboardReplacesBackground ? 0 : 1, BACKGROUND_FADE_DURATION, Easing.OutQuint);
|
||||
}
|
||||
|
||||
this.FadeColour(EnableUserDim ? OsuColour.Gray(1 - (float)DimLevel) : Color4.White, BACKGROUND_FADE_DURATION, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,8 +16,8 @@ namespace osu.Game.Screens.Backgrounds
|
||||
{
|
||||
private WorkingBeatmap beatmap;
|
||||
protected Bindable<double> DimLevel;
|
||||
protected Bindable<double> BlurLevel;
|
||||
public Bindable<bool> EnableUserDim;
|
||||
public Bindable<bool> StoryboardReplacesBackground = new Bindable<bool>();
|
||||
|
||||
protected UserDimContainer FadeContainer;
|
||||
|
||||
@ -56,6 +56,7 @@ namespace osu.Game.Screens.Backgrounds
|
||||
b.Depth = newDepth;
|
||||
FadeContainer.Child = Background = b;
|
||||
Background.BlurSigma = BlurTarget;
|
||||
FadeContainer.StoryboardReplacesBackground.BindTo(StoryboardReplacesBackground);
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ namespace osu.Game.Screens.Play
|
||||
CheckCanPause = () => AllowPause && ValidForResume && !HasFailed && !RulesetContainer.HasReplayLoaded,
|
||||
Children = new Container[]
|
||||
{
|
||||
storyboardContainer = new UserDimContainer
|
||||
storyboardContainer = new UserDimContainer(true)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0,
|
||||
@ -351,6 +351,8 @@ namespace osu.Game.Screens.Play
|
||||
DimLevel.ValueChanged += _ => UpdateBackgroundElements();
|
||||
ShowStoryboard.ValueChanged += _ => UpdateBackgroundElements();
|
||||
Background.EnableUserDim.Value = true;
|
||||
storyboardContainer.StoryboardReplacesBackground.Value = Beatmap.Value.Storyboard.ReplacesBackground && Beatmap.Value.Storyboard.HasDrawable;
|
||||
storyboardContainer.StoryboardReplacesBackground.BindTo(Background?.StoryboardReplacesBackground);
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
@ -412,6 +414,7 @@ namespace osu.Game.Screens.Play
|
||||
float fadeOutDuration = instant ? 0 : 250;
|
||||
this.FadeOut(fadeOutDuration);
|
||||
Background.EnableUserDim.Value = false;
|
||||
storyboardContainer.StoryboardReplacesBackground.Value = false;
|
||||
}
|
||||
|
||||
protected override bool OnScroll(ScrollEvent e) => mouseWheelDisabled.Value && !pauseContainer.IsPaused;
|
||||
@ -440,14 +443,6 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
if (ShowStoryboard && storyboard == null)
|
||||
initializeStoryboard(true);
|
||||
|
||||
var beatmap = Beatmap.Value;
|
||||
var storyboardVisible = ShowStoryboard && beatmap.Storyboard.HasDrawable;
|
||||
|
||||
storyboardContainer?.FadeTo(storyboardVisible && 1 - (float)DimLevel > 0 ? 1 : 0, BACKGROUND_FADE_DURATION, Easing.OutQuint);
|
||||
|
||||
if (storyboardVisible && beatmap.Storyboard.ReplacesBackground)
|
||||
Background?.FadeColour(Color4.Black, BACKGROUND_FADE_DURATION, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected virtual Results CreateResults(ScoreInfo score) => new SoloResults(score);
|
||||
|
Loading…
x
Reference in New Issue
Block a user