mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 23:53:51 +09:00
Merge pull request #12391 from frenzibyte/replays-tooltip-graph
Display separate "replays watched" tooltip for replays subsection
This commit is contained in:
@ -19,13 +19,12 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
{
|
{
|
||||||
UserHistoryGraph graph;
|
UserHistoryGraph graph;
|
||||||
|
|
||||||
Add(graph = new UserHistoryGraph
|
Add(graph = new UserHistoryGraph("Test")
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = 200,
|
Height = 200,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
TooltipCounterName = "Test"
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var values = new[]
|
var values = new[]
|
||||||
|
@ -15,6 +15,11 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
|||||||
{
|
{
|
||||||
private ProfileLineChart chart;
|
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)
|
protected ChartProfileSubsection(Bindable<User> user, string headerText)
|
||||||
: base(user, headerText)
|
: base(user, headerText)
|
||||||
{
|
{
|
||||||
@ -30,7 +35,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
|||||||
Left = 20,
|
Left = 20,
|
||||||
Right = 40
|
Right = 40
|
||||||
},
|
},
|
||||||
Child = chart = new ProfileLineChart()
|
Child = chart = new ProfileLineChart(GraphCounterName)
|
||||||
};
|
};
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
|
@ -9,6 +9,8 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
|||||||
{
|
{
|
||||||
public class PlayHistorySubsection : ChartProfileSubsection
|
public class PlayHistorySubsection : ChartProfileSubsection
|
||||||
{
|
{
|
||||||
|
protected override string GraphCounterName => "Plays";
|
||||||
|
|
||||||
public PlayHistorySubsection(Bindable<User> user)
|
public PlayHistorySubsection(Bindable<User> user)
|
||||||
: base(user, "Play History")
|
: base(user, "Play History")
|
||||||
{
|
{
|
||||||
|
@ -42,7 +42,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
|||||||
private readonly Container<TickLine> rowLinesContainer;
|
private readonly Container<TickLine> rowLinesContainer;
|
||||||
private readonly Container<TickLine> columnLinesContainer;
|
private readonly Container<TickLine> columnLinesContainer;
|
||||||
|
|
||||||
public ProfileLineChart()
|
public ProfileLineChart(string graphCounterName)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
Height = 250;
|
Height = 250;
|
||||||
@ -88,7 +88,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
graph = new UserHistoryGraph
|
graph = new UserHistoryGraph(graphCounterName)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both
|
RelativeSizeAxes = Axes.Both
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,8 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
|||||||
{
|
{
|
||||||
public class ReplaysSubsection : ChartProfileSubsection
|
public class ReplaysSubsection : ChartProfileSubsection
|
||||||
{
|
{
|
||||||
|
protected override string GraphCounterName => "Replays Watched";
|
||||||
|
|
||||||
public ReplaysSubsection(Bindable<User> user)
|
public ReplaysSubsection(Bindable<User> user)
|
||||||
: base(user, "Replays Watched History")
|
: base(user, "Replays Watched History")
|
||||||
{
|
{
|
||||||
|
@ -11,25 +11,28 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
|||||||
{
|
{
|
||||||
public class UserHistoryGraph : UserGraph<DateTime, long>
|
public class UserHistoryGraph : UserGraph<DateTime, long>
|
||||||
{
|
{
|
||||||
|
private readonly string tooltipCounterName;
|
||||||
|
|
||||||
[CanBeNull]
|
[CanBeNull]
|
||||||
public UserHistoryCount[] Values
|
public UserHistoryCount[] Values
|
||||||
{
|
{
|
||||||
set => Data = value?.Select(v => new KeyValuePair<DateTime, long>(v.Date, v.Count)).ToArray();
|
set => Data = value?.Select(v => new KeyValuePair<DateTime, long>(v.Date, v.Count)).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
public UserHistoryGraph(string tooltipCounterName)
|
||||||
/// 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>
|
this.tooltipCounterName = tooltipCounterName;
|
||||||
public string TooltipCounterName { get; set; } = "Plays";
|
}
|
||||||
|
|
||||||
protected override float GetDataPointHeight(long playCount) => playCount;
|
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)
|
protected override object GetTooltipContent(DateTime date, long playCount)
|
||||||
{
|
{
|
||||||
return new TooltipDisplayContent
|
return new TooltipDisplayContent
|
||||||
{
|
{
|
||||||
|
Name = tooltipCounterName,
|
||||||
Count = playCount.ToString("N0"),
|
Count = playCount.ToString("N0"),
|
||||||
Date = date.ToString("MMMM yyyy")
|
Date = date.ToString("MMMM yyyy")
|
||||||
};
|
};
|
||||||
@ -37,14 +40,17 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
|||||||
|
|
||||||
protected class HistoryGraphTooltip : UserGraphTooltip
|
protected class HistoryGraphTooltip : UserGraphTooltip
|
||||||
{
|
{
|
||||||
|
private readonly string tooltipCounterName;
|
||||||
|
|
||||||
public HistoryGraphTooltip(string tooltipCounterName)
|
public HistoryGraphTooltip(string tooltipCounterName)
|
||||||
: base(tooltipCounterName)
|
: base(tooltipCounterName)
|
||||||
{
|
{
|
||||||
|
this.tooltipCounterName = tooltipCounterName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool SetContent(object content)
|
public override bool SetContent(object content)
|
||||||
{
|
{
|
||||||
if (!(content is TooltipDisplayContent info))
|
if (!(content is TooltipDisplayContent info) || info.Name != tooltipCounterName)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Counter.Text = info.Count;
|
Counter.Text = info.Count;
|
||||||
@ -55,6 +61,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
|||||||
|
|
||||||
private class TooltipDisplayContent
|
private class TooltipDisplayContent
|
||||||
{
|
{
|
||||||
|
public string Name;
|
||||||
public string Count;
|
public string Count;
|
||||||
public string Date;
|
public string Date;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user