2019-08-13 02:16:41 +08:00
|
|
|
|
// 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.
|
|
|
|
|
|
2019-12-09 01:49:58 +08:00
|
|
|
|
using System.Threading;
|
2019-08-13 02:16:41 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2019-08-10 23:06:52 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2019-08-10 18:22:45 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2019-08-10 18:53:34 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-08-10 18:22:45 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Game.Graphics;
|
2019-08-10 18:53:34 +08:00
|
|
|
|
using osu.Game.Overlays.News;
|
2019-08-10 18:22:45 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
|
{
|
|
|
|
|
public class NewsOverlay : FullscreenOverlay
|
|
|
|
|
{
|
2019-08-10 18:53:34 +08:00
|
|
|
|
private NewsHeader header;
|
2019-08-15 03:52:36 +08:00
|
|
|
|
|
2019-08-15 02:24:36 +08:00
|
|
|
|
private Container<NewsContent> content;
|
2019-08-10 18:53:34 +08:00
|
|
|
|
|
2019-08-10 23:06:52 +08:00
|
|
|
|
public readonly Bindable<string> Current = new Bindable<string>(null);
|
|
|
|
|
|
2020-01-24 17:24:35 +08:00
|
|
|
|
public NewsOverlay()
|
|
|
|
|
: base(OverlayColourScheme.Purple)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-10 18:22:45 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-08-10 18:26:54 +08:00
|
|
|
|
Colour = colours.PurpleDarkAlternative
|
2019-08-10 18:53:34 +08:00
|
|
|
|
},
|
2020-04-13 17:23:28 +08:00
|
|
|
|
new OverlayScrollContainer
|
2019-08-10 18:53:34 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Child = new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2019-08-15 03:52:36 +08:00
|
|
|
|
header = new NewsHeader
|
2019-08-15 02:24:36 +08:00
|
|
|
|
{
|
|
|
|
|
ShowFrontPage = ShowFrontPage
|
|
|
|
|
},
|
2019-08-15 03:52:36 +08:00
|
|
|
|
content = new Container<NewsContent>
|
2019-08-15 02:24:36 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
}
|
2019-08-10 18:53:34 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2019-08-10 18:22:45 +08:00
|
|
|
|
};
|
2019-08-10 23:06:52 +08:00
|
|
|
|
|
2020-02-04 05:43:04 +08:00
|
|
|
|
header.Post.BindTo(Current);
|
2019-08-10 23:06:52 +08:00
|
|
|
|
Current.TriggerChange();
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-14 18:40:59 +08:00
|
|
|
|
private CancellationTokenSource loadContentCancellation;
|
2019-12-09 01:49:58 +08:00
|
|
|
|
|
2019-12-14 18:40:59 +08:00
|
|
|
|
protected void LoadAndShowContent(NewsContent newContent)
|
2019-12-09 01:49:58 +08:00
|
|
|
|
{
|
|
|
|
|
content.FadeTo(0.2f, 300, Easing.OutQuint);
|
|
|
|
|
|
2019-12-14 18:40:59 +08:00
|
|
|
|
loadContentCancellation?.Cancel();
|
2019-12-09 01:49:58 +08:00
|
|
|
|
|
|
|
|
|
LoadComponentAsync(newContent, c =>
|
|
|
|
|
{
|
|
|
|
|
content.Child = c;
|
|
|
|
|
content.FadeIn(300, Easing.OutQuint);
|
2019-12-14 18:40:59 +08:00
|
|
|
|
}, (loadContentCancellation = new CancellationTokenSource()).Token);
|
2019-12-09 01:49:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-10 23:06:52 +08:00
|
|
|
|
public void ShowFrontPage()
|
|
|
|
|
{
|
|
|
|
|
Current.Value = null;
|
|
|
|
|
Show();
|
2019-08-10 18:22:45 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|