1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 23:52:57 +08:00

Update usage of FadeEdgeEffect

Improves the visual appearance of DirectPanels' shadows too.
This commit is contained in:
Dean Herbert 2017-08-25 14:36:14 +09:00
parent 67513177e6
commit 70154d1036
3 changed files with 23 additions and 41 deletions

@ -1 +1 @@
Subproject commit da5fbf8c580b079671298f6da54be10a00bf434c
Subproject commit 3db7e231653ec6ffe28b5dcd1a86230ec754cc1c

View File

@ -11,14 +11,12 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transforms;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using OpenTK.Graphics;
using osu.Framework.Input;
using osu.Framework.MathUtils;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
using osu.Framework.Logging;
@ -49,6 +47,23 @@ namespace osu.Game.Overlays.Direct
SetInfo = setInfo;
}
private readonly EdgeEffectParameters edgeEffectNormal = new EdgeEffectParameters
{
Type = EdgeEffectType.Shadow,
Offset = new Vector2(0f, 1f),
Radius = 2f,
Colour = Color4.Black.Opacity(0.25f),
};
private readonly EdgeEffectParameters edgeEffectHovered = new EdgeEffectParameters
{
Type = EdgeEffectType.Shadow,
Offset = new Vector2(0f, 5f),
Radius = 10f,
Colour = Color4.Black.Opacity(0.3f),
};
[BackgroundDependencyLoader(permitNulls: true)]
private void load(APIAccess api, BeatmapManager beatmaps, OsuColour colours, NotificationOverlay notifications)
{
@ -60,13 +75,7 @@ namespace osu.Game.Overlays.Direct
{
RelativeSizeAxes = Axes.Both,
Masking = true,
EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Shadow,
Offset = new Vector2(0f, 1f),
Radius = 2f,
Colour = Color4.Black.Opacity(0.25f),
},
EdgeEffect = edgeEffectNormal,
Children = new[]
{
// temporary blackness until the actual background loads.
@ -92,8 +101,7 @@ namespace osu.Game.Overlays.Direct
protected override bool OnHover(InputState state)
{
content.FadeEdgeEffectTo(1f, hover_transition_time, Easing.OutQuint);
content.TransformTo(content.PopulateTransform(new TransformEdgeEffectRadius(), 14, hover_transition_time, Easing.OutQuint));
content.TweenEdgeEffectTo(edgeEffectHovered, hover_transition_time, Easing.OutQuint);
content.MoveToY(-4, hover_transition_time, Easing.OutQuint);
return base.OnHover(state);
@ -101,8 +109,7 @@ namespace osu.Game.Overlays.Direct
protected override void OnHoverLost(InputState state)
{
content.FadeEdgeEffectTo(0.25f, hover_transition_time, Easing.OutQuint);
content.TransformTo(content.PopulateTransform(new TransformEdgeEffectRadius(), 2, hover_transition_time, Easing.OutQuint));
content.TweenEdgeEffectTo(edgeEffectNormal, hover_transition_time, Easing.OutQuint);
content.MoveToY(0, hover_transition_time, Easing.OutQuint);
base.OnHoverLost(state);
@ -278,30 +285,5 @@ namespace osu.Game.Overlays.Direct
Value = value;
}
}
private class TransformEdgeEffectRadius : Transform<float, Container>
{
/// <summary>
/// Current value of the transformed colour in linear colour space.
/// </summary>
private float valueAt(double time)
{
if (time < StartTime) return StartValue;
if (time >= EndTime) return EndValue;
return Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing);
}
public override string TargetMember => "EdgeEffect.Colour";
protected override void Apply(Container c, double time)
{
EdgeEffectParameters e = c.EdgeEffect;
e.Radius = valueAt(time);
c.EdgeEffect = e;
}
protected override void ReadIntoStartValue(Container d) => StartValue = d.EdgeEffect.Radius;
}
}
}

View File

@ -122,14 +122,14 @@ namespace osu.Game.Overlays.KeyBinding
protected override bool OnHover(InputState state)
{
this.FadeEdgeEffectTo<Container>(1, transition_time, Easing.OutQuint);
FadeEdgeEffectTo(1, transition_time, Easing.OutQuint);
return base.OnHover(state);
}
protected override void OnHoverLost(InputState state)
{
this.FadeEdgeEffectTo<Container>(0, transition_time, Easing.OutQuint);
FadeEdgeEffectTo(0, transition_time, Easing.OutQuint);
base.OnHoverLost(state);
}