diff --git a/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs b/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs index e8fc40825d..52c9ab5aa4 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs @@ -2,9 +2,13 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Game.Online.API; using osu.Game.Users; +using OpenTK; +using OpenTK.Graphics; namespace osu.Game.Overlays.Toolbar { @@ -20,7 +24,20 @@ namespace osu.Game.Overlays.Toolbar Add(new OpaqueBackground { Depth = 1 }); - Flow.Add(avatar = new Avatar()); + Flow.Add(avatar = new Avatar + { + Masking = true, + Size = new Vector2(32), + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + CornerRadius = 4, + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Shadow, + Radius = 4, + Colour = Color4.Black.Opacity(0.1f), + } + }); } [BackgroundDependencyLoader] diff --git a/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs b/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs index 9ec560ba41..ff556ed0af 100644 --- a/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs +++ b/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs @@ -33,7 +33,7 @@ namespace osu.Game.Screens.Select.Leaderboards }; private Box background; - private Container content, avatarContainer; + private Container content, avatar; private DrawableRank scoreRank; private OsuSpriteText nameLabel; private GlowingSpriteText scoreLabel; @@ -63,13 +63,13 @@ namespace osu.Game.Screens.Select.Leaderboards // TODO: This fade to 0.01 is hacky, find a better way FadeTo(0.01f); - foreach (Drawable d in new Drawable[] { avatarContainer, nameLabel, scoreLabel, scoreRank, flagBadgeContainer, maxCombo, accuracy, modsContainer, }) + foreach (Drawable d in new Drawable[] { avatar, nameLabel, scoreLabel, scoreRank, flagBadgeContainer, maxCombo, accuracy, modsContainer, }) { d.FadeOut(); } content.MoveToY(75); - avatarContainer.MoveToX(75); + avatar.MoveToX(75); nameLabel.MoveToX(150); Delay(index * 50); @@ -81,10 +81,10 @@ namespace osu.Game.Screens.Select.Leaderboards Delay(100); Schedule(() => { - avatarContainer.FadeIn(300, EasingTypes.OutQuint); + avatar.FadeIn(300, EasingTypes.OutQuint); nameLabel.FadeIn(350, EasingTypes.OutQuint); - avatarContainer.MoveToX(0, 300, EasingTypes.OutQuint); + avatar.MoveToX(0, 300, EasingTypes.OutQuint); nameLabel.MoveToX(0, 350, EasingTypes.OutQuint); Delay(250); @@ -165,21 +165,13 @@ namespace osu.Game.Screens.Select.Leaderboards Padding = new MarginPadding(edge_margin), Children = new Drawable[] { - avatarContainer = new Container + avatar = new Avatar { Size = new Vector2(height - edge_margin * 2, height - edge_margin * 2), CornerRadius = corner_radius, Masking = true, EdgeEffect = imageShadow, - Children = new Drawable[] - { - new Avatar - { - RelativeSizeAxes = Axes.Both, - UserId = Score.User.Id, - Masking = false, - }, - }, + UserId = Score.User?.Id ?? Score.UserID, }, new Container { diff --git a/osu.Game/Users/Avatar.cs b/osu.Game/Users/Avatar.cs index 7a44d8601c..398150473d 100644 --- a/osu.Game/Users/Avatar.cs +++ b/osu.Game/Users/Avatar.cs @@ -21,22 +21,11 @@ namespace osu.Game.Users private OsuGame game; private Texture guestTexture; - public Avatar() + [BackgroundDependencyLoader(permitNulls: true)] + private void load(OsuGameBase game, TextureStore textures) { - Size = new Vector2(32); - Anchor = Anchor.CentreLeft; - Origin = Anchor.CentreLeft; - - CornerRadius = Size.X / 8; - - EdgeEffect = new EdgeEffect - { - Type = EdgeEffectType.Shadow, - Radius = 4, - Colour = Color4.Black.Opacity(0.1f), - }; - - Masking = true; + this.game = game; + guestTexture = textures.Get(@"Online/avatar-guest"); } [BackgroundDependencyLoader(permitNulls: true)]