From fa33e0bd6bc5c8abb6e88938c206bad2691ba0c7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 21 Sep 2018 02:36:39 +0900 Subject: [PATCH 1/5] Fix background brightness being adjusted globally --- osu.Game/Graphics/Backgrounds/Background.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game/Graphics/Backgrounds/Background.cs b/osu.Game/Graphics/Backgrounds/Background.cs index 6fc8b0e070..d3d530a540 100644 --- a/osu.Game/Graphics/Backgrounds/Background.cs +++ b/osu.Game/Graphics/Backgrounds/Background.cs @@ -6,7 +6,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; -using OpenTK.Graphics; namespace osu.Game.Graphics.Backgrounds { @@ -28,7 +27,6 @@ namespace osu.Game.Graphics.Backgrounds RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.Centre, - Colour = Color4.DarkGray, FillMode = FillMode.Fill, }); } From 07a1c39fe525dc11f06917fc3d7f3510c21e4d27 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 21 Sep 2018 02:55:24 +0900 Subject: [PATCH 2/5] Use random default background on starting the game --- osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs index 38df9b13ef..f52633a34a 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs @@ -1,8 +1,9 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . +// Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Allocation; using osu.Framework.Graphics; +using osu.Framework.MathUtils; using osu.Framework.Threading; using osu.Game.Graphics.Backgrounds; @@ -20,6 +21,7 @@ namespace osu.Game.Screens.Backgrounds [BackgroundDependencyLoader] private void load() { + currentDisplay = RNG.Next(0, background_count); display(new Background(backgroundName)); } From 78d78b5510370108a61b0b16c2f8679a67cd987c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 21 Sep 2018 03:13:15 +0900 Subject: [PATCH 3/5] Fade menu background a bit when menu is active --- osu.Game/Screens/Menu/MainMenu.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index 7e97859be6..2dd6e1d7e1 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -10,6 +10,7 @@ using osu.Framework.Input.EventArgs; using osu.Framework.Input.States; using osu.Framework.Screens; using osu.Game.Beatmaps; +using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Screens.Backgrounds; using osu.Game.Screens.Charts; @@ -64,6 +65,20 @@ namespace osu.Game.Screens.Menu }, sideFlashes = new MenuSideFlashes(), }; + + buttons.StateChanged += state => + { + switch (state) + { + case ButtonSystemState.Initial: + case ButtonSystemState.Exit: + background.FadeColour(Color4.White, 500, Easing.OutSine); + break; + default: + background.FadeColour(OsuColour.Gray(0.8f), 500, Easing.OutSine); + break; + } + }; } [BackgroundDependencyLoader(true)] From 83bf38f4bc03c48e3425eb93a4d433362530038f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 21 Sep 2018 03:13:34 +0900 Subject: [PATCH 4/5] Make menu background blurrable Not actually blurring yet, needs further testing. --- .../Backgrounds/BackgroundScreenBeatmap.cs | 25 ++++++------------- .../Backgrounds/BackgroundScreenDefault.cs | 12 ++++----- osu.Game/Screens/BlurrableBackgroundScreen.cs | 20 +++++++++++++++ 3 files changed, 33 insertions(+), 24 deletions(-) create mode 100644 osu.Game/Screens/BlurrableBackgroundScreen.cs diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index 78561cecbf..62f24e8e5c 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -4,20 +4,14 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Textures; -using osu.Framework.Graphics.Transforms; -using OpenTK; using osu.Game.Beatmaps; using osu.Game.Graphics.Backgrounds; namespace osu.Game.Screens.Backgrounds { - public class BackgroundScreenBeatmap : BackgroundScreen + public class BackgroundScreenBeatmap : BlurrableBackgroundScreen { - private Background background; - private WorkingBeatmap beatmap; - private Vector2 blurTarget; - public WorkingBeatmap Beatmap { get { return beatmap; } @@ -33,17 +27,17 @@ namespace osu.Game.Screens.Backgrounds LoadComponentAsync(new BeatmapBackground(beatmap), b => { float newDepth = 0; - if (background != null) + if (Background != null) { - newDepth = background.Depth + 1; - background.FinishTransforms(); - background.FadeOut(250); - background.Expire(); + newDepth = Background.Depth + 1; + Background.FinishTransforms(); + Background.FadeOut(250); + Background.Expire(); } b.Depth = newDepth; - Add(background = b); - background.BlurSigma = blurTarget; + Add(Background = b); + Background.BlurSigma = BlurTarget; }); }); } @@ -54,9 +48,6 @@ namespace osu.Game.Screens.Backgrounds Beatmap = beatmap; } - public TransformSequence BlurTo(Vector2 sigma, double duration, Easing easing = Easing.None) - => background?.BlurTo(blurTarget = sigma, duration, easing); - public override bool Equals(BackgroundScreen other) { var otherBeatmapBackground = other as BackgroundScreenBeatmap; diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs index f52633a34a..989883c8b3 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . +// Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Allocation; @@ -9,15 +9,13 @@ using osu.Game.Graphics.Backgrounds; namespace osu.Game.Screens.Backgrounds { - public class BackgroundScreenDefault : BackgroundScreen + public class BackgroundScreenDefault : BlurrableBackgroundScreen { private int currentDisplay; private const int background_count = 5; private string backgroundName => $@"Menu/menu-background-{currentDisplay % background_count + 1}"; - private Background current; - [BackgroundDependencyLoader] private void load() { @@ -27,10 +25,10 @@ namespace osu.Game.Screens.Backgrounds private void display(Background newBackground) { - current?.FadeOut(800, Easing.InOutSine); - current?.Expire(); + Background?.FadeOut(800, Easing.InOutSine); + Background?.Expire(); - Add(current = newBackground); + Add(Background = newBackground); currentDisplay++; } diff --git a/osu.Game/Screens/BlurrableBackgroundScreen.cs b/osu.Game/Screens/BlurrableBackgroundScreen.cs new file mode 100644 index 0000000000..92d32badc4 --- /dev/null +++ b/osu.Game/Screens/BlurrableBackgroundScreen.cs @@ -0,0 +1,20 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Transforms; +using osu.Game.Graphics.Backgrounds; +using OpenTK; + +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) + => Background?.BlurTo(BlurTarget = sigma, duration, easing); + } +} From 4380ef15bf32810090c693e95078a18e29eb7efd Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 21 Sep 2018 16:31:09 +0900 Subject: [PATCH 5/5] Fix potential exception during async load callback --- osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index 62f24e8e5c..e326cdb0ca 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -12,6 +12,7 @@ namespace osu.Game.Screens.Backgrounds public class BackgroundScreenBeatmap : BlurrableBackgroundScreen { private WorkingBeatmap beatmap; + public WorkingBeatmap Beatmap { get { return beatmap; } @@ -24,7 +25,7 @@ namespace osu.Game.Screens.Backgrounds Schedule(() => { - LoadComponentAsync(new BeatmapBackground(beatmap), b => + LoadComponentAsync(new BeatmapBackground(beatmap), b => Schedule(() => { float newDepth = 0; if (Background != null) @@ -38,7 +39,7 @@ namespace osu.Game.Screens.Backgrounds b.Depth = newDepth; Add(Background = b); Background.BlurSigma = BlurTarget; - }); + })); }); } }