mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 00:53:31 +08:00
Update tooltip implementation
This commit is contained in:
parent
536e7d8757
commit
132d51a2cc
@ -196,17 +196,30 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
}
|
||||
}
|
||||
|
||||
public string TooltipText => Statistics.Value?.Ranks.Global == null ? "" : $"#{ranks[dayIndex].Value:#,##0}|{ranked_days - ranks[dayIndex].Key + 1}";
|
||||
public object TooltipContent
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Statistics.Value?.Ranks.Global == null)
|
||||
return null;
|
||||
|
||||
var days = ranked_days - ranks[dayIndex].Key + 1;
|
||||
|
||||
return new TooltipDisplayContent
|
||||
{
|
||||
Rank = $"#{ranks[dayIndex].Value:#,##0}",
|
||||
Time = days == 0 ? "now" : $"{days} days ago"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public ITooltip GetCustomTooltip() => new RankGraphTooltip();
|
||||
|
||||
public class RankGraphTooltip : VisibilityContainer, ITooltip
|
||||
private class RankGraphTooltip : VisibilityContainer, ITooltip
|
||||
{
|
||||
private readonly OsuSpriteText globalRankingText, timeText;
|
||||
private readonly Box background;
|
||||
|
||||
public string TooltipText { get; set; }
|
||||
|
||||
public RankGraphTooltip()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
@ -260,11 +273,14 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
background.Colour = colours.GreySeafoamDark;
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
public bool SetContent(object content)
|
||||
{
|
||||
var info = TooltipText.Split('|');
|
||||
globalRankingText.Text = info[0];
|
||||
timeText.Text = info[1] == "0" ? "now" : $"{info[1]} days ago";
|
||||
if (!(content is TooltipDisplayContent info))
|
||||
return false;
|
||||
|
||||
globalRankingText.Text = info.Rank;
|
||||
timeText.Text = info.Time;
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool instantMove = true;
|
||||
@ -280,9 +296,24 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
this.MoveTo(pos, 200, Easing.OutQuint);
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
}
|
||||
|
||||
public string TooltipText
|
||||
{
|
||||
set => throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
protected override void PopIn() => this.FadeIn(200, Easing.OutQuint);
|
||||
|
||||
protected override void PopOut() => this.FadeOut(200, Easing.OutQuint);
|
||||
}
|
||||
|
||||
private class TooltipDisplayContent
|
||||
{
|
||||
public string Rank;
|
||||
public string Time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user