From 6af330e50fda7b4d4675859d2dac0b5105275d4b Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Wed, 1 Jul 2026 22:09:35 -0700 Subject: [PATCH 1/2] Move `UserCardTooltip` to own file --- .../Online/TestSceneUserClickableAvatar.cs | 4 +- osu.Game/Users/Drawables/ClickableAvatar.cs | 41 -------------- osu.Game/Users/Drawables/UserCardTooltip.cs | 53 +++++++++++++++++++ 3 files changed, 55 insertions(+), 43 deletions(-) create mode 100644 osu.Game/Users/Drawables/UserCardTooltip.cs diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserClickableAvatar.cs b/osu.Game.Tests/Visual/Online/TestSceneUserClickableAvatar.cs index 3333eae56731..b087da28b8d6 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneUserClickableAvatar.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneUserClickableAvatar.cs @@ -44,9 +44,9 @@ public void SetUp() => Schedule(() => public void TestClickableAvatarHover() { AddStep("hover avatar with user panel", () => InputManager.MoveMouseTo(this.ChildrenOfType().ElementAt(1))); - AddUntilStep("wait for tooltip to show", () => this.ChildrenOfType().FirstOrDefault()?.State.Value == Visibility.Visible); + AddUntilStep("wait for tooltip to show", () => this.ChildrenOfType().FirstOrDefault()?.State.Value == Visibility.Visible); AddStep("hover out", () => InputManager.MoveMouseTo(new Vector2(0))); - AddUntilStep("wait for tooltip to hide", () => this.ChildrenOfType().FirstOrDefault()?.State.Value == Visibility.Hidden); + AddUntilStep("wait for tooltip to hide", () => this.ChildrenOfType().FirstOrDefault()?.State.Value == Visibility.Hidden); AddStep("hover avatar without user panel", () => InputManager.MoveMouseTo(this.ChildrenOfType().ElementAt(0))); AddUntilStep("wait for tooltip to show", () => this.ChildrenOfType().FirstOrDefault()?.State.Value == Visibility.Visible); diff --git a/osu.Game/Users/Drawables/ClickableAvatar.cs b/osu.Game/Users/Drawables/ClickableAvatar.cs index 26622a1f30de..3954ee2af04e 100644 --- a/osu.Game/Users/Drawables/ClickableAvatar.cs +++ b/osu.Game/Users/Drawables/ClickableAvatar.cs @@ -1,9 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; using osu.Framework.Input.Events; @@ -64,45 +62,6 @@ protected override bool OnClick(ClickEvent e) return base.OnClick(e); } - public partial class UserCardTooltip : VisibilityContainer, ITooltip - { - public UserCardTooltip() - { - AutoSizeAxes = Axes.Both; - } - - protected override void PopIn() => this.FadeIn(150, Easing.OutQuint); - protected override void PopOut() => this.Delay(150).FadeOut(500, Easing.OutQuint); - - public void Move(Vector2 pos) => Position = pos; - - private APIUser? user; - - public void SetContent(APIUser? content) - { - if (content == user && Children.Any()) - return; - - user = content; - - if (user != null) - { - LoadComponentAsync(new UserGridPanel(user) - { - Width = 300, - }, panel => Child = panel); - } - else - { - var tooltip = new OsuTooltipContainer.OsuTooltip(); - tooltip.SetContent(ContextMenuStrings.ViewProfile); - tooltip.Show(); - - Child = tooltip; - } - } - } - public partial class NoCardTooltip : VisibilityContainer, ITooltip { private readonly OsuTooltipContainer.OsuTooltip tooltip; diff --git a/osu.Game/Users/Drawables/UserCardTooltip.cs b/osu.Game/Users/Drawables/UserCardTooltip.cs new file mode 100644 index 000000000000..5ac18b76fc66 --- /dev/null +++ b/osu.Game/Users/Drawables/UserCardTooltip.cs @@ -0,0 +1,53 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Linq; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; +using osu.Game.Graphics.Cursor; +using osu.Game.Localisation; +using osu.Game.Online.API.Requests.Responses; +using osuTK; + +namespace osu.Game.Users.Drawables +{ + public partial class UserCardTooltip : VisibilityContainer, ITooltip + { + public UserCardTooltip() + { + AutoSizeAxes = Axes.Both; + } + + protected override void PopIn() => this.FadeIn(150, Easing.OutQuint); + protected override void PopOut() => this.Delay(150).FadeOut(500, Easing.OutQuint); + + public void Move(Vector2 pos) => Position = pos; + + private APIUser? user; + + public void SetContent(APIUser? content) + { + if (content == user && Children.Any()) + return; + + user = content; + + if (user != null) + { + LoadComponentAsync(new UserGridPanel(user) + { + Width = 300, + }, panel => Child = panel); + } + else + { + var tooltip = new OsuTooltipContainer.OsuTooltip(); + tooltip.SetContent(ContextMenuStrings.ViewProfile); + tooltip.Show(); + + Child = tooltip; + } + } + } +} From e5722a321429ae628cdf01312e6d37c5c6717848 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Wed, 1 Jul 2026 22:10:01 -0700 Subject: [PATCH 2/2] Show user card tooltip on user brick panels --- osu.Game/Users/UserBrickPanel.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/osu.Game/Users/UserBrickPanel.cs b/osu.Game/Users/UserBrickPanel.cs index fff1307e0a95..2aeda7f34798 100644 --- a/osu.Game/Users/UserBrickPanel.cs +++ b/osu.Game/Users/UserBrickPanel.cs @@ -4,20 +4,23 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; using osu.Game.Online.API.Requests.Responses; +using osu.Game.Users.Drawables; using osuTK; namespace osu.Game.Users { - public partial class UserBrickPanel : UserPanel + public partial class UserBrickPanel : UserPanel, IHasCustomTooltip { public UserBrickPanel(APIUser user) : base(user) { AutoSizeAxes = Axes.Both; CornerRadius = 6; + TooltipContent = user; } // Matches osu!web styling. @@ -58,5 +61,8 @@ public UserBrickPanel(APIUser user) }) } }; + + public ITooltip GetCustomTooltip() => new UserCardTooltip(); + public APIUser? TooltipContent { get; } } }