From e2b07628fb5719540ea3d1405de25a83b469b8da Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 6 Nov 2023 15:24:12 +0900 Subject: [PATCH 1/2] Add player name skin component 3 minute implementation. Addresses https://github.com/ppy/osu/discussions/25340. --- osu.Game/Skinning/Components/PlayerName.cs | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 osu.Game/Skinning/Components/PlayerName.cs diff --git a/osu.Game/Skinning/Components/PlayerName.cs b/osu.Game/Skinning/Components/PlayerName.cs new file mode 100644 index 0000000000..34ace53d47 --- /dev/null +++ b/osu.Game/Skinning/Components/PlayerName.cs @@ -0,0 +1,40 @@ +// Copyright (c) ppy Pty Ltd . 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); + } +} From 69d6feb5a8b9137aaf74956945b897d7741fe3a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 6 Nov 2023 08:51:31 +0100 Subject: [PATCH 2/2] Add test coverage for player name skin component --- .../Archives/modified-argon-20231106.osk | Bin 0 -> 1397 bytes osu.Game.Tests/Skins/SkinDeserialisationTest.cs | 4 +++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 osu.Game.Tests/Resources/Archives/modified-argon-20231106.osk diff --git a/osu.Game.Tests/Resources/Archives/modified-argon-20231106.osk b/osu.Game.Tests/Resources/Archives/modified-argon-20231106.osk new file mode 100644 index 0000000000000000000000000000000000000000..70c4ff64d74b2efe0cd630812a41186f11f0467d GIT binary patch literal 1397 zcmWIWW@Zs#U|`^2`0JV$epO>m++rZ_AXtQfp*TA;PcJhsQ?+L!*C7W1*5ALomQQ8$ zRN?Tl(ze##D%fqh-IMQq+0!D$AGu<6llCVZ$xCSax#ym1WAgEgE7h`dx2y;i@;>BY zo8cj)v2)g*`ldCh-M58r@f+Vz{8uC{Cv{oK{FVC3rel?2Ts@D>x5@}wOkC=+bLX2# zi%I)u9S#Zke{oLIYNO+eVy33HxdyzJI$n0@t(Ea^#ZoElIZyPgx-5&|%=KzDx<5ld z0L3F)-r3fd0zJ_S#JoTZ@z} ze0N~b1p^}kqe~$dPMq~W>2uo0m(fVq$7E`WL)4t^AYt!M-445)K5zQ`>GWrXNAoI= zs&-bY&g@j3`Ll9fW#-R-;;(la%U-air$2j|`fTZI%ceC9A4^0MCV9ndWk7YG!T++N zdL{;jQ^E`kVnFx#CT8Y>|EA=N9DWrRJ3sgB|*Ix^Mn12Z6Ttf4I7hBN|o;ho4ex z-L`VowiPOST_$cdYu=l>w>j;)O4yP5_qQxMJ?}baG`(!MR5;IL{J8d;?B?ydr?dJy zV>de-V7EN}E&KJg8$G5%5(bIy^t-E9ZxP@3IfwJuWw)uf-bXThGf`n!`KB{rW^I|_ zw&MorD=#SfFv%opnFbu+#r;0weuId6<)zKt{>PDj^TEUY6Xrf< zdeZ6Bno%xiHDke}TPZuh)p_#HM-6-)cAcKz?=l;;-K z%xlUHocj7LJw}(e`%h%n?Mk~#%S9I2Fsqf=+!M(Sna}R|-TX=9TZM!t#}6!ykUsz5 z4MKBujhA8uxmWH z{Ed0fHl5y6TVDPT*sAo_zTad2^35DV6K;veG_6mT(_1pLTP^R$ikkwg%bq-Mu0ATt zzvF?G_R_tg5ghghr>=aySyZ5Vfu4>@DCeJ+i%ciNt+cPL*)OUb!SLwd_e1&Z^~u6z z<+GI!|KD9;zq^3R#NBHKPhwL{Rw)Pj$z}1$>{SzD3N(G)s#{J9ExqX_-RCf$+sAj_ zpZ@lG$&Fd;#Z!J|2I=fuZx(2I!20>Ft^XKNldR0tq$)LFQq=@vJ|GUrNvurEOwCC_ z57ZD2Ur>zzPW&%bg5eD4l4bWH!XarHP z(g$4^dgg}eVPI%H3DpJ9>gZb0^BqEKCL^v~h;9aYKp@PJVL=a;0B=?{kUR?zegx8a IKotxO0R77}LjV8( literal 0 HcmV?d00001 diff --git a/osu.Game.Tests/Skins/SkinDeserialisationTest.cs b/osu.Game.Tests/Skins/SkinDeserialisationTest.cs index 98008a003d..67f9d20fce 100644 --- a/osu.Game.Tests/Skins/SkinDeserialisationTest.cs +++ b/osu.Game.Tests/Skins/SkinDeserialisationTest.cs @@ -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", }; ///