2019-03-10 06:58:14 +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.Sprites;
|
|
|
|
|
using osu.Framework.Graphics.Textures;
|
2021-06-26 01:10:04 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2022-11-03 13:30:30 +08:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
|
using osu.Game.Online;
|
2019-03-10 06:58:14 +08:00
|
|
|
|
using osu.Game.Users;
|
|
|
|
|
using osuTK;
|
|
|
|
|
|
2019-04-26 12:49:44 +08:00
|
|
|
|
namespace osu.Game.Overlays.Profile.Header.Components
|
2019-03-10 06:58:14 +08:00
|
|
|
|
{
|
2019-11-29 12:52:23 +08:00
|
|
|
|
[LongRunningLoad]
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class DrawableBadge : OsuClickableContainer
|
2019-03-10 06:58:14 +08:00
|
|
|
|
{
|
|
|
|
|
public static readonly Vector2 DRAWABLE_BADGE_SIZE = new Vector2(86, 40);
|
|
|
|
|
|
|
|
|
|
private readonly Badge badge;
|
|
|
|
|
|
|
|
|
|
public DrawableBadge(Badge badge)
|
|
|
|
|
{
|
|
|
|
|
this.badge = badge;
|
|
|
|
|
Size = DRAWABLE_BADGE_SIZE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2022-11-03 13:30:30 +08:00
|
|
|
|
private void load(LargeTextureStore textures, ILinkHandler? linkHandler)
|
2019-03-10 06:58:14 +08:00
|
|
|
|
{
|
2022-11-03 13:30:30 +08:00
|
|
|
|
Child = new Sprite
|
2019-03-10 06:58:14 +08:00
|
|
|
|
{
|
|
|
|
|
FillMode = FillMode.Fit,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Texture = textures.Get(badge.ImageUrl),
|
|
|
|
|
};
|
2022-11-03 13:30:30 +08:00
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(badge.Url))
|
|
|
|
|
Action = () => linkHandler?.HandleLink(badge.Url);
|
2019-03-10 06:58:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
2022-11-03 13:30:30 +08:00
|
|
|
|
this.FadeInFromZero(200);
|
2019-03-10 06:58:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-03 13:30:30 +08:00
|
|
|
|
public override LocalisableString TooltipText => badge.Description;
|
2019-03-10 06:58:14 +08:00
|
|
|
|
}
|
|
|
|
|
}
|