mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 01:43:15 +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:
parent
7699a3bb38
commit
ade7311c15
@ -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 @@ namespace osu.Game.Online.Chat
|
||||
|
||||
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))
|
||||
{
|
||||
|
@ -237,6 +237,8 @@ namespace osu.Game.Overlays.Chat
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user