2018-01-05 11:21:19 +00:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-02-07 04:59:30 +00:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-10-06 14:32:35 +00:00
|
|
|
|
|
2016-11-08 23:13:20 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
2017-06-26 10:06:08 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-12-30 21:40:28 +00:00
|
|
|
|
using osu.Framework.Threading;
|
2016-11-23 02:59:50 +00:00
|
|
|
|
using osu.Game.Graphics.Backgrounds;
|
2016-10-06 14:32:35 +00:00
|
|
|
|
|
2016-11-14 08:23:33 +00:00
|
|
|
|
namespace osu.Game.Screens.Backgrounds
|
2016-10-06 14:32:35 +00:00
|
|
|
|
{
|
2017-02-17 09:59:30 +00:00
|
|
|
|
public class BackgroundScreenDefault : BackgroundScreen
|
2016-10-06 14:32:35 +00:00
|
|
|
|
{
|
2017-06-26 10:06:08 +00:00
|
|
|
|
private int currentDisplay;
|
|
|
|
|
private const int background_count = 5;
|
|
|
|
|
|
|
|
|
|
private string backgroundName => $@"Menu/menu-background-{currentDisplay % background_count + 1}";
|
|
|
|
|
|
|
|
|
|
private Background current;
|
|
|
|
|
|
2016-11-12 10:44:16 +00:00
|
|
|
|
[BackgroundDependencyLoader]
|
2017-02-27 14:32:32 +00:00
|
|
|
|
private void load()
|
2016-10-06 14:32:35 +00:00
|
|
|
|
{
|
2017-06-26 10:06:08 +00:00
|
|
|
|
display(new Background(backgroundName));
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-26 14:05:35 +00:00
|
|
|
|
private void display(Background newBackground)
|
2017-06-26 10:06:08 +00:00
|
|
|
|
{
|
2017-12-30 21:40:28 +00:00
|
|
|
|
current?.FadeOut(800, Easing.InOutSine);
|
2017-06-26 10:06:08 +00:00
|
|
|
|
current?.Expire();
|
|
|
|
|
|
2017-06-26 14:05:35 +00:00
|
|
|
|
Add(current = newBackground);
|
2017-12-30 21:40:28 +00:00
|
|
|
|
currentDisplay++;
|
2017-06-26 10:06:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-12-30 21:40:28 +00:00
|
|
|
|
private ScheduledDelegate nextTask;
|
|
|
|
|
|
2017-06-26 10:06:08 +00:00
|
|
|
|
public void Next()
|
|
|
|
|
{
|
2017-12-30 21:40:28 +00:00
|
|
|
|
nextTask?.Cancel();
|
|
|
|
|
nextTask = Scheduler.AddDelayed(() =>
|
|
|
|
|
{
|
|
|
|
|
LoadComponentAsync(new Background(backgroundName) { Depth = currentDisplay }, display);
|
|
|
|
|
}, 100);
|
2016-10-06 14:32:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-06-26 14:05:35 +00:00
|
|
|
|
}
|