Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement beat-synchronized animation in skip overlay #29866

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions osu.Game/Screens/Play/SkipOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Audio.Track;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Framework.Utils;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
Expand All @@ -26,7 +28,7 @@

namespace osu.Game.Screens.Play
{
public partial class SkipOverlay : CompositeDrawable, IKeyBindingHandler<GlobalAction>
public partial class SkipOverlay : BeatSyncedContainer, IKeyBindingHandler<GlobalAction>
{
/// <summary>
/// The total number of successful skips performed by this overlay.
Expand All @@ -36,10 +38,9 @@ public partial class SkipOverlay : CompositeDrawable, IKeyBindingHandler<GlobalA
private readonly double startTime;

public Action RequestSkip;

private Button button;
private ButtonContainer buttonContainer;
private Box remainingTimeBox;
private Circle remainingTimeBox;

private FadeContainer fadeContainer;
private double displayTime;
Expand Down Expand Up @@ -87,13 +88,14 @@ private void load(OsuColour colours)
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
remainingTimeBox = new Box
remainingTimeBox = new Circle
{
Height = 5,
RelativeSizeAxes = Axes.X,
Colour = colours.Yellow,
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
Colour = colours.Yellow,
RelativeSizeAxes = Axes.X,
Masking = true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant, Circle already enables masking by default (it wouldn't be a circle otherwise)

}
}
}
Expand Down Expand Up @@ -210,6 +212,17 @@ public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
{
}

protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
{
base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes);

if (fadeOutBeginTime <= gameplayClock.CurrentTime)
return;

float progress = (float)(gameplayClock.CurrentTime - displayTime) / (float)(fadeOutBeginTime - displayTime);
Comment on lines +219 to +222
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is fadeOutBeginTime checked against current time (therefore clamping from the left), but progress is not forcefully clamped to be no larger than 1?

remainingTimeBox.ResizeWidthTo(Math.Max(0, (float)(1 - progress)), timingPoint.BeatLength * 2, Easing.OutQuint);
}

public partial class FadeContainer : Container, IStateful<Visibility>
{
[CanBeNull]
Expand Down