Updated implementation to be based around a "LinkId" (atm the position of the link, anything unique to a link inside its message will be fine), which does not allow matching (OnHover related) between different links

This commit is contained in:
FreezyLemon 2017-12-01 21:31:12 +01:00
parent 7699a3bb38
commit ade7311c15
2 changed files with 6 additions and 2 deletions

View File

@ -18,13 +18,15 @@ namespace osu.Game.Online.Chat
{
public class ChatLinkSpriteText : OsuLinkSpriteText
{
public int LinkId;
private Color4 hoverColour;
private Color4 urlColour;
protected override bool OnHover(InputState state)
{
// Every word is one sprite in chat (for word wrap) so we need to find all other sprites that display the same link
var otherSpritesWithSameLink = ((Container<Drawable>)Parent).Children.Where(child => (child as OsuLinkSpriteText)?.Url == Url && !Equals(child));
var otherSpritesWithSameLink = ((Container<Drawable>)Parent).Children.Where(child => (child as ChatLinkSpriteText)?.LinkId == LinkId && !Equals(child));
var hoverResult = base.OnHover(state);
@ -39,7 +41,7 @@ protected override bool OnHover(InputState state)
protected override void OnHoverLost(InputState state)
{
var spritesWithSameLink = ((Container<Drawable>)Parent).Children.Where(child => (child as OsuLinkSpriteText)?.Url == Url);
var spritesWithSameLink = ((Container<Drawable>)Parent).Children.Where(child => (child as ChatLinkSpriteText)?.LinkId == LinkId);
if (spritesWithSameLink.Any(sprite => sprite.IsHovered))
{

View File

@ -237,6 +237,8 @@ private void updateMessageContent()
if (message.IsAction)
sprite.Font = @"Exo2.0-MediumItalic";
sprite.Colour = urlColour;
// We want to use something that is unique to every formatted link, so I just use the position of the link
((ChatLinkSpriteText)sprite).LinkId = prevIndex;
});
}