mirror of
https://github.com/ppy/osu.git
synced 2026-05-17 20:35:39 +08:00
50426eb3c8
Part of #32584. Very much inspired by the respective component for displaying profile pictures on the user overlay * allow disabling interactivity/tooltips * add option to show placeholder on null team instead of hiding component entirely * move setting corner radius out to respective parent components to allow for easier overriding
54 lines
1.6 KiB
C#
54 lines
1.6 KiB
C#
// 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 osu.Game.Online.API.Requests.Responses;
|
|
|
|
namespace osu.Game.Users.Drawables
|
|
{
|
|
[LongRunningLoad]
|
|
public partial class DrawableTeamFlag : CompositeDrawable
|
|
{
|
|
private readonly APITeam? team;
|
|
|
|
private readonly Sprite sprite;
|
|
|
|
/// <summary>
|
|
/// A simple, non-interactable flag sprite for the specified user.
|
|
/// </summary>
|
|
/// <param name="team">The team. A null value will show a placeholder background.</param>
|
|
public DrawableTeamFlag(APITeam? team)
|
|
{
|
|
this.team = team;
|
|
|
|
InternalChildren = new Drawable[]
|
|
{
|
|
new Box
|
|
{
|
|
RelativeSizeAxes = Axes.Both,
|
|
Colour = Colour4.FromHex("333"),
|
|
},
|
|
sprite = new Sprite
|
|
{
|
|
RelativeSizeAxes = Axes.Both,
|
|
Anchor = Anchor.Centre,
|
|
Origin = Anchor.Centre,
|
|
FillMode = FillMode.Fit,
|
|
}
|
|
};
|
|
}
|
|
|
|
[BackgroundDependencyLoader]
|
|
private void load(LargeTextureStore textures)
|
|
{
|
|
if (team != null)
|
|
sprite.Texture = textures.Get(team.FlagUrl);
|
|
}
|
|
}
|
|
}
|