1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-17 13:23:00 +08:00
Files
osu-lazer/osu.Game/Users/Drawables/DrawableTeamFlag.cs
T
Krzysztof Gutkowski 50426eb3c8 Refactor UpdateableTeamFlag for use on team overlay (#36286)
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
2026-02-10 23:18:36 +09:00

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);
}
}
}