1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00

Add missing async content loading logic to NewsOverlay

This commit is contained in:
Lucas A 2019-12-08 18:49:58 +01:00
parent 4d4e17f7c0
commit 88ec0c1486

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;
@ -16,7 +17,6 @@ namespace osu.Game.Overlays
{
private NewsHeader header;
//ReSharper disable NotAccessedField.Local
private Container<NewsContent> content;
public readonly Bindable<string> Current = new Bindable<string>(null);
@ -59,6 +59,21 @@ namespace osu.Game.Overlays
Current.TriggerChange();
}
private CancellationTokenSource loadChildCancellation;
protected void LoadAndShowChild(NewsContent newContent)
{
content.FadeTo(0.2f, 300, Easing.OutQuint);
loadChildCancellation?.Cancel();
LoadComponentAsync(newContent, c =>
{
content.Child = c;
content.FadeIn(300, Easing.OutQuint);
}, (loadChildCancellation = new CancellationTokenSource()).Token);
}
public void ShowFrontPage()
{
Current.Value = null;