mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 17:43:05 +08:00
Add player name skin component
3 minute implementation. Addresses https://github.com/ppy/osu/discussions/25340.
This commit is contained in:
parent
bc9cdb4ce0
commit
e2b07628fb
40
osu.Game/Skinning/Components/PlayerName.cs
Normal file
40
osu.Game/Skinning/Components/PlayerName.cs
Normal 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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user