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;
|
2019-08-10 19:26:19 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
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.
|
2019-08-10 19:26:19 +08:00
|
|
|
|
/// </summary>
|
2019-08-11 15:15:44 +08:00
|
|
|
|
public class ScreenTitleTextureIcon : CompositeDrawable
|
2019-08-10 19:26:19 +08:00
|
|
|
|
{
|
2019-08-11 15:15:44 +08:00
|
|
|
|
private readonly string textureName;
|
2019-08-10 19:26:19 +08:00
|
|
|
|
|
2019-08-11 15:15:44 +08:00
|
|
|
|
public ScreenTitleTextureIcon(string textureName)
|
2019-08-10 19:26:19 +08:00
|
|
|
|
{
|
2019-08-11 15:15:44 +08:00
|
|
|
|
this.textureName = textureName;
|
2019-08-10 19:26:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2019-12-27 02:03:39 +08:00
|
|
|
|
private void load(TextureStore textures)
|
2019-08-10 19:26:19 +08:00
|
|
|
|
{
|
2019-12-27 02:03:39 +08:00
|
|
|
|
Size = new Vector2(ScreenTitle.ICON_SIZE);
|
2019-08-10 19:26:19 +08:00
|
|
|
|
|
2019-12-27 02:03:39 +08:00
|
|
|
|
InternalChild = new Sprite
|
2019-08-10 19:26:19 +08:00
|
|
|
|
{
|
2019-12-27 02:03:39 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Texture = textures.Get(textureName),
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2019-12-27 10:37:06 +08:00
|
|
|
|
FillMode = FillMode.Fit
|
2019-08-10 19:26:19 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|