added isEnabled to tooltip

This commit is contained in:
Joshua Hegedus 2023-11-06 11:54:57 +01:00
parent 718492a0b7
commit 034f53da4b
No known key found for this signature in database
GPG Key ID: 331D6A883C797319
2 changed files with 19 additions and 2 deletions

View File

@ -14,13 +14,15 @@ namespace osu.Game.Users.Drawables
{
public partial class ClickableAvatar : OsuClickableContainer, IHasCustomTooltip<UserGridPanel>
{
public ITooltip<UserGridPanel> GetCustomTooltip() => new UserGridPanelTooltip();
public ITooltip<UserGridPanel> GetCustomTooltip() => new UserGridPanelTooltip(IsTooltipEnabled);
public UserGridPanel TooltipContent => new UserGridPanel(user!)
{
Width = 300
};
public bool IsTooltipEnabled;
private readonly APIUser? user;
[Resolved]
@ -33,6 +35,7 @@ namespace osu.Game.Users.Drawables
public ClickableAvatar(APIUser? user = null)
{
this.user = user;
IsTooltipEnabled = true;
if (user?.Id != APIUser.SYSTEM_USER_ID)
Action = openProfile;
@ -60,10 +63,21 @@ namespace osu.Game.Users.Drawables
private partial class UserGridPanelTooltip : VisibilityContainer, ITooltip<UserGridPanel>
{
private readonly bool isEnabled;
private UserGridPanel? displayedUser;
public UserGridPanelTooltip(bool isEnabled = true)
{
this.isEnabled = isEnabled;
}
protected override void PopIn()
{
if (displayedUser is null || !isEnabled)
{
return;
}
Child = displayedUser;
this.FadeIn(20, Easing.OutQuint);
}

View File

@ -47,17 +47,20 @@ namespace osu.Game.Users.Drawables
private readonly bool isInteractive;
private readonly bool showGuestOnNull;
private readonly bool showUserPanel;
/// <summary>
/// Construct a new UpdateableAvatar.
/// </summary>
/// <param name="user">The initial user to display.</param>
/// <param name="isInteractive">If set to true, hover/click sounds will play and clicking the avatar will open the user's profile.</param>
/// <param name="showUserPanel">If set to true, the user status panel will be displayed in the tooltip.</param>
/// <param name="showGuestOnNull">Whether to show a default guest representation on null user (as opposed to nothing).</param>
public UpdateableAvatar(APIUser? user = null, bool isInteractive = true, bool showGuestOnNull = true)
public UpdateableAvatar(APIUser? user = null, bool isInteractive = true, bool showUserPanel = true, bool showGuestOnNull = true)
{
this.isInteractive = isInteractive;
this.showGuestOnNull = showGuestOnNull;
this.showUserPanel = showUserPanel;
User = user;
}