1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 17:32:54 +08:00

Only play OsuHoverContainer hover effect if action is present (#4833)

Only play OsuHoverContainer hover effect if action is present

Co-authored-by: Dan Balasescu <1329837+smoogipoo@users.noreply.github.com>
This commit is contained in:
Dean Herbert 2019-05-21 17:16:06 +09:00 committed by GitHub
commit 324c8ce0bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,18 +20,41 @@ namespace osu.Game.Graphics.Containers
protected virtual IEnumerable<Drawable> EffectTargets => new[] { Content };
public OsuHoverContainer()
{
Enabled.ValueChanged += e =>
{
if (!e.NewValue) unhover();
};
}
private bool isHovered;
protected override bool OnHover(HoverEvent e)
{
if (!Enabled.Value)
return false;
EffectTargets.ForEach(d => d.FadeColour(HoverColour, FADE_DURATION, Easing.OutQuint));
isHovered = true;
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
EffectTargets.ForEach(d => d.FadeColour(IdleColour, FADE_DURATION, Easing.OutQuint));
unhover();
base.OnHoverLost(e);
}
private void unhover()
{
if (!isHovered) return;
isHovered = false;
EffectTargets.ForEach(d => d.FadeColour(IdleColour, FADE_DURATION, Easing.OutQuint));
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{