Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions osu.Game.Tests/Visual/Online/TestSceneUserClickableAvatar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public void SetUp() => Schedule(() =>
public void TestClickableAvatarHover()
{
AddStep("hover avatar with user panel", () => InputManager.MoveMouseTo(this.ChildrenOfType<ClickableAvatar>().ElementAt(1)));
AddUntilStep("wait for tooltip to show", () => this.ChildrenOfType<ClickableAvatar.UserCardTooltip>().FirstOrDefault()?.State.Value == Visibility.Visible);
AddUntilStep("wait for tooltip to show", () => this.ChildrenOfType<UserCardTooltip>().FirstOrDefault()?.State.Value == Visibility.Visible);
AddStep("hover out", () => InputManager.MoveMouseTo(new Vector2(0)));
AddUntilStep("wait for tooltip to hide", () => this.ChildrenOfType<ClickableAvatar.UserCardTooltip>().FirstOrDefault()?.State.Value == Visibility.Hidden);
AddUntilStep("wait for tooltip to hide", () => this.ChildrenOfType<UserCardTooltip>().FirstOrDefault()?.State.Value == Visibility.Hidden);

AddStep("hover avatar without user panel", () => InputManager.MoveMouseTo(this.ChildrenOfType<ClickableAvatar>().ElementAt(0)));
AddUntilStep("wait for tooltip to show", () => this.ChildrenOfType<OsuTooltipContainer.OsuTooltip>().FirstOrDefault()?.State.Value == Visibility.Visible);
Expand Down
41 changes: 0 additions & 41 deletions osu.Game/Users/Drawables/ClickableAvatar.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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;
Expand Down Expand Up @@ -64,45 +62,6 @@ protected override bool OnClick(ClickEvent e)
return base.OnClick(e);
}

public partial class UserCardTooltip : VisibilityContainer, ITooltip<APIUser?>
{
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<APIUser?>
{
private readonly OsuTooltipContainer.OsuTooltip tooltip;
Expand Down
53 changes: 53 additions & 0 deletions osu.Game/Users/Drawables/UserCardTooltip.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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<APIUser?>
{
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;
}
}
}
}
8 changes: 7 additions & 1 deletion osu.Game/Users/UserBrickPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<APIUser?>
{
public UserBrickPanel(APIUser user)
: base(user)
{
AutoSizeAxes = Axes.Both;
CornerRadius = 6;
TooltipContent = user;
}

// Matches osu!web styling.
Expand Down Expand Up @@ -58,5 +61,8 @@ public UserBrickPanel(APIUser user)
})
}
};

public ITooltip<APIUser?> GetCustomTooltip() => new UserCardTooltip();
public APIUser? TooltipContent { get; }
}
}
Loading