mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Add and use ILinkHandler
interface
This commit is contained in:
@ -13,6 +13,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Online;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Graphics.Containers
|
||||
@ -25,7 +26,7 @@ namespace osu.Game.Graphics.Containers
|
||||
}
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private OsuGame game { get; set; }
|
||||
private ILinkHandler linkHandler { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private GameHost host { get; set; }
|
||||
@ -81,8 +82,8 @@ namespace osu.Game.Graphics.Containers
|
||||
{
|
||||
if (action != null)
|
||||
action();
|
||||
else if (game != null)
|
||||
game.HandleLink(link);
|
||||
else if (linkHandler != null)
|
||||
linkHandler.HandleLink(link);
|
||||
// fallback to handle cases where OsuGame is not available, ie. tournament client.
|
||||
else if (link.Action == LinkAction.External)
|
||||
host.OpenUrlExternally(link.Argument.ToString());
|
||||
|
@ -8,6 +8,7 @@ using Markdig.Syntax.Inlines;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers.Markdown;
|
||||
using osu.Game.Online;
|
||||
using osu.Game.Online.Chat;
|
||||
using osu.Game.Overlays;
|
||||
|
||||
@ -16,7 +17,7 @@ namespace osu.Game.Graphics.Containers.Markdown
|
||||
public class OsuMarkdownLinkText : MarkdownLinkText
|
||||
{
|
||||
[Resolved(canBeNull: true)]
|
||||
private OsuGame game { get; set; }
|
||||
private ILinkHandler linkHandler { get; set; }
|
||||
|
||||
private readonly string text;
|
||||
private readonly string title;
|
||||
@ -51,7 +52,7 @@ namespace osu.Game.Graphics.Containers.Markdown
|
||||
};
|
||||
}
|
||||
|
||||
protected override void OnLinkPressed() => game?.HandleLink(Url);
|
||||
protected override void OnLinkPressed() => linkHandler?.HandleLink(Url);
|
||||
|
||||
private class OsuMarkdownLinkCompiler : DrawableLinkCompiler
|
||||
{
|
||||
|
Reference in New Issue
Block a user