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-14 01:50:49 +08:00
|
|
|
|
using System;
|
|
|
|
|
using osu.Framework.Graphics;
|
2019-08-13 02:16:41 +08:00
|
|
|
|
using osu.Game.Overlays;
|
2019-12-11 21:32:43 +08:00
|
|
|
|
using osu.Game.Overlays.News;
|
2019-08-10 18:26:54 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Online
|
|
|
|
|
{
|
|
|
|
|
public class TestSceneNewsOverlay : OsuTestScene
|
|
|
|
|
{
|
2019-12-11 21:32:43 +08:00
|
|
|
|
private TestNewsOverlay news;
|
2019-08-10 18:26:54 +08:00
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
2019-12-11 21:32:43 +08:00
|
|
|
|
Add(news = new TestNewsOverlay());
|
2019-08-10 18:26:54 +08:00
|
|
|
|
AddStep(@"Show", news.Show);
|
|
|
|
|
AddStep(@"Hide", news.Hide);
|
2019-08-10 23:06:52 +08:00
|
|
|
|
|
|
|
|
|
AddStep(@"Show front page", () => news.ShowFrontPage());
|
|
|
|
|
AddStep(@"Custom article", () => news.Current.Value = "Test Article 101");
|
2019-12-14 01:50:49 +08:00
|
|
|
|
|
2019-12-18 02:25:17 +08:00
|
|
|
|
AddStep(@"Article covers", () => news.LoadAndShowContent(new NewsCoverTest()));
|
2019-08-10 18:26:54 +08:00
|
|
|
|
}
|
2019-12-11 21:32:43 +08:00
|
|
|
|
|
|
|
|
|
private class TestNewsOverlay : NewsOverlay
|
|
|
|
|
{
|
2019-12-18 02:25:17 +08:00
|
|
|
|
public new void LoadAndShowContent(NewsContent content) => base.LoadAndShowContent(content);
|
2019-12-11 21:32:43 +08:00
|
|
|
|
}
|
2019-12-14 01:50:49 +08:00
|
|
|
|
|
|
|
|
|
private class NewsCoverTest : NewsContent
|
|
|
|
|
{
|
|
|
|
|
public NewsCoverTest()
|
|
|
|
|
{
|
|
|
|
|
Spacing = new osuTK.Vector2(0, 10);
|
|
|
|
|
|
2019-12-14 01:59:40 +08:00
|
|
|
|
var article = new NewsArticleCover.ArticleInfo
|
2019-12-14 01:50:49 +08:00
|
|
|
|
{
|
|
|
|
|
Author = "Ephemeral",
|
2019-12-14 01:59:40 +08:00
|
|
|
|
CoverUrl = "https://assets.ppy.sh/artists/58/header.jpg",
|
2019-12-14 01:50:49 +08:00
|
|
|
|
Time = new DateTime(2019, 12, 4),
|
|
|
|
|
Title = "New Featured Artist: Kurokotei"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new NewsArticleCover(article)
|
|
|
|
|
{
|
|
|
|
|
Height = 200
|
|
|
|
|
},
|
|
|
|
|
new NewsArticleCover(article)
|
|
|
|
|
{
|
|
|
|
|
Height = 120
|
|
|
|
|
},
|
|
|
|
|
new NewsArticleCover(article)
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.None,
|
|
|
|
|
Size = new osuTK.Vector2(400, 200),
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-08-10 18:26:54 +08:00
|
|
|
|
}
|
|
|
|
|
}
|