1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-24 20:07:25 +08:00
osu-lazer/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs
Dean Herbert f2d302f8dc Create a LargeTextureStore for cached (but not atlased) global textures
Also
- Fixes first transition depth being incorrect.
- Improves smoothness of transitions (and adds a slight delay to offset from screen switches).
2017-12-31 07:05:04 +09:00

47 lines
1.3 KiB
C#

// Copyright (c) 2007-2017 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.Threading;
using osu.Game.Graphics.Backgrounds;
namespace osu.Game.Screens.Backgrounds
{
public class BackgroundScreenDefault : BackgroundScreen
{
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()
{
display(new Background(backgroundName));
}
private void display(Background newBackground)
{
current?.FadeOut(800, Easing.InOutSine);
current?.Expire();
Add(current = newBackground);
currentDisplay++;
}
private ScheduledDelegate nextTask;
public void Next()
{
nextTask?.Cancel();
nextTask = Scheduler.AddDelayed(() =>
{
LoadComponentAsync(new Background(backgroundName) { Depth = currentDisplay }, display);
}, 100);
}
}
}