Add hover animations to GameTypePicker and RoomAvailabilityPicker.

This commit is contained in:
DrabWeb
2018-08-14 11:54:35 -03:00
parent c66578ba5b
commit ea523baa4a
2 changed files with 52 additions and 4 deletions

View File

@ -10,6 +10,8 @@ using osu.Game.Graphics;
using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer;
using osu.Game.Screens.Multi.Components; using osu.Game.Screens.Multi.Components;
using OpenTK; using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Input.States;
namespace osu.Game.Screens.Multi.Screens.Match.Settings namespace osu.Game.Screens.Multi.Screens.Match.Settings
{ {
@ -36,7 +38,7 @@ namespace osu.Game.Screens.Multi.Screens.Match.Settings
{ {
private const float transition_duration = 200; private const float transition_duration = 200;
private readonly Container selection; private readonly CircularContainer hover, selection;
public GameTypePickerItem(GameType value) : base(value) public GameTypePickerItem(GameType value) : base(value)
{ {
@ -58,10 +60,24 @@ namespace osu.Game.Screens.Multi.Screens.Match.Settings
icon = new DrawableGameType(Value) icon = new DrawableGameType(Value)
{ {
Size = new Vector2(height), Size = new Vector2(height),
Margin = new MarginPadding(selection_width),
},
new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding(selection_width),
Child = hover = new CircularContainer
{
RelativeSizeAxes = Axes.Both,
Masking = true,
Alpha = 0,
Child = new Box
{
RelativeSizeAxes = Axes.Both,
},
},
}, },
}; };
icon.Margin = new MarginPadding(selection_width);
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -70,6 +86,18 @@ namespace osu.Game.Screens.Multi.Screens.Match.Settings
selection.Colour = colours.Yellow; selection.Colour = colours.Yellow;
} }
protected override bool OnHover(InputState state)
{
hover.FadeTo(0.05f, transition_duration, Easing.OutQuint);
return base.OnHover(state);
}
protected override void OnHoverLost(InputState state)
{
hover.FadeOut(transition_duration, Easing.OutQuint);
base.OnHoverLost(state);
}
protected override void OnActivated() protected override void OnActivated()
{ {
selection.FadeIn(transition_duration, Easing.OutQuint); selection.FadeIn(transition_duration, Easing.OutQuint);

View File

@ -10,6 +10,8 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer;
using OpenTK; using OpenTK;
using osu.Framework.Input.States;
using OpenTK.Graphics;
namespace osu.Game.Screens.Multi.Screens.Match.Settings namespace osu.Game.Screens.Multi.Screens.Match.Settings
{ {
@ -34,7 +36,7 @@ namespace osu.Game.Screens.Multi.Screens.Match.Settings
{ {
private const float transition_duration = 200; private const float transition_duration = 200;
private readonly Box selection; private readonly Box hover, selection;
public RoomAvailabilityPickerItem(RoomAvailability value) : base(value) public RoomAvailabilityPickerItem(RoomAvailability value) : base(value)
{ {
@ -55,6 +57,12 @@ namespace osu.Game.Screens.Multi.Screens.Match.Settings
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Alpha = 0, Alpha = 0,
}, },
hover = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.White,
Alpha = 0,
},
new OsuSpriteText new OsuSpriteText
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
@ -71,6 +79,18 @@ namespace osu.Game.Screens.Multi.Screens.Match.Settings
selection.Colour = colours.GreenLight; selection.Colour = colours.GreenLight;
} }
protected override bool OnHover(InputState state)
{
hover.FadeTo(0.05f, transition_duration, Easing.OutQuint);
return base.OnHover(state);
}
protected override void OnHoverLost(InputState state)
{
hover.FadeOut(transition_duration, Easing.OutQuint);
base.OnHoverLost(state);
}
protected override void OnActivated() protected override void OnActivated()
{ {
selection.FadeIn(transition_duration, Easing.OutQuint); selection.FadeIn(transition_duration, Easing.OutQuint);