From de6d8fc6378b77b27c2c99702bfd88fd639e0788 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Wed, 13 Mar 2019 16:47:03 +0900 Subject: [PATCH 01/34] Move user blurring into VIsualSettingsContainer --- .../Visual/TestCaseBackgroundScreenBeatmap.cs | 90 ++++++++++--------- ...ontainer.cs => VisualSettingsContainer.cs} | 48 ++++++---- .../Backgrounds/BackgroundScreenBeatmap.cs | 9 +- osu.Game/Screens/Play/Player.cs | 10 +-- osu.Game/Screens/Play/PlayerLoader.cs | 31 ++++--- .../Play/ScreenWithBeatmapBackground.cs | 37 -------- osu.Game/Screens/Ranking/Results.cs | 6 +- osu.Game/Screens/Select/SongSelect.cs | 4 +- 8 files changed, 107 insertions(+), 128 deletions(-) rename osu.Game/Graphics/Containers/{UserDimContainer.cs => VisualSettingsContainer.cs} (53%) diff --git a/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs index 5484824c5b..03078abd3a 100644 --- a/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs +++ b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs @@ -43,13 +43,13 @@ namespace osu.Game.Tests.Visual typeof(ScreenWithBeatmapBackground), typeof(PlayerLoader), typeof(Player), - typeof(UserDimContainer), + typeof(VisualSettingsContainer), typeof(OsuScreen) }; private DummySongSelect songSelect; - private DimAccessiblePlayerLoader playerLoader; - private DimAccessiblePlayer player; + private TestPlayerLoader playerLoader; + private TestPlayer player; private DatabaseContextFactory factory; private BeatmapManager manager; private RulesetStore rulesets; @@ -91,13 +91,13 @@ namespace osu.Game.Tests.Visual } /// - /// Check if properly triggers background dim previews when a user hovers over the visual settings panel. + /// Check if properly triggers the visual settings preview when a user hovers over the visual settings panel. /// [Test] public void PlayerLoaderSettingsHoverTest() { setupUserSettings(); - AddStep("Start player loader", () => songSelect.Push(playerLoader = new DimAccessiblePlayerLoader(player = new DimAccessiblePlayer()))); + AddStep("Start player loader", () => songSelect.Push(playerLoader = new TestPlayerLoader(player = new TestPlayer()))); AddUntilStep(() => playerLoader?.IsLoaded ?? false, "Wait for Player Loader to load"); AddAssert("Background retained from song select", () => songSelect.IsBackgroundCurrent()); AddStep("Trigger background preview", () => @@ -106,16 +106,16 @@ namespace osu.Game.Tests.Visual InputManager.MoveMouseTo(playerLoader.VisualSettingsPos); }); waitForDim(); - AddAssert("Screen is dimmed", () => songSelect.IsBackgroundDimmed()); + AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied()); AddStep("Stop background preview", () => InputManager.MoveMouseTo(playerLoader.ScreenPos)); waitForDim(); - AddAssert("Screen is undimmed", () => songSelect.IsBackgroundUndimmed()); + AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && songSelect.IsUserBlurDisabled()); } /// /// In the case of a user triggering the dim preview the instant player gets loaded, then moving the cursor off of the visual settings: - /// The OnHover of PlayerLoader will trigger, which could potentially trigger an undim unless checked for in PlayerLoader. - /// We need to check that in this scenario, the dim is still properly applied after entering player. + /// The OnHover of PlayerLoader will trigger, which could potentially cause visual settings to be unapplied unless checked for in PlayerLoader. + /// We need to check that in this scenario, the dim and blur is still properly applied after entering player. /// [Test] public void PlayerLoaderTransitionTest() @@ -124,7 +124,7 @@ namespace osu.Game.Tests.Visual AddStep("Trigger hover event", () => playerLoader.TriggerOnHover()); AddAssert("Background retained from song select", () => songSelect.IsBackgroundCurrent()); waitForDim(); - AddAssert("Screen is dimmed and unblurred", () => songSelect.IsBackgroundDimmed() && songSelect.IsBackgroundUnblurred()); + AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied()); } /// @@ -165,24 +165,24 @@ namespace osu.Game.Tests.Visual } /// - /// Check if the is properly accepting user dim changes at all. + /// Check if the is properly accepting user-defined visual changes at all. /// [Test] public void DisableUserDimTest() { performFullSetup(); waitForDim(); - AddAssert("Screen is dimmed", () => songSelect.IsBackgroundDimmed()); + AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied()); AddStep("EnableUserDim disabled", () => songSelect.DimEnabled.Value = false); waitForDim(); - AddAssert("Screen is undimmed", () => songSelect.IsBackgroundUndimmed()); + AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && songSelect.IsUserBlurDisabled()); AddStep("EnableUserDim enabled", () => songSelect.DimEnabled.Value = true); waitForDim(); - AddAssert("Screen is dimmed", () => songSelect.IsBackgroundDimmed()); + AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied()); } /// - /// Check if the fade container retains dim when pausing + /// Check if the visual settings container retains dim and blur when pausing /// [Test] public void PauseTest() @@ -190,14 +190,14 @@ namespace osu.Game.Tests.Visual performFullSetup(true); AddStep("Pause", () => player.CurrentPausableGameplayContainer.Pause()); waitForDim(); - AddAssert("Screen is dimmed", () => songSelect.IsBackgroundDimmed()); + AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied()); AddStep("Unpause", () => player.CurrentPausableGameplayContainer.Resume()); waitForDim(); - AddAssert("Screen is dimmed", () => songSelect.IsBackgroundDimmed()); + AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied()); } /// - /// Check if the fade container removes user dim when suspending for + /// Check if the visual settings container removes user dim when suspending for /// [Test] public void TransitionTest() @@ -205,11 +205,12 @@ namespace osu.Game.Tests.Visual performFullSetup(); AddStep("Transition to Results", () => player.Push(new FadeAccessibleResults(new ScoreInfo { User = new User { Username = "osu!" } }))); waitForDim(); - AddAssert("Screen is undimmed and is original background", () => songSelect.IsBackgroundUndimmed() && songSelect.IsBackgroundCurrent()); + AddAssert("Screen is undimmed, original background retained", () => + songSelect.IsBackgroundUndimmed() && songSelect.IsBackgroundCurrent() && songSelect.IsUserBlurDisabled()); } /// - /// Check if background gets undimmed when leaving for + /// Check if background gets undimmed and unblurred when leaving for /// [Test] public void TransitionOutTest() @@ -217,7 +218,7 @@ namespace osu.Game.Tests.Visual performFullSetup(); AddStep("Exit to song select", () => player.Exit()); waitForDim(); - AddAssert("Screen is undimmed", () => songSelect.IsBackgroundUndimmed()); + AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && songSelect.IsUserBlurDisabled()); } private void waitForDim() => AddWaitStep(5, "Wait for dim"); @@ -243,7 +244,7 @@ namespace osu.Game.Tests.Visual AddStep("Start player loader", () => { - songSelect.Push(playerLoader = new DimAccessiblePlayerLoader(player = new DimAccessiblePlayer + songSelect.Push(playerLoader = new TestPlayerLoader(player = new TestPlayer { AllowPause = allowPause, Ready = true, @@ -261,7 +262,7 @@ namespace osu.Game.Tests.Visual { Beatmap.Value.Mods.Value = Beatmap.Value.Mods.Value.Concat(new[] { new OsuModNoFail() }); songSelect.DimLevel.Value = 0.7f; - songSelect.BlurLevel.Value = 0.0f; + songSelect.BlurLevel.Value = 0.4f; }); } @@ -270,7 +271,7 @@ namespace osu.Game.Tests.Visual protected override BackgroundScreen CreateBackground() { FadeAccessibleBackground background = new FadeAccessibleBackground(Beatmap.Value); - DimEnabled.BindTo(background.EnableUserDim); + DimEnabled.BindTo(background.EnableVisualSettings); return background; } @@ -289,10 +290,12 @@ namespace osu.Game.Tests.Visual public bool IsBackgroundDimmed() => ((FadeAccessibleBackground)Background).CurrentColour == OsuColour.Gray(1 - (float)DimLevel.Value); - public bool IsBackgroundUnblurred() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(0); - public bool IsBackgroundUndimmed() => ((FadeAccessibleBackground)Background).CurrentColour == Color4.White; + public bool IsUserBlurApplied() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2((float)BlurLevel.Value * 25); + + public bool IsUserBlurDisabled() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(0); + public bool IsBackgroundInvisible() => ((FadeAccessibleBackground)Background).CurrentAlpha == 0; public bool IsBackgroundVisible() => ((FadeAccessibleBackground)Background).CurrentAlpha == 1; @@ -314,23 +317,23 @@ namespace osu.Game.Tests.Visual protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value); } - private class DimAccessiblePlayer : Player + private class TestPlayer : Player { protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value); - protected override UserDimContainer CreateStoryboardContainer() + protected override VisualSettingsContainer CreateStoryboardContainer() { - return new TestUserDimContainer(true) + return new TestVisualSettingsContainer(true) { RelativeSizeAxes = Axes.Both, Alpha = 1, - EnableUserDim = { Value = true } + EnableVisualSettings = { Value = true } }; } public PausableGameplayContainer CurrentPausableGameplayContainer => PausableGameplayContainer; - public UserDimContainer CurrentStoryboardContainer => StoryboardContainer; + public VisualSettingsContainer CurrentStoryboardContainer => StoryboardContainer; // Whether or not the player should be allowed to load. public bool Ready; @@ -339,9 +342,9 @@ namespace osu.Game.Tests.Visual public readonly Bindable ReplacesBackground = new Bindable(); public readonly Bindable IsPaused = new Bindable(); - public bool IsStoryboardVisible() => ((TestUserDimContainer)CurrentStoryboardContainer).CurrentAlpha == 1; + public bool IsStoryboardVisible() => ((TestVisualSettingsContainer)CurrentStoryboardContainer).CurrentAlpha == 1; - public bool IsStoryboardInvisible() => ((TestUserDimContainer)CurrentStoryboardContainer).CurrentAlpha <= 1; + public bool IsStoryboardInvisible() => ((TestVisualSettingsContainer)CurrentStoryboardContainer).CurrentAlpha <= 1; [BackgroundDependencyLoader] private void load(OsuConfigManager config) @@ -368,12 +371,12 @@ namespace osu.Game.Tests.Visual } } - private class DimAccessiblePlayerLoader : PlayerLoader + private class TestPlayerLoader : PlayerLoader { public VisualSettings VisualSettingsPos => VisualSettings; public BackgroundScreen ScreenPos => Background; - public DimAccessiblePlayerLoader(Player player) + public TestPlayerLoader(Player player) : base(() => player) { } @@ -385,14 +388,15 @@ namespace osu.Game.Tests.Visual private class FadeAccessibleBackground : BackgroundScreenBeatmap { - protected override UserDimContainer CreateFadeContainer() => fadeContainer = new TestUserDimContainer { RelativeSizeAxes = Axes.Both }; + protected override VisualSettingsContainer CreateFadeContainer() => fadeContainer = new TestVisualSettingsContainer { RelativeSizeAxes = Axes.Both }; public Color4 CurrentColour => fadeContainer.CurrentColour; + public float CurrentAlpha => fadeContainer.CurrentAlpha; - public Vector2 CurrentBlur => Background.BlurSigma; + public Vector2 CurrentBlur => fadeContainer.CurrentBlur; - private TestUserDimContainer fadeContainer; + private TestVisualSettingsContainer fadeContainer; public FadeAccessibleBackground(WorkingBeatmap beatmap) : base(beatmap) @@ -400,12 +404,14 @@ namespace osu.Game.Tests.Visual } } - private class TestUserDimContainer : UserDimContainer + private class TestVisualSettingsContainer : VisualSettingsContainer { - public Color4 CurrentColour => DimContainer.Colour; - public float CurrentAlpha => DimContainer.Alpha; + public Color4 CurrentColour => LocalContainer.Colour; + public float CurrentAlpha => LocalContainer.Alpha; - public TestUserDimContainer(bool isStoryboard = false) + public Vector2 CurrentBlur => LocalContainer.BlurSigma; + + public TestVisualSettingsContainer(bool isStoryboard = false) : base(isStoryboard) { } diff --git a/osu.Game/Graphics/Containers/UserDimContainer.cs b/osu.Game/Graphics/Containers/VisualSettingsContainer.cs similarity index 53% rename from osu.Game/Graphics/Containers/UserDimContainer.cs rename to osu.Game/Graphics/Containers/VisualSettingsContainer.cs index 4c8928e122..cd81fa98ea 100644 --- a/osu.Game/Graphics/Containers/UserDimContainer.cs +++ b/osu.Game/Graphics/Containers/VisualSettingsContainer.cs @@ -6,83 +6,93 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Configuration; +using osuTK; using osuTK.Graphics; namespace osu.Game.Graphics.Containers { /// - /// A container that applies user-configured dim levels to its contents. + /// A container that applies user-configured visual settings to its contents. /// This container specifies behavior that applies to both Storyboards and Backgrounds. /// - public class UserDimContainer : Container + public class VisualSettingsContainer : Container { private const float background_fade_duration = 800; private Bindable dimLevel { get; set; } + private Bindable blurLevel { get; set; } + private Bindable showStoryboard { get; set; } /// /// Whether or not user-configured dim levels should be applied to the container. /// - public readonly Bindable EnableUserDim = new Bindable(); + public readonly Bindable EnableVisualSettings = new Bindable(); /// /// Whether or not the storyboard loaded should completely hide the background behind it. /// public readonly Bindable StoryboardReplacesBackground = new Bindable(); - protected Container DimContainer { get; } + protected BufferedContainer LocalContainer { get; } - protected override Container Content => DimContainer; + protected override Container Content => LocalContainer; private readonly bool isStoryboard; + private Vector2 returnBlur; + /// - /// Creates a new . + /// Creates a new . /// - /// Whether or not this instance of UserDimContainer contains a storyboard. + /// Whether or not this instance contains a storyboard. /// /// While both backgrounds and storyboards allow user dim levels to be applied, storyboards can be toggled via - /// and can cause backgrounds to become hidden via . + /// and can cause backgrounds to become hidden via . Storyboards are also currently unable to be blurred. /// /// - public UserDimContainer(bool isStoryboard = false) + public VisualSettingsContainer(bool isStoryboard = false) { this.isStoryboard = isStoryboard; - AddInternal(DimContainer = new Container { RelativeSizeAxes = Axes.Both }); + AddInternal(LocalContainer = new BufferedContainer { RelativeSizeAxes = Axes.Both }); } [BackgroundDependencyLoader] private void load(OsuConfigManager config) { dimLevel = config.GetBindable(OsuSetting.DimLevel); + blurLevel = config.GetBindable(OsuSetting.BlurLevel); showStoryboard = config.GetBindable(OsuSetting.ShowStoryboard); - EnableUserDim.ValueChanged += _ => updateBackgroundDim(); - dimLevel.ValueChanged += _ => updateBackgroundDim(); - showStoryboard.ValueChanged += _ => updateBackgroundDim(); - StoryboardReplacesBackground.ValueChanged += _ => updateBackgroundDim(); + EnableVisualSettings.ValueChanged += _ => updateVisuals(); + dimLevel.ValueChanged += _ => updateVisuals(); + blurLevel.ValueChanged += _ => updateVisuals(); + showStoryboard.ValueChanged += _ => updateVisuals(); + StoryboardReplacesBackground.ValueChanged += _ => updateVisuals(); } protected override void LoadComplete() { base.LoadComplete(); - updateBackgroundDim(); + updateVisuals(); } - private void updateBackgroundDim() + private void updateVisuals() { if (isStoryboard) { - DimContainer.FadeTo(!showStoryboard.Value || dimLevel.Value == 1 ? 0 : 1, background_fade_duration, Easing.OutQuint); + LocalContainer.FadeTo(!showStoryboard.Value || dimLevel.Value == 1 ? 0 : 1, background_fade_duration, Easing.OutQuint); } else { // The background needs to be hidden in the case of it being replaced by the storyboard - DimContainer.FadeTo(showStoryboard.Value && StoryboardReplacesBackground.Value ? 0 : 1, background_fade_duration, Easing.OutQuint); + LocalContainer.FadeTo(showStoryboard.Value && StoryboardReplacesBackground.Value ? 0 : 1, background_fade_duration, Easing.OutQuint); + + // Only blur if this container contains a background + LocalContainer.BlurTo(EnableVisualSettings.Value ? new Vector2((float)blurLevel.Value * 25) : new Vector2(0), background_fade_duration, Easing.OutQuint); } - DimContainer.FadeColour(EnableUserDim.Value ? OsuColour.Gray(1 - (float)dimLevel.Value) : Color4.White, background_fade_duration, Easing.OutQuint); + LocalContainer.FadeColour(EnableVisualSettings.Value ? OsuColour.Gray(1 - (float)dimLevel.Value) : Color4.White, background_fade_duration, Easing.OutQuint); } } } diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index 13d1ff39ef..ee393fc13e 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics.Textures; using osu.Game.Beatmaps; using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Containers; +using osuTK; namespace osu.Game.Screens.Backgrounds { @@ -18,13 +19,13 @@ namespace osu.Game.Screens.Backgrounds /// /// Whether or not user dim settings should be applied to this Background. /// - public readonly Bindable EnableUserDim = new Bindable(); + public readonly Bindable EnableVisualSettings = new Bindable(); public readonly Bindable StoryboardReplacesBackground = new Bindable(); - private readonly UserDimContainer fadeContainer; + private readonly VisualSettingsContainer fadeContainer; - protected virtual UserDimContainer CreateFadeContainer() => new UserDimContainer { RelativeSizeAxes = Axes.Both }; + protected virtual VisualSettingsContainer CreateFadeContainer() => new VisualSettingsContainer { RelativeSizeAxes = Axes.Both }; public virtual WorkingBeatmap Beatmap { @@ -62,7 +63,7 @@ namespace osu.Game.Screens.Backgrounds { Beatmap = beatmap; InternalChild = fadeContainer = CreateFadeContainer(); - fadeContainer.EnableUserDim.BindTo(EnableUserDim); + fadeContainer.EnableVisualSettings.BindTo(EnableVisualSettings); } public override bool Equals(BackgroundScreen other) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index ced0a43679..98429589ca 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -71,13 +71,13 @@ namespace osu.Game.Screens.Play private FailOverlay failOverlay; private DrawableStoryboard storyboard; - protected UserDimContainer StoryboardContainer { get; private set; } + protected VisualSettingsContainer StoryboardContainer { get; private set; } - protected virtual UserDimContainer CreateStoryboardContainer() => new UserDimContainer(true) + protected virtual VisualSettingsContainer CreateStoryboardContainer() => new VisualSettingsContainer(true) { RelativeSizeAxes = Axes.Both, Alpha = 1, - EnableUserDim = { Value = true } + EnableVisualSettings = { Value = true } }; public bool LoadedBeatmapSuccessfully => RulesetContainer?.Objects.Any() == true; @@ -318,7 +318,7 @@ namespace osu.Game.Screens.Play if (enabled.NewValue) initializeStoryboard(true); }; - Background.EnableUserDim.Value = true; + Background.EnableVisualSettings.Value = true; Background.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground); StoryboardContainer.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground); @@ -365,7 +365,7 @@ namespace osu.Game.Screens.Play float fadeOutDuration = instant ? 0 : 250; this.FadeOut(fadeOutDuration); - Background.EnableUserDim.Value = false; + Background.EnableVisualSettings.Value = false; storyboardReplacesBackground.Value = false; } diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 269baad955..e45421ce4a 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -26,8 +26,9 @@ namespace osu.Game.Screens.Play { public class PlayerLoader : ScreenWithBeatmapBackground { + protected static readonly Vector2 BACKGROUND_BLUR = new Vector2(15); + private readonly Func createPlayer; - private static readonly Vector2 background_blur = new Vector2(15); private Player player; @@ -118,12 +119,16 @@ namespace osu.Game.Screens.Play private void contentIn() { + Background?.BlurTo(BACKGROUND_BLUR, 800, Easing.OutQuint); + content.ScaleTo(1, 650, Easing.OutQuint); content.FadeInFromZero(400); } private void contentOut() { + Background?.BlurTo(new Vector2(0), 800, Easing.OutQuint); + content.ScaleTo(0.7f, 300, Easing.InQuint); content.FadeOut(250); } @@ -133,6 +138,7 @@ namespace osu.Game.Screens.Play base.OnEntering(last); content.ScaleTo(0.7f); + Background?.FadeColour(Color4.White, 800, Easing.OutQuint); contentIn(); @@ -158,11 +164,10 @@ namespace osu.Game.Screens.Play protected override bool OnHover(HoverEvent e) { - // restore our screen defaults if (this.IsCurrentScreen()) { - InitializeBackgroundElements(); - Background.EnableUserDim.Value = false; + Background.BlurTo(BACKGROUND_BLUR, 800, Easing.OutQuint); + Background.EnableVisualSettings.Value = false; } return base.OnHover(e); @@ -172,22 +177,16 @@ namespace osu.Game.Screens.Play { if (GetContainingInputManager()?.HoveredDrawables.Contains(VisualSettings) == true) { - // Update background elements is only being called here because blur logic still exists in Player. - // Will need to be removed when resolving https://github.com/ppy/osu/issues/4322 - UpdateBackgroundElements(); - if (this.IsCurrentScreen()) - Background.EnableUserDim.Value = true; + if (this.IsCurrentScreen() && Background != null) + { + Background.BlurTo(new Vector2(0), 800, Easing.OutQuint); + Background.EnableVisualSettings.Value = true; + } } base.OnHoverLost(e); } - protected override void InitializeBackgroundElements() - { - Background?.FadeColour(Color4.White, BACKGROUND_FADE_DURATION, Easing.OutQuint); - Background?.BlurTo(background_blur, BACKGROUND_FADE_DURATION, Easing.OutQuint); - } - private void pushWhenLoaded() { if (!this.IsCurrentScreen()) return; @@ -250,7 +249,7 @@ namespace osu.Game.Screens.Play this.FadeOut(150); cancelLoad(); - Background.EnableUserDim.Value = false; + Background.EnableVisualSettings.Value = false; return base.OnExiting(next); } diff --git a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs index 328aa1d18e..2ffa1c3da9 100644 --- a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs +++ b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs @@ -17,49 +17,12 @@ namespace osu.Game.Screens.Play protected new BackgroundScreenBeatmap Background => (BackgroundScreenBeatmap)base.Background; - protected const float BACKGROUND_FADE_DURATION = 800; - - #region User Settings - - protected Bindable BlurLevel; protected Bindable ShowStoryboard; - #endregion - [BackgroundDependencyLoader] private void load(OsuConfigManager config) { - BlurLevel = config.GetBindable(OsuSetting.BlurLevel); ShowStoryboard = config.GetBindable(OsuSetting.ShowStoryboard); } - - public override void OnEntering(IScreen last) - { - base.OnEntering(last); - BlurLevel.ValueChanged += _ => UpdateBackgroundElements(); - InitializeBackgroundElements(); - } - - public override void OnResuming(IScreen last) - { - base.OnResuming(last); - InitializeBackgroundElements(); - } - - /// - /// Called once on entering screen. By Default, performs a full call. - /// - protected virtual void InitializeBackgroundElements() => UpdateBackgroundElements(); - - /// - /// Called when background elements require updates, usually due to a user changing a setting. - /// - /// - protected virtual void UpdateBackgroundElements() - { - if (!this.IsCurrentScreen()) return; - - Background?.BlurTo(new Vector2((float)BlurLevel.Value * 25), BACKGROUND_FADE_DURATION, Easing.OutQuint); - } } } diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index 47ac472b9e..eb3ce66547 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -24,6 +24,8 @@ namespace osu.Game.Screens.Ranking { public abstract class Results : OsuScreen { + protected static readonly Vector2 BACKGROUND_BLUR = new Vector2(20); + private Container circleOuterBackground; private Container circleOuter; private Container circleInner; @@ -38,8 +40,6 @@ namespace osu.Game.Screens.Ranking private Container currentPage; - private static readonly Vector2 background_blur = new Vector2(20); - protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap.Value); private const float overscan = 1.3f; @@ -58,7 +58,7 @@ namespace osu.Game.Screens.Ranking public override void OnEntering(IScreen last) { base.OnEntering(last); - (Background as BackgroundScreenBeatmap)?.BlurTo(background_blur, 2500, Easing.OutQuint); + (Background as BackgroundScreenBeatmap)?.BlurTo(BACKGROUND_BLUR, 2500, Easing.OutQuint); Background.ScaleTo(1.1f, transition_time, Easing.OutQuint); allCircles.ForEach(c => diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 5d4ead69d6..d10e6994d5 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -37,8 +37,8 @@ namespace osu.Game.Screens.Select { public abstract class SongSelect : OsuScreen { + protected static readonly Vector2 BACKGROUND_BLUR = new Vector2(20); private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 245); - private static readonly Vector2 background_blur = new Vector2(20); private const float left_area_padding = 20; public readonly FilterControl FilterControl; @@ -556,7 +556,7 @@ namespace osu.Game.Screens.Select if (Background is BackgroundScreenBeatmap backgroundModeBeatmap) { backgroundModeBeatmap.Beatmap = beatmap; - backgroundModeBeatmap.BlurTo(background_blur, 750, Easing.OutQuint); + backgroundModeBeatmap.BlurTo(BACKGROUND_BLUR, 750, Easing.OutQuint); backgroundModeBeatmap.FadeColour(Color4.White, 250); } From 8714902349998aa4ce4985133abedd51a98caa8a Mon Sep 17 00:00:00 2001 From: David Zhao Date: Thu, 14 Mar 2019 14:02:46 +0900 Subject: [PATCH 02/34] Handle all blurring directly from background --- .../Containers/VisualSettingsContainer.cs | 41 +++++++++++++------ .../Backgrounds/BackgroundScreenBeatmap.cs | 5 ++- osu.Game/Screens/Play/PlayerLoader.cs | 14 ++++--- osu.Game/Screens/Ranking/Results.cs | 4 +- osu.Game/Screens/Select/SongSelect.cs | 5 ++- 5 files changed, 46 insertions(+), 23 deletions(-) diff --git a/osu.Game/Graphics/Containers/VisualSettingsContainer.cs b/osu.Game/Graphics/Containers/VisualSettingsContainer.cs index cd81fa98ea..3d9e340d5f 100644 --- a/osu.Game/Graphics/Containers/VisualSettingsContainer.cs +++ b/osu.Game/Graphics/Containers/VisualSettingsContainer.cs @@ -1,11 +1,16 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Logging; +using osu.Game.Beatmaps; using osu.Game.Configuration; +using osu.Game.Graphics.Backgrounds; +using osu.Game.Screens.Backgrounds; using osuTK; using osuTK.Graphics; @@ -19,6 +24,8 @@ namespace osu.Game.Graphics.Containers { private const float background_fade_duration = 800; + public Action ContentLoadComplete = () => { }; + private Bindable dimLevel { get; set; } private Bindable blurLevel { get; set; } @@ -35,13 +42,13 @@ namespace osu.Game.Graphics.Containers /// public readonly Bindable StoryboardReplacesBackground = new Bindable(); - protected BufferedContainer LocalContainer { get; } + protected Container LocalContainer { get; } protected override Container Content => LocalContainer; private readonly bool isStoryboard; - private Vector2 returnBlur; + public Bindable AddedBlur = new Bindable(); /// /// Creates a new . @@ -55,7 +62,7 @@ namespace osu.Game.Graphics.Containers public VisualSettingsContainer(bool isStoryboard = false) { this.isStoryboard = isStoryboard; - AddInternal(LocalContainer = new BufferedContainer { RelativeSizeAxes = Axes.Both }); + AddInternal(LocalContainer = new Container { RelativeSizeAxes = Axes.Both }); } [BackgroundDependencyLoader] @@ -64,20 +71,21 @@ namespace osu.Game.Graphics.Containers dimLevel = config.GetBindable(OsuSetting.DimLevel); blurLevel = config.GetBindable(OsuSetting.BlurLevel); showStoryboard = config.GetBindable(OsuSetting.ShowStoryboard); - EnableVisualSettings.ValueChanged += _ => updateVisuals(); - dimLevel.ValueChanged += _ => updateVisuals(); - blurLevel.ValueChanged += _ => updateVisuals(); - showStoryboard.ValueChanged += _ => updateVisuals(); - StoryboardReplacesBackground.ValueChanged += _ => updateVisuals(); + EnableVisualSettings.ValueChanged += _ => UpdateVisuals(); + dimLevel.ValueChanged += _ => UpdateVisuals(); + blurLevel.ValueChanged += _ => UpdateVisuals(); + showStoryboard.ValueChanged += _ => UpdateVisuals(); + StoryboardReplacesBackground.ValueChanged += _ => UpdateVisuals(); + AddedBlur.ValueChanged += _ => UpdateVisuals(); } protected override void LoadComplete() { base.LoadComplete(); - updateVisuals(); + UpdateVisuals(); } - private void updateVisuals() + public void UpdateVisuals() { if (isStoryboard) { @@ -88,8 +96,17 @@ namespace osu.Game.Graphics.Containers // The background needs to be hidden in the case of it being replaced by the storyboard LocalContainer.FadeTo(showStoryboard.Value && StoryboardReplacesBackground.Value ? 0 : 1, background_fade_duration, Easing.OutQuint); - // Only blur if this container contains a background - LocalContainer.BlurTo(EnableVisualSettings.Value ? new Vector2((float)blurLevel.Value * 25) : new Vector2(0), background_fade_duration, Easing.OutQuint); + foreach (Drawable c in LocalContainer) + { + // Only blur if this container contains a background + // We can't blur the container like we did with the dim because buffered containers add considerable draw overhead. + // As a result, this blurs the background directly. + ((Background)c)?.BlurTo(EnableVisualSettings.Value + ? new Vector2(AddedBlur.Value + (float)blurLevel.Value * 25) + : new Vector2(AddedBlur.Value), background_fade_duration, Easing.OutQuint); + + Logger.Log("Enable visual settings: " + EnableVisualSettings.Value + " Added blur is: " + AddedBlur.Value); + } } LocalContainer.FadeColour(EnableVisualSettings.Value ? OsuColour.Gray(1 - (float)dimLevel.Value) : Color4.White, background_fade_duration, Easing.OutQuint); diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index ee393fc13e..3670ac7663 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -8,7 +8,6 @@ using osu.Framework.Graphics.Textures; using osu.Game.Beatmaps; using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Containers; -using osuTK; namespace osu.Game.Screens.Backgrounds { @@ -23,6 +22,8 @@ namespace osu.Game.Screens.Backgrounds public readonly Bindable StoryboardReplacesBackground = new Bindable(); + public readonly Bindable AddedBlur = new Bindable(); + private readonly VisualSettingsContainer fadeContainer; protected virtual VisualSettingsContainer CreateFadeContainer() => new VisualSettingsContainer { RelativeSizeAxes = Axes.Both }; @@ -52,6 +53,7 @@ namespace osu.Game.Screens.Backgrounds b.Depth = newDepth; fadeContainer.Add(Background = b); + fadeContainer.UpdateVisuals(); Background.BlurSigma = BlurTarget; StoryboardReplacesBackground.BindTo(fadeContainer.StoryboardReplacesBackground); })); @@ -64,6 +66,7 @@ namespace osu.Game.Screens.Backgrounds Beatmap = beatmap; InternalChild = fadeContainer = CreateFadeContainer(); fadeContainer.EnableVisualSettings.BindTo(EnableVisualSettings); + fadeContainer.AddedBlur.BindTo(AddedBlur); } public override bool Equals(BackgroundScreen other) diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index e45421ce4a..6eee681e67 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -26,7 +26,7 @@ namespace osu.Game.Screens.Play { public class PlayerLoader : ScreenWithBeatmapBackground { - protected static readonly Vector2 BACKGROUND_BLUR = new Vector2(15); + private const float background_blur = 15; private readonly Func createPlayer; @@ -119,7 +119,7 @@ namespace osu.Game.Screens.Play private void contentIn() { - Background?.BlurTo(BACKGROUND_BLUR, 800, Easing.OutQuint); + Background.AddedBlur.Value = background_blur; content.ScaleTo(1, 650, Easing.OutQuint); content.FadeInFromZero(400); @@ -127,7 +127,7 @@ namespace osu.Game.Screens.Play private void contentOut() { - Background?.BlurTo(new Vector2(0), 800, Easing.OutQuint); + Background.AddedBlur.Value = 0; content.ScaleTo(0.7f, 300, Easing.InQuint); content.FadeOut(250); @@ -166,7 +166,7 @@ namespace osu.Game.Screens.Play { if (this.IsCurrentScreen()) { - Background.BlurTo(BACKGROUND_BLUR, 800, Easing.OutQuint); + Background.AddedBlur.Value = background_blur; Background.EnableVisualSettings.Value = false; } @@ -179,7 +179,7 @@ namespace osu.Game.Screens.Play { if (this.IsCurrentScreen() && Background != null) { - Background.BlurTo(new Vector2(0), 800, Easing.OutQuint); + Background.AddedBlur.Value = 0; Background.EnableVisualSettings.Value = true; } } @@ -239,6 +239,8 @@ namespace osu.Game.Screens.Play public override void OnSuspending(IScreen next) { + Background.EnableVisualSettings.Value = true; + base.OnSuspending(next); cancelLoad(); } @@ -249,7 +251,7 @@ namespace osu.Game.Screens.Play this.FadeOut(150); cancelLoad(); - Background.EnableVisualSettings.Value = false; + Background.EnableVisualSettings.Value = true; return base.OnExiting(next); } diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index eb3ce66547..a30534a5d3 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -24,7 +24,7 @@ namespace osu.Game.Screens.Ranking { public abstract class Results : OsuScreen { - protected static readonly Vector2 BACKGROUND_BLUR = new Vector2(20); + private const float background_blur = 20; private Container circleOuterBackground; private Container circleOuter; @@ -58,7 +58,7 @@ namespace osu.Game.Screens.Ranking public override void OnEntering(IScreen last) { base.OnEntering(last); - (Background as BackgroundScreenBeatmap)?.BlurTo(BACKGROUND_BLUR, 2500, Easing.OutQuint); + ((BackgroundScreenBeatmap)Background).AddedBlur.Value = background_blur; Background.ScaleTo(1.1f, transition_time, Easing.OutQuint); allCircles.ForEach(c => diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index d10e6994d5..22e4b2ffa2 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -37,8 +37,8 @@ namespace osu.Game.Screens.Select { public abstract class SongSelect : OsuScreen { - protected static readonly Vector2 BACKGROUND_BLUR = new Vector2(20); private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 245); + private const float background_blur = 20; private const float left_area_padding = 20; public readonly FilterControl FilterControl; @@ -556,8 +556,9 @@ namespace osu.Game.Screens.Select if (Background is BackgroundScreenBeatmap backgroundModeBeatmap) { backgroundModeBeatmap.Beatmap = beatmap; - backgroundModeBeatmap.BlurTo(BACKGROUND_BLUR, 750, Easing.OutQuint); + backgroundModeBeatmap.AddedBlur.Value = background_blur; backgroundModeBeatmap.FadeColour(Color4.White, 250); + Logger.Log("blur updated!"); } beatmapInfoWedge.Beatmap = beatmap; From 8cdfb1fd610bed0896cce606178a0854887370fe Mon Sep 17 00:00:00 2001 From: David Zhao Date: Thu, 14 Mar 2019 16:09:17 +0900 Subject: [PATCH 03/34] Remove BlurrableBackgroundScreen, rework tests --- .../Visual/TestCaseBackgroundScreenBeatmap.cs | 21 ++++++++++------- .../Containers/VisualSettingsContainer.cs | 16 ++++++++----- osu.Game/Screens/BackgroundScreen.cs | 3 +++ .../Backgrounds/BackgroundScreenBeatmap.cs | 4 ++-- .../Backgrounds/BackgroundScreenCustom.cs | 2 +- .../Backgrounds/BackgroundScreenDefault.cs | 2 +- osu.Game/Screens/BlurrableBackgroundScreen.cs | 23 ------------------- osu.Game/Screens/Play/PlayerLoader.cs | 10 ++++---- osu.Game/Screens/Ranking/Results.cs | 4 ++-- osu.Game/Screens/Select/SongSelect.cs | 4 ++-- 10 files changed, 40 insertions(+), 49 deletions(-) delete mode 100644 osu.Game/Screens/BlurrableBackgroundScreen.cs diff --git a/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs index 03078abd3a..efaa752283 100644 --- a/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs +++ b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs @@ -109,7 +109,7 @@ namespace osu.Game.Tests.Visual AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied()); AddStep("Stop background preview", () => InputManager.MoveMouseTo(playerLoader.ScreenPos)); waitForDim(); - AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && songSelect.IsUserBlurDisabled()); + AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && playerLoader.IsBlurCorrect()); } /// @@ -203,10 +203,11 @@ namespace osu.Game.Tests.Visual public void TransitionTest() { performFullSetup(); - AddStep("Transition to Results", () => player.Push(new FadeAccessibleResults(new ScoreInfo { User = new User { Username = "osu!" } }))); + var results = new FadeAccessibleResults(new ScoreInfo { User = new User { Username = "osu!" } }); + AddStep("Transition to Results", () => player.Push(results)); waitForDim(); - AddAssert("Screen is undimmed, original background retained", () => - songSelect.IsBackgroundUndimmed() && songSelect.IsBackgroundCurrent() && songSelect.IsUserBlurDisabled()); + AddAssert("Screen is undimmed, original background retained", () => + songSelect.IsBackgroundUndimmed() && songSelect.IsBackgroundCurrent() && results.IsBlurCorrect()); } /// @@ -218,7 +219,7 @@ namespace osu.Game.Tests.Visual performFullSetup(); AddStep("Exit to song select", () => player.Exit()); waitForDim(); - AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && songSelect.IsUserBlurDisabled()); + AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && songSelect.IsBlurCorrect()); } private void waitForDim() => AddWaitStep(5, "Wait for dim"); @@ -300,6 +301,8 @@ namespace osu.Game.Tests.Visual public bool IsBackgroundVisible() => ((FadeAccessibleBackground)Background).CurrentAlpha == 1; + public bool IsBlurCorrect() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(BACKGROUND_BLUR); + /// /// Make sure every time a screen gets pushed, the background doesn't get replaced /// @@ -315,6 +318,8 @@ namespace osu.Game.Tests.Visual } protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value); + + public bool IsBlurCorrect() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(BACKGROUND_BLUR); } private class TestPlayer : Player @@ -383,6 +388,8 @@ namespace osu.Game.Tests.Visual public void TriggerOnHover() => OnHover(new HoverEvent(new InputState())); + public bool IsBlurCorrect() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(BACKGROUND_BLUR); + protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value); } @@ -394,7 +401,7 @@ namespace osu.Game.Tests.Visual public float CurrentAlpha => fadeContainer.CurrentAlpha; - public Vector2 CurrentBlur => fadeContainer.CurrentBlur; + public Vector2 CurrentBlur => Background.BlurSigma; private TestVisualSettingsContainer fadeContainer; @@ -409,8 +416,6 @@ namespace osu.Game.Tests.Visual public Color4 CurrentColour => LocalContainer.Colour; public float CurrentAlpha => LocalContainer.Alpha; - public Vector2 CurrentBlur => LocalContainer.BlurSigma; - public TestVisualSettingsContainer(bool isStoryboard = false) : base(isStoryboard) { diff --git a/osu.Game/Graphics/Containers/VisualSettingsContainer.cs b/osu.Game/Graphics/Containers/VisualSettingsContainer.cs index 3d9e340d5f..c45b130044 100644 --- a/osu.Game/Graphics/Containers/VisualSettingsContainer.cs +++ b/osu.Game/Graphics/Containers/VisualSettingsContainer.cs @@ -24,8 +24,6 @@ namespace osu.Game.Graphics.Containers { private const float background_fade_duration = 800; - public Action ContentLoadComplete = () => { }; - private Bindable dimLevel { get; set; } private Bindable blurLevel { get; set; } @@ -50,6 +48,10 @@ namespace osu.Game.Graphics.Containers public Bindable AddedBlur = new Bindable(); + public Vector2 BlurTarget => EnableVisualSettings.Value + ? new Vector2(AddedBlur.Value + (float)blurLevel.Value * 25) + : new Vector2(AddedBlur.Value); + /// /// Creates a new . /// @@ -71,7 +73,11 @@ namespace osu.Game.Graphics.Containers dimLevel = config.GetBindable(OsuSetting.DimLevel); blurLevel = config.GetBindable(OsuSetting.BlurLevel); showStoryboard = config.GetBindable(OsuSetting.ShowStoryboard); - EnableVisualSettings.ValueChanged += _ => UpdateVisuals(); + EnableVisualSettings.ValueChanged += _ => + { + Logger.Log("Oh fuck"); + UpdateVisuals(); + }; dimLevel.ValueChanged += _ => UpdateVisuals(); blurLevel.ValueChanged += _ => UpdateVisuals(); showStoryboard.ValueChanged += _ => UpdateVisuals(); @@ -101,9 +107,7 @@ namespace osu.Game.Graphics.Containers // Only blur if this container contains a background // We can't blur the container like we did with the dim because buffered containers add considerable draw overhead. // As a result, this blurs the background directly. - ((Background)c)?.BlurTo(EnableVisualSettings.Value - ? new Vector2(AddedBlur.Value + (float)blurLevel.Value * 25) - : new Vector2(AddedBlur.Value), background_fade_duration, Easing.OutQuint); + ((Background)c)?.BlurTo(BlurTarget, background_fade_duration, Easing.OutQuint); Logger.Log("Enable visual settings: " + EnableVisualSettings.Value + " Added blur is: " + AddedBlur.Value); } diff --git a/osu.Game/Screens/BackgroundScreen.cs b/osu.Game/Screens/BackgroundScreen.cs index bbe162cf7c..7eca192a6b 100644 --- a/osu.Game/Screens/BackgroundScreen.cs +++ b/osu.Game/Screens/BackgroundScreen.cs @@ -5,12 +5,15 @@ using System; using osu.Framework.Screens; using osu.Framework.Graphics; using osu.Framework.Input.Events; +using osu.Game.Graphics.Backgrounds; using osuTK; namespace osu.Game.Screens { public abstract class BackgroundScreen : Screen, IEquatable { + protected Background Background; + protected BackgroundScreen() { Anchor = Anchor.Centre; diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index 3670ac7663..3e3315d03a 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -11,7 +11,7 @@ using osu.Game.Graphics.Containers; namespace osu.Game.Screens.Backgrounds { - public class BackgroundScreenBeatmap : BlurrableBackgroundScreen + public class BackgroundScreenBeatmap : BackgroundScreen { private WorkingBeatmap beatmap; @@ -54,7 +54,7 @@ namespace osu.Game.Screens.Backgrounds b.Depth = newDepth; fadeContainer.Add(Background = b); fadeContainer.UpdateVisuals(); - Background.BlurSigma = BlurTarget; + Background.BlurSigma = fadeContainer.BlurTarget; StoryboardReplacesBackground.BindTo(fadeContainer.StoryboardReplacesBackground); })); }); diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenCustom.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenCustom.cs index 0cb41bc562..538f347737 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenCustom.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenCustom.cs @@ -12,7 +12,7 @@ namespace osu.Game.Screens.Backgrounds public BackgroundScreenCustom(string textureName) { this.textureName = textureName; - AddInternal(new Background(textureName)); + AddInternal(Background = new Background(textureName)); } public override bool Equals(BackgroundScreen other) diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs index 87a6b5d591..73590b3318 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs @@ -13,7 +13,7 @@ using osu.Game.Users; namespace osu.Game.Screens.Backgrounds { - public class BackgroundScreenDefault : BlurrableBackgroundScreen + public class BackgroundScreenDefault : BackgroundScreen { private int currentDisplay; private const int background_count = 5; diff --git a/osu.Game/Screens/BlurrableBackgroundScreen.cs b/osu.Game/Screens/BlurrableBackgroundScreen.cs deleted file mode 100644 index d19e699acb..0000000000 --- a/osu.Game/Screens/BlurrableBackgroundScreen.cs +++ /dev/null @@ -1,23 +0,0 @@ -// 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.Graphics; -using osu.Framework.Graphics.Transforms; -using osu.Game.Graphics.Backgrounds; -using osuTK; - -namespace osu.Game.Screens -{ - public abstract class BlurrableBackgroundScreen : BackgroundScreen - { - protected Background Background; - - protected Vector2 BlurTarget; - - public TransformSequence BlurTo(Vector2 sigma, double duration, Easing easing = Easing.None) - { - BlurTarget = sigma; - return Background?.BlurTo(BlurTarget, duration, easing); - } - } -} diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 6eee681e67..4200a7390d 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -26,7 +26,7 @@ namespace osu.Game.Screens.Play { public class PlayerLoader : ScreenWithBeatmapBackground { - private const float background_blur = 15; + protected const float BACKGROUND_BLUR = 15; private readonly Func createPlayer; @@ -119,7 +119,8 @@ namespace osu.Game.Screens.Play private void contentIn() { - Background.AddedBlur.Value = background_blur; + Background.AddedBlur.Value = BACKGROUND_BLUR; + Background.EnableVisualSettings.Value = false; content.ScaleTo(1, 650, Easing.OutQuint); content.FadeInFromZero(400); @@ -128,6 +129,7 @@ namespace osu.Game.Screens.Play private void contentOut() { Background.AddedBlur.Value = 0; + Background.EnableVisualSettings.Value = true; content.ScaleTo(0.7f, 300, Easing.InQuint); content.FadeOut(250); @@ -166,7 +168,7 @@ namespace osu.Game.Screens.Play { if (this.IsCurrentScreen()) { - Background.AddedBlur.Value = background_blur; + Background.AddedBlur.Value = BACKGROUND_BLUR; Background.EnableVisualSettings.Value = false; } @@ -251,7 +253,7 @@ namespace osu.Game.Screens.Play this.FadeOut(150); cancelLoad(); - Background.EnableVisualSettings.Value = true; + Background.EnableVisualSettings.Value = false; return base.OnExiting(next); } diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index a30534a5d3..bd8daa6b03 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -24,7 +24,7 @@ namespace osu.Game.Screens.Ranking { public abstract class Results : OsuScreen { - private const float background_blur = 20; + protected const float BACKGROUND_BLUR = 20; private Container circleOuterBackground; private Container circleOuter; @@ -58,7 +58,7 @@ namespace osu.Game.Screens.Ranking public override void OnEntering(IScreen last) { base.OnEntering(last); - ((BackgroundScreenBeatmap)Background).AddedBlur.Value = background_blur; + ((BackgroundScreenBeatmap)Background).AddedBlur.Value = BACKGROUND_BLUR; Background.ScaleTo(1.1f, transition_time, Easing.OutQuint); allCircles.ForEach(c => diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 22e4b2ffa2..6551c70de3 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -38,7 +38,7 @@ namespace osu.Game.Screens.Select public abstract class SongSelect : OsuScreen { private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 245); - private const float background_blur = 20; + protected const float BACKGROUND_BLUR = 20; private const float left_area_padding = 20; public readonly FilterControl FilterControl; @@ -556,7 +556,7 @@ namespace osu.Game.Screens.Select if (Background is BackgroundScreenBeatmap backgroundModeBeatmap) { backgroundModeBeatmap.Beatmap = beatmap; - backgroundModeBeatmap.AddedBlur.Value = background_blur; + backgroundModeBeatmap.AddedBlur.Value = BACKGROUND_BLUR; backgroundModeBeatmap.FadeColour(Color4.White, 250); Logger.Log("blur updated!"); } From 8fc90bb9a03247b3c4ca77a6bde37639fefa716a Mon Sep 17 00:00:00 2001 From: David Zhao Date: Thu, 14 Mar 2019 16:26:34 +0900 Subject: [PATCH 04/34] Remove unused usings --- osu.Game/Graphics/Containers/VisualSettingsContainer.cs | 3 --- osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs | 3 --- 2 files changed, 6 deletions(-) diff --git a/osu.Game/Graphics/Containers/VisualSettingsContainer.cs b/osu.Game/Graphics/Containers/VisualSettingsContainer.cs index c45b130044..ebbd975231 100644 --- a/osu.Game/Graphics/Containers/VisualSettingsContainer.cs +++ b/osu.Game/Graphics/Containers/VisualSettingsContainer.cs @@ -1,16 +1,13 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Logging; -using osu.Game.Beatmaps; using osu.Game.Configuration; using osu.Game.Graphics.Backgrounds; -using osu.Game.Screens.Backgrounds; using osuTK; using osuTK.Graphics; diff --git a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs index 2ffa1c3da9..174e39f3cb 100644 --- a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs +++ b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs @@ -3,11 +3,8 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; -using osu.Framework.Graphics; -using osu.Framework.Screens; using osu.Game.Configuration; using osu.Game.Screens.Backgrounds; -using osuTK; namespace osu.Game.Screens.Play { From 3208f1dde8b2ac139edbe6a350d70343e8d1bfcf Mon Sep 17 00:00:00 2001 From: David Zhao Date: Thu, 14 Mar 2019 16:40:25 +0900 Subject: [PATCH 05/34] Fix potential transitiontest failure on local unit tests --- osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs index efaa752283..2eb479b505 100644 --- a/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs +++ b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs @@ -205,6 +205,7 @@ namespace osu.Game.Tests.Visual performFullSetup(); var results = new FadeAccessibleResults(new ScoreInfo { User = new User { Username = "osu!" } }); AddStep("Transition to Results", () => player.Push(results)); + AddUntilStep(results.IsCurrentScreen, "Wait for results is current"); waitForDim(); AddAssert("Screen is undimmed, original background retained", () => songSelect.IsBackgroundUndimmed() && songSelect.IsBackgroundCurrent() && results.IsBlurCorrect()); From eac7672c6b964acf2972539bc99e8e402b848155 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Mon, 18 Mar 2019 14:03:54 +0900 Subject: [PATCH 06/34] Clean up debug logging --- osu.Game/Graphics/Containers/VisualSettingsContainer.cs | 8 +------- osu.Game/Screens/Select/SongSelect.cs | 1 - 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/osu.Game/Graphics/Containers/VisualSettingsContainer.cs b/osu.Game/Graphics/Containers/VisualSettingsContainer.cs index ebbd975231..edc8d4394a 100644 --- a/osu.Game/Graphics/Containers/VisualSettingsContainer.cs +++ b/osu.Game/Graphics/Containers/VisualSettingsContainer.cs @@ -70,11 +70,7 @@ namespace osu.Game.Graphics.Containers dimLevel = config.GetBindable(OsuSetting.DimLevel); blurLevel = config.GetBindable(OsuSetting.BlurLevel); showStoryboard = config.GetBindable(OsuSetting.ShowStoryboard); - EnableVisualSettings.ValueChanged += _ => - { - Logger.Log("Oh fuck"); - UpdateVisuals(); - }; + EnableVisualSettings.ValueChanged += _ => UpdateVisuals(); dimLevel.ValueChanged += _ => UpdateVisuals(); blurLevel.ValueChanged += _ => UpdateVisuals(); showStoryboard.ValueChanged += _ => UpdateVisuals(); @@ -105,8 +101,6 @@ namespace osu.Game.Graphics.Containers // We can't blur the container like we did with the dim because buffered containers add considerable draw overhead. // As a result, this blurs the background directly. ((Background)c)?.BlurTo(BlurTarget, background_fade_duration, Easing.OutQuint); - - Logger.Log("Enable visual settings: " + EnableVisualSettings.Value + " Added blur is: " + AddedBlur.Value); } } diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 6551c70de3..385c4e0a0d 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -558,7 +558,6 @@ namespace osu.Game.Screens.Select backgroundModeBeatmap.Beatmap = beatmap; backgroundModeBeatmap.AddedBlur.Value = BACKGROUND_BLUR; backgroundModeBeatmap.FadeColour(Color4.White, 250); - Logger.Log("blur updated!"); } beatmapInfoWedge.Beatmap = beatmap; From 0024a0bdb2974864a4c5c892c497ef5185787790 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Mon, 18 Mar 2019 14:35:03 +0900 Subject: [PATCH 07/34] Remove unused using --- osu.Game/Graphics/Containers/VisualSettingsContainer.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Graphics/Containers/VisualSettingsContainer.cs b/osu.Game/Graphics/Containers/VisualSettingsContainer.cs index edc8d4394a..1ed4f0e23e 100644 --- a/osu.Game/Graphics/Containers/VisualSettingsContainer.cs +++ b/osu.Game/Graphics/Containers/VisualSettingsContainer.cs @@ -5,7 +5,6 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Logging; using osu.Game.Configuration; using osu.Game.Graphics.Backgrounds; using osuTK; From 27a92e017c99f6963604c24e0d85d457e24ec1ff Mon Sep 17 00:00:00 2001 From: David Zhao Date: Tue, 19 Mar 2019 13:06:14 +0900 Subject: [PATCH 08/34] rename back to UserDimContainer --- .../Visual/TestCaseBackgroundScreenBeatmap.cs | 26 +++++++++---------- ...ttingsContainer.cs => UserDimContainer.cs} | 20 +++++++------- .../Backgrounds/BackgroundScreenBeatmap.cs | 4 +-- osu.Game/Screens/Play/Player.cs | 4 +-- 4 files changed, 27 insertions(+), 27 deletions(-) rename osu.Game/Graphics/Containers/{VisualSettingsContainer.cs => UserDimContainer.cs} (80%) diff --git a/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs index 2eb479b505..4549f1663d 100644 --- a/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs +++ b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs @@ -43,7 +43,7 @@ namespace osu.Game.Tests.Visual typeof(ScreenWithBeatmapBackground), typeof(PlayerLoader), typeof(Player), - typeof(VisualSettingsContainer), + typeof(UserDimContainer), typeof(OsuScreen) }; @@ -165,7 +165,7 @@ namespace osu.Game.Tests.Visual } /// - /// Check if the is properly accepting user-defined visual changes at all. + /// Check if the is properly accepting user-defined visual changes at all. /// [Test] public void DisableUserDimTest() @@ -327,9 +327,9 @@ namespace osu.Game.Tests.Visual { protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value); - protected override VisualSettingsContainer CreateStoryboardContainer() + protected override UserDimContainer CreateStoryboardContainer() { - return new TestVisualSettingsContainer(true) + return new TestUserDimContainer(true) { RelativeSizeAxes = Axes.Both, Alpha = 1, @@ -339,7 +339,7 @@ namespace osu.Game.Tests.Visual public PausableGameplayContainer CurrentPausableGameplayContainer => PausableGameplayContainer; - public VisualSettingsContainer CurrentStoryboardContainer => StoryboardContainer; + public UserDimContainer CurrentStoryboardContainer => StoryboardContainer; // Whether or not the player should be allowed to load. public bool Ready; @@ -348,9 +348,9 @@ namespace osu.Game.Tests.Visual public readonly Bindable ReplacesBackground = new Bindable(); public readonly Bindable IsPaused = new Bindable(); - public bool IsStoryboardVisible() => ((TestVisualSettingsContainer)CurrentStoryboardContainer).CurrentAlpha == 1; + public bool IsStoryboardVisible() => ((TestUserDimContainer)CurrentStoryboardContainer).CurrentAlpha == 1; - public bool IsStoryboardInvisible() => ((TestVisualSettingsContainer)CurrentStoryboardContainer).CurrentAlpha <= 1; + public bool IsStoryboardInvisible() => ((TestUserDimContainer)CurrentStoryboardContainer).CurrentAlpha <= 1; [BackgroundDependencyLoader] private void load(OsuConfigManager config) @@ -396,7 +396,7 @@ namespace osu.Game.Tests.Visual private class FadeAccessibleBackground : BackgroundScreenBeatmap { - protected override VisualSettingsContainer CreateFadeContainer() => fadeContainer = new TestVisualSettingsContainer { RelativeSizeAxes = Axes.Both }; + protected override UserDimContainer CreateFadeContainer() => fadeContainer = new TestUserDimContainer { RelativeSizeAxes = Axes.Both }; public Color4 CurrentColour => fadeContainer.CurrentColour; @@ -404,7 +404,7 @@ namespace osu.Game.Tests.Visual public Vector2 CurrentBlur => Background.BlurSigma; - private TestVisualSettingsContainer fadeContainer; + private TestUserDimContainer fadeContainer; public FadeAccessibleBackground(WorkingBeatmap beatmap) : base(beatmap) @@ -412,12 +412,12 @@ namespace osu.Game.Tests.Visual } } - private class TestVisualSettingsContainer : VisualSettingsContainer + private class TestUserDimContainer : UserDimContainer { - public Color4 CurrentColour => LocalContainer.Colour; - public float CurrentAlpha => LocalContainer.Alpha; + public Color4 CurrentColour => DimContainer.Colour; + public float CurrentAlpha => DimContainer.Alpha; - public TestVisualSettingsContainer(bool isStoryboard = false) + public TestUserDimContainer(bool isStoryboard = false) : base(isStoryboard) { } diff --git a/osu.Game/Graphics/Containers/VisualSettingsContainer.cs b/osu.Game/Graphics/Containers/UserDimContainer.cs similarity index 80% rename from osu.Game/Graphics/Containers/VisualSettingsContainer.cs rename to osu.Game/Graphics/Containers/UserDimContainer.cs index 1ed4f0e23e..68c9c89226 100644 --- a/osu.Game/Graphics/Containers/VisualSettingsContainer.cs +++ b/osu.Game/Graphics/Containers/UserDimContainer.cs @@ -16,7 +16,7 @@ namespace osu.Game.Graphics.Containers /// A container that applies user-configured visual settings to its contents. /// This container specifies behavior that applies to both Storyboards and Backgrounds. /// - public class VisualSettingsContainer : Container + public class UserDimContainer : Container { private const float background_fade_duration = 800; @@ -36,9 +36,9 @@ namespace osu.Game.Graphics.Containers /// public readonly Bindable StoryboardReplacesBackground = new Bindable(); - protected Container LocalContainer { get; } + protected Container DimContainer { get; } - protected override Container Content => LocalContainer; + protected override Container Content => DimContainer; private readonly bool isStoryboard; @@ -49,7 +49,7 @@ namespace osu.Game.Graphics.Containers : new Vector2(AddedBlur.Value); /// - /// Creates a new . + /// Creates a new . /// /// Whether or not this instance contains a storyboard. /// @@ -57,10 +57,10 @@ namespace osu.Game.Graphics.Containers /// and can cause backgrounds to become hidden via . Storyboards are also currently unable to be blurred. /// /// - public VisualSettingsContainer(bool isStoryboard = false) + public UserDimContainer(bool isStoryboard = false) { this.isStoryboard = isStoryboard; - AddInternal(LocalContainer = new Container { RelativeSizeAxes = Axes.Both }); + AddInternal(DimContainer = new Container { RelativeSizeAxes = Axes.Both }); } [BackgroundDependencyLoader] @@ -87,14 +87,14 @@ namespace osu.Game.Graphics.Containers { if (isStoryboard) { - LocalContainer.FadeTo(!showStoryboard.Value || dimLevel.Value == 1 ? 0 : 1, background_fade_duration, Easing.OutQuint); + DimContainer.FadeTo(!showStoryboard.Value || dimLevel.Value == 1 ? 0 : 1, background_fade_duration, Easing.OutQuint); } else { // The background needs to be hidden in the case of it being replaced by the storyboard - LocalContainer.FadeTo(showStoryboard.Value && StoryboardReplacesBackground.Value ? 0 : 1, background_fade_duration, Easing.OutQuint); + DimContainer.FadeTo(showStoryboard.Value && StoryboardReplacesBackground.Value ? 0 : 1, background_fade_duration, Easing.OutQuint); - foreach (Drawable c in LocalContainer) + foreach (Drawable c in DimContainer) { // Only blur if this container contains a background // We can't blur the container like we did with the dim because buffered containers add considerable draw overhead. @@ -103,7 +103,7 @@ namespace osu.Game.Graphics.Containers } } - LocalContainer.FadeColour(EnableVisualSettings.Value ? OsuColour.Gray(1 - (float)dimLevel.Value) : Color4.White, background_fade_duration, Easing.OutQuint); + DimContainer.FadeColour(EnableVisualSettings.Value ? OsuColour.Gray(1 - (float)dimLevel.Value) : Color4.White, background_fade_duration, Easing.OutQuint); } } } diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index 3e3315d03a..901d1aa2e5 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -24,9 +24,9 @@ namespace osu.Game.Screens.Backgrounds public readonly Bindable AddedBlur = new Bindable(); - private readonly VisualSettingsContainer fadeContainer; + private readonly UserDimContainer fadeContainer; - protected virtual VisualSettingsContainer CreateFadeContainer() => new VisualSettingsContainer { RelativeSizeAxes = Axes.Both }; + protected virtual UserDimContainer CreateFadeContainer() => new UserDimContainer { RelativeSizeAxes = Axes.Both }; public virtual WorkingBeatmap Beatmap { diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 77f69eb80e..042711d820 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -71,9 +71,9 @@ namespace osu.Game.Screens.Play private FailOverlay failOverlay; private DrawableStoryboard storyboard; - protected VisualSettingsContainer StoryboardContainer { get; private set; } + protected UserDimContainer StoryboardContainer { get; private set; } - protected virtual VisualSettingsContainer CreateStoryboardContainer() => new VisualSettingsContainer(true) + protected virtual UserDimContainer CreateStoryboardContainer() => new UserDimContainer(true) { RelativeSizeAxes = Axes.Both, Alpha = 1, From df37973e842028b9bb834599343ab4ff151958f5 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Tue, 19 Mar 2019 13:13:19 +0900 Subject: [PATCH 09/34] Move showstoryboard into player --- osu.Game/Screens/Play/Player.cs | 7 +++++-- osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs | 8 -------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 042711d820..12977aaae3 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -73,6 +73,8 @@ namespace osu.Game.Screens.Play private DrawableStoryboard storyboard; protected UserDimContainer StoryboardContainer { get; private set; } + private Bindable showStoryboard; + protected virtual UserDimContainer CreateStoryboardContainer() => new UserDimContainer(true) { RelativeSizeAxes = Axes.Both, @@ -97,6 +99,7 @@ namespace osu.Game.Screens.Play sampleRestart = audio.Sample.Get(@"Gameplay/restart"); mouseWheelDisabled = config.GetBindable(OsuSetting.MouseDisableWheel); + showStoryboard = config.GetBindable(OsuSetting.ShowStoryboard); ScoreProcessor = RulesetContainer.CreateScoreProcessor(); if (!ScoreProcessor.Mode.Disabled) @@ -169,7 +172,7 @@ namespace osu.Game.Screens.Play // bind clock into components that require it RulesetContainer.IsPaused.BindTo(gameplayClockContainer.IsPaused); - if (ShowStoryboard.Value) + if (showStoryboard.Value) initializeStoryboard(false); // Bind ScoreProcessor to ourselves @@ -313,7 +316,7 @@ namespace osu.Game.Screens.Play .Delay(250) .FadeIn(250); - ShowStoryboard.ValueChanged += enabled => + showStoryboard.ValueChanged += enabled => { if (enabled.NewValue) initializeStoryboard(true); }; diff --git a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs index 174e39f3cb..9eda1be818 100644 --- a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs +++ b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs @@ -13,13 +13,5 @@ namespace osu.Game.Screens.Play protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap.Value); protected new BackgroundScreenBeatmap Background => (BackgroundScreenBeatmap)base.Background; - - protected Bindable ShowStoryboard; - - [BackgroundDependencyLoader] - private void load(OsuConfigManager config) - { - ShowStoryboard = config.GetBindable(OsuSetting.ShowStoryboard); - } } } From dc26e90a8dad211abce21888944145f9b8add92a Mon Sep 17 00:00:00 2001 From: David Zhao Date: Tue, 19 Mar 2019 13:16:06 +0900 Subject: [PATCH 10/34] Remove unused usings --- osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs index 9eda1be818..d7d2c97598 100644 --- a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs +++ b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs @@ -1,9 +1,6 @@ // 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.Bindables; -using osu.Game.Configuration; using osu.Game.Screens.Backgrounds; namespace osu.Game.Screens.Play From a8e20722866540391a71400e44e16bdae3ea24c3 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Tue, 19 Mar 2019 20:15:28 +0900 Subject: [PATCH 11/34] Make blurtarget private, improve documentation --- .../Visual/TestCaseBackgroundScreenBeatmap.cs | 2 +- .../Graphics/Containers/UserDimContainer.cs | 38 +++++++++++-------- .../Backgrounds/BackgroundScreenBeatmap.cs | 5 +-- osu.Game/Screens/Play/Player.cs | 2 +- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs index 4549f1663d..756f16abc2 100644 --- a/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs +++ b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs @@ -333,7 +333,7 @@ namespace osu.Game.Tests.Visual { RelativeSizeAxes = Axes.Both, Alpha = 1, - EnableVisualSettings = { Value = true } + EnableUserDim = { Value = true } }; } diff --git a/osu.Game/Graphics/Containers/UserDimContainer.cs b/osu.Game/Graphics/Containers/UserDimContainer.cs index 68c9c89226..3593394495 100644 --- a/osu.Game/Graphics/Containers/UserDimContainer.cs +++ b/osu.Game/Graphics/Containers/UserDimContainer.cs @@ -20,31 +20,37 @@ namespace osu.Game.Graphics.Containers { private const float background_fade_duration = 800; - private Bindable dimLevel { get; set; } - - private Bindable blurLevel { get; set; } - - private Bindable showStoryboard { get; set; } - /// /// Whether or not user-configured dim levels should be applied to the container. /// - public readonly Bindable EnableVisualSettings = new Bindable(); + public readonly Bindable EnableUserDim = new Bindable(); /// /// Whether or not the storyboard loaded should completely hide the background behind it. /// public readonly Bindable StoryboardReplacesBackground = new Bindable(); + /// + /// The amount of blur to be applied to the background in addition to user-specified blur. + /// + /// + /// Used in contexts where there can potentially be both user and screen-specified blurring occuring at the same time, such as in + /// + public Bindable AddedBlur = new Bindable(); + + private Bindable dimLevel { get; set; } + + private Bindable blurLevel { get; set; } + + private Bindable showStoryboard { get; set; } + protected Container DimContainer { get; } protected override Container Content => DimContainer; private readonly bool isStoryboard; - public Bindable AddedBlur = new Bindable(); - - public Vector2 BlurTarget => EnableVisualSettings.Value + private Vector2 blurTarget => EnableUserDim.Value ? new Vector2(AddedBlur.Value + (float)blurLevel.Value * 25) : new Vector2(AddedBlur.Value); @@ -69,7 +75,7 @@ namespace osu.Game.Graphics.Containers dimLevel = config.GetBindable(OsuSetting.DimLevel); blurLevel = config.GetBindable(OsuSetting.BlurLevel); showStoryboard = config.GetBindable(OsuSetting.ShowStoryboard); - EnableVisualSettings.ValueChanged += _ => UpdateVisuals(); + EnableUserDim.ValueChanged += _ => UpdateVisuals(); dimLevel.ValueChanged += _ => UpdateVisuals(); blurLevel.ValueChanged += _ => UpdateVisuals(); showStoryboard.ValueChanged += _ => UpdateVisuals(); @@ -83,7 +89,7 @@ namespace osu.Game.Graphics.Containers UpdateVisuals(); } - public void UpdateVisuals() + public void UpdateVisuals(bool instant = false) { if (isStoryboard) { @@ -97,13 +103,13 @@ namespace osu.Game.Graphics.Containers foreach (Drawable c in DimContainer) { // Only blur if this container contains a background - // We can't blur the container like we did with the dim because buffered containers add considerable draw overhead. - // As a result, this blurs the background directly. - ((Background)c)?.BlurTo(BlurTarget, background_fade_duration, Easing.OutQuint); + // We can't blur the container like we did with the dim because buffered containers add considerable draw overhead. As a result, this blurs the background directly. + // We need to support instant blurring here in the case of SongSelect, where blurring shouldn't be from 0 every time the beatmap is changed. + ((Background)c)?.BlurTo(blurTarget, instant ? 0 : background_fade_duration, Easing.OutQuint); } } - DimContainer.FadeColour(EnableVisualSettings.Value ? OsuColour.Gray(1 - (float)dimLevel.Value) : Color4.White, background_fade_duration, Easing.OutQuint); + DimContainer.FadeColour(EnableUserDim.Value ? OsuColour.Gray(1 - (float)dimLevel.Value) : Color4.White, background_fade_duration, Easing.OutQuint); } } } diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index 901d1aa2e5..1baa711f86 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -53,8 +53,7 @@ namespace osu.Game.Screens.Backgrounds b.Depth = newDepth; fadeContainer.Add(Background = b); - fadeContainer.UpdateVisuals(); - Background.BlurSigma = fadeContainer.BlurTarget; + fadeContainer.UpdateVisuals(true); StoryboardReplacesBackground.BindTo(fadeContainer.StoryboardReplacesBackground); })); }); @@ -65,7 +64,7 @@ namespace osu.Game.Screens.Backgrounds { Beatmap = beatmap; InternalChild = fadeContainer = CreateFadeContainer(); - fadeContainer.EnableVisualSettings.BindTo(EnableVisualSettings); + fadeContainer.EnableUserDim.BindTo(EnableVisualSettings); fadeContainer.AddedBlur.BindTo(AddedBlur); } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 12977aaae3..fc24e55de2 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -79,7 +79,7 @@ namespace osu.Game.Screens.Play { RelativeSizeAxes = Axes.Both, Alpha = 1, - EnableVisualSettings = { Value = true } + EnableUserDim = { Value = true } }; public bool LoadedBeatmapSuccessfully => RulesetContainer?.Objects.Any() == true; From 3af3baf5e61eca0475ddf5c085f0a7f9cbf82815 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Tue, 19 Mar 2019 20:22:21 +0900 Subject: [PATCH 12/34] Fix merge --- osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs index 8967e95782..263cfe0fc8 100644 --- a/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs +++ b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs @@ -97,7 +97,7 @@ namespace osu.Game.Tests.Visual public void PlayerLoaderSettingsHoverTest() { setupUserSettings(); - AddStep("Start player loader", () => songSelect.Push(playerLoader = new DimAccessiblePlayerLoader(player = new DimAccessiblePlayer()))); + AddStep("Start player loader", () => songSelect.Push(playerLoader = new TestPlayerLoader(player = new TestPlayer()))); AddUntilStep("Wait for Player Loader to load", () => playerLoader?.IsLoaded ?? false); AddAssert("Background retained from song select", () => songSelect.IsBackgroundCurrent()); AddStep("Trigger background preview", () => @@ -205,7 +205,7 @@ namespace osu.Game.Tests.Visual performFullSetup(); var results = new FadeAccessibleResults(new ScoreInfo { User = new User { Username = "osu!" } }); AddStep("Transition to Results", () => player.Push(results)); - AddUntilStep(results.IsCurrentScreen, "Wait for results is current"); + AddUntilStep("Wait for results is current", results.IsCurrentScreen); waitForDim(); AddAssert("Screen is undimmed, original background retained", () => songSelect.IsBackgroundUndimmed() && songSelect.IsBackgroundCurrent() && results.IsBlurCorrect()); From 15637f9c4a9ef0d3bdc1af745223b4523464779b Mon Sep 17 00:00:00 2001 From: David Zhao Date: Wed, 20 Mar 2019 14:17:35 +0900 Subject: [PATCH 13/34] Rework instant blur logic such that updateVisuals doesn't need to be public --- .../Visual/TestCaseBackgroundScreenBeatmap.cs | 2 +- .../Graphics/Containers/UserDimContainer.cs | 47 ++++++++++++------- osu.Game/Screens/BackgroundScreen.cs | 3 -- .../Backgrounds/BackgroundScreenBeatmap.cs | 15 ++++-- .../Backgrounds/BackgroundScreenCustom.cs | 2 +- .../Backgrounds/BackgroundScreenDefault.cs | 8 ++-- osu.Game/Screens/Play/Player.cs | 5 +- osu.Game/Screens/Play/PlayerLoader.cs | 22 ++++----- osu.Game/Screens/Ranking/Results.cs | 2 +- osu.Game/Screens/Select/SongSelect.cs | 2 +- 10 files changed, 61 insertions(+), 47 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs index 263cfe0fc8..084bb6a02e 100644 --- a/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs +++ b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs @@ -273,7 +273,7 @@ namespace osu.Game.Tests.Visual protected override BackgroundScreen CreateBackground() { FadeAccessibleBackground background = new FadeAccessibleBackground(Beatmap.Value); - DimEnabled.BindTo(background.EnableVisualSettings); + DimEnabled.BindTo(background.EnableUserDim); return background; } diff --git a/osu.Game/Graphics/Containers/UserDimContainer.cs b/osu.Game/Graphics/Containers/UserDimContainer.cs index 3593394495..d68f607dcd 100644 --- a/osu.Game/Graphics/Containers/UserDimContainer.cs +++ b/osu.Game/Graphics/Containers/UserDimContainer.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; @@ -36,7 +37,7 @@ namespace osu.Game.Graphics.Containers /// /// Used in contexts where there can potentially be both user and screen-specified blurring occuring at the same time, such as in /// - public Bindable AddedBlur = new Bindable(); + public readonly Bindable BlurAmount = new Bindable(); private Bindable dimLevel { get; set; } @@ -51,8 +52,10 @@ namespace osu.Game.Graphics.Containers private readonly bool isStoryboard; private Vector2 blurTarget => EnableUserDim.Value - ? new Vector2(AddedBlur.Value + (float)blurLevel.Value * 25) - : new Vector2(AddedBlur.Value); + ? new Vector2(BlurAmount.Value + (float)blurLevel.Value * 25) + : new Vector2(BlurAmount.Value); + + private Background background => DimContainer.Children.OfType().FirstOrDefault(); /// /// Creates a new . @@ -69,27 +72,38 @@ namespace osu.Game.Graphics.Containers AddInternal(DimContainer = new Container { RelativeSizeAxes = Axes.Both }); } + /// + /// Set the blur of the background in this UserDimContainer to our blur target instantly. + /// + /// + /// We need to support instant blurring here in the case of changing beatmap backgrounds, where blurring shouldn't be from 0 every time the beatmap is changed. + /// + public void ApplyInstantBlur() + { + background?.BlurTo(blurTarget, 0, Easing.OutQuint); + } + [BackgroundDependencyLoader] private void load(OsuConfigManager config) { dimLevel = config.GetBindable(OsuSetting.DimLevel); blurLevel = config.GetBindable(OsuSetting.BlurLevel); showStoryboard = config.GetBindable(OsuSetting.ShowStoryboard); - EnableUserDim.ValueChanged += _ => UpdateVisuals(); - dimLevel.ValueChanged += _ => UpdateVisuals(); - blurLevel.ValueChanged += _ => UpdateVisuals(); - showStoryboard.ValueChanged += _ => UpdateVisuals(); - StoryboardReplacesBackground.ValueChanged += _ => UpdateVisuals(); - AddedBlur.ValueChanged += _ => UpdateVisuals(); + EnableUserDim.ValueChanged += _ => updateVisuals(); + dimLevel.ValueChanged += _ => updateVisuals(); + blurLevel.ValueChanged += _ => updateVisuals(); + showStoryboard.ValueChanged += _ => updateVisuals(); + StoryboardReplacesBackground.ValueChanged += _ => updateVisuals(); + BlurAmount.ValueChanged += _ => updateVisuals(); } protected override void LoadComplete() { base.LoadComplete(); - UpdateVisuals(); + updateVisuals(); } - public void UpdateVisuals(bool instant = false) + private void updateVisuals() { if (isStoryboard) { @@ -100,13 +114,10 @@ namespace osu.Game.Graphics.Containers // The background needs to be hidden in the case of it being replaced by the storyboard DimContainer.FadeTo(showStoryboard.Value && StoryboardReplacesBackground.Value ? 0 : 1, background_fade_duration, Easing.OutQuint); - foreach (Drawable c in DimContainer) - { - // Only blur if this container contains a background - // We can't blur the container like we did with the dim because buffered containers add considerable draw overhead. As a result, this blurs the background directly. - // We need to support instant blurring here in the case of SongSelect, where blurring shouldn't be from 0 every time the beatmap is changed. - ((Background)c)?.BlurTo(blurTarget, instant ? 0 : background_fade_duration, Easing.OutQuint); - } + // Only blur if this container contains a background + // We can't blur the container like we did with the dim because buffered containers add considerable draw overhead. + // As a result, this blurs the background directly. + background?.BlurTo(blurTarget, background_fade_duration, Easing.OutQuint); } DimContainer.FadeColour(EnableUserDim.Value ? OsuColour.Gray(1 - (float)dimLevel.Value) : Color4.White, background_fade_duration, Easing.OutQuint); diff --git a/osu.Game/Screens/BackgroundScreen.cs b/osu.Game/Screens/BackgroundScreen.cs index 7eca192a6b..bbe162cf7c 100644 --- a/osu.Game/Screens/BackgroundScreen.cs +++ b/osu.Game/Screens/BackgroundScreen.cs @@ -5,15 +5,12 @@ using System; using osu.Framework.Screens; using osu.Framework.Graphics; using osu.Framework.Input.Events; -using osu.Game.Graphics.Backgrounds; using osuTK; namespace osu.Game.Screens { public abstract class BackgroundScreen : Screen, IEquatable { - protected Background Background; - protected BackgroundScreen() { Anchor = Anchor.Centre; diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index 1baa711f86..5f86fe8d20 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -13,16 +13,21 @@ namespace osu.Game.Screens.Backgrounds { public class BackgroundScreenBeatmap : BackgroundScreen { + protected Background Background; + private WorkingBeatmap beatmap; /// /// Whether or not user dim settings should be applied to this Background. /// - public readonly Bindable EnableVisualSettings = new Bindable(); + public readonly Bindable EnableUserDim = new Bindable(); public readonly Bindable StoryboardReplacesBackground = new Bindable(); - public readonly Bindable AddedBlur = new Bindable(); + /// + /// The amount of blur to be applied in addition to user-specified blur. + /// + public readonly Bindable BlurAmount = new Bindable(); private readonly UserDimContainer fadeContainer; @@ -53,7 +58,7 @@ namespace osu.Game.Screens.Backgrounds b.Depth = newDepth; fadeContainer.Add(Background = b); - fadeContainer.UpdateVisuals(true); + fadeContainer.ApplyInstantBlur(); StoryboardReplacesBackground.BindTo(fadeContainer.StoryboardReplacesBackground); })); }); @@ -64,8 +69,8 @@ namespace osu.Game.Screens.Backgrounds { Beatmap = beatmap; InternalChild = fadeContainer = CreateFadeContainer(); - fadeContainer.EnableUserDim.BindTo(EnableVisualSettings); - fadeContainer.AddedBlur.BindTo(AddedBlur); + fadeContainer.EnableUserDim.BindTo(EnableUserDim); + fadeContainer.BlurAmount.BindTo(BlurAmount); } public override bool Equals(BackgroundScreen other) diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenCustom.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenCustom.cs index 538f347737..0cb41bc562 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenCustom.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenCustom.cs @@ -12,7 +12,7 @@ namespace osu.Game.Screens.Backgrounds public BackgroundScreenCustom(string textureName) { this.textureName = textureName; - AddInternal(Background = new Background(textureName)); + AddInternal(new Background(textureName)); } public override bool Equals(BackgroundScreen other) diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs index 73590b3318..3aeb2f9923 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs @@ -15,6 +15,8 @@ namespace osu.Game.Screens.Backgrounds { public class BackgroundScreenDefault : BackgroundScreen { + private Background background; + private int currentDisplay; private const int background_count = 5; @@ -39,10 +41,10 @@ namespace osu.Game.Screens.Backgrounds private void display(Background newBackground) { - Background?.FadeOut(800, Easing.InOutSine); - Background?.Expire(); + background?.FadeOut(800, Easing.InOutSine); + background?.Expire(); - AddInternal(Background = newBackground); + AddInternal(background = newBackground); currentDisplay++; } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index fc24e55de2..1ce8bf559d 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -321,7 +321,8 @@ namespace osu.Game.Screens.Play if (enabled.NewValue) initializeStoryboard(true); }; - Background.EnableVisualSettings.Value = true; + Background.EnableUserDim.Value = true; + Background.BlurAmount.Value = 0; Background.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground); StoryboardContainer.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground); @@ -368,7 +369,7 @@ namespace osu.Game.Screens.Play float fadeOutDuration = instant ? 0 : 250; this.FadeOut(fadeOutDuration); - Background.EnableVisualSettings.Value = false; + Background.EnableUserDim.Value = false; storyboardReplacesBackground.Value = false; } diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 4200a7390d..86156e292c 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -119,18 +119,12 @@ namespace osu.Game.Screens.Play private void contentIn() { - Background.AddedBlur.Value = BACKGROUND_BLUR; - Background.EnableVisualSettings.Value = false; - content.ScaleTo(1, 650, Easing.OutQuint); content.FadeInFromZero(400); } private void contentOut() { - Background.AddedBlur.Value = 0; - Background.EnableVisualSettings.Value = true; - content.ScaleTo(0.7f, 300, Easing.InQuint); content.FadeOut(250); } @@ -166,10 +160,12 @@ namespace osu.Game.Screens.Play protected override bool OnHover(HoverEvent e) { + // Acts as an "on hover lost" trigger for the visual settings panel. + // Returns background dim and blur to the values specified by PlayerLoader. if (this.IsCurrentScreen()) { - Background.AddedBlur.Value = BACKGROUND_BLUR; - Background.EnableVisualSettings.Value = false; + Background.BlurAmount.Value = BACKGROUND_BLUR; + Background.EnableUserDim.Value = false; } return base.OnHover(e); @@ -177,12 +173,14 @@ namespace osu.Game.Screens.Play protected override void OnHoverLost(HoverLostEvent e) { + // Acts as an "on hover" trigger for the visual settings panel. + // Preview user-defined background dim and blur when hovered on the visual settings panel. if (GetContainingInputManager()?.HoveredDrawables.Contains(VisualSettings) == true) { if (this.IsCurrentScreen() && Background != null) { - Background.AddedBlur.Value = 0; - Background.EnableVisualSettings.Value = true; + Background.BlurAmount.Value = 0; + Background.EnableUserDim.Value = true; } } @@ -241,7 +239,7 @@ namespace osu.Game.Screens.Play public override void OnSuspending(IScreen next) { - Background.EnableVisualSettings.Value = true; + Background.EnableUserDim.Value = true; base.OnSuspending(next); cancelLoad(); @@ -253,7 +251,7 @@ namespace osu.Game.Screens.Play this.FadeOut(150); cancelLoad(); - Background.EnableVisualSettings.Value = false; + Background.EnableUserDim.Value = false; return base.OnExiting(next); } diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index bd8daa6b03..dafb4c0aad 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -58,7 +58,7 @@ namespace osu.Game.Screens.Ranking public override void OnEntering(IScreen last) { base.OnEntering(last); - ((BackgroundScreenBeatmap)Background).AddedBlur.Value = BACKGROUND_BLUR; + ((BackgroundScreenBeatmap)Background).BlurAmount.Value = BACKGROUND_BLUR; Background.ScaleTo(1.1f, transition_time, Easing.OutQuint); allCircles.ForEach(c => diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 385c4e0a0d..9985f984a0 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -556,7 +556,7 @@ namespace osu.Game.Screens.Select if (Background is BackgroundScreenBeatmap backgroundModeBeatmap) { backgroundModeBeatmap.Beatmap = beatmap; - backgroundModeBeatmap.AddedBlur.Value = BACKGROUND_BLUR; + backgroundModeBeatmap.BlurAmount.Value = BACKGROUND_BLUR; backgroundModeBeatmap.FadeColour(Color4.White, 250); } From 996464468342286adcf37246787a64eff2683481 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Wed, 20 Mar 2019 14:37:32 +0900 Subject: [PATCH 14/34] Fix merge --- osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index 18d6fcc317..8b04b545f5 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -39,6 +39,7 @@ namespace osu.Game.Screens.Backgrounds Beatmap = beatmap; InternalChild = fadeContainer = CreateFadeContainer(); fadeContainer.EnableUserDim.BindTo(EnableUserDim); + fadeContainer.BlurAmount.BindTo(BlurAmount); } [BackgroundDependencyLoader] From 86658e357bae27c4c9559227c135301a85d50319 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Wed, 20 Mar 2019 14:55:52 +0900 Subject: [PATCH 15/34] Override add instead --- .../Graphics/Containers/UserDimContainer.cs | 22 ++++++++----------- .../Backgrounds/BackgroundScreenBeatmap.cs | 1 - 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/osu.Game/Graphics/Containers/UserDimContainer.cs b/osu.Game/Graphics/Containers/UserDimContainer.cs index d68f607dcd..22b0175a94 100644 --- a/osu.Game/Graphics/Containers/UserDimContainer.cs +++ b/osu.Game/Graphics/Containers/UserDimContainer.cs @@ -55,8 +55,6 @@ namespace osu.Game.Graphics.Containers ? new Vector2(BlurAmount.Value + (float)blurLevel.Value * 25) : new Vector2(BlurAmount.Value); - private Background background => DimContainer.Children.OfType().FirstOrDefault(); - /// /// Creates a new . /// @@ -72,15 +70,13 @@ namespace osu.Game.Graphics.Containers AddInternal(DimContainer = new Container { RelativeSizeAxes = Axes.Both }); } - /// - /// Set the blur of the background in this UserDimContainer to our blur target instantly. - /// - /// - /// We need to support instant blurring here in the case of changing beatmap backgrounds, where blurring shouldn't be from 0 every time the beatmap is changed. - /// - public void ApplyInstantBlur() + public override void Add(Drawable drawable) { - background?.BlurTo(blurTarget, 0, Easing.OutQuint); + // We need to blur instantly here in the case of changing beatmap backgrounds, where blurring shouldn't be from 0 every time the beatmap is changed. + if (drawable is Background b) + b.BlurTo(blurTarget, 0, Easing.OutQuint); + + base.Add(drawable); } [BackgroundDependencyLoader] @@ -114,10 +110,10 @@ namespace osu.Game.Graphics.Containers // The background needs to be hidden in the case of it being replaced by the storyboard DimContainer.FadeTo(showStoryboard.Value && StoryboardReplacesBackground.Value ? 0 : 1, background_fade_duration, Easing.OutQuint); - // Only blur if this container contains a background + // This only works if the background is a direct child of DimContainer. // We can't blur the container like we did with the dim because buffered containers add considerable draw overhead. - // As a result, this blurs the background directly. - background?.BlurTo(blurTarget, background_fade_duration, Easing.OutQuint); + // As a result, this blurs the background directly via the direct children of DimContainer. + DimContainer.Children.OfType().FirstOrDefault()?.BlurTo(blurTarget, background_fade_duration, Easing.OutQuint); } DimContainer.FadeColour(EnableUserDim.Value ? OsuColour.Gray(1 - (float)dimLevel.Value) : Color4.White, background_fade_duration, Easing.OutQuint); diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index 8b04b545f5..111cc9d2c1 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -86,7 +86,6 @@ namespace osu.Game.Screens.Backgrounds b.Depth = newDepth; fadeContainer.Add(Background = b); - fadeContainer.ApplyInstantBlur(); StoryboardReplacesBackground.BindTo(fadeContainer.StoryboardReplacesBackground); } From 2467ece0205dc2b4827269c370892556bddd1ec9 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Wed, 20 Mar 2019 14:58:32 +0900 Subject: [PATCH 16/34] store a field --- osu.Game/Graphics/Containers/UserDimContainer.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/Containers/UserDimContainer.cs b/osu.Game/Graphics/Containers/UserDimContainer.cs index 22b0175a94..61129b43af 100644 --- a/osu.Game/Graphics/Containers/UserDimContainer.cs +++ b/osu.Game/Graphics/Containers/UserDimContainer.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; @@ -55,6 +54,8 @@ namespace osu.Game.Graphics.Containers ? new Vector2(BlurAmount.Value + (float)blurLevel.Value * 25) : new Vector2(BlurAmount.Value); + private Background background; + /// /// Creates a new . /// @@ -74,7 +75,10 @@ namespace osu.Game.Graphics.Containers { // We need to blur instantly here in the case of changing beatmap backgrounds, where blurring shouldn't be from 0 every time the beatmap is changed. if (drawable is Background b) + { + background = b; b.BlurTo(blurTarget, 0, Easing.OutQuint); + } base.Add(drawable); } @@ -113,7 +117,7 @@ namespace osu.Game.Graphics.Containers // This only works if the background is a direct child of DimContainer. // We can't blur the container like we did with the dim because buffered containers add considerable draw overhead. // As a result, this blurs the background directly via the direct children of DimContainer. - DimContainer.Children.OfType().FirstOrDefault()?.BlurTo(blurTarget, background_fade_duration, Easing.OutQuint); + background?.BlurTo(blurTarget, background_fade_duration, Easing.OutQuint); } DimContainer.FadeColour(EnableUserDim.Value ? OsuColour.Gray(1 - (float)dimLevel.Value) : Color4.White, background_fade_duration, Easing.OutQuint); From f670e4664dd8f1dafd4fa1e38093b17f5106ba90 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Wed, 20 Mar 2019 15:06:07 +0900 Subject: [PATCH 17/34] Amend comment --- osu.Game/Graphics/Containers/UserDimContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Graphics/Containers/UserDimContainer.cs b/osu.Game/Graphics/Containers/UserDimContainer.cs index 61129b43af..beb9653b71 100644 --- a/osu.Game/Graphics/Containers/UserDimContainer.cs +++ b/osu.Game/Graphics/Containers/UserDimContainer.cs @@ -73,7 +73,7 @@ namespace osu.Game.Graphics.Containers public override void Add(Drawable drawable) { - // We need to blur instantly here in the case of changing beatmap backgrounds, where blurring shouldn't be from 0 every time the beatmap is changed. + // Make sure we're already at the correct blur target when a background is added to the container. if (drawable is Background b) { background = b; From 1086688e0ad8505efeee32c74a1a6221a7b18d29 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Wed, 20 Mar 2019 15:13:59 +0900 Subject: [PATCH 18/34] Fix variable hiding --- .../Screens/Backgrounds/BackgroundScreenDefault.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs index 7697b9959e..7092ac0c4a 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs @@ -58,16 +58,16 @@ namespace osu.Game.Screens.Backgrounds private Background createBackground() { - Background background; + Background newBackground; if (user.Value?.IsSupporter ?? false) - background = new SkinnedBackground(skin.Value, backgroundName); + newBackground = new SkinnedBackground(skin.Value, backgroundName); else - background = new Background(backgroundName); + newBackground = new Background(backgroundName); - background.Depth = currentDisplay; + newBackground.Depth = currentDisplay; - return background; + return newBackground; } private class SkinnedBackground : Background From e9034c8a30bbd4b0b412f04d9a1d055b804bf7e6 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Wed, 20 Mar 2019 16:50:47 +0900 Subject: [PATCH 19/34] Move blurring logic into Update instead --- osu.Game/Screens/Play/PlayerLoader.cs | 56 ++++++++++++--------------- 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 86156e292c..a2d433107b 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -2,13 +2,11 @@ // See the LICENCE file in the repository root for full licence text. using System; -using System.Linq; using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; -using osu.Framework.Input.Events; using osu.Framework.Localisation; using osu.Framework.Screens; using osu.Framework.Threading; @@ -41,6 +39,8 @@ namespace osu.Game.Screens.Play public override bool DisallowExternalBeatmapRulesetChanges => true; + public override bool HandlePositionalInput => true; + private Task loadTask; public PlayerLoader(Func createPlayer) @@ -158,35 +158,6 @@ namespace osu.Game.Screens.Play private bool readyForPush => player.LoadState == LoadState.Ready && IsHovered && GetContainingInputManager()?.DraggedDrawable == null; - protected override bool OnHover(HoverEvent e) - { - // Acts as an "on hover lost" trigger for the visual settings panel. - // Returns background dim and blur to the values specified by PlayerLoader. - if (this.IsCurrentScreen()) - { - Background.BlurAmount.Value = BACKGROUND_BLUR; - Background.EnableUserDim.Value = false; - } - - return base.OnHover(e); - } - - protected override void OnHoverLost(HoverLostEvent e) - { - // Acts as an "on hover" trigger for the visual settings panel. - // Preview user-defined background dim and blur when hovered on the visual settings panel. - if (GetContainingInputManager()?.HoveredDrawables.Contains(VisualSettings) == true) - { - if (this.IsCurrentScreen() && Background != null) - { - Background.BlurAmount.Value = 0; - Background.EnableUserDim.Value = true; - } - } - - base.OnHoverLost(e); - } - private void pushWhenLoaded() { if (!this.IsCurrentScreen()) return; @@ -267,6 +238,29 @@ namespace osu.Game.Screens.Play } } + protected override void Update() + { + base.Update(); + + if (!this.IsCurrentScreen()) + return; + + if (Background.BlurAmount.Value != 0 && VisualSettings.IsHovered) + { + // Acts as an "on hover" trigger for the visual settings panel. + // Preview user-defined background dim and blur when hovered on the visual settings panel. + Background.EnableUserDim.Value = true; + Background.BlurAmount.Value = 0; + } + else if (Background.BlurAmount.Value != BACKGROUND_BLUR && !VisualSettings.IsHovered) + { + // Acts as an "on hover lost" trigger for the visual settings panel. + // Returns background dim and blur to the values specified by PlayerLoader. + Background.EnableUserDim.Value = false; + Background.BlurAmount.Value = BACKGROUND_BLUR; + } + } + private class BeatmapMetadataDisplay : Container { private class MetadataLine : Container From a5916f995eb2e9814ef2faa02d11cfc7e8293fa1 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Wed, 20 Mar 2019 16:54:42 +0900 Subject: [PATCH 20/34] Use the previous conditional instead --- osu.Game/Screens/Play/PlayerLoader.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index a2d433107b..68335f96ce 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Linq; using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Graphics; @@ -245,14 +246,14 @@ namespace osu.Game.Screens.Play if (!this.IsCurrentScreen()) return; - if (Background.BlurAmount.Value != 0 && VisualSettings.IsHovered) + if (GetContainingInputManager()?.HoveredDrawables.Contains(VisualSettings) == true) { // Acts as an "on hover" trigger for the visual settings panel. // Preview user-defined background dim and blur when hovered on the visual settings panel. Background.EnableUserDim.Value = true; Background.BlurAmount.Value = 0; } - else if (Background.BlurAmount.Value != BACKGROUND_BLUR && !VisualSettings.IsHovered) + else { // Acts as an "on hover lost" trigger for the visual settings panel. // Returns background dim and blur to the values specified by PlayerLoader. From fbfef844de0e7ba250a08fee75a1780fd7605e84 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Wed, 20 Mar 2019 17:18:42 +0900 Subject: [PATCH 21/34] Add test case for resuming PlayerLoader --- .../Visual/TestCaseBackgroundScreenBeatmap.cs | 20 +++++++++++++++++++ osu.Game/Screens/Play/PlayerLoader.cs | 2 -- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs index 084bb6a02e..193bc9fb08 100644 --- a/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs +++ b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs @@ -223,6 +223,26 @@ namespace osu.Game.Tests.Visual AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && songSelect.IsBlurCorrect()); } + /// + /// Check if hovering on the visual settings dialogue after resuming from player still previews the background dim. + /// + [Test] + public void ResumeFromPlayerTest() + { + performFullSetup(); + AddStep("Move mouse to Visual Settings", () => InputManager.MoveMouseTo(playerLoader.VisualSettingsPos)); + AddStep("Resume PlayerLoader", () => + { + player.ValidForResume = false; + player.RestartRequested?.Invoke(); + player.Exit(); + }); + waitForDim(); + AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied()); + AddStep("Move mouse to center of screen", () => InputManager.MoveMouseTo(playerLoader.ScreenPos)); + AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && playerLoader.IsBlurCorrect()); + } + private void waitForDim() => AddWaitStep("Wait for dim", 5); private void createFakeStoryboard() => AddStep("Create storyboard", () => diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 68335f96ce..92ff57b799 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -211,8 +211,6 @@ namespace osu.Game.Screens.Play public override void OnSuspending(IScreen next) { - Background.EnableUserDim.Value = true; - base.OnSuspending(next); cancelLoad(); } From b5e8eb2a4a55a27f431c73bba5c549283d9e55df Mon Sep 17 00:00:00 2001 From: David Zhao Date: Wed, 20 Mar 2019 17:31:06 +0900 Subject: [PATCH 22/34] Wait for dim --- osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs index 193bc9fb08..5f5d84af42 100644 --- a/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs +++ b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs @@ -240,6 +240,7 @@ namespace osu.Game.Tests.Visual waitForDim(); AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied()); AddStep("Move mouse to center of screen", () => InputManager.MoveMouseTo(playerLoader.ScreenPos)); + waitForDim(); AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && playerLoader.IsBlurCorrect()); } From 9013afe41243aaee9e13e6646661e3821fc50d02 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Wed, 20 Mar 2019 19:35:40 +0900 Subject: [PATCH 23/34] Query for input manager once --- osu.Game/Screens/Play/PlayerLoader.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 92ff57b799..da51e25b4e 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -8,6 +8,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; +using osu.Framework.Input; using osu.Framework.Localisation; using osu.Framework.Screens; using osu.Framework.Threading; @@ -44,6 +45,8 @@ namespace osu.Game.Screens.Play private Task loadTask; + private InputManager inputManager; + public PlayerLoader(Func createPlayer) { this.createPlayer = createPlayer; @@ -203,6 +206,12 @@ namespace osu.Game.Screens.Play } } + protected override void LoadComplete() + { + inputManager = GetContainingInputManager(); + base.LoadComplete(); + } + private void cancelLoad() { pushDebounce?.Cancel(); @@ -244,7 +253,7 @@ namespace osu.Game.Screens.Play if (!this.IsCurrentScreen()) return; - if (GetContainingInputManager()?.HoveredDrawables.Contains(VisualSettings) == true) + if (inputManager.HoveredDrawables.Contains(VisualSettings)) { // Acts as an "on hover" trigger for the visual settings panel. // Preview user-defined background dim and blur when hovered on the visual settings panel. From 18de9e51c51c4f5b83e8a11cada9288b6e0af09b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 20 Mar 2019 19:38:53 +0900 Subject: [PATCH 24/34] Formatting and naming improvements --- .../Graphics/Containers/UserDimContainer.cs | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/osu.Game/Graphics/Containers/UserDimContainer.cs b/osu.Game/Graphics/Containers/UserDimContainer.cs index beb9653b71..c790d6777d 100644 --- a/osu.Game/Graphics/Containers/UserDimContainer.cs +++ b/osu.Game/Graphics/Containers/UserDimContainer.cs @@ -38,9 +38,9 @@ namespace osu.Game.Graphics.Containers /// public readonly Bindable BlurAmount = new Bindable(); - private Bindable dimLevel { get; set; } + private Bindable userDimLevel { get; set; } - private Bindable blurLevel { get; set; } + private Bindable userBlurLevel { get; set; } private Bindable showStoryboard { get; set; } @@ -51,7 +51,7 @@ namespace osu.Game.Graphics.Containers private readonly bool isStoryboard; private Vector2 blurTarget => EnableUserDim.Value - ? new Vector2(BlurAmount.Value + (float)blurLevel.Value * 25) + ? new Vector2(BlurAmount.Value + (float)userBlurLevel.Value * 25) : new Vector2(BlurAmount.Value); private Background background; @@ -77,7 +77,7 @@ namespace osu.Game.Graphics.Containers if (drawable is Background b) { background = b; - b.BlurTo(blurTarget, 0, Easing.OutQuint); + background.BlurTo(blurTarget, 0, Easing.OutQuint); } base.Add(drawable); @@ -86,12 +86,13 @@ namespace osu.Game.Graphics.Containers [BackgroundDependencyLoader] private void load(OsuConfigManager config) { - dimLevel = config.GetBindable(OsuSetting.DimLevel); - blurLevel = config.GetBindable(OsuSetting.BlurLevel); + userDimLevel = config.GetBindable(OsuSetting.DimLevel); + userBlurLevel = config.GetBindable(OsuSetting.BlurLevel); showStoryboard = config.GetBindable(OsuSetting.ShowStoryboard); + EnableUserDim.ValueChanged += _ => updateVisuals(); - dimLevel.ValueChanged += _ => updateVisuals(); - blurLevel.ValueChanged += _ => updateVisuals(); + userDimLevel.ValueChanged += _ => updateVisuals(); + userBlurLevel.ValueChanged += _ => updateVisuals(); showStoryboard.ValueChanged += _ => updateVisuals(); StoryboardReplacesBackground.ValueChanged += _ => updateVisuals(); BlurAmount.ValueChanged += _ => updateVisuals(); @@ -107,7 +108,7 @@ namespace osu.Game.Graphics.Containers { if (isStoryboard) { - DimContainer.FadeTo(!showStoryboard.Value || dimLevel.Value == 1 ? 0 : 1, background_fade_duration, Easing.OutQuint); + DimContainer.FadeTo(!showStoryboard.Value || userDimLevel.Value == 1 ? 0 : 1, background_fade_duration, Easing.OutQuint); } else { @@ -120,7 +121,7 @@ namespace osu.Game.Graphics.Containers background?.BlurTo(blurTarget, background_fade_duration, Easing.OutQuint); } - DimContainer.FadeColour(EnableUserDim.Value ? OsuColour.Gray(1 - (float)dimLevel.Value) : Color4.White, background_fade_duration, Easing.OutQuint); + DimContainer.FadeColour(EnableUserDim.Value ? OsuColour.Gray(1 - (float)userDimLevel.Value) : Color4.White, background_fade_duration, Easing.OutQuint); } } } From cda5bc28c8a0104ceb845f22a47b79e28633bb88 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 20 Mar 2019 19:41:20 +0900 Subject: [PATCH 25/34] Add proper comment --- osu.Game/Screens/Play/PlayerLoader.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index da51e25b4e..50816a873f 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -253,16 +253,16 @@ namespace osu.Game.Screens.Play if (!this.IsCurrentScreen()) return; + // We need to perform this check here rather than in OnHover as any number of children of VisualSettings + // may also be handling the hover events. if (inputManager.HoveredDrawables.Contains(VisualSettings)) { - // Acts as an "on hover" trigger for the visual settings panel. // Preview user-defined background dim and blur when hovered on the visual settings panel. Background.EnableUserDim.Value = true; Background.BlurAmount.Value = 0; } else { - // Acts as an "on hover lost" trigger for the visual settings panel. // Returns background dim and blur to the values specified by PlayerLoader. Background.EnableUserDim.Value = false; Background.BlurAmount.Value = BACKGROUND_BLUR; From 8543e8c36f5416aab16b0ad9a4b2fc008d4ecbd6 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Wed, 20 Mar 2019 19:42:39 +0900 Subject: [PATCH 26/34] Put loadcomplete next to other protected overrides --- osu.Game/Screens/Play/PlayerLoader.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index da51e25b4e..ed8adc0e5f 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -157,6 +157,12 @@ namespace osu.Game.Screens.Play logo.Delay(resuming ? 0 : 500).MoveToOffset(new Vector2(0, -0.24f), 500, Easing.InOutExpo); } + protected override void LoadComplete() + { + inputManager = GetContainingInputManager(); + base.LoadComplete(); + } + private ScheduledDelegate pushDebounce; protected VisualSettings VisualSettings; @@ -206,12 +212,6 @@ namespace osu.Game.Screens.Play } } - protected override void LoadComplete() - { - inputManager = GetContainingInputManager(); - base.LoadComplete(); - } - private void cancelLoad() { pushDebounce?.Cancel(); From 01f795b0464757dec7e2f7edd57fc8c7025bd24f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 20 Mar 2019 19:45:04 +0900 Subject: [PATCH 27/34] Make restart public rather than reimplementing --- osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs | 7 +------ osu.Game/Screens/Play/Player.cs | 8 ++++---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs index 5f5d84af42..6f7d465cfe 100644 --- a/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs +++ b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs @@ -231,12 +231,7 @@ namespace osu.Game.Tests.Visual { performFullSetup(); AddStep("Move mouse to Visual Settings", () => InputManager.MoveMouseTo(playerLoader.VisualSettingsPos)); - AddStep("Resume PlayerLoader", () => - { - player.ValidForResume = false; - player.RestartRequested?.Invoke(); - player.Exit(); - }); + AddStep("Resume PlayerLoader", () => player.Restart()); waitForDim(); AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied()); AddStep("Move mouse to center of screen", () => InputManager.MoveMouseTo(playerLoader.ScreenPos)); diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 1ce8bf559d..7071841722 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -112,7 +112,7 @@ namespace osu.Game.Screens.Play PausableGameplayContainer = new PausableGameplayContainer { Retries = RestartCount, - OnRetry = restart, + OnRetry = Restart, OnQuit = performUserRequestedExit, Start = gameplayClockContainer.Start, Stop = gameplayClockContainer.Stop, @@ -154,7 +154,7 @@ namespace osu.Game.Screens.Play }, failOverlay = new FailOverlay { - OnRetry = restart, + OnRetry = Restart, OnQuit = performUserRequestedExit, }, new HotkeyRetryOverlay @@ -164,7 +164,7 @@ namespace osu.Game.Screens.Play if (!this.IsCurrentScreen()) return; fadeOut(true); - restart(); + Restart(); }, } }; @@ -235,7 +235,7 @@ namespace osu.Game.Screens.Play this.Exit(); } - private void restart() + public void Restart() { if (!this.IsCurrentScreen()) return; From 2ff7aa6c2e448d36800ea6584b7256b79eee8c2a Mon Sep 17 00:00:00 2001 From: David Zhao Date: Wed, 20 Mar 2019 19:49:37 +0900 Subject: [PATCH 28/34] Remove handle positional input --- osu.Game/Screens/Play/PlayerLoader.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 7163e95816..902764faa5 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -41,8 +41,6 @@ namespace osu.Game.Screens.Play public override bool DisallowExternalBeatmapRulesetChanges => true; - public override bool HandlePositionalInput => true; - private Task loadTask; private InputManager inputManager; From 2e9d823af47cb247c7b320729f38100afa6ca0f4 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Wed, 20 Mar 2019 19:59:54 +0900 Subject: [PATCH 29/34] Add comment regarding HandlePositionalInput --- osu.Game/Screens/Play/PlayerLoader.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 902764faa5..299fc2d299 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -164,6 +164,9 @@ namespace osu.Game.Screens.Play private ScheduledDelegate pushDebounce; protected VisualSettings VisualSettings; + // HandlePositionalInput is being set to true here because IsHovered will not update unless we do so. + public override bool HandlePositionalInput => true; + private bool readyForPush => player.LoadState == LoadState.Ready && IsHovered && GetContainingInputManager()?.DraggedDrawable == null; private void pushWhenLoaded() From 8865d539923efcb1be11d3e141593f9fd87b28cd Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 20 Mar 2019 20:04:07 +0900 Subject: [PATCH 30/34] Reword comment --- osu.Game/Screens/Play/PlayerLoader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 299fc2d299..9eebce4888 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -164,7 +164,7 @@ namespace osu.Game.Screens.Play private ScheduledDelegate pushDebounce; protected VisualSettings VisualSettings; - // HandlePositionalInput is being set to true here because IsHovered will not update unless we do so. + // required for IsHovered usage in readyForPush public override bool HandlePositionalInput => true; private bool readyForPush => player.LoadState == LoadState.Ready && IsHovered && GetContainingInputManager()?.DraggedDrawable == null; From ba89bfee0c195e5368545ee85a5f2b7da4f02422 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 20 Mar 2019 20:12:46 +0900 Subject: [PATCH 31/34] Define explicit method to add background Also cleans up some redundant/misplaced comments. --- .../Graphics/Containers/UserDimContainer.cs | 27 ++++++++++++------- .../Backgrounds/BackgroundScreenBeatmap.cs | 2 +- osu.Game/Screens/Play/PlayerLoader.cs | 2 +- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/osu.Game/Graphics/Containers/UserDimContainer.cs b/osu.Game/Graphics/Containers/UserDimContainer.cs index c790d6777d..18a45dd0cd 100644 --- a/osu.Game/Graphics/Containers/UserDimContainer.cs +++ b/osu.Game/Graphics/Containers/UserDimContainer.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; @@ -50,12 +51,13 @@ namespace osu.Game.Graphics.Containers private readonly bool isStoryboard; + /// + /// As an optimisation, we add the two blur portions to be applied rather than actually applying two separate blurs. + /// private Vector2 blurTarget => EnableUserDim.Value ? new Vector2(BlurAmount.Value + (float)userBlurLevel.Value * 25) : new Vector2(BlurAmount.Value); - private Background background; - /// /// Creates a new . /// @@ -71,14 +73,22 @@ namespace osu.Game.Graphics.Containers AddInternal(DimContainer = new Container { RelativeSizeAxes = Axes.Both }); } - public override void Add(Drawable drawable) + private Background background; + + public Background Background { - // Make sure we're already at the correct blur target when a background is added to the container. - if (drawable is Background b) + get => background; + set { - background = b; + background = value; background.BlurTo(blurTarget, 0, Easing.OutQuint); } + } + + public override void Add(Drawable drawable) + { + if (drawable is Background) + throw new InvalidOperationException($"Use {nameof(Background)} to set a background."); base.Add(drawable); } @@ -115,10 +125,7 @@ namespace osu.Game.Graphics.Containers // The background needs to be hidden in the case of it being replaced by the storyboard DimContainer.FadeTo(showStoryboard.Value && StoryboardReplacesBackground.Value ? 0 : 1, background_fade_duration, Easing.OutQuint); - // This only works if the background is a direct child of DimContainer. - // We can't blur the container like we did with the dim because buffered containers add considerable draw overhead. - // As a result, this blurs the background directly via the direct children of DimContainer. - background?.BlurTo(blurTarget, background_fade_duration, Easing.OutQuint); + Background?.BlurTo(blurTarget, background_fade_duration, Easing.OutQuint); } DimContainer.FadeColour(EnableUserDim.Value ? OsuColour.Gray(1 - (float)userDimLevel.Value) : Color4.White, background_fade_duration, Easing.OutQuint); diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index 111cc9d2c1..6df418753c 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -85,7 +85,7 @@ namespace osu.Game.Screens.Backgrounds } b.Depth = newDepth; - fadeContainer.Add(Background = b); + fadeContainer.Background = Background = b; StoryboardReplacesBackground.BindTo(fadeContainer.StoryboardReplacesBackground); } diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 9eebce4888..e9ee5d3fa8 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -164,7 +164,7 @@ namespace osu.Game.Screens.Play private ScheduledDelegate pushDebounce; protected VisualSettings VisualSettings; - // required for IsHovered usage in readyForPush + // Hhere because IsHovered will not update unless we do so. public override bool HandlePositionalInput => true; private bool readyForPush => player.LoadState == LoadState.Ready && IsHovered && GetContainingInputManager()?.DraggedDrawable == null; From 298c98871d663d8f1d3ed3ad65c65c67b079f56b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 20 Mar 2019 20:18:08 +0900 Subject: [PATCH 32/34] Actually add the background --- osu.Game/Graphics/Containers/UserDimContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Graphics/Containers/UserDimContainer.cs b/osu.Game/Graphics/Containers/UserDimContainer.cs index 18a45dd0cd..b078f40420 100644 --- a/osu.Game/Graphics/Containers/UserDimContainer.cs +++ b/osu.Game/Graphics/Containers/UserDimContainer.cs @@ -80,7 +80,7 @@ namespace osu.Game.Graphics.Containers get => background; set { - background = value; + base.Add(background = value); background.BlurTo(blurTarget, 0, Easing.OutQuint); } } From 6a7ab6a0010fd9534d92b17735280750d82c57d4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 20 Mar 2019 20:47:25 +0900 Subject: [PATCH 33/34] Do less import work in [SetUp] step --- .../Visual/TestCaseBackgroundScreenBeatmap.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs index 6f7d465cfe..8636e7721e 100644 --- a/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs +++ b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs @@ -74,21 +74,17 @@ namespace osu.Game.Tests.Visual Dependencies.Cache(manager = new BeatmapManager(LocalStorage, factory, rulesets, null, null, host, Beatmap.Default)); Dependencies.Cache(new OsuConfigManager(LocalStorage)); + manager.Import(TestResources.GetTestBeatmapForImport()); + Beatmap.SetDefault(); } [SetUp] - public virtual void SetUp() + public virtual void SetUp() => Schedule(() => { - Schedule(() => - { - manager.Delete(manager.GetAllUsableBeatmapSets()); - var temp = TestResources.GetTestBeatmapForImport(); - manager.Import(temp); - Child = screenStackContainer = new ScreenStackCacheContainer { RelativeSizeAxes = Axes.Both }; - screenStackContainer.ScreenStack.Push(songSelect = new DummySongSelect()); - }); - } + Child = screenStackContainer = new ScreenStackCacheContainer { RelativeSizeAxes = Axes.Both }; + screenStackContainer.ScreenStack.Push(songSelect = new DummySongSelect()); + }); /// /// Check if properly triggers the visual settings preview when a user hovers over the visual settings panel. From c555019692ec11fb24fa7e5258b819b69716ffe4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 20 Mar 2019 22:50:50 +0900 Subject: [PATCH 34/34] Update framework --- osu.Game/osu.Game.csproj | 2 +- osu.iOS.props | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index c02207702c..d8561770fd 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -16,7 +16,7 @@ - + diff --git a/osu.iOS.props b/osu.iOS.props index 2633da77b3..3dcb647cd2 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -105,8 +105,8 @@ - - + +