Add tooltip to ScoreComponentLabel.

This commit is contained in:
DrabWeb 2018-06-03 22:26:30 -03:00
parent db4c26e1ab
commit a7bab14b30
1 changed files with 11 additions and 6 deletions

View File

@ -8,6 +8,7 @@
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input;
using osu.Game.Graphics;
@ -165,8 +166,8 @@ private void load()
Margin = new MarginPadding { Left = edge_margin },
Children = new Drawable[]
{
maxCombo = new ScoreComponentLabel(FontAwesome.fa_link, Score.MaxCombo.ToString()),
accuracy = new ScoreComponentLabel(FontAwesome.fa_crosshairs, string.Format(Score.Accuracy % 1 == 0 ? @"{0:P0}" : @"{0:P2}", Score.Accuracy)),
maxCombo = new ScoreComponentLabel(FontAwesome.fa_link, Score.MaxCombo.ToString(), "Max Combo"),
accuracy = new ScoreComponentLabel(FontAwesome.fa_crosshairs, string.Format(Score.Accuracy % 1 == 0 ? @"{0:P0}" : @"{0:P2}", Score.Accuracy), "Accuracy"),
},
},
},
@ -309,20 +310,24 @@ public GlowingSpriteText(string text, string font, int textSize, Color4 textColo
}
}
private class ScoreComponentLabel : Container
private class ScoreComponentLabel : Container, IHasTooltip
{
private const float icon_size = 20;
private readonly string name;
private readonly FillFlowContainer content;
protected override Container<Drawable> Content => content;
public override bool Contains(Vector2 screenSpacePos) => content.Contains(screenSpacePos);
public ScoreComponentLabel(FontAwesome icon, string value)
public string TooltipText => name;
public ScoreComponentLabel(FontAwesome icon, string value, string name)
{
this.name = name;
AutoSizeAxes = Axes.Y;
Width = 60;
InternalChild = content = new FillFlowContainer
Child = content = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,