Add NewsHeader class

This commit is contained in:
Lucas A 2019-08-10 12:53:34 +02:00
parent 4b0ac381b7
commit b19c378fc8
2 changed files with 91 additions and 1 deletions

View File

@ -0,0 +1,71 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.News
{
public class NewsHeader : OverlayHeader
{
private const string front_page_string = "Front Page";
private NewsHeaderTitle title;
public NewsHeader()
{
TabControl.AddItem(front_page_string);
}
[BackgroundDependencyLoader]
private void load(OsuColour colour)
{
TabControl.AccentColour = colour.Violet;
}
protected override Drawable CreateBackground() => new NewsHeaderBackground();
protected override Drawable CreateContent() => new Container();
protected override ScreenTitle CreateTitle() => title = new NewsHeaderTitle();
private class NewsHeaderBackground : Sprite
{
public NewsHeaderBackground()
{
RelativeSizeAxes = Axes.Both;
FillMode = FillMode.Fill;
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
Texture = textures.Get(@"Headers/changelog"); //using changelog bg until corresponding osu-resources pr is merged.
}
}
private class NewsHeaderTitle : ScreenTitle
{
private const string article_string = "Article";
public bool IsReadingArticle
{
set => Section = value ? article_string : front_page_string;
}
public NewsHeaderTitle()
{
Title = "News";
IsReadingArticle = false;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
AccentColour = colours.Violet;
}
}
}
}

View File

@ -1,12 +1,17 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Overlays.News;
namespace osu.Game.Overlays namespace osu.Game.Overlays
{ {
public class NewsOverlay : FullscreenOverlay public class NewsOverlay : FullscreenOverlay
{ {
private NewsHeader header;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
@ -16,7 +21,21 @@ namespace osu.Game.Overlays
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = colours.PurpleDarkAlternative Colour = colours.PurpleDarkAlternative
} },
new OsuScrollContainer
{
RelativeSizeAxes = Axes.Both,
Child = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
header = new NewsHeader()
},
},
},
}; };
} }
} }