Merge branch 'master' into spinner-spinning

This commit is contained in:
smoogipoo
2020-08-01 01:06:53 +09:00
13 changed files with 146 additions and 42 deletions

View File

@ -29,7 +29,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
private SpinnerTicks ticks;
private int completeTick;
private int wholeRotationCount;
private SpinnerFill fill;
private Container mainContainer;
private SpinnerCentreLayer centre;
@ -95,6 +96,33 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
drawableSpinner.State.BindValueChanged(updateStateTransforms, true);
}
protected override void Update()
{
base.Update();
if (drawableSpinner.RotationTracker.Complete.Value)
{
if (checkNewRotationCount)
{
fill.FinishTransforms(false, nameof(Alpha));
fill
.FadeTo(tracking_alpha + 0.2f, 60, Easing.OutExpo)
.Then()
.FadeTo(tracking_alpha, 250, Easing.OutQuint);
}
}
else
{
fill.Alpha = (float)Interpolation.Damp(fill.Alpha, drawableSpinner.RotationTracker.Tracking ? tracking_alpha : idle_alpha, 0.98f, (float)Math.Abs(Clock.ElapsedFrameTime));
}
const float initial_scale = 0.2f;
float targetScale = initial_scale + (1 - initial_scale) * drawableSpinner.Progress;
fill.Scale = new Vector2((float)Interpolation.Lerp(fill.Scale.X, targetScale, Math.Clamp(Math.Abs(Time.Elapsed) / 100, 0, 1)));
mainContainer.Rotation = drawableSpinner.RotationTracker.Rotation;
}
private void updateStateTransforms(ValueChangedEvent<ArmedState> state)
{
centre.ScaleTo(0);
@ -145,26 +173,17 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
centre.FadeAccent(colour, duration);
}
private bool updateCompleteTick() => completeTick != (completeTick = (int)(drawableSpinner.RotationTracker.CumulativeRotation / 360));
protected override void Update()
private bool checkNewRotationCount
{
base.Update();
if (drawableSpinner.RotationTracker.Complete.Value && updateCompleteTick())
get
{
fill.FinishTransforms(false, nameof(Alpha));
fill
.FadeTo(tracking_alpha + 0.2f, 60, Easing.OutExpo)
.Then()
.FadeTo(tracking_alpha, 250, Easing.OutQuint);
int rotations = (int)(drawableSpinner.RotationTracker.CumulativeRotation / 360);
if (wholeRotationCount == rotations) return false;
wholeRotationCount = rotations;
return true;
}
const float initial_scale = 0.2f;
float targetScale = initial_scale + (1 - initial_scale) * drawableSpinner.Progress;
fill.Scale = new Vector2((float)Interpolation.Lerp(fill.Scale.X, targetScale, Math.Clamp(Math.Abs(Time.Elapsed) / 100, 0, 1)));
mainContainer.Rotation = drawableSpinner.RotationTracker.Rotation;
}
}
}

View File

@ -93,8 +93,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
spinningMiddle.Rotation = discTop.Rotation = drawableSpinner.RotationTracker.Rotation;
discBottom.Rotation = discTop.Rotation / 3;
Scale = new Vector2(final_scale * 0.8f
+ (float)Interpolation.ApplyEasing(Easing.Out, drawableSpinner.Progress) * (final_scale * 0.2f));
Scale = new Vector2(final_scale * (0.8f + (float)Interpolation.ApplyEasing(Easing.Out, drawableSpinner.Progress) * 0.2f));
}
}
}

View File

@ -104,9 +104,11 @@ namespace osu.Game.Rulesets.Osu.Skinning
};
case OsuSkinComponents.SpinnerBody:
if (Source.GetTexture("spinner-top") != null)
bool hasBackground = Source.GetTexture("spinner-background") != null;
if (Source.GetTexture("spinner-top") != null && !hasBackground)
return new LegacyNewStyleSpinner();
else if (Source.GetTexture("spinner-background") != null)
else if (hasBackground)
return new LegacyOldStyleSpinner();
return null;