1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 20:33:37 +08:00

Refactor ProfileItemContainer to not use sounds

This commit is contained in:
Andrei Zavatski 2020-01-19 22:57:39 +03:00
parent 8906416294
commit 5f11084aed

View File

@ -5,28 +5,31 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osuTK.Graphics;
using System.Collections.Generic;
namespace osu.Game.Overlays.Profile.Sections namespace osu.Game.Overlays.Profile.Sections
{ {
public class ProfileItemContainer : OsuHoverContainer public class ProfileItemContainer : Container
{ {
protected override IEnumerable<Drawable> EffectTargets => new[] { background }; private const int hover_duration = 200;
protected override Container<Drawable> Content => content; protected override Container<Drawable> Content => content;
private Color4 idleColour;
private Color4 hoverColour;
private readonly Box background; private readonly Box background;
private readonly Container content; private readonly Container content;
public ProfileItemContainer() public ProfileItemContainer()
{ {
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
Enabled.Value = true; //manually enabled, because we have no action
Masking = true; Masking = true;
CornerRadius = 6; CornerRadius = 6;
base.Content.AddRange(new Drawable[] AddRangeInternal(new Drawable[]
{ {
background = new Box background = new Box
{ {
@ -42,8 +45,20 @@ namespace osu.Game.Overlays.Profile.Sections
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
IdleColour = colours.GreySeafoam; background.Colour = idleColour = colours.GreySeafoam;
HoverColour = colours.GreySeafoamLight; hoverColour = colours.GreySeafoamLight;
}
protected override bool OnHover(HoverEvent e)
{
background.FadeColour(hoverColour, hover_duration, Easing.OutQuint);
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
base.OnHoverLost(e);
background.FadeColour(idleColour, hover_duration, Easing.OutQuint);
} }
} }
} }