1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-07 07:27:25 +08:00
osu-lazer/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs
Dean Herbert 83bf38f4bc Make menu background blurrable
Not actually blurring yet, needs further testing.
2018-09-21 03:13:34 +09:00

47 lines
1.4 KiB
C#

// 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.Allocation;
using osu.Framework.Graphics;
using osu.Framework.MathUtils;
using osu.Framework.Threading;
using osu.Game.Graphics.Backgrounds;
namespace osu.Game.Screens.Backgrounds
{
public class BackgroundScreenDefault : BlurrableBackgroundScreen
{
private int currentDisplay;
private const int background_count = 5;
private string backgroundName => $@"Menu/menu-background-{currentDisplay % background_count + 1}";
[BackgroundDependencyLoader]
private void load()
{
currentDisplay = RNG.Next(0, background_count);
display(new Background(backgroundName));
}
private void display(Background newBackground)
{
Background?.FadeOut(800, Easing.InOutSine);
Background?.Expire();
Add(Background = newBackground);
currentDisplay++;
}
private ScheduledDelegate nextTask;
public void Next()
{
nextTask?.Cancel();
nextTask = Scheduler.AddDelayed(() =>
{
LoadComponentAsync(new Background(backgroundName) { Depth = currentDisplay }, display);
}, 100);
}
}
}