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

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 class ChatLinkSpriteText : OsuLinkSpriteText
{ {
public int LinkId;
private Color4 hoverColour; private Color4 hoverColour;
private Color4 urlColour; private Color4 urlColour;
protected override bool OnHover(InputState state) 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 // 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); var hoverResult = base.OnHover(state);
@ -39,7 +41,7 @@ namespace osu.Game.Online.Chat
protected override void OnHoverLost(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)) if (spritesWithSameLink.Any(sprite => sprite.IsHovered))
{ {

View File

@ -237,6 +237,8 @@ namespace osu.Game.Overlays.Chat
if (message.IsAction) if (message.IsAction)
sprite.Font = @"Exo2.0-MediumItalic"; sprite.Font = @"Exo2.0-MediumItalic";
sprite.Colour = urlColour; 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;
}); });
} }