1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 23:47:24 +08:00
osu-lazer/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs

47 lines
1.3 KiB
C#
Raw Normal View History

2018-01-05 19:21:19 +08:00
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2016-11-09 07:13:20 +08:00
using osu.Framework.Allocation;
2017-06-26 18:06:08 +08:00
using osu.Framework.Graphics;
using osu.Framework.Threading;
2016-11-23 10:59:50 +08:00
using osu.Game.Graphics.Backgrounds;
2016-11-14 16:23:33 +08:00
namespace osu.Game.Screens.Backgrounds
{
2017-02-17 17:59:30 +08:00
public class BackgroundScreenDefault : BackgroundScreen
{
2017-06-26 18:06:08 +08:00
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()
{
2017-06-26 18:06:08 +08:00
display(new Background(backgroundName));
}
2017-06-26 22:05:35 +08:00
private void display(Background newBackground)
2017-06-26 18:06:08 +08:00
{
current?.FadeOut(800, Easing.InOutSine);
2017-06-26 18:06:08 +08:00
current?.Expire();
2017-06-26 22:05:35 +08:00
Add(current = newBackground);
currentDisplay++;
2017-06-26 18:06:08 +08:00
}
private ScheduledDelegate nextTask;
2017-06-26 18:06:08 +08:00
public void Next()
{
nextTask?.Cancel();
nextTask = Scheduler.AddDelayed(() =>
{
LoadComponentAsync(new Background(backgroundName) { Depth = currentDisplay }, display);
}, 100);
}
}
2017-06-26 22:05:35 +08:00
}