2017-12-02 03:32:08 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using osu.Framework.Graphics;
|
2017-12-04 20:33:42 +08:00
|
|
|
|
using osu.Framework.Graphics.Colour;
|
2017-12-02 03:32:08 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics;
|
2017-12-20 14:54:13 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Graphics.Containers;
|
2017-12-02 03:32:08 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Graphics.Sprites
|
|
|
|
|
{
|
2017-12-29 03:11:21 +08:00
|
|
|
|
public class OsuSpriteLink : OsuSpriteText
|
2017-12-02 03:32:08 +08:00
|
|
|
|
{
|
|
|
|
|
protected override IEnumerable<Drawable> FlowingChildren => Children;
|
|
|
|
|
|
2017-12-20 14:54:13 +08:00
|
|
|
|
protected override Container<Drawable> Content => content;
|
|
|
|
|
|
2017-12-29 04:45:58 +08:00
|
|
|
|
private readonly OsuHoverContainer content;
|
2017-12-20 14:54:13 +08:00
|
|
|
|
|
2017-12-29 03:11:21 +08:00
|
|
|
|
public OsuSpriteLink()
|
2017-12-20 14:54:13 +08:00
|
|
|
|
{
|
2017-12-26 03:46:04 +08:00
|
|
|
|
AddInternal(content = new OsuHoverContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Action = OnLinkClicked,
|
|
|
|
|
});
|
2017-12-11 18:05:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-12-02 03:32:08 +08:00
|
|
|
|
private string url;
|
|
|
|
|
|
|
|
|
|
public string Url
|
|
|
|
|
{
|
2017-12-26 03:46:04 +08:00
|
|
|
|
get => url;
|
2017-12-02 03:32:08 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
2017-12-06 17:27:30 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(value))
|
2017-12-02 03:32:08 +08:00
|
|
|
|
url = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-04 20:33:42 +08:00
|
|
|
|
public ColourInfo TextColour
|
|
|
|
|
{
|
2017-12-26 03:46:04 +08:00
|
|
|
|
get => Content.Colour;
|
|
|
|
|
set => Content.Colour = value;
|
2017-12-04 20:33:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-12-07 23:30:15 +08:00
|
|
|
|
protected virtual void OnLinkClicked() => Process.Start(Url);
|
2017-12-02 03:32:08 +08:00
|
|
|
|
}
|
|
|
|
|
}
|