mirror of
https://github.com/ppy/osu
synced 2024-12-14 02:46:27 +00:00
Remove outdated elements
This commit is contained in:
parent
0b4213f330
commit
57b935ec50
@ -1,68 +1,25 @@
|
|||||||
// 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;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Overlays.News;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Online
|
namespace osu.Game.Tests.Visual.Online
|
||||||
{
|
{
|
||||||
public class TestSceneNewsOverlay : OsuTestScene
|
public class TestSceneNewsOverlay : OsuTestScene
|
||||||
{
|
{
|
||||||
private TestNewsOverlay news;
|
private NewsOverlay news;
|
||||||
|
|
||||||
protected override bool UseOnlineAPI => true;
|
protected override bool UseOnlineAPI => true;
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
Add(news = new TestNewsOverlay());
|
Add(news = new NewsOverlay());
|
||||||
AddStep(@"Show", news.Show);
|
AddStep(@"Show", news.Show);
|
||||||
AddStep(@"Hide", news.Hide);
|
AddStep(@"Hide", news.Hide);
|
||||||
|
|
||||||
AddStep(@"Show front page", () => news.ShowFrontPage());
|
AddStep(@"Show front page", () => news.ShowFrontPage());
|
||||||
AddStep(@"Custom article", () => news.Current.Value = "Test Article 101");
|
AddStep(@"Custom article", () => news.Current.Value = "Test Article 101");
|
||||||
|
|
||||||
AddStep(@"Article covers", () => news.LoadDisplay(new NewsCoverTest()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private class TestNewsOverlay : NewsOverlay
|
|
||||||
{
|
|
||||||
public void LoadDisplay(NewsContent content) => base.LoadDisplay(content);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class NewsCoverTest : NewsContent
|
|
||||||
{
|
|
||||||
public NewsCoverTest()
|
|
||||||
{
|
|
||||||
Spacing = new osuTK.Vector2(0, 10);
|
|
||||||
|
|
||||||
var article = new NewsArticleCover.ArticleInfo
|
|
||||||
{
|
|
||||||
Author = "Ephemeral",
|
|
||||||
CoverUrl = "https://assets.ppy.sh/artists/58/header.jpg",
|
|
||||||
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),
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,9 +87,7 @@ namespace osu.Game.Overlays.News.Displays
|
|||||||
{
|
{
|
||||||
lastCursor = response.Cursor;
|
lastCursor = response.Cursor;
|
||||||
|
|
||||||
FillFlowContainer<NewsCard> flow;
|
var flow = new FillFlowContainer<NewsCard>
|
||||||
|
|
||||||
flow = new FillFlowContainer<NewsCard>
|
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
|
@ -1,174 +0,0 @@
|
|||||||
// 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;
|
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Colour;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Graphics.Cursor;
|
|
||||||
using osu.Framework.Graphics.Shapes;
|
|
||||||
using osu.Framework.Graphics.Sprites;
|
|
||||||
using osu.Framework.Graphics.Textures;
|
|
||||||
using osu.Framework.Input.Events;
|
|
||||||
using osu.Game.Graphics;
|
|
||||||
using osu.Game.Graphics.Sprites;
|
|
||||||
using osuTK.Graphics;
|
|
||||||
|
|
||||||
namespace osu.Game.Overlays.News
|
|
||||||
{
|
|
||||||
public class NewsArticleCover : Container
|
|
||||||
{
|
|
||||||
private const int hover_duration = 300;
|
|
||||||
|
|
||||||
private readonly Box gradient;
|
|
||||||
|
|
||||||
public NewsArticleCover(ArticleInfo info)
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X;
|
|
||||||
Masking = true;
|
|
||||||
CornerRadius = 4;
|
|
||||||
|
|
||||||
NewsBackground bg;
|
|
||||||
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = ColourInfo.GradientVertical(OsuColour.Gray(0.2f), OsuColour.Gray(0.1f))
|
|
||||||
},
|
|
||||||
new DelayedLoadWrapper(bg = new NewsBackground(info.CoverUrl)
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
FillMode = FillMode.Fill,
|
|
||||||
Alpha = 0
|
|
||||||
})
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
},
|
|
||||||
gradient = new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.1f), Color4.Black.Opacity(0.7f)),
|
|
||||||
Alpha = 0
|
|
||||||
},
|
|
||||||
new DateContainer(info.Time)
|
|
||||||
{
|
|
||||||
Margin = new MarginPadding
|
|
||||||
{
|
|
||||||
Right = 20,
|
|
||||||
Top = 20,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new OsuSpriteText
|
|
||||||
{
|
|
||||||
Anchor = Anchor.BottomLeft,
|
|
||||||
Origin = Anchor.BottomLeft,
|
|
||||||
Margin = new MarginPadding
|
|
||||||
{
|
|
||||||
Left = 25,
|
|
||||||
Bottom = 50,
|
|
||||||
},
|
|
||||||
Font = OsuFont.GetFont(Typeface.Torus, 24, FontWeight.Bold),
|
|
||||||
Text = info.Title,
|
|
||||||
},
|
|
||||||
new OsuSpriteText
|
|
||||||
{
|
|
||||||
Anchor = Anchor.BottomLeft,
|
|
||||||
Origin = Anchor.BottomLeft,
|
|
||||||
Margin = new MarginPadding
|
|
||||||
{
|
|
||||||
Left = 25,
|
|
||||||
Bottom = 30,
|
|
||||||
},
|
|
||||||
Font = OsuFont.GetFont(Typeface.Torus, 16, FontWeight.Bold),
|
|
||||||
Text = "by " + info.Author
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
bg.OnLoadComplete += d => d.FadeIn(250, Easing.In);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
|
||||||
{
|
|
||||||
gradient.FadeIn(hover_duration, Easing.OutQuint);
|
|
||||||
return base.OnHover(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnHoverLost(HoverLostEvent e)
|
|
||||||
{
|
|
||||||
base.OnHoverLost(e);
|
|
||||||
gradient.FadeOut(hover_duration, Easing.OutQuint);
|
|
||||||
}
|
|
||||||
|
|
||||||
[LongRunningLoad]
|
|
||||||
private class NewsBackground : Sprite
|
|
||||||
{
|
|
||||||
private readonly string url;
|
|
||||||
|
|
||||||
public NewsBackground(string coverUrl)
|
|
||||||
{
|
|
||||||
url = coverUrl ?? "Headers/news";
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(LargeTextureStore store)
|
|
||||||
{
|
|
||||||
Texture = store.Get(url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DateContainer : Container, IHasTooltip
|
|
||||||
{
|
|
||||||
private readonly DateTime date;
|
|
||||||
|
|
||||||
public DateContainer(DateTime date)
|
|
||||||
{
|
|
||||||
this.date = date;
|
|
||||||
|
|
||||||
Anchor = Anchor.TopRight;
|
|
||||||
Origin = Anchor.TopRight;
|
|
||||||
Masking = true;
|
|
||||||
CornerRadius = 4;
|
|
||||||
AutoSizeAxes = Axes.Both;
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = Color4.Black.Opacity(0.5f),
|
|
||||||
},
|
|
||||||
new OsuSpriteText
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Font = OsuFont.GetFont(Typeface.Torus, 12, FontWeight.Bold, false, false),
|
|
||||||
Text = date.ToString("d MMM yyy").ToUpper(),
|
|
||||||
Margin = new MarginPadding
|
|
||||||
{
|
|
||||||
Vertical = 4,
|
|
||||||
Horizontal = 8,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public string TooltipText => date.ToString("dddd dd MMMM yyyy hh:mm:ss UTCz").ToUpper();
|
|
||||||
}
|
|
||||||
|
|
||||||
// fake API data struct to use for now as a skeleton for data, as there is no API struct for news article info for now
|
|
||||||
public class ArticleInfo
|
|
||||||
{
|
|
||||||
public string Title { get; set; }
|
|
||||||
public string CoverUrl { get; set; }
|
|
||||||
public DateTime Time { get; set; }
|
|
||||||
public string Author { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
// 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 osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
|
|
||||||
namespace osu.Game.Overlays.News
|
|
||||||
{
|
|
||||||
public abstract class NewsContent : FillFlowContainer
|
|
||||||
{
|
|
||||||
protected NewsContent()
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X;
|
|
||||||
AutoSizeAxes = Axes.Y;
|
|
||||||
Direction = FillDirection.Vertical;
|
|
||||||
Padding = new MarginPadding { Bottom = 100, Top = 20, Horizontal = 50 };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user