mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 08:20:00 +09:00
Move all storyboard show logic into UserDimContainer
This commit is contained in:
@ -13,20 +13,42 @@ namespace osu.Game.Graphics.Containers
|
|||||||
public class UserDimContainer : Container
|
public class UserDimContainer : Container
|
||||||
{
|
{
|
||||||
protected Bindable<double> DimLevel;
|
protected Bindable<double> DimLevel;
|
||||||
|
protected Bindable<bool> ShowStoryboard;
|
||||||
public Bindable<bool> EnableUserDim = new Bindable<bool>();
|
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]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuConfigManager config)
|
private void load(OsuConfigManager config)
|
||||||
{
|
{
|
||||||
DimLevel = config.GetBindable<double>(OsuSetting.DimLevel);
|
DimLevel = config.GetBindable<double>(OsuSetting.DimLevel);
|
||||||
|
ShowStoryboard = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
|
||||||
EnableUserDim.ValueChanged += _ => updateBackgroundDim();
|
EnableUserDim.ValueChanged += _ => updateBackgroundDim();
|
||||||
DimLevel.ValueChanged += _ => updateBackgroundDim();
|
DimLevel.ValueChanged += _ => updateBackgroundDim();
|
||||||
|
ShowStoryboard.ValueChanged += _ => updateBackgroundDim();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void 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;
|
private WorkingBeatmap beatmap;
|
||||||
protected Bindable<double> DimLevel;
|
protected Bindable<double> DimLevel;
|
||||||
protected Bindable<double> BlurLevel;
|
|
||||||
public Bindable<bool> EnableUserDim;
|
public Bindable<bool> EnableUserDim;
|
||||||
|
public Bindable<bool> StoryboardReplacesBackground = new Bindable<bool>();
|
||||||
|
|
||||||
protected UserDimContainer FadeContainer;
|
protected UserDimContainer FadeContainer;
|
||||||
|
|
||||||
@ -56,6 +56,7 @@ namespace osu.Game.Screens.Backgrounds
|
|||||||
b.Depth = newDepth;
|
b.Depth = newDepth;
|
||||||
FadeContainer.Child = Background = b;
|
FadeContainer.Child = Background = b;
|
||||||
Background.BlurSigma = BlurTarget;
|
Background.BlurSigma = BlurTarget;
|
||||||
|
FadeContainer.StoryboardReplacesBackground.BindTo(StoryboardReplacesBackground);
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ namespace osu.Game.Screens.Play
|
|||||||
CheckCanPause = () => AllowPause && ValidForResume && !HasFailed && !RulesetContainer.HasReplayLoaded,
|
CheckCanPause = () => AllowPause && ValidForResume && !HasFailed && !RulesetContainer.HasReplayLoaded,
|
||||||
Children = new Container[]
|
Children = new Container[]
|
||||||
{
|
{
|
||||||
storyboardContainer = new UserDimContainer
|
storyboardContainer = new UserDimContainer(true)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Alpha = 0,
|
Alpha = 0,
|
||||||
@ -351,6 +351,8 @@ namespace osu.Game.Screens.Play
|
|||||||
DimLevel.ValueChanged += _ => UpdateBackgroundElements();
|
DimLevel.ValueChanged += _ => UpdateBackgroundElements();
|
||||||
ShowStoryboard.ValueChanged += _ => UpdateBackgroundElements();
|
ShowStoryboard.ValueChanged += _ => UpdateBackgroundElements();
|
||||||
Background.EnableUserDim.Value = true;
|
Background.EnableUserDim.Value = true;
|
||||||
|
storyboardContainer.StoryboardReplacesBackground.Value = Beatmap.Value.Storyboard.ReplacesBackground && Beatmap.Value.Storyboard.HasDrawable;
|
||||||
|
storyboardContainer.StoryboardReplacesBackground.BindTo(Background?.StoryboardReplacesBackground);
|
||||||
|
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
@ -412,6 +414,7 @@ namespace osu.Game.Screens.Play
|
|||||||
float fadeOutDuration = instant ? 0 : 250;
|
float fadeOutDuration = instant ? 0 : 250;
|
||||||
this.FadeOut(fadeOutDuration);
|
this.FadeOut(fadeOutDuration);
|
||||||
Background.EnableUserDim.Value = false;
|
Background.EnableUserDim.Value = false;
|
||||||
|
storyboardContainer.StoryboardReplacesBackground.Value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnScroll(ScrollEvent e) => mouseWheelDisabled.Value && !pauseContainer.IsPaused;
|
protected override bool OnScroll(ScrollEvent e) => mouseWheelDisabled.Value && !pauseContainer.IsPaused;
|
||||||
@ -440,14 +443,6 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
if (ShowStoryboard && storyboard == null)
|
if (ShowStoryboard && storyboard == null)
|
||||||
initializeStoryboard(true);
|
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);
|
protected virtual Results CreateResults(ScoreInfo score) => new SoloResults(score);
|
||||||
|
Reference in New Issue
Block a user