2018-09-21 02:13:34 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
2018-09-21 01:55:24 +08:00
|
|
|
|
using osu.Framework.MathUtils;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Threading;
|
|
|
|
|
using osu.Game.Graphics.Backgrounds;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Backgrounds
|
|
|
|
|
{
|
2018-09-21 02:13:34 +08:00
|
|
|
|
public class BackgroundScreenDefault : BlurrableBackgroundScreen
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
private int currentDisplay;
|
|
|
|
|
private const int background_count = 5;
|
|
|
|
|
|
|
|
|
|
private string backgroundName => $@"Menu/menu-background-{currentDisplay % background_count + 1}";
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
2018-09-21 01:55:24 +08:00
|
|
|
|
currentDisplay = RNG.Next(0, background_count);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
display(new Background(backgroundName));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void display(Background newBackground)
|
|
|
|
|
{
|
2018-09-21 02:13:34 +08:00
|
|
|
|
Background?.FadeOut(800, Easing.InOutSine);
|
|
|
|
|
Background?.Expire();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-09-21 02:13:34 +08:00
|
|
|
|
Add(Background = newBackground);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
currentDisplay++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ScheduledDelegate nextTask;
|
|
|
|
|
|
|
|
|
|
public void Next()
|
|
|
|
|
{
|
|
|
|
|
nextTask?.Cancel();
|
|
|
|
|
nextTask = Scheduler.AddDelayed(() =>
|
|
|
|
|
{
|
|
|
|
|
LoadComponentAsync(new Background(backgroundName) { Depth = currentDisplay }, display);
|
|
|
|
|
}, 100);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|