1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-19 08:23:20 +08:00

Make TooltipCounterName an abstract property

This commit is contained in:
Andrei Zavatski 2020-02-09 00:36:41 +03:00
parent 9e5da60614
commit e2ecef732c
4 changed files with 19 additions and 24 deletions

View File

@ -25,9 +25,9 @@ namespace osu.Game.Tests.Visual.Online
public TestSceneUserHistoryGraph()
{
UserHistoryGraph graph;
TestGraph graph;
Add(graph = new UserHistoryGraph("Counter Name")
Add(graph = new TestGraph
{
RelativeSizeAxes = Axes.X,
Height = 200,
@ -108,5 +108,15 @@ namespace osu.Game.Tests.Visual.Online
AddStep("Set null values", () => graph.Values = null);
AddStep("Set empty values", () => graph.Values = Array.Empty<UserHistoryCount>());
}
private class TestGraph : UserHistoryGraph
{
protected override UserGraphTooltip GetTooltip() => new TestTooltip();
private class TestTooltip : HistoryGraphTooltip
{
protected override string TooltipCounterName => "Test Counter";
}
}
}
}

View File

@ -80,10 +80,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
private class RankGraphTooltip : UserGraphTooltip
{
public RankGraphTooltip()
: base(@"Global Ranking")
{
}
protected override string TooltipCounterName => @"Global Ranking";
public override bool SetContent(object content)
{

View File

@ -9,7 +9,7 @@ using static osu.Game.Users.User;
namespace osu.Game.Overlays.Profile.Sections.Historical
{
public class UserHistoryGraph : UserGraph<DateTime, long>
public abstract class UserHistoryGraph : UserGraph<DateTime, long>
{
private UserHistoryCount[] values;
@ -23,13 +23,6 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
}
}
private readonly string tooltipCounterName;
public UserHistoryGraph(string tooltipCounterName)
{
this.tooltipCounterName = tooltipCounterName;
}
private void updateValues(UserHistoryCount[] values)
{
if (values == null || !values.Any())
@ -61,15 +54,8 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
};
}
protected override UserGraphTooltip GetTooltip() => new HistoryGraphTooltip(tooltipCounterName);
private class HistoryGraphTooltip : UserGraphTooltip
protected abstract class HistoryGraphTooltip : UserGraphTooltip
{
public HistoryGraphTooltip(string topText)
: base(topText)
{
}
public override bool SetContent(object content)
{
if (!(content is TooltipDisplayContent info))

View File

@ -153,7 +153,9 @@ namespace osu.Game.Overlays.Profile
protected readonly OsuSpriteText Counter, BottomText;
private readonly Box background;
protected UserGraphTooltip(string topText)
protected abstract string TooltipCounterName { get; }
protected UserGraphTooltip()
{
AutoSizeAxes = Axes.Both;
Masking = true;
@ -181,7 +183,7 @@ namespace osu.Game.Overlays.Profile
new OsuSpriteText
{
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
Text = $"{topText} "
Text = $"{TooltipCounterName} "
},
Counter = new OsuSpriteText
{