Skip to content

Commit

Permalink
Add option to open some links internally
Browse files Browse the repository at this point in the history
  • Loading branch information
Feodor0090 committed Jan 22, 2022
1 parent 3d6f8aa commit 4be13e9
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions osu.Game.Rulesets.OvkTab/API/VkModelsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,32 @@ public static IEnumerable<Drawable> ParseAttachments(this IEnumerable<Attachment
});
break;
case VkNet.Model.Attachments.Link x:
result.Add(new SimpleAttachment(FontAwesome.Solid.ExternalLinkAlt, x.Title, x.Uri.AbsoluteUri, null, new[]
var globalLinkBtn = new SimpleAttachment.IconAttachmentAction(FontAwesome.Solid.Link, b =>
{
new SimpleAttachment.IconAttachmentAction(FontAwesome.Solid.Link, b =>
game.HandleLink(new LinkDetails(LinkAction.External, x.Uri.AbsoluteUri));
});
SimpleAttachment.AttachmentAction[] linkBtns;
IconUsage linkIcon;
if (x.Uri.Host == "osu.ppy.sh")
{
linkBtns = new[] { new SimpleAttachment.IconAttachmentAction(FontAwesome.Solid.AngleDoubleRight, b =>
{
game.HandleLink(new LinkDetails(LinkAction.External, x.Uri.AbsoluteUri));
}),
}));
string url = x.Uri.AbsoluteUri;
game.HandleLink(url);
}), globalLinkBtn };
linkIcon = FontAwesome.Solid.Hashtag;
}
else
{
linkIcon = FontAwesome.Solid.ExternalLinkAlt;
linkBtns = new[] { globalLinkBtn };
}
result.Add(new SimpleAttachment(linkIcon, x.Title, x.Uri.AbsoluteUri, null, linkBtns));
break;
case Sticker x:
result.Add(new Sprite
{
Width = 150,
Height = 150,
Size = new(150),
Texture = lts?.Get(x.Images.Skip(1).First().Url.AbsoluteUri)
});
break;
Expand Down

0 comments on commit 4be13e9

Please sign in to comment.