Improve look & behaviour of background transitions

This commit is contained in:
Bartłomiej Dach 2020-10-30 22:40:24 +01:00
parent 391dd73843
commit 78842ab95a
2 changed files with 9 additions and 2 deletions

View File

@ -97,6 +97,8 @@ public SeasonalBackground(string url)
private void load(LargeTextureStore textures)
{
Sprite.Texture = textures.Get(url) ?? textures.Get(fallback_texture_name);
// ensure we're not loading in without a transition.
this.FadeInFromZero(200, Easing.InOutSine);
}
}
}

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Threading;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -52,7 +53,8 @@ private void load(IAPIProvider api, SkinManager skinManager, OsuConfigManager co
currentDisplay = RNG.Next(0, background_count);
LoadComponentAsync(seasonalBackgroundLoader, _ => LoadComponentAsync(createBackground(), display));
LoadComponentAsync(seasonalBackgroundLoader);
Next();
}
private void display(Background newBackground)
@ -65,11 +67,14 @@ private void display(Background newBackground)
}
private ScheduledDelegate nextTask;
private CancellationTokenSource cancellationTokenSource;
public void Next()
{
nextTask?.Cancel();
nextTask = Scheduler.AddDelayed(() => { LoadComponentAsync(createBackground(), display); }, 100);
cancellationTokenSource?.Cancel();
cancellationTokenSource = new CancellationTokenSource();
nextTask = Scheduler.AddDelayed(() => LoadComponentAsync(createBackground(), display, cancellationTokenSource.Token), 100);
}
private Background createBackground()