mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:37:28 +08:00
Merge pull request #25374 from peppy/add-skinnable-player-name
Add player name skin component
This commit is contained in:
commit
41cd9a4db6
BIN
osu.Game.Tests/Resources/Archives/modified-argon-20231106.osk
Normal file
BIN
osu.Game.Tests/Resources/Archives/modified-argon-20231106.osk
Normal file
Binary file not shown.
@ -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>
|
||||
|
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