mirror of
https://github.com/osukey/osukey.git
synced 2025-08-06 16:13:57 +09:00
Make menu background blurrable
Not actually blurring yet, needs further testing.
This commit is contained in:
@ -4,20 +4,14 @@
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.Graphics.Transforms;
|
|
||||||
using OpenTK;
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics.Backgrounds;
|
using osu.Game.Graphics.Backgrounds;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Backgrounds
|
namespace osu.Game.Screens.Backgrounds
|
||||||
{
|
{
|
||||||
public class BackgroundScreenBeatmap : BackgroundScreen
|
public class BackgroundScreenBeatmap : BlurrableBackgroundScreen
|
||||||
{
|
{
|
||||||
private Background background;
|
|
||||||
|
|
||||||
private WorkingBeatmap beatmap;
|
private WorkingBeatmap beatmap;
|
||||||
private Vector2 blurTarget;
|
|
||||||
|
|
||||||
public WorkingBeatmap Beatmap
|
public WorkingBeatmap Beatmap
|
||||||
{
|
{
|
||||||
get { return beatmap; }
|
get { return beatmap; }
|
||||||
@ -33,17 +27,17 @@ namespace osu.Game.Screens.Backgrounds
|
|||||||
LoadComponentAsync(new BeatmapBackground(beatmap), b =>
|
LoadComponentAsync(new BeatmapBackground(beatmap), b =>
|
||||||
{
|
{
|
||||||
float newDepth = 0;
|
float newDepth = 0;
|
||||||
if (background != null)
|
if (Background != null)
|
||||||
{
|
{
|
||||||
newDepth = background.Depth + 1;
|
newDepth = Background.Depth + 1;
|
||||||
background.FinishTransforms();
|
Background.FinishTransforms();
|
||||||
background.FadeOut(250);
|
Background.FadeOut(250);
|
||||||
background.Expire();
|
Background.Expire();
|
||||||
}
|
}
|
||||||
|
|
||||||
b.Depth = newDepth;
|
b.Depth = newDepth;
|
||||||
Add(background = b);
|
Add(Background = b);
|
||||||
background.BlurSigma = blurTarget;
|
Background.BlurSigma = BlurTarget;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -54,9 +48,6 @@ namespace osu.Game.Screens.Backgrounds
|
|||||||
Beatmap = beatmap;
|
Beatmap = beatmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TransformSequence<Background> BlurTo(Vector2 sigma, double duration, Easing easing = Easing.None)
|
|
||||||
=> background?.BlurTo(blurTarget = sigma, duration, easing);
|
|
||||||
|
|
||||||
public override bool Equals(BackgroundScreen other)
|
public override bool Equals(BackgroundScreen other)
|
||||||
{
|
{
|
||||||
var otherBeatmapBackground = other as BackgroundScreenBeatmap;
|
var otherBeatmapBackground = other as BackgroundScreenBeatmap;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
@ -9,15 +9,13 @@ using osu.Game.Graphics.Backgrounds;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.Backgrounds
|
namespace osu.Game.Screens.Backgrounds
|
||||||
{
|
{
|
||||||
public class BackgroundScreenDefault : BackgroundScreen
|
public class BackgroundScreenDefault : BlurrableBackgroundScreen
|
||||||
{
|
{
|
||||||
private int currentDisplay;
|
private int currentDisplay;
|
||||||
private const int background_count = 5;
|
private const int background_count = 5;
|
||||||
|
|
||||||
private string backgroundName => $@"Menu/menu-background-{currentDisplay % background_count + 1}";
|
private string backgroundName => $@"Menu/menu-background-{currentDisplay % background_count + 1}";
|
||||||
|
|
||||||
private Background current;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
@ -27,10 +25,10 @@ namespace osu.Game.Screens.Backgrounds
|
|||||||
|
|
||||||
private void display(Background newBackground)
|
private void display(Background newBackground)
|
||||||
{
|
{
|
||||||
current?.FadeOut(800, Easing.InOutSine);
|
Background?.FadeOut(800, Easing.InOutSine);
|
||||||
current?.Expire();
|
Background?.Expire();
|
||||||
|
|
||||||
Add(current = newBackground);
|
Add(Background = newBackground);
|
||||||
currentDisplay++;
|
currentDisplay++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
20
osu.Game/Screens/BlurrableBackgroundScreen.cs
Normal file
20
osu.Game/Screens/BlurrableBackgroundScreen.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// 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<Background> BlurTo(Vector2 sigma, double duration, Easing easing = Easing.None)
|
||||||
|
=> Background?.BlurTo(BlurTarget = sigma, duration, easing);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user