mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Add hover effects
This commit is contained in:
@ -25,7 +25,6 @@ namespace osu.Game.Overlays.Direct
|
|||||||
public DirectGridPanel(BeatmapSetInfo beatmap) : base(beatmap)
|
public DirectGridPanel(BeatmapSetInfo beatmap) : base(beatmap)
|
||||||
{
|
{
|
||||||
Height = 140 + vertical_padding; //full height of all the elements plus vertical padding (autosize uses the image)
|
Height = 140 + vertical_padding; //full height of all the elements plus vertical padding (autosize uses the image)
|
||||||
CornerRadius = 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -39,6 +38,8 @@ namespace osu.Game.Overlays.Direct
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours, LocalisationEngine localisation)
|
private void load(OsuColour colours, LocalisationEngine localisation)
|
||||||
{
|
{
|
||||||
|
Content.CornerRadius = 4;
|
||||||
|
|
||||||
AddRange(new Drawable[]
|
AddRange(new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
new Box
|
||||||
|
@ -28,20 +28,15 @@ namespace osu.Game.Overlays.Direct
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
Height = height;
|
Height = height;
|
||||||
CornerRadius = 5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(LocalisationEngine localisation)
|
private void load(LocalisationEngine localisation)
|
||||||
{
|
{
|
||||||
Children = new[]
|
Content.CornerRadius = 5;
|
||||||
|
|
||||||
|
AddRange(new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = Color4.Black,
|
|
||||||
},
|
|
||||||
CreateBackground(),
|
|
||||||
new Box
|
new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
@ -132,7 +127,7 @@ namespace osu.Game.Overlays.Direct
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DownloadButton : OsuClickableContainer
|
private class DownloadButton : OsuClickableContainer
|
||||||
|
@ -9,11 +9,14 @@ 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.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.Transforms;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.Drawables;
|
using osu.Game.Beatmaps.Drawables;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
using osu.Framework.Input;
|
||||||
|
using osu.Framework.MathUtils;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Direct
|
namespace osu.Game.Overlays.Direct
|
||||||
{
|
{
|
||||||
@ -23,35 +26,62 @@ namespace osu.Game.Overlays.Direct
|
|||||||
|
|
||||||
protected Box BlackBackground;
|
protected Box BlackBackground;
|
||||||
|
|
||||||
|
private const double hover_transition_time = 400;
|
||||||
|
|
||||||
|
private Container content;
|
||||||
|
|
||||||
|
protected override Container<Drawable> Content => content;
|
||||||
|
|
||||||
protected DirectPanel(BeatmapSetInfo setInfo)
|
protected DirectPanel(BeatmapSetInfo setInfo)
|
||||||
{
|
{
|
||||||
SetInfo = setInfo;
|
SetInfo = setInfo;
|
||||||
|
|
||||||
Masking = true;
|
|
||||||
EdgeEffect = new EdgeEffectParameters
|
|
||||||
{
|
|
||||||
Type = EdgeEffectType.Shadow,
|
|
||||||
Offset = new Vector2(0f, 1f),
|
|
||||||
Radius = 3f,
|
|
||||||
Colour = Color4.Black.Opacity(0.25f),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
AddRange(new[]
|
AddInternal(content = new Container
|
||||||
{
|
{
|
||||||
// temporary blackness until the actual background loads.
|
RelativeSizeAxes = Axes.Both,
|
||||||
BlackBackground = new Box
|
Masking = true,
|
||||||
|
EdgeEffect = new EdgeEffectParameters
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
Type = EdgeEffectType.Shadow,
|
||||||
Colour = Color4.Black,
|
Offset = new Vector2(0f, 1f),
|
||||||
|
Radius = 2f,
|
||||||
|
Colour = Color4.Black.Opacity(0.25f),
|
||||||
},
|
},
|
||||||
CreateBackground(),
|
Children = new[]
|
||||||
|
{
|
||||||
|
// temporary blackness until the actual background loads.
|
||||||
|
BlackBackground = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = Color4.Black,
|
||||||
|
},
|
||||||
|
CreateBackground(),
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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.MoveToY(-4, hover_transition_time, Easing.OutQuint);
|
||||||
|
|
||||||
|
return base.OnHover(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
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.MoveToY(0, hover_transition_time, Easing.OutQuint);
|
||||||
|
|
||||||
|
base.OnHoverLost(state);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
@ -127,5 +157,30 @@ namespace osu.Game.Overlays.Direct
|
|||||||
Value = value;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user