mirror of https://github.com/ppy/osu
Add back `Enabled` checks to `TooltipText` and `OnClick` to fix guest case
This commit is contained in:
parent
0b41dbf579
commit
a86f06df96
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue