1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 20:22:55 +08:00

Merge pull request #25374 from peppy/add-skinnable-player-name

Add player name skin component
This commit is contained in:
Bartłomiej Dach 2023-11-06 09:34:11 +01:00 committed by GitHub
commit 41cd9a4db6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 1 deletions

View File

@ -54,7 +54,9 @@ namespace osu.Game.Tests.Skins
// Covers key counters
"Archives/modified-argon-pro-20230618.osk",
// Covers "Argon" health display
"Archives/modified-argon-pro-20231001.osk"
"Archives/modified-argon-pro-20231001.osk",
// Covers player name text component.
"Archives/modified-argon-20231106.osk",
};
/// <summary>

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