mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 16:59:53 +09:00
Refactor tooltip construction
This commit is contained in:
@ -62,16 +62,13 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
Graph.FadeTo(Data.Length > 1 ? 1 : 0, FADE_DURATION, Easing.Out);
|
Graph.FadeTo(Data.Length > 1 ? 1 : 0, FADE_DURATION, Easing.Out);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override object GetTooltipContent()
|
protected override object GetTooltipContent(int index, int rank)
|
||||||
{
|
{
|
||||||
if (Statistics.Value?.Ranks.Global == null)
|
var days = ranked_days - index + 1;
|
||||||
return null;
|
|
||||||
|
|
||||||
var days = ranked_days - Data[DataIndex].Key + 1;
|
|
||||||
|
|
||||||
return new TooltipDisplayContent
|
return new TooltipDisplayContent
|
||||||
{
|
{
|
||||||
Rank = $"#{Data[DataIndex].Value:#,##0}",
|
Rank = $"#{rank:#,##0}",
|
||||||
Time = days == 0 ? "now" : $"{days} days ago"
|
Time = days == 0 ? "now" : $"{days} days ago"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -42,15 +42,12 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override object GetTooltipContent()
|
protected override object GetTooltipContent(DateTime date, long playCount)
|
||||||
{
|
{
|
||||||
if (!Data?.Any() ?? true)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return new TooltipDisplayContent
|
return new TooltipDisplayContent
|
||||||
{
|
{
|
||||||
Count = Data[DataIndex].Value.ToString("N0"),
|
Count = playCount.ToString("N0"),
|
||||||
Date = Data[DataIndex].Key.ToString("MMMM yyyy")
|
Date = date.ToString("MMMM yyyy")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Overlays.Profile
|
|||||||
|
|
||||||
protected readonly UserLineGraph Graph;
|
protected readonly UserLineGraph Graph;
|
||||||
protected KeyValuePair<TKey, TValue>[] Data;
|
protected KeyValuePair<TKey, TValue>[] Data;
|
||||||
protected int DataIndex;
|
private int dataIndex;
|
||||||
|
|
||||||
protected UserGraph()
|
protected UserGraph()
|
||||||
{
|
{
|
||||||
@ -33,7 +33,7 @@ namespace osu.Game.Overlays.Profile
|
|||||||
Alpha = 0
|
Alpha = 0
|
||||||
});
|
});
|
||||||
|
|
||||||
Graph.OnBallMove += i => DataIndex = i;
|
Graph.OnBallMove += i => dataIndex = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -71,11 +71,21 @@ namespace osu.Game.Overlays.Profile
|
|||||||
|
|
||||||
public ITooltip GetCustomTooltip() => GetTooltip();
|
public ITooltip GetCustomTooltip() => GetTooltip();
|
||||||
|
|
||||||
public object TooltipContent => GetTooltipContent();
|
|
||||||
|
|
||||||
protected abstract UserGraphTooltip GetTooltip();
|
protected abstract UserGraphTooltip GetTooltip();
|
||||||
|
|
||||||
protected abstract object GetTooltipContent();
|
public object TooltipContent
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (Data == null || Data.Length == 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var (key, value) = Data[dataIndex];
|
||||||
|
return GetTooltipContent(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract object GetTooltipContent(TKey key, TValue value);
|
||||||
|
|
||||||
protected class UserLineGraph : LineGraph
|
protected class UserLineGraph : LineGraph
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user