diff --git a/osu.Game.Tests/Visual/Online/TestCaseBeatmapSetOverlay.cs b/osu.Game.Tests/Visual/Online/TestCaseBeatmapSetOverlay.cs index 19d295cf12..9cbccbd603 100644 --- a/osu.Game.Tests/Visual/Online/TestCaseBeatmapSetOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestCaseBeatmapSetOverlay.cs @@ -24,7 +24,6 @@ namespace osu.Game.Tests.Visual.Online public override IReadOnlyList RequiredTypes => new[] { typeof(Header), - typeof(ClickableUserContainer), typeof(ScoreTable), typeof(ScoreTableRow), typeof(ScoreTableHeaderRow), diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ClickableUserContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ClickableUserContainer.cs deleted file mode 100644 index 2448ae17f8..0000000000 --- a/osu.Game/Overlays/BeatmapSet/Scores/ClickableUserContainer.cs +++ /dev/null @@ -1,51 +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.Allocation; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Input.Events; -using osu.Game.Users; - -namespace osu.Game.Overlays.BeatmapSet.Scores -{ - public abstract class ClickableUserContainer : Container - { - private UserProfileOverlay profile; - - protected ClickableUserContainer() - { - AutoSizeAxes = Axes.Both; - } - - [BackgroundDependencyLoader(true)] - private void load(UserProfileOverlay profile) - { - this.profile = profile; - } - - private User user; - - public User User - { - get => user; - set - { - if (user == value) - return; - - user = value; - - OnUserChanged(user); - } - } - - protected abstract void OnUserChanged(User user); - - protected override bool OnClick(ClickEvent e) - { - profile?.ShowUser(user); - return true; - } - } -} diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs index 2cb16a5785..adb79eedfa 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs @@ -5,10 +5,10 @@ using System.Collections.Generic; using System.Linq; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Input.Events; using osu.Game.Graphics; +using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; +using osu.Game.Online.Chat; using osu.Game.Online.Leaderboards; using osu.Game.Rulesets.UI; using osu.Game.Scoring; @@ -53,17 +53,27 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Colour = score.Accuracy == 1 ? Color4.GreenYellow : Color4.White }; - protected override Drawable CreatePlayerCell() => new FillFlowContainer + protected override Drawable CreatePlayerCell() { - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(5, 0), - Children = new Drawable[] + var username = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: TEXT_SIZE)) { - new DrawableFlag(score.User.Country) { Size = new Vector2(20, 13) }, - new ClickableScoreUsername { User = score.User } - } - }; + AutoSizeAxes = Axes.Both, + }; + + username.AddLink(score.User.Username, null, LinkAction.OpenUserProfile, score.User.Id.ToString(), "Open profile"); + + return new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(5, 0), + Children = new Drawable[] + { + new DrawableFlag(score.User.Country) { Size = new Vector2(20, 13) }, + username + } + }; + } protected override IEnumerable CreateStatisticsCells() { @@ -100,47 +110,5 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Scale = new Vector2(0.3f) }) }; - - private class ClickableScoreUsername : ClickableUserContainer - { - private const int fade_duration = 100; - - private readonly SpriteText text; - private readonly SpriteText textBold; - - public ClickableScoreUsername() - { - Add(text = new OsuSpriteText - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Font = OsuFont.GetFont(size: TEXT_SIZE) - }); - - Add(textBold = new OsuSpriteText - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.Bold), - Alpha = 0, - }); - } - - protected override void OnUserChanged(User user) => text.Text = textBold.Text = user.Username; - - protected override bool OnHover(HoverEvent e) - { - textBold.Show(); - text.Hide(); - return base.OnHover(e); - } - - protected override void OnHoverLost(HoverLostEvent e) - { - textBold.Hide(); - text.Show(); - base.OnHoverLost(e); - } - } } } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs index 1ec4b7197d..f401dc93a7 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs @@ -6,11 +6,11 @@ using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; -using osu.Framework.Input.Events; using osu.Game.Graphics; +using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; +using osu.Game.Online.Chat; using osu.Game.Online.Leaderboards; using osu.Game.Scoring; using osu.Game.Users; @@ -24,7 +24,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private readonly SpriteText rankText; private readonly DrawableRank rank; private readonly UpdateableAvatar avatar; - private readonly UsernameText usernameText; + private readonly LinkFlowContainer usernameText; private readonly SpriteText date; private readonly DrawableFlag flag; @@ -77,10 +77,11 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Spacing = new Vector2(0, 3), Children = new Drawable[] { - usernameText = new UsernameText + usernameText = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 20, weight: FontWeight.Bold, italics: true)) { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, }, date = new SpriteText { @@ -113,69 +114,15 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { set { - avatar.User = usernameText.User = value.User; + avatar.User = value.User; flag.Country = value.User.Country; date.Text = $@"achieved {value.Date.Humanize()}"; + + usernameText.Clear(); + usernameText.AddLink(value.User.Username, null, LinkAction.OpenUserProfile, value.User.Id.ToString(), "Open profile"); + rank.UpdateRank(value.Rank); } } - - private class UsernameText : ClickableUserContainer - { - private const float username_fade_duration = 150; - - private readonly FillFlowContainer hoverContainer; - - private readonly SpriteText normalText; - private readonly SpriteText hoveredText; - - public UsernameText() - { - var font = OsuFont.GetFont(size: 20, weight: FontWeight.Bold, italics: true); - - Children = new Drawable[] - { - normalText = new OsuSpriteText { Font = font }, - hoverContainer = new FillFlowContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Alpha = 0, - Direction = FillDirection.Vertical, - Spacing = new Vector2(0, 1), - Children = new Drawable[] - { - hoveredText = new OsuSpriteText { Font = font }, - new Box - { - BypassAutoSizeAxes = Axes.Both, - RelativeSizeAxes = Axes.X, - Height = 1 - } - } - } - }; - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - hoverContainer.Colour = colours.Blue; - } - - protected override void OnUserChanged(User user) => normalText.Text = hoveredText.Text = user.Username; - - protected override bool OnHover(HoverEvent e) - { - hoverContainer.FadeIn(username_fade_duration, Easing.OutQuint); - return base.OnHover(e); - } - - protected override void OnHoverLost(HoverLostEvent e) - { - hoverContainer.FadeOut(username_fade_duration, Easing.OutQuint); - base.OnHoverLost(e); - } - } } }