2019-09-11 15:40:58 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Game.Users.Drawables;
|
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
using osuTK;
|
|
|
|
|
using osu.Framework.Input.Events;
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Rankings
|
|
|
|
|
{
|
2019-09-12 21:44:15 +08:00
|
|
|
|
public class DismissableFlag : UpdateableFlag
|
2019-09-11 15:40:58 +08:00
|
|
|
|
{
|
|
|
|
|
private const int duration = 200;
|
|
|
|
|
|
|
|
|
|
public Action Action;
|
|
|
|
|
|
2019-09-11 16:26:09 +08:00
|
|
|
|
private readonly SpriteIcon hoverIcon;
|
2019-09-11 15:40:58 +08:00
|
|
|
|
|
2019-09-12 21:44:15 +08:00
|
|
|
|
public DismissableFlag()
|
2019-09-11 15:40:58 +08:00
|
|
|
|
{
|
2019-09-11 16:26:09 +08:00
|
|
|
|
AddInternal(hoverIcon = new SpriteIcon
|
2019-09-11 15:40:58 +08:00
|
|
|
|
{
|
2019-09-11 16:26:09 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2019-09-11 15:40:58 +08:00
|
|
|
|
Depth = -1,
|
2019-09-11 16:26:09 +08:00
|
|
|
|
Alpha = 0,
|
|
|
|
|
Size = new Vector2(10),
|
|
|
|
|
Icon = FontAwesome.Solid.Times,
|
2019-09-11 15:40:58 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnHover(HoverEvent e)
|
|
|
|
|
{
|
2019-09-11 16:26:09 +08:00
|
|
|
|
hoverIcon.FadeIn(duration, Easing.OutQuint);
|
|
|
|
|
this.FadeColour(Color4.Gray, duration, Easing.OutQuint);
|
2019-09-11 15:40:58 +08:00
|
|
|
|
return base.OnHover(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnHoverLost(HoverLostEvent e)
|
|
|
|
|
{
|
|
|
|
|
base.OnHoverLost(e);
|
2019-09-11 16:26:09 +08:00
|
|
|
|
hoverIcon.FadeOut(duration, Easing.OutQuint);
|
|
|
|
|
this.FadeColour(Color4.White, duration, Easing.OutQuint);
|
2019-09-11 15:40:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnClick(ClickEvent e)
|
|
|
|
|
{
|
|
|
|
|
Action?.Invoke();
|
2019-09-11 16:26:09 +08:00
|
|
|
|
return true;
|
2019-09-11 15:40:58 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|