1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-28 09:37:23 +08:00

Update ScreenTitle in line with the new web design (#7350)

Update ScreenTitle in line with the new web design

Co-authored-by: Dean Herbert <pe@ppy.sh>
This commit is contained in:
Dean Herbert 2019-12-27 11:10:46 +09:00 committed by GitHub
commit 66ae97709a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 51 additions and 66 deletions

View File

@ -4,6 +4,7 @@
using System; using System;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osuTK; using osuTK;
@ -13,15 +14,15 @@ namespace osu.Game.Graphics.UserInterface
{ {
public abstract class ScreenTitle : CompositeDrawable, IHasAccentColour public abstract class ScreenTitle : CompositeDrawable, IHasAccentColour
{ {
public const float ICON_WIDTH = ICON_SIZE + icon_spacing; public const float ICON_WIDTH = ICON_SIZE + spacing;
public const float ICON_SIZE = 25; public const float ICON_SIZE = 30;
private const float spacing = 6;
private const int text_offset = 2;
private SpriteIcon iconSprite; private SpriteIcon iconSprite;
private readonly OsuSpriteText titleText, pageText; private readonly OsuSpriteText titleText, pageText;
private const float icon_spacing = 10;
protected IconUsage Icon protected IconUsage Icon
{ {
set set
@ -63,26 +64,35 @@ namespace osu.Game.Graphics.UserInterface
new FillFlowContainer new FillFlowContainer
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Spacing = new Vector2(icon_spacing, 0), Spacing = new Vector2(spacing, 0),
Direction = FillDirection.Horizontal,
Children = new[] Children = new[]
{ {
CreateIcon(), CreateIcon().With(t =>
new FillFlowContainer
{ {
AutoSizeAxes = Axes.Both, t.Anchor = Anchor.Centre;
Direction = FillDirection.Horizontal, t.Origin = Anchor.Centre;
Spacing = new Vector2(6, 0), }),
Children = new[] titleText = new OsuSpriteText
{ {
titleText = new OsuSpriteText Anchor = Anchor.Centre,
{ Origin = Anchor.Centre,
Font = OsuFont.GetFont(size: 30, weight: FontWeight.Light), Font = OsuFont.GetFont(size: 20, weight: FontWeight.Bold),
}, Margin = new MarginPadding { Bottom = text_offset }
pageText = new OsuSpriteText },
{ new Circle
Font = OsuFont.GetFont(size: 30, weight: FontWeight.Light), {
} Anchor = Anchor.Centre,
} Origin = Anchor.Centre,
Size = new Vector2(4),
Colour = Color4.Gray,
},
pageText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = OsuFont.GetFont(size: 20),
Margin = new MarginPadding { Bottom = text_offset }
} }
} }
}, },

View File

@ -4,7 +4,6 @@
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.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osuTK; using osuTK;
@ -16,8 +15,6 @@ namespace osu.Game.Graphics.UserInterface
/// </summary> /// </summary>
public class ScreenTitleTextureIcon : CompositeDrawable public class ScreenTitleTextureIcon : CompositeDrawable
{ {
private const float circle_allowance = 0.8f;
private readonly string textureName; private readonly string textureName;
public ScreenTitleTextureIcon(string textureName) public ScreenTitleTextureIcon(string textureName)
@ -26,38 +23,16 @@ namespace osu.Game.Graphics.UserInterface
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(TextureStore textures, OsuColour colours) private void load(TextureStore textures)
{ {
Size = new Vector2(ScreenTitle.ICON_SIZE / circle_allowance); Size = new Vector2(ScreenTitle.ICON_SIZE);
InternalChildren = new Drawable[] InternalChild = new Sprite
{ {
new CircularContainer RelativeSizeAxes = Axes.Both,
{ Texture = textures.Get(textureName),
Masking = true, Anchor = Anchor.Centre,
BorderColour = colours.Violet, Origin = Anchor.Centre,
BorderThickness = 3,
MaskingSmoothness = 1,
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
new Sprite
{
RelativeSizeAxes = Axes.Both,
Texture = textures.Get(textureName),
Size = new Vector2(circle_allowance),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colours.Violet,
Alpha = 0,
AlwaysPresent = true,
},
}
},
}; };
} }
} }

View File

@ -111,7 +111,7 @@ namespace osu.Game.Overlays.Changelog
public ChangelogHeaderTitle() public ChangelogHeaderTitle()
{ {
Title = "Changelog"; Title = "changelog";
Version = null; Version = null;
} }

View File

@ -15,7 +15,7 @@ namespace osu.Game.Overlays.News
{ {
public class NewsHeader : OverlayHeader public class NewsHeader : OverlayHeader
{ {
private const string front_page_string = "Front Page"; private const string front_page_string = "frontpage";
private NewsHeaderTitle title; private NewsHeaderTitle title;
@ -33,7 +33,7 @@ namespace osu.Game.Overlays.News
ShowFrontPage?.Invoke(); ShowFrontPage?.Invoke();
}; };
Current.ValueChanged += showArticle; Current.ValueChanged += showPost;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -42,7 +42,7 @@ namespace osu.Game.Overlays.News
TabControl.AccentColour = colour.Violet; TabControl.AccentColour = colour.Violet;
} }
private void showArticle(ValueChangedEvent<string> e) private void showPost(ValueChangedEvent<string> e)
{ {
if (e.OldValue != null) if (e.OldValue != null)
TabControl.RemoveItem(e.OldValue); TabControl.RemoveItem(e.OldValue);
@ -52,12 +52,12 @@ namespace osu.Game.Overlays.News
TabControl.AddItem(e.NewValue); TabControl.AddItem(e.NewValue);
TabControl.Current.Value = e.NewValue; TabControl.Current.Value = e.NewValue;
title.IsReadingArticle = true; title.IsReadingPost = true;
} }
else else
{ {
TabControl.Current.Value = front_page_string; TabControl.Current.Value = front_page_string;
title.IsReadingArticle = false; title.IsReadingPost = false;
} }
} }
@ -84,17 +84,17 @@ namespace osu.Game.Overlays.News
private class NewsHeaderTitle : ScreenTitle private class NewsHeaderTitle : ScreenTitle
{ {
private const string article_string = "Article"; private const string post_string = "post";
public bool IsReadingArticle public bool IsReadingPost
{ {
set => Section = value ? article_string : front_page_string; set => Section = value ? post_string : front_page_string;
} }
public NewsHeaderTitle() public NewsHeaderTitle()
{ {
Title = "News"; Title = "news";
IsReadingArticle = false; IsReadingPost = false;
} }
protected override Drawable CreateIcon() => new ScreenTitleTextureIcon(@"Icons/news"); protected override Drawable CreateIcon() => new ScreenTitleTextureIcon(@"Icons/news");

View File

@ -101,8 +101,8 @@ namespace osu.Game.Overlays.Profile
{ {
public ProfileHeaderTitle() public ProfileHeaderTitle()
{ {
Title = "Player"; Title = "player";
Section = "Info"; Section = "info";
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]