mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Move user dim logic into UserDimContainer instead
This commit is contained in:
@ -144,7 +144,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
public void UpdateBindables()
|
public void UpdateBindables()
|
||||||
{
|
{
|
||||||
DimEnabled = Background.UpdateDim;
|
DimEnabled = Background.UpdateUserDim;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AssertDimmed()
|
public bool AssertDimmed()
|
||||||
|
36
osu.Game/Graphics/Containers/UserDimContainer.cs
Normal file
36
osu.Game/Graphics/Containers/UserDimContainer.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// 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.Game.Configuration;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Graphics.Containers
|
||||||
|
{
|
||||||
|
public class UserDimContainer : Container
|
||||||
|
{
|
||||||
|
#region User Settings
|
||||||
|
|
||||||
|
protected Bindable<double> DimLevel;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public Bindable<bool> EnableUserDim = new Bindable<bool>();
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuConfigManager config)
|
||||||
|
{
|
||||||
|
DimLevel = config.GetBindable<double>(OsuSetting.DimLevel);
|
||||||
|
EnableUserDim.ValueChanged += _ => updateBackgroundDim();
|
||||||
|
DimLevel.ValueChanged += _ => updateBackgroundDim();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateBackgroundDim()
|
||||||
|
{
|
||||||
|
this.FadeColour(EnableUserDim ? OsuColour.Gray(1 - (float)DimLevel) : Color4.White, 800, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -11,6 +11,9 @@ using osu.Game.Beatmaps;
|
|||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Backgrounds;
|
using osu.Game.Graphics.Backgrounds;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Users;
|
||||||
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Backgrounds
|
namespace osu.Game.Screens.Backgrounds
|
||||||
@ -19,9 +22,10 @@ namespace osu.Game.Screens.Backgrounds
|
|||||||
{
|
{
|
||||||
private WorkingBeatmap beatmap;
|
private WorkingBeatmap beatmap;
|
||||||
protected Bindable<double> DimLevel;
|
protected Bindable<double> DimLevel;
|
||||||
public Bindable<bool> UpdateDim;
|
protected Bindable<double> BlurLevel;
|
||||||
|
public Bindable<bool> EnableUserDim;
|
||||||
|
|
||||||
protected Container FadeContainer;
|
protected UserDimContainer FadeContainer;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuConfigManager config)
|
private void load(OsuConfigManager config)
|
||||||
@ -41,7 +45,7 @@ namespace osu.Game.Screens.Backgrounds
|
|||||||
|
|
||||||
Schedule(() =>
|
Schedule(() =>
|
||||||
{
|
{
|
||||||
FadeContainer = new Container { RelativeSizeAxes = Axes.Both };
|
FadeContainer = new UserDimContainer { RelativeSizeAxes = Axes.Both };
|
||||||
LoadComponentAsync(new BeatmapBackground(beatmap), b => Schedule(() =>
|
LoadComponentAsync(new BeatmapBackground(beatmap), b => Schedule(() =>
|
||||||
{
|
{
|
||||||
float newDepth = 0;
|
float newDepth = 0;
|
||||||
@ -57,38 +61,14 @@ namespace osu.Game.Screens.Backgrounds
|
|||||||
Background.BlurSigma = BlurTarget;
|
Background.BlurSigma = BlurTarget;
|
||||||
}));
|
}));
|
||||||
InternalChild = FadeContainer;
|
InternalChild = FadeContainer;
|
||||||
updateBackgroundDim();
|
EnableUserDim = FadeContainer.EnableUserDim;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnEntering(IScreen last)
|
|
||||||
{
|
|
||||||
base.OnEntering(last);
|
|
||||||
DimLevel.ValueChanged += _ => updateBackgroundDim();
|
|
||||||
UpdateDim.ValueChanged += _ => updateBackgroundDim();
|
|
||||||
updateBackgroundDim();
|
|
||||||
}
|
|
||||||
public override void OnResuming(IScreen last)
|
|
||||||
{
|
|
||||||
base.OnResuming(last);
|
|
||||||
updateBackgroundDim();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool OnExiting(IScreen last)
|
|
||||||
{
|
|
||||||
return base.OnExiting(last);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateBackgroundDim()
|
|
||||||
{
|
|
||||||
FadeContainer?.FadeColour(UpdateDim ? OsuColour.Gray(1 - (float)DimLevel) : Color4.White, 800, Easing.OutQuint);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BackgroundScreenBeatmap(WorkingBeatmap beatmap = null)
|
public BackgroundScreenBeatmap(WorkingBeatmap beatmap = null)
|
||||||
{
|
{
|
||||||
Beatmap = beatmap;
|
Beatmap = beatmap;
|
||||||
UpdateDim = new Bindable<bool>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(BackgroundScreen other)
|
public override bool Equals(BackgroundScreen other)
|
||||||
|
@ -19,7 +19,6 @@ using osu.Framework.Threading;
|
|||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Graphics;
|
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Cursor;
|
using osu.Game.Graphics.Cursor;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
@ -61,7 +60,6 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
public CursorContainer Cursor => RulesetContainer.Cursor;
|
public CursorContainer Cursor => RulesetContainer.Cursor;
|
||||||
public bool ProvidingUserCursor => RulesetContainer?.Cursor != null && !RulesetContainer.HasReplayLoaded.Value;
|
public bool ProvidingUserCursor => RulesetContainer?.Cursor != null && !RulesetContainer.HasReplayLoaded.Value;
|
||||||
protected float BackgroundOpacity => 1 - (float)DimLevel;
|
|
||||||
|
|
||||||
private IAdjustableClock sourceClock;
|
private IAdjustableClock sourceClock;
|
||||||
|
|
||||||
@ -88,7 +86,7 @@ namespace osu.Game.Screens.Play
|
|||||||
private FailOverlay failOverlay;
|
private FailOverlay failOverlay;
|
||||||
|
|
||||||
private DrawableStoryboard storyboard;
|
private DrawableStoryboard storyboard;
|
||||||
private Container storyboardContainer;
|
private UserDimContainer storyboardContainer;
|
||||||
|
|
||||||
public bool LoadedBeatmapSuccessfully => RulesetContainer?.Objects.Any() == true;
|
public bool LoadedBeatmapSuccessfully => RulesetContainer?.Objects.Any() == true;
|
||||||
|
|
||||||
@ -175,9 +173,9 @@ namespace osu.Game.Screens.Play
|
|||||||
OnRetry = Restart,
|
OnRetry = Restart,
|
||||||
OnQuit = performUserRequestedExit,
|
OnQuit = performUserRequestedExit,
|
||||||
CheckCanPause = () => AllowPause && ValidForResume && !HasFailed && !RulesetContainer.HasReplayLoaded,
|
CheckCanPause = () => AllowPause && ValidForResume && !HasFailed && !RulesetContainer.HasReplayLoaded,
|
||||||
Children = new[]
|
Children = new Container[]
|
||||||
{
|
{
|
||||||
storyboardContainer = new Container
|
storyboardContainer = new UserDimContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Alpha = 0,
|
Alpha = 0,
|
||||||
@ -242,6 +240,8 @@ namespace osu.Game.Screens.Play
|
|||||||
if (ShowStoryboard)
|
if (ShowStoryboard)
|
||||||
initializeStoryboard(false);
|
initializeStoryboard(false);
|
||||||
|
|
||||||
|
storyboardContainer.EnableUserDim.Value = true;
|
||||||
|
|
||||||
// Bind ScoreProcessor to ourselves
|
// Bind ScoreProcessor to ourselves
|
||||||
ScoreProcessor.AllJudged += onCompletion;
|
ScoreProcessor.AllJudged += onCompletion;
|
||||||
ScoreProcessor.Failed += onFail;
|
ScoreProcessor.Failed += onFail;
|
||||||
@ -346,7 +346,7 @@ namespace osu.Game.Screens.Play
|
|||||||
.Delay(250)
|
.Delay(250)
|
||||||
.FadeIn(250);
|
.FadeIn(250);
|
||||||
|
|
||||||
Background.UpdateDim.Value = true;
|
Background.EnableUserDim.Value = true;
|
||||||
|
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
@ -407,7 +407,7 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
float fadeOutDuration = instant ? 0 : 250;
|
float fadeOutDuration = instant ? 0 : 250;
|
||||||
this.FadeOut(fadeOutDuration);
|
this.FadeOut(fadeOutDuration);
|
||||||
Background.UpdateDim.Value = false;
|
Background.EnableUserDim.Value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnScroll(ScrollEvent e) => mouseWheelDisabled.Value && !pauseContainer.IsPaused;
|
protected override bool OnScroll(ScrollEvent e) => mouseWheelDisabled.Value && !pauseContainer.IsPaused;
|
||||||
@ -440,9 +440,7 @@ 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?
|
storyboardContainer?.FadeTo(storyboardVisible && 1 - (float)DimLevel > 0 ? 1 : 0, BACKGROUND_FADE_DURATION, Easing.OutQuint);
|
||||||
.FadeColour(OsuColour.Gray(BackgroundOpacity), BACKGROUND_FADE_DURATION, Easing.OutQuint)
|
|
||||||
.FadeTo(storyboardVisible && BackgroundOpacity > 0 ? 1 : 0, BACKGROUND_FADE_DURATION, Easing.OutQuint);
|
|
||||||
|
|
||||||
if (storyboardVisible && beatmap.Storyboard.ReplacesBackground)
|
if (storyboardVisible && beatmap.Storyboard.ReplacesBackground)
|
||||||
Background?.FadeColour(Color4.Black, BACKGROUND_FADE_DURATION, Easing.OutQuint);
|
Background?.FadeColour(Color4.Black, BACKGROUND_FADE_DURATION, Easing.OutQuint);
|
||||||
|
@ -243,9 +243,6 @@ namespace osu.Game.Screens.Play
|
|||||||
this.FadeOut(150);
|
this.FadeOut(150);
|
||||||
cancelLoad();
|
cancelLoad();
|
||||||
|
|
||||||
if (Background != null)
|
|
||||||
Background.UpdateDim.Value = false;
|
|
||||||
|
|
||||||
return base.OnExiting(next);
|
return base.OnExiting(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user