mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 07:13:21 +08:00
Fix animation playback not running on skin change
This commit is contained in:
parent
d017e725fb
commit
ee8804b50b
@ -28,8 +28,13 @@ namespace osu.Game.Rulesets.Judgements
|
|||||||
|
|
||||||
protected Container JudgementBody { get; private set; }
|
protected Container JudgementBody { get; private set; }
|
||||||
|
|
||||||
|
public override bool RemoveCompletedTransforms => false;
|
||||||
|
|
||||||
private SkinnableDrawable skinnableJudgement;
|
private SkinnableDrawable skinnableJudgement;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private ISkinSource skinSource { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Duration of initial fade in.
|
/// Duration of initial fade in.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -65,6 +70,27 @@ namespace osu.Game.Rulesets.Judgements
|
|||||||
prepareDrawables();
|
prepareDrawables();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
skinSource.SourceChanged += onSkinChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onSkinChanged()
|
||||||
|
{
|
||||||
|
// on a skin change, the child component will update but not get correctly triggered to play its animation.
|
||||||
|
// we need to trigger a reinitialisation to make things right.
|
||||||
|
currentDrawableType = null;
|
||||||
|
|
||||||
|
PrepareForUse();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
skinSource.SourceChanged -= onSkinChanged;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Apply top-level animations to the current judgement when successfully hit.
|
/// Apply top-level animations to the current judgement when successfully hit.
|
||||||
/// Generally used for fading, defaulting to a simple fade out based on <see cref="FadeOutDelay"/>.
|
/// Generally used for fading, defaulting to a simple fade out based on <see cref="FadeOutDelay"/>.
|
||||||
@ -110,6 +136,12 @@ namespace osu.Game.Rulesets.Judgements
|
|||||||
|
|
||||||
prepareDrawables();
|
prepareDrawables();
|
||||||
|
|
||||||
|
runAnimation();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void runAnimation()
|
||||||
|
{
|
||||||
|
ClearTransforms(true);
|
||||||
LifetimeStart = Result.TimeAbsolute;
|
LifetimeStart = Result.TimeAbsolute;
|
||||||
|
|
||||||
using (BeginAbsoluteSequence(Result.TimeAbsolute, true))
|
using (BeginAbsoluteSequence(Result.TimeAbsolute, true))
|
||||||
@ -135,21 +167,16 @@ namespace osu.Game.Rulesets.Judgements
|
|||||||
{
|
{
|
||||||
var drawableAnimation = (Drawable)animatable;
|
var drawableAnimation = (Drawable)animatable;
|
||||||
|
|
||||||
drawableAnimation.ClearTransforms();
|
|
||||||
|
|
||||||
animatable.PlayAnimation();
|
animatable.PlayAnimation();
|
||||||
|
|
||||||
// a derived version of DrawableJudgement may be adjusting lifetime.
|
// a derived version of DrawableJudgement may be proposing a lifetime.
|
||||||
// if not adjusted (or the skinned portion requires greater bounds than calculated) use the skinned source's lifetime.
|
// if not adjusted (or the skinned portion requires greater bounds than calculated) use the skinned source's lifetime.
|
||||||
double lastTransformTime = drawableAnimation.LatestTransformEndTime;
|
double lastTransformTime = drawableAnimation.LatestTransformEndTime;
|
||||||
|
|
||||||
if (LifetimeEnd == double.MaxValue || lastTransformTime > LifetimeEnd)
|
if (LifetimeEnd == double.MaxValue || lastTransformTime > LifetimeEnd)
|
||||||
{
|
|
||||||
LifetimeEnd = lastTransformTime;
|
LifetimeEnd = lastTransformTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private HitResult? currentDrawableType;
|
private HitResult? currentDrawableType;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user