1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-19 01:17:19 +08:00

Merge pull request #12391 from frenzibyte/replays-tooltip-graph

Display separate "replays watched" tooltip for replays subsection
This commit is contained in:
Dean Herbert 2021-04-13 19:25:50 +09:00 committed by GitHub
commit 0cf13dab8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 26 additions and 11 deletions

View File

@ -19,13 +19,12 @@ namespace osu.Game.Tests.Visual.Online
{
UserHistoryGraph graph;
Add(graph = new UserHistoryGraph
Add(graph = new UserHistoryGraph("Test")
{
RelativeSizeAxes = Axes.X,
Height = 200,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
TooltipCounterName = "Test"
});
var values = new[]

View File

@ -15,6 +15,11 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
{
private ProfileLineChart chart;
/// <summary>
/// Text describing the value being plotted on the graph, which will be displayed as a prefix to the value in the history graph tooltip.
/// </summary>
protected abstract string GraphCounterName { get; }
protected ChartProfileSubsection(Bindable<User> user, string headerText)
: base(user, headerText)
{
@ -30,7 +35,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
Left = 20,
Right = 40
},
Child = chart = new ProfileLineChart()
Child = chart = new ProfileLineChart(GraphCounterName)
};
protected override void LoadComplete()

View File

@ -9,6 +9,8 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
{
public class PlayHistorySubsection : ChartProfileSubsection
{
protected override string GraphCounterName => "Plays";
public PlayHistorySubsection(Bindable<User> user)
: base(user, "Play History")
{

View File

@ -42,7 +42,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
private readonly Container<TickLine> rowLinesContainer;
private readonly Container<TickLine> columnLinesContainer;
public ProfileLineChart()
public ProfileLineChart(string graphCounterName)
{
RelativeSizeAxes = Axes.X;
Height = 250;
@ -88,7 +88,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
}
}
},
graph = new UserHistoryGraph
graph = new UserHistoryGraph(graphCounterName)
{
RelativeSizeAxes = Axes.Both
}

View File

@ -9,6 +9,8 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
{
public class ReplaysSubsection : ChartProfileSubsection
{
protected override string GraphCounterName => "Replays Watched";
public ReplaysSubsection(Bindable<User> user)
: base(user, "Replays Watched History")
{

View File

@ -11,25 +11,28 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
{
public class UserHistoryGraph : UserGraph<DateTime, long>
{
private readonly string tooltipCounterName;
[CanBeNull]
public UserHistoryCount[] Values
{
set => Data = value?.Select(v => new KeyValuePair<DateTime, long>(v.Date, v.Count)).ToArray();
}
/// <summary>
/// Text describing the value being plotted on the graph, which will be displayed as a prefix to the value in the <see cref="HistoryGraphTooltip"/>.
/// </summary>
public string TooltipCounterName { get; set; } = "Plays";
public UserHistoryGraph(string tooltipCounterName)
{
this.tooltipCounterName = tooltipCounterName;
}
protected override float GetDataPointHeight(long playCount) => playCount;
protected override UserGraphTooltip GetTooltip() => new HistoryGraphTooltip(TooltipCounterName);
protected override UserGraphTooltip GetTooltip() => new HistoryGraphTooltip(tooltipCounterName);
protected override object GetTooltipContent(DateTime date, long playCount)
{
return new TooltipDisplayContent
{
Name = tooltipCounterName,
Count = playCount.ToString("N0"),
Date = date.ToString("MMMM yyyy")
};
@ -37,14 +40,17 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
protected class HistoryGraphTooltip : UserGraphTooltip
{
private readonly string tooltipCounterName;
public HistoryGraphTooltip(string tooltipCounterName)
: base(tooltipCounterName)
{
this.tooltipCounterName = tooltipCounterName;
}
public override bool SetContent(object content)
{
if (!(content is TooltipDisplayContent info))
if (!(content is TooltipDisplayContent info) || info.Name != tooltipCounterName)
return false;
Counter.Text = info.Count;
@ -55,6 +61,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
private class TooltipDisplayContent
{
public string Name;
public string Count;
public string Date;
}