Skip to content

Commit

Permalink
Fix hit circle animation reset when skin is changed
Browse files Browse the repository at this point in the history
The transforms applied in `Animate` call was not applied because the piece is recreated.
  • Loading branch information
ekrctb committed Jun 2, 2021
1 parent dce24e3 commit b82190e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 0 additions & 2 deletions osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ protected override void UpdateHitStateTransforms(ArmedState state)
// todo: temporary / arbitrary, used for lifetime optimisation.
this.Delay(800).FadeOut();

(CirclePiece.Drawable as IMainCirclePiece)?.Animate(state);

switch (state)
{
case ArmedState.Idle:
Expand Down
4 changes: 4 additions & 0 deletions osu.Game.Rulesets.Osu/Skinning/Default/MainCirclePiece.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public MainCirclePiece()

private readonly IBindable<Color4> accentColour = new Bindable<Color4>();
private readonly IBindable<int> indexInCurrentCombo = new Bindable<int>();
private readonly IBindable<ArmedState> armedState = new Bindable<ArmedState>();

[Resolved]
private DrawableHitObject drawableObject { get; set; }
Expand All @@ -53,6 +54,7 @@ private void load()

accentColour.BindTo(drawableObject.AccentColour);
indexInCurrentCombo.BindTo(drawableOsuObject.IndexInCurrentComboBindable);
armedState.BindTo(drawableObject.State);
}

protected override void LoadComplete()
Expand All @@ -67,6 +69,8 @@ protected override void LoadComplete()
}, true);

indexInCurrentCombo.BindValueChanged(index => number.Text = (index.NewValue + 1).ToString(), true);

armedState.BindValueChanged(state => Animate(state.NewValue), true);
}

public void Animate(ArmedState state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public LegacyMainCirclePiece(string priorityLookup = null, bool hasNumber = true

private readonly Bindable<Color4> accentColour = new Bindable<Color4>();
private readonly IBindable<int> indexInCurrentCombo = new Bindable<int>();
private readonly IBindable<ArmedState> armedState = new Bindable<ArmedState>();

[Resolved]
private DrawableHitObject drawableObject { get; set; }
Expand Down Expand Up @@ -115,6 +116,7 @@ private void load()

accentColour.BindTo(drawableObject.AccentColour);
indexInCurrentCombo.BindTo(drawableOsuObject.IndexInCurrentComboBindable);
armedState.BindTo(drawableObject.State);

Texture getTextureWithFallback(string name)
{
Expand All @@ -139,6 +141,8 @@ protected override void LoadComplete()
accentColour.BindValueChanged(colour => hitCircleSprite.Colour = LegacyColourCompatibility.DisallowZeroAlpha(colour.NewValue), true);
if (hasNumber)
indexInCurrentCombo.BindValueChanged(index => hitCircleText.Text = (index.NewValue + 1).ToString(), true);

armedState.BindValueChanged(state => Animate(state.NewValue), true);
}

public void Animate(ArmedState state)
Expand Down

0 comments on commit b82190e

Please sign in to comment.