2018-05-22 21:41:10 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2018-05-22 21:29:52 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
|
|
|
|
using osu.Framework.Input;
|
2018-06-19 19:19:52 +08:00
|
|
|
|
using osu.Framework.Platform;
|
2018-05-25 17:51:57 +08:00
|
|
|
|
using OpenTK;
|
2018-05-22 21:29:52 +08:00
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Graphics.UserInterface
|
|
|
|
|
{
|
|
|
|
|
public class ExternalLinkButton : CompositeDrawable, IHasTooltip
|
|
|
|
|
{
|
|
|
|
|
public string Link { get; set; }
|
|
|
|
|
|
|
|
|
|
private Color4 hoverColour;
|
2018-06-19 19:19:52 +08:00
|
|
|
|
private GameHost host;
|
2018-05-22 21:29:52 +08:00
|
|
|
|
|
|
|
|
|
public ExternalLinkButton(string link = null)
|
|
|
|
|
{
|
|
|
|
|
Link = link;
|
2018-05-25 17:51:57 +08:00
|
|
|
|
Size = new Vector2(12);
|
2018-05-22 21:29:52 +08:00
|
|
|
|
InternalChild = new SpriteIcon
|
|
|
|
|
{
|
|
|
|
|
Icon = FontAwesome.fa_external_link,
|
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2018-06-19 19:19:52 +08:00
|
|
|
|
private void load(OsuColour colours, GameHost host)
|
2018-05-22 21:29:52 +08:00
|
|
|
|
{
|
|
|
|
|
hoverColour = colours.Yellow;
|
2018-06-19 19:19:52 +08:00
|
|
|
|
this.host = host;
|
2018-05-22 21:29:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnHover(InputState state)
|
|
|
|
|
{
|
|
|
|
|
InternalChild.FadeColour(hoverColour, 500, Easing.OutQuint);
|
|
|
|
|
return base.OnHover(state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnHoverLost(InputState state)
|
|
|
|
|
{
|
|
|
|
|
InternalChild.FadeColour(Color4.White, 500, Easing.OutQuint);
|
|
|
|
|
base.OnHoverLost(state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnClick(InputState state)
|
|
|
|
|
{
|
|
|
|
|
if(Link != null)
|
2018-06-19 19:19:52 +08:00
|
|
|
|
host.OpenUrlExternally(Link);
|
2018-05-22 21:29:52 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string TooltipText => "View in browser";
|
|
|
|
|
}
|
|
|
|
|
}
|