mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 12:17:46 +08:00
Add missing async content loading logic to NewsOverlay
This commit is contained in:
parent
4d4e17f7c0
commit
88ec0c1486
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Threading;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -16,7 +17,6 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
private NewsHeader header;
|
private NewsHeader header;
|
||||||
|
|
||||||
//ReSharper disable NotAccessedField.Local
|
|
||||||
private Container<NewsContent> content;
|
private Container<NewsContent> content;
|
||||||
|
|
||||||
public readonly Bindable<string> Current = new Bindable<string>(null);
|
public readonly Bindable<string> Current = new Bindable<string>(null);
|
||||||
@ -59,6 +59,21 @@ namespace osu.Game.Overlays
|
|||||||
Current.TriggerChange();
|
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()
|
public void ShowFrontPage()
|
||||||
{
|
{
|
||||||
Current.Value = null;
|
Current.Value = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user