mirror of
https://github.com/osukey/osukey.git
synced 2025-06-05 21:07:18 +09:00
Add NewsHeader class
This commit is contained in:
parent
4b0ac381b7
commit
b19c378fc8
71
osu.Game/Overlays/News/NewsHeader.cs
Normal file
71
osu.Game/Overlays/News/NewsHeader.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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()
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user