Add back `Enabled` checks to `TooltipText` and `OnClick` to fix guest case

This commit is contained in:
Joseph Madamba 2023-02-09 16:09:38 -08:00
parent 0b41dbf579
commit a86f06df96
1 changed files with 16 additions and 1 deletions

View File

@ -4,6 +4,7 @@
#nullable disable
using osu.Framework.Allocation;
using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Game.Graphics.Containers;
using osu.Game.Online.API.Requests.Responses;
@ -14,7 +15,13 @@ public partial class ClickableAvatar : OsuClickableContainer
{
private const string default_tooltip_text = "view profile";
public override LocalisableString TooltipText { get; set; } = default_tooltip_text;
private LocalisableString tooltip = default_tooltip_text;
public override LocalisableString TooltipText
{
get => Enabled.Value ? tooltip : default;
set => tooltip = value;
}
/// <summary>
/// By default, the tooltip will show "view profile" as avatars are usually displayed next to a username.
@ -53,5 +60,13 @@ private void openProfile()
if (user?.Id > 1 || !string.IsNullOrEmpty(user?.Username))
game?.ShowUser(user);
}
protected override bool OnClick(ClickEvent e)
{
if (!Enabled.Value)
return false;
return base.OnClick(e);
}
}
}