1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 19:42:55 +08:00

Add player name skin component

3 minute implementation.

Addresses https://github.com/ppy/osu/discussions/25340.
This commit is contained in:
Dean Herbert 2023-11-06 15:24:12 +09:00
parent bc9cdb4ce0
commit e2b07628fb
No known key found for this signature in database

View File

@ -0,0 +1,40 @@
// 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 JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics.Sprites;
using osu.Game.Screens.Play;
namespace osu.Game.Skinning.Components
{
[UsedImplicitly]
public partial class PlayerName : FontAdjustableSkinComponent
{
private readonly OsuSpriteText text;
public PlayerName()
{
AutoSizeAxes = Axes.Both;
InternalChildren = new Drawable[]
{
text = new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
}
};
}
[BackgroundDependencyLoader]
private void load(GameplayState gameplayState)
{
text.Text = gameplayState.Score.ScoreInfo.User.Username;
}
protected override void SetFont(FontUsage font) => text.Font = font.With(size: 40);
}
}