From fec0db8fe142d9b014b96b801ad2aa7d36353ce1 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Mon, 17 Jun 2019 21:55:07 +0300 Subject: [PATCH] Merge UpdateableAvatar.cs and Avatar.cs + Rename Avatar to DrawableAvatar --- .../Online/Leaderboards/LeaderboardScore.cs | 5 +- osu.Game/Overlays/BeatmapSet/AuthorInfo.cs | 2 +- .../Chat/Tabs/PrivateChannelTabItem.cs | 6 +- .../Overlays/Toolbar/ToolbarUserButton.cs | 1 + .../Multi/Lounge/Components/RoomInspector.cs | 1 + .../Multi/Match/Components/HostInfo.cs | 1 + .../DrawableAvatar.cs} | 63 ++++++++++++++++++- osu.Game/Users/UpdateableAvatar.cs | 49 --------------- 8 files changed, 69 insertions(+), 59 deletions(-) rename osu.Game/Users/{Avatar.cs => Drawables/DrawableAvatar.cs} (60%) delete mode 100644 osu.Game/Users/UpdateableAvatar.cs diff --git a/osu.Game/Online/Leaderboards/LeaderboardScore.cs b/osu.Game/Online/Leaderboards/LeaderboardScore.cs index 1da697e72e..9840b59805 100644 --- a/osu.Game/Online/Leaderboards/LeaderboardScore.cs +++ b/osu.Game/Online/Leaderboards/LeaderboardScore.cs @@ -17,7 +17,6 @@ using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Rulesets.UI; using osu.Game.Scoring; -using osu.Game.Users; using osu.Game.Users.Drawables; using osuTK; using osuTK.Graphics; @@ -66,7 +65,7 @@ namespace osu.Game.Online.Leaderboards statisticsLabels = GetStatistics(score).Select(s => new ScoreComponentLabel(s)).ToList(); - Avatar innerAvatar; + DrawableAvatar innerAvatar; Children = new Drawable[] { @@ -113,7 +112,7 @@ namespace osu.Game.Online.Leaderboards Children = new[] { avatar = new DelayedLoadWrapper( - innerAvatar = new Avatar(user) + innerAvatar = new DrawableAvatar(user) { RelativeSizeAxes = Axes.Both, CornerRadius = corner_radius, diff --git a/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs b/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs index 7331faa618..096e91b65b 100644 --- a/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs +++ b/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs @@ -6,7 +6,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps; using osu.Game.Graphics.Sprites; -using osu.Game.Users; +using osu.Game.Users.Drawables; using osuTK; using osuTK.Graphics; using osu.Framework.Graphics.Effects; diff --git a/osu.Game/Overlays/Chat/Tabs/PrivateChannelTabItem.cs b/osu.Game/Overlays/Chat/Tabs/PrivateChannelTabItem.cs index b8165e70cb..9e87bae864 100644 --- a/osu.Game/Overlays/Chat/Tabs/PrivateChannelTabItem.cs +++ b/osu.Game/Overlays/Chat/Tabs/PrivateChannelTabItem.cs @@ -10,7 +10,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Online.Chat; -using osu.Game.Users; +using osu.Game.Users.Drawables; using osuTK; namespace osu.Game.Overlays.Chat.Tabs @@ -25,7 +25,7 @@ namespace osu.Game.Overlays.Chat.Tabs if (value.Type != ChannelType.PM) throw new ArgumentException("Argument value needs to have the targettype user!"); - Avatar avatar; + DrawableAvatar avatar; AddRange(new Drawable[] { @@ -48,7 +48,7 @@ namespace osu.Game.Overlays.Chat.Tabs Anchor = Anchor.Centre, Origin = Anchor.Centre, Masking = true, - Child = new DelayedLoadWrapper(avatar = new Avatar(value.Users.First()) + Child = new DelayedLoadWrapper(avatar = new DrawableAvatar(value.Users.First()) { RelativeSizeAxes = Axes.Both, OpenOnClick = { Value = false }, diff --git a/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs b/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs index ea15e5498b..bccef3d9fe 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics.Effects; using osu.Game.Graphics; using osu.Game.Online.API; using osu.Game.Users; +using osu.Game.Users.Drawables; using osuTK; using osuTK.Graphics; diff --git a/osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs b/osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs index 1a18f742a9..5030d8cb50 100644 --- a/osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs +++ b/osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs @@ -19,6 +19,7 @@ using osu.Game.Online.API.Requests; using osu.Game.Online.Multiplayer; using osu.Game.Screens.Multi.Components; using osu.Game.Users; +using osu.Game.Users.Drawables; using osuTK; using osuTK.Graphics; diff --git a/osu.Game/Screens/Multi/Match/Components/HostInfo.cs b/osu.Game/Screens/Multi/Match/Components/HostInfo.cs index b898cd0466..8851a96605 100644 --- a/osu.Game/Screens/Multi/Match/Components/HostInfo.cs +++ b/osu.Game/Screens/Multi/Match/Components/HostInfo.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics.Containers; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Users; +using osu.Game.Users.Drawables; using osuTK; namespace osu.Game.Screens.Multi.Match.Components diff --git a/osu.Game/Users/Avatar.cs b/osu.Game/Users/Drawables/DrawableAvatar.cs similarity index 60% rename from osu.Game/Users/Avatar.cs rename to osu.Game/Users/Drawables/DrawableAvatar.cs index 8937f94768..dae00549fa 100644 --- a/osu.Game/Users/Avatar.cs +++ b/osu.Game/Users/Drawables/DrawableAvatar.cs @@ -6,14 +6,71 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Framework.Input.Events; using osu.Game.Graphics.Containers; -namespace osu.Game.Users +namespace osu.Game.Users.Drawables { - public class Avatar : Container + /// + /// An avatar which can update to a new user when needed. + /// + public class UpdateableAvatar : ModelBackedDrawable + { + public User User + { + get => Model; + set => Model = value; + } + + public new bool Masking + { + get => base.Masking; + set => base.Masking = value; + } + + public new float CornerRadius + { + get => base.CornerRadius; + set => base.CornerRadius = value; + } + + public new EdgeEffectParameters EdgeEffect + { + get => base.EdgeEffect; + set => base.EdgeEffect = value; + } + + /// + /// Whether to show a default guest representation on null user (as opposed to nothing). + /// + public bool ShowGuestOnNull = true; + + /// + /// Whether to open the user's profile when clicked. + /// + public readonly BindableBool OpenOnClick = new BindableBool(true); + + protected override Drawable CreateDrawable(User user) + { + if (user == null && !ShowGuestOnNull) + return null; + + var avatar = new DrawableAvatar(user) + { + RelativeSizeAxes = Axes.Both, + }; + + avatar.OnLoadComplete += d => d.FadeInFromZero(300, Easing.OutQuint); + avatar.OpenOnClick.BindTo(OpenOnClick); + + return avatar; + } + } + + public class DrawableAvatar : Container { /// /// Whether to open the user's profile when clicked. @@ -29,7 +86,7 @@ namespace osu.Game.Users /// An avatar for specified user. /// /// The user. A null value will get a placeholder avatar. - public Avatar(User user = null) + public DrawableAvatar(User user = null) { this.user = user; } diff --git a/osu.Game/Users/UpdateableAvatar.cs b/osu.Game/Users/UpdateableAvatar.cs deleted file mode 100644 index 8eb08f963d..0000000000 --- a/osu.Game/Users/UpdateableAvatar.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Framework.Bindables; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; - -namespace osu.Game.Users -{ - /// - /// An avatar which can update to a new user when needed. - /// - public class UpdateableAvatar : ModelBackedDrawable - { - /// - /// Whether to show a default guest representation on null user (as opposed to nothing). - /// - public bool ShowGuestOnNull = true; - - public User User - { - get => Model; - set => Model = value; - } - - /// - /// Whether to open the user's profile when clicked. - /// - public readonly BindableBool OpenOnClick = new BindableBool(true); - - protected override Drawable CreateDrawable(User user) - { - if (user != null || ShowGuestOnNull) - { - var avatar = new Avatar(user) - { - RelativeSizeAxes = Axes.Both, - }; - - avatar.OnLoadComplete += d => d.FadeInFromZero(300, Easing.OutQuint); - avatar.OpenOnClick.BindTo(OpenOnClick); - - return avatar; - } - - return null; - } - } -}