2022-09-27 09:52:43 +00:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Effects;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Framework.Input.Bindings;
|
|
|
|
using osu.Framework.Input.Events;
|
2022-10-07 10:27:00 +00:00
|
|
|
using osu.Framework.Utils;
|
2022-09-27 10:48:27 +00:00
|
|
|
using osu.Game.Graphics;
|
2022-09-27 09:52:43 +00:00
|
|
|
using osu.Game.Rulesets.Mania.UI;
|
|
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.Skinning.Argon
|
|
|
|
{
|
|
|
|
public partial class ArgonKeyArea : CompositeDrawable, IKeyBindingHandler<ManiaAction>
|
|
|
|
{
|
|
|
|
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
|
|
|
|
|
|
|
private Container directionContainer = null!;
|
2022-09-27 10:13:37 +00:00
|
|
|
private Drawable background = null!;
|
2022-09-27 09:52:43 +00:00
|
|
|
|
2022-09-27 10:48:27 +00:00
|
|
|
private Circle hitTargetLine = null!;
|
|
|
|
|
2022-10-04 07:05:36 +00:00
|
|
|
private Container<Circle> bottomIcon = null!;
|
|
|
|
private CircularContainer topIcon = null!;
|
|
|
|
|
2022-10-05 11:02:02 +00:00
|
|
|
private Bindable<Color4> accentColour = null!;
|
|
|
|
|
2022-09-27 09:52:43 +00:00
|
|
|
[Resolved]
|
|
|
|
private Column column { get; set; } = null!;
|
|
|
|
|
|
|
|
public ArgonKeyArea()
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(IScrollingInfo scrollingInfo)
|
|
|
|
{
|
|
|
|
const float icon_circle_size = 8;
|
2022-09-27 10:13:37 +00:00
|
|
|
const float icon_spacing = 7;
|
|
|
|
const float icon_vertical_offset = -30;
|
2022-09-27 09:52:43 +00:00
|
|
|
|
|
|
|
InternalChild = directionContainer = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2022-10-07 10:08:55 +00:00
|
|
|
// Ensure the area is tall enough to put the target line in the correct location.
|
|
|
|
// This is to also allow the main background component to overlap the target line
|
|
|
|
// and avoid an inner corner radius being shown below the target line.
|
|
|
|
Height = Stage.HIT_TARGET_POSITION + ArgonNotePiece.CORNER_RADIUS * 2,
|
2022-09-27 09:52:43 +00:00
|
|
|
Children = new[]
|
|
|
|
{
|
2022-10-06 09:07:56 +00:00
|
|
|
new Container
|
2022-09-27 09:52:43 +00:00
|
|
|
{
|
2022-10-06 09:07:56 +00:00
|
|
|
Masking = true,
|
2022-09-27 09:52:43 +00:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2022-10-06 09:07:56 +00:00
|
|
|
CornerRadius = ArgonNotePiece.CORNER_RADIUS,
|
|
|
|
Child = background = new Box
|
|
|
|
{
|
|
|
|
Name = "Key gradient",
|
2022-10-06 09:29:07 +00:00
|
|
|
Alpha = 0,
|
2022-10-06 09:07:56 +00:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
2022-09-27 09:52:43 +00:00
|
|
|
},
|
2022-10-04 07:05:36 +00:00
|
|
|
hitTargetLine = new Circle
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Anchor = Anchor.TopCentre,
|
2022-10-07 10:08:55 +00:00
|
|
|
Origin = Anchor.TopCentre,
|
2022-10-04 07:05:36 +00:00
|
|
|
Colour = OsuColour.Gray(196 / 255f),
|
2022-10-06 09:07:56 +00:00
|
|
|
Height = ArgonNotePiece.CORNER_RADIUS * 2,
|
2022-10-04 07:05:36 +00:00
|
|
|
Masking = true,
|
2022-10-07 11:04:39 +00:00
|
|
|
EdgeEffect = new EdgeEffectParameters { Type = EdgeEffectType.Glow },
|
2022-10-04 07:05:36 +00:00
|
|
|
},
|
|
|
|
new Container
|
2022-09-27 09:52:43 +00:00
|
|
|
{
|
|
|
|
Name = "Icons",
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
2022-10-04 07:05:36 +00:00
|
|
|
Children = new Drawable[]
|
2022-09-27 09:52:43 +00:00
|
|
|
{
|
2022-10-04 07:05:36 +00:00
|
|
|
bottomIcon = new Container<Circle>
|
2022-09-27 09:52:43 +00:00
|
|
|
{
|
2022-10-04 07:05:36 +00:00
|
|
|
AutoSizeAxes = Axes.Both,
|
2022-09-27 10:13:37 +00:00
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
Origin = Anchor.Centre,
|
2022-09-27 09:52:43 +00:00
|
|
|
Blending = BlendingParameters.Additive,
|
2022-10-04 07:05:36 +00:00
|
|
|
Y = icon_vertical_offset,
|
|
|
|
Children = new[]
|
|
|
|
{
|
|
|
|
new Circle
|
|
|
|
{
|
|
|
|
Size = new Vector2(icon_circle_size),
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
Origin = Anchor.Centre,
|
2022-10-07 11:04:39 +00:00
|
|
|
EdgeEffect = new EdgeEffectParameters { Type = EdgeEffectType.Glow },
|
2022-10-04 07:05:36 +00:00
|
|
|
},
|
|
|
|
new Circle
|
|
|
|
{
|
|
|
|
X = -icon_spacing,
|
|
|
|
Y = icon_spacing * 1.2f,
|
|
|
|
Size = new Vector2(icon_circle_size),
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
Origin = Anchor.Centre,
|
2022-10-07 11:04:39 +00:00
|
|
|
EdgeEffect = new EdgeEffectParameters { Type = EdgeEffectType.Glow },
|
2022-10-04 07:05:36 +00:00
|
|
|
},
|
|
|
|
new Circle
|
|
|
|
{
|
|
|
|
X = icon_spacing,
|
|
|
|
Y = icon_spacing * 1.2f,
|
|
|
|
Size = new Vector2(icon_circle_size),
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
Origin = Anchor.Centre,
|
2022-10-07 11:04:39 +00:00
|
|
|
EdgeEffect = new EdgeEffectParameters { Type = EdgeEffectType.Glow },
|
2022-10-04 07:05:36 +00:00
|
|
|
},
|
|
|
|
}
|
2022-09-27 10:13:37 +00:00
|
|
|
},
|
2022-10-04 07:05:36 +00:00
|
|
|
topIcon = new CircularContainer
|
2022-09-27 10:13:37 +00:00
|
|
|
{
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Y = -icon_vertical_offset,
|
|
|
|
Size = new Vector2(22, 14),
|
|
|
|
Masking = true,
|
|
|
|
BorderThickness = 4,
|
|
|
|
BorderColour = Color4.White,
|
2022-10-07 11:04:39 +00:00
|
|
|
EdgeEffect = new EdgeEffectParameters { Type = EdgeEffectType.Glow },
|
2022-09-27 10:13:37 +00:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Alpha = 0,
|
|
|
|
AlwaysPresent = true,
|
|
|
|
},
|
|
|
|
},
|
2022-09-27 09:52:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
direction.BindTo(scrollingInfo.Direction);
|
|
|
|
direction.BindValueChanged(onDirectionChanged, true);
|
2022-10-05 11:02:02 +00:00
|
|
|
|
|
|
|
accentColour = column.AccentColour.GetBoundCopy();
|
|
|
|
accentColour.BindValueChanged(colour =>
|
2022-10-06 09:07:56 +00:00
|
|
|
{
|
2022-10-07 10:27:00 +00:00
|
|
|
background.Colour = colour.NewValue.Darken(0.2f);
|
2022-10-06 09:07:56 +00:00
|
|
|
bottomIcon.Colour = colour.NewValue;
|
|
|
|
},
|
|
|
|
true);
|
2022-10-07 10:02:08 +00:00
|
|
|
|
|
|
|
// Yes, proxy everything.
|
|
|
|
column.TopLevelContainer.Add(CreateProxy());
|
2022-09-27 09:52:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void onDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)
|
|
|
|
{
|
|
|
|
switch (direction.NewValue)
|
|
|
|
{
|
|
|
|
case ScrollingDirection.Up:
|
|
|
|
directionContainer.Scale = new Vector2(1, -1);
|
|
|
|
directionContainer.Anchor = Anchor.TopLeft;
|
|
|
|
directionContainer.Origin = Anchor.BottomLeft;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ScrollingDirection.Down:
|
|
|
|
directionContainer.Scale = new Vector2(1, 1);
|
|
|
|
directionContainer.Anchor = Anchor.BottomLeft;
|
|
|
|
directionContainer.Origin = Anchor.BottomLeft;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool OnPressed(KeyBindingPressEvent<ManiaAction> e)
|
|
|
|
{
|
2022-10-04 07:05:36 +00:00
|
|
|
if (e.Action != column.Action.Value) return false;
|
2022-09-27 10:32:58 +00:00
|
|
|
|
2022-10-07 10:27:00 +00:00
|
|
|
const double lighting_fade_in_duration = 70;
|
|
|
|
Color4 lightingColour = getLightingColour();
|
2022-09-27 09:52:43 +00:00
|
|
|
|
2022-10-04 07:05:36 +00:00
|
|
|
background
|
2022-10-07 11:30:38 +00:00
|
|
|
.FlashColour(accentColour.Value.Lighten(0.8f), 200, Easing.OutQuint)
|
2022-10-07 10:27:00 +00:00
|
|
|
.FadeTo(1, lighting_fade_in_duration, Easing.OutQuint)
|
|
|
|
.Then()
|
2022-10-07 11:30:38 +00:00
|
|
|
.FadeTo(0.8f, 500);
|
2022-09-27 10:48:27 +00:00
|
|
|
|
2022-10-04 07:05:36 +00:00
|
|
|
hitTargetLine.FadeColour(Color4.White, lighting_fade_in_duration, Easing.OutQuint);
|
|
|
|
hitTargetLine.TransformTo(nameof(EdgeEffect), new EdgeEffectParameters
|
|
|
|
{
|
|
|
|
Type = EdgeEffectType.Glow,
|
2022-10-07 10:27:00 +00:00
|
|
|
Colour = lightingColour.Opacity(0.4f),
|
2022-10-04 07:05:36 +00:00
|
|
|
Radius = 20,
|
|
|
|
}, lighting_fade_in_duration, Easing.OutQuint);
|
2022-09-27 10:48:27 +00:00
|
|
|
|
2022-10-04 07:05:36 +00:00
|
|
|
topIcon.ScaleTo(0.9f, lighting_fade_in_duration, Easing.OutQuint);
|
|
|
|
topIcon.TransformTo(nameof(EdgeEffect), new EdgeEffectParameters
|
|
|
|
{
|
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
Colour = lightingColour.Opacity(0.1f),
|
|
|
|
Radius = 20,
|
|
|
|
}, lighting_fade_in_duration, Easing.OutQuint);
|
|
|
|
|
|
|
|
bottomIcon.FadeColour(Color4.White, lighting_fade_in_duration, Easing.OutQuint);
|
|
|
|
|
|
|
|
foreach (var circle in bottomIcon)
|
|
|
|
{
|
|
|
|
circle.TransformTo(nameof(EdgeEffect), new EdgeEffectParameters
|
|
|
|
{
|
|
|
|
Type = EdgeEffectType.Glow,
|
2022-10-07 10:27:00 +00:00
|
|
|
Colour = lightingColour.Opacity(0.2f),
|
2022-10-04 07:05:36 +00:00
|
|
|
Radius = 60,
|
|
|
|
}, lighting_fade_in_duration, Easing.OutQuint);
|
2022-09-27 09:52:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnReleased(KeyBindingReleaseEvent<ManiaAction> e)
|
|
|
|
{
|
2022-10-04 07:05:36 +00:00
|
|
|
if (e.Action != column.Action.Value) return;
|
|
|
|
|
2022-10-07 10:27:00 +00:00
|
|
|
const double lighting_fade_out_duration = 800;
|
2022-10-04 07:05:36 +00:00
|
|
|
|
2022-10-07 10:27:00 +00:00
|
|
|
Color4 lightingColour = getLightingColour().Opacity(0);
|
|
|
|
|
|
|
|
// background fades out faster than lighting elements to give better definition to the player.
|
|
|
|
background.FadeTo(0.3f, 50, Easing.OutQuint)
|
|
|
|
.Then()
|
|
|
|
.FadeOut(lighting_fade_out_duration, Easing.OutQuint);
|
2022-10-04 07:05:36 +00:00
|
|
|
|
|
|
|
topIcon.ScaleTo(1f, 200, Easing.OutQuint);
|
|
|
|
topIcon.TransformTo(nameof(EdgeEffect), new EdgeEffectParameters
|
2022-09-27 09:52:43 +00:00
|
|
|
{
|
2022-10-04 07:05:36 +00:00
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
Colour = lightingColour,
|
|
|
|
Radius = 20,
|
|
|
|
}, lighting_fade_out_duration, Easing.OutQuint);
|
2022-09-27 10:32:58 +00:00
|
|
|
|
2022-10-04 07:05:36 +00:00
|
|
|
hitTargetLine.FadeColour(OsuColour.Gray(196 / 255f), lighting_fade_out_duration, Easing.OutQuint);
|
|
|
|
hitTargetLine.TransformTo(nameof(EdgeEffect), new EdgeEffectParameters
|
|
|
|
{
|
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
Colour = lightingColour,
|
2022-10-06 09:07:56 +00:00
|
|
|
Radius = 25,
|
2022-10-04 07:05:36 +00:00
|
|
|
}, lighting_fade_out_duration, Easing.OutQuint);
|
2022-09-27 09:52:43 +00:00
|
|
|
|
2022-10-05 11:02:02 +00:00
|
|
|
bottomIcon.FadeColour(accentColour.Value, lighting_fade_out_duration, Easing.OutQuint);
|
2022-09-27 10:13:37 +00:00
|
|
|
|
2022-10-04 07:05:36 +00:00
|
|
|
foreach (var circle in bottomIcon)
|
|
|
|
{
|
|
|
|
circle.TransformTo(nameof(EdgeEffect), new EdgeEffectParameters
|
|
|
|
{
|
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
Colour = lightingColour,
|
|
|
|
Radius = 30,
|
|
|
|
}, lighting_fade_out_duration, Easing.OutQuint);
|
2022-09-27 09:52:43 +00:00
|
|
|
}
|
|
|
|
}
|
2022-10-07 10:27:00 +00:00
|
|
|
|
|
|
|
private Color4 getLightingColour() => Interpolation.ValueAt(0.2f, accentColour.Value, Color4.White, 0, 1);
|
2022-09-27 09:52:43 +00:00
|
|
|
}
|
|
|
|
}
|