mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 08:52:56 +08:00
Simplify tooltip implementation
This commit is contained in:
parent
68c37585e5
commit
5866b67a5b
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
@ -15,22 +16,23 @@ namespace osu.Game.Users.Drawables
|
|||||||
{
|
{
|
||||||
private const string default_tooltip_text = "view profile";
|
private const string default_tooltip_text = "view profile";
|
||||||
|
|
||||||
private LocalisableString tooltip = default_tooltip_text;
|
|
||||||
|
|
||||||
public override LocalisableString TooltipText
|
public override LocalisableString TooltipText
|
||||||
{
|
{
|
||||||
get => Enabled.Value ? tooltip : string.Empty;
|
get
|
||||||
set => tooltip = value;
|
{
|
||||||
|
if (!Enabled.Value)
|
||||||
|
return string.Empty;
|
||||||
|
|
||||||
|
return ShowUsernameTooltip ? (user?.Username ?? string.Empty) : default_tooltip_text;
|
||||||
|
}
|
||||||
|
set => throw new InvalidOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// By default, the tooltip will show "view profile" as avatars are usually displayed next to a username.
|
/// 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.
|
/// Setting this to <c>true</c> exposes the username via tooltip for special cases where this is not true.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool ShowUsernameTooltip
|
public bool ShowUsernameTooltip { get; set; }
|
||||||
{
|
|
||||||
set => TooltipText = value ? (user?.Username ?? string.Empty) : default_tooltip_text;
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly APIUser user;
|
private readonly APIUser user;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user