From df148f8787c1d743c0a4056a47111cba5a408468 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Mon, 18 Feb 2019 12:55:42 +0900 Subject: [PATCH] Fix background dim not being disabled on playerloader exit --- .../Visual/TestCaseBackgroundScreenBeatmap.cs | 1 + .../Screens/Backgrounds/BackgroundScreenBeatmap.cs | 12 +++--------- osu.Game/Screens/Play/Player.cs | 11 ++++++----- osu.Game/Screens/Play/PlayerLoader.cs | 1 + 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs index aadc033a7c..a94f13b0b2 100644 --- a/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs +++ b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs @@ -40,6 +40,7 @@ namespace osu.Game.Tests.Visual private class DimAccessiblePlayer : Player { protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(); + public void EnableScreenDim() { Background.UpdateDim.Value = true; diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index 90b9a129d4..6ea8899876 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -11,6 +11,7 @@ using osu.Game.Beatmaps; using osu.Game.Configuration; using osu.Game.Graphics; using osu.Game.Graphics.Backgrounds; +using osuTK.Graphics; namespace osu.Game.Screens.Backgrounds { @@ -20,7 +21,6 @@ namespace osu.Game.Screens.Backgrounds protected Bindable DimLevel; public Bindable UpdateDim; - protected float BackgroundOpacity => 1 - (float)DimLevel; protected Container FadeContainer; [BackgroundDependencyLoader] @@ -76,16 +76,15 @@ namespace osu.Game.Screens.Backgrounds public override bool OnExiting(IScreen last) { - UpdateDim.Value = false; return base.OnExiting(last); } private void updateBackgroundDim() { if (UpdateDim) - FadeContainer?.FadeColour(OsuColour.Gray(BackgroundOpacity), 800, Easing.OutQuint); + FadeContainer?.FadeColour(OsuColour.Gray(1 - (float)DimLevel), 800, Easing.OutQuint); else - FadeContainer?.FadeColour(OsuColour.Gray(1.0f), 800, Easing.OutQuint); + FadeContainer?.FadeColour(Color4.White, 800, Easing.OutQuint); } public BackgroundScreenBeatmap(WorkingBeatmap beatmap = null) @@ -94,11 +93,6 @@ namespace osu.Game.Screens.Backgrounds UpdateDim = new Bindable(); } - public void EnableUserDim() - { - UpdateDim.Value = true; - } - public override bool Equals(BackgroundScreen other) { var otherBeatmapBackground = other as BackgroundScreenBeatmap; diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index e2decab69c..2526b2e3ab 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -248,7 +248,7 @@ namespace osu.Game.Screens.Play foreach (var mod in Beatmap.Value.Mods.Value.OfType()) mod.ApplyToScoreProcessor(ScoreProcessor); - Background?.EnableUserDim(); + Background.UpdateDim.Value = true; } private void applyRateFromMods() @@ -298,7 +298,7 @@ namespace osu.Game.Screens.Play if (RulesetContainer.ReplayScore == null) scoreManager.Import(score, true); - this.Push(CreateResults(score)); + this.Push(CreateResults(score)); onCompletionEvent = null; }); @@ -389,15 +389,16 @@ namespace osu.Game.Screens.Play { // In the case of replays, we may have changed the playback rate. applyRateFromMods(); - + Background.UpdateDim.Value = false; fadeOut(); return base.OnExiting(next); } if (LoadedBeatmapSuccessfully) + { pauseContainer?.Pause(); - - Background.UpdateDim.Value = false; + return true; + } return true; } diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index c55c05f61c..4bb126e0e2 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -242,6 +242,7 @@ namespace osu.Game.Screens.Play content.ScaleTo(0.7f, 150, Easing.InQuint); this.FadeOut(150); cancelLoad(); + Background.UpdateDim.Value = false; return base.OnExiting(next); }