mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Simplify user graph tooltips logic
The same tooltip can be used for the rank graph, the play history graph, and the replay history graph. The only difference between those three is the displayed label, which has now been included as part of the `TooltipContent`, rather than unnecessarily recreating tooltips just for different sprite texts.
This commit is contained in:
@ -8,7 +8,6 @@ using Humanizer;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.LocalisationExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
@ -61,40 +60,16 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
placeholder.FadeIn(FADE_DURATION, Easing.Out);
|
||||
}
|
||||
|
||||
protected override object GetTooltipContent(int index, int rank)
|
||||
protected override UserGraphTooltipContent GetTooltipContent(int index, int rank)
|
||||
{
|
||||
var days = ranked_days - index + 1;
|
||||
|
||||
return new TooltipDisplayContent
|
||||
return new UserGraphTooltipContent
|
||||
{
|
||||
Rank = rank.ToLocalisableString("\\##,##0"),
|
||||
Name = UsersStrings.ShowRankGlobalSimple,
|
||||
Count = rank.ToLocalisableString("\\##,##0"),
|
||||
Time = days == 0 ? "now" : $"{"day".ToQuantity(days)} ago"
|
||||
};
|
||||
}
|
||||
|
||||
protected override UserGraphTooltip GetTooltip() => new RankGraphTooltip();
|
||||
|
||||
private class RankGraphTooltip : UserGraphTooltip
|
||||
{
|
||||
public RankGraphTooltip()
|
||||
: base(UsersStrings.ShowRankGlobalSimple)
|
||||
{
|
||||
}
|
||||
|
||||
public override void SetContent(object content)
|
||||
{
|
||||
if (!(content is TooltipDisplayContent info))
|
||||
return;
|
||||
|
||||
Counter.Text = info.Rank;
|
||||
BottomText.Text = info.Time;
|
||||
}
|
||||
}
|
||||
|
||||
private class TooltipDisplayContent
|
||||
{
|
||||
public LocalisableString Rank;
|
||||
public string Time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user