2019-03-09 06:44:01 +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-05-21 10:50:03 +08:00
|
|
|
|
using System;
|
2019-03-09 06:44:01 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-12-26 02:56:43 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2019-03-29 13:03:00 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2019-03-09 06:44:01 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Graphics.UserInterface
|
|
|
|
|
{
|
2019-03-12 02:10:37 +08:00
|
|
|
|
public abstract class ScreenTitle : CompositeDrawable, IHasAccentColour
|
2019-03-09 06:44:01 +08:00
|
|
|
|
{
|
2019-12-26 03:09:14 +08:00
|
|
|
|
public const float ICON_WIDTH = ICON_SIZE + spacing;
|
|
|
|
|
|
2019-12-27 10:53:31 +08:00
|
|
|
|
public const float ICON_SIZE = 25;
|
2019-12-26 03:09:14 +08:00
|
|
|
|
private const float spacing = 6;
|
2019-12-26 02:56:43 +08:00
|
|
|
|
private const int text_offset = 2;
|
2019-05-21 10:50:03 +08:00
|
|
|
|
|
|
|
|
|
private SpriteIcon iconSprite;
|
2019-03-09 06:44:01 +08:00
|
|
|
|
private readonly OsuSpriteText titleText, pageText;
|
2019-05-21 10:50:03 +08:00
|
|
|
|
|
2019-03-29 13:03:00 +08:00
|
|
|
|
protected IconUsage Icon
|
2019-03-09 06:44:01 +08:00
|
|
|
|
{
|
2019-05-21 10:50:03 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (iconSprite == null)
|
|
|
|
|
throw new InvalidOperationException($"Cannot use {nameof(Icon)} with a custom {nameof(CreateIcon)} function.");
|
|
|
|
|
|
|
|
|
|
iconSprite.Icon = value;
|
|
|
|
|
}
|
2019-03-09 06:44:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-03-12 02:10:37 +08:00
|
|
|
|
protected string Title
|
2019-03-09 06:44:01 +08:00
|
|
|
|
{
|
|
|
|
|
set => titleText.Text = value;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-12 02:10:37 +08:00
|
|
|
|
protected string Section
|
2019-03-09 06:44:01 +08:00
|
|
|
|
{
|
|
|
|
|
set => pageText.Text = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Color4 AccentColour
|
|
|
|
|
{
|
|
|
|
|
get => pageText.Colour;
|
|
|
|
|
set => pageText.Colour = value;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-21 10:50:03 +08:00
|
|
|
|
protected virtual Drawable CreateIcon() => iconSprite = new SpriteIcon
|
|
|
|
|
{
|
|
|
|
|
Size = new Vector2(ICON_SIZE),
|
|
|
|
|
};
|
|
|
|
|
|
2019-03-12 02:10:37 +08:00
|
|
|
|
protected ScreenTitle()
|
2019-03-09 06:44:01 +08:00
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2019-12-26 03:09:14 +08:00
|
|
|
|
Spacing = new Vector2(spacing, 0),
|
2019-12-26 02:56:43 +08:00
|
|
|
|
Direction = FillDirection.Horizontal,
|
2019-05-21 10:50:03 +08:00
|
|
|
|
Children = new[]
|
2019-03-09 06:44:01 +08:00
|
|
|
|
{
|
2019-12-26 02:56:43 +08:00
|
|
|
|
CreateIcon().With(t =>
|
|
|
|
|
{
|
|
|
|
|
t.Anchor = Anchor.Centre;
|
|
|
|
|
t.Origin = Anchor.Centre;
|
|
|
|
|
}),
|
|
|
|
|
titleText = new OsuSpriteText
|
2019-03-09 06:44:01 +08:00
|
|
|
|
{
|
2019-12-26 02:56:43 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Font = OsuFont.GetFont(size: 20, weight: FontWeight.Bold),
|
|
|
|
|
Margin = new MarginPadding { Bottom = text_offset }
|
|
|
|
|
},
|
2019-12-27 09:53:20 +08:00
|
|
|
|
new Circle
|
2019-12-26 02:56:43 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Size = new Vector2(4),
|
2019-12-27 09:53:20 +08:00
|
|
|
|
Colour = Color4.Gray,
|
2019-12-26 02:56:43 +08:00
|
|
|
|
},
|
|
|
|
|
pageText = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Font = OsuFont.GetFont(size: 20),
|
|
|
|
|
Margin = new MarginPadding { Bottom = text_offset }
|
2019-03-09 06:44:01 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-22 05:18:45 +08:00
|
|
|
|
},
|
2019-03-09 06:44:01 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|