1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 15:57:24 +08:00

partial change

This commit is contained in:
Joshua Hegedus 2023-11-06 15:25:12 +01:00
parent a01f6187f4
commit f897c21b3f
No known key found for this signature in database
GPG Key ID: 331D6A883C797319

View File

@ -15,14 +15,14 @@ using osuTK;
namespace osu.Game.Users.Drawables
{
public partial class ClickableAvatar : OsuClickableContainer, IHasCustomTooltip<UserGridPanel>
public partial class ClickableAvatar : OsuClickableContainer, IHasCustomTooltip<APIUser>
{
public ITooltip<UserGridPanel> GetCustomTooltip() => new UserGridPanelTooltip(this);
public UserGridPanel TooltipContent => new UserGridPanel(user!)
public ITooltip<APIUser> GetCustomTooltip()
{
Width = 300
};
return new APIUserTooltip(user);
}
public APIUser? TooltipContent => user;
public override LocalisableString TooltipText
{
@ -36,12 +36,6 @@ namespace osu.Game.Users.Drawables
set => throw new NotSupportedException();
}
/// <summary>
/// By default, the tooltip will show "view profile" as avatars are usually displayed next to a username.
/// Setting this to <c>true</c> exposes the username via tooltip for special cases where this is not true.
/// </summary>
// public bool ShowUsernameTooltip { get; set; }
public bool IsTooltipEnabled { get; set; }
private readonly APIUser? user;
@ -86,28 +80,23 @@ namespace osu.Game.Users.Drawables
return base.OnClick(e);
}
public partial class UserGridPanelTooltip : VisibilityContainer, ITooltip<UserGridPanel>
public partial class APIUserTooltip : VisibilityContainer, ITooltip<APIUser>
{
private readonly ClickableAvatar parent;
private UserGridPanel? displayedUser;
private bool isEnabled;
private APIUser? user;
public UserGridPanelTooltip(ClickableAvatar parent)
public APIUserTooltip(APIUser? user)
{
this.parent = parent ?? throw new ArgumentNullException(nameof(parent));
isEnabled = this.parent.IsTooltipEnabled;
this.user = user;
}
protected override void PopIn()
{
parent.SetValue(out isEnabled);
if (displayedUser is null || !isEnabled)
if (user is null)
{
return;
}
Child = displayedUser;
Child = new UserGridPanel(user);
this.FadeIn(20, Easing.OutQuint);
}
@ -115,9 +104,9 @@ namespace osu.Game.Users.Drawables
public void Move(Vector2 pos) => Position = pos;
public void SetContent(UserGridPanel userGridPanel)
public void SetContent(APIUser user)
{
displayedUser = userGridPanel;
this.user = user;
}
}
}