1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-19 04:42:55 +08:00
osu-lazer/osu.Game/Graphics/UserInterface/ScreenTitleTextureIcon.cs

65 lines
2.1 KiB
C#
Raw Normal View History

2019-08-10 20:03:44 +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.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osuTK;
namespace osu.Game.Graphics.UserInterface
{
/// <summary>
2019-08-11 15:15:44 +08:00
/// A custom icon class for use with <see cref="ScreenTitle.CreateIcon()"/> based off a texture resource.
/// </summary>
2019-08-11 15:15:44 +08:00
public class ScreenTitleTextureIcon : CompositeDrawable
{
private const float circle_allowance = 0.8f;
2019-08-11 15:15:44 +08:00
private readonly string textureName;
2019-08-11 15:15:44 +08:00
public ScreenTitleTextureIcon(string textureName)
{
2019-08-11 15:15:44 +08:00
this.textureName = textureName;
}
[BackgroundDependencyLoader]
private void load(TextureStore textures, OsuColour colours)
{
Size = new Vector2(ScreenTitle.ICON_SIZE / circle_allowance);
InternalChildren = new Drawable[]
{
new CircularContainer
{
Masking = true,
BorderColour = colours.Violet,
BorderThickness = 3,
MaskingSmoothness = 1,
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
new Sprite
{
RelativeSizeAxes = Axes.Both,
2019-08-11 15:15:44 +08:00
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,
},
}
},
};
}
}
}