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

Added some tooltip text handling.

Also fixed a bug caused by SameLinkSprites where "this" is actually supposed to be included by just adding a manual function call.
This commit is contained in:
FreezyLemon 2017-12-07 13:49:44 +01:00
parent 07660a6600
commit 5ded6e877c

View File

@ -12,6 +12,7 @@ using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays.Chat; using osu.Game.Overlays.Chat;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -26,11 +27,29 @@ namespace osu.Game.Online.Chat
private readonly ChatHoverContainer content; private readonly ChatHoverContainer content;
/// <summary>
/// Every other sprite in the containing ChatLine that represents the same link.
/// </summary>
protected IEnumerable<ChatLink> SameLinkSprites { get; private set; } protected IEnumerable<ChatLink> SameLinkSprites { get; private set; }
protected override Container<Drawable> Content => content ?? base.Content; protected override Container<Drawable> Content => content ?? base.Content;
public string TooltipText => LinkId != -1 ? Url : null; public string TooltipText
{
get
{
if (LinkId == -1 || Url == Text)
return null;
if (Url.StartsWith("osu://chan/"))
return "Switch to channel " + Url.Substring(11);
if (Url.StartsWith("osu://edit/") && TimeSpan.TryParse(Url.Substring(11).Split(' ')[0], out TimeSpan editorTimeStamp))
return "Go to " + editorTimeStamp.ToString();
return Url;
}
}
public ChatLink() public ChatLink()
{ {
@ -68,6 +87,8 @@ namespace osu.Game.Online.Chat
return; return;
} }
Content.FadeColour(urlColour, 500, Easing.OutQuint);
foreach (ChatLink sprite in SameLinkSprites) foreach (ChatLink sprite in SameLinkSprites)
sprite.Content.FadeColour(urlColour, 500, Easing.OutQuint); sprite.Content.FadeColour(urlColour, 500, Easing.OutQuint);