Fix LegacyComboCounter not unsubscribing from skin

This commit is contained in:
Sebastian Krajewski 2022-03-28 18:08:35 +02:00
parent 05a978ce8c
commit 001a98e069

View File

@ -44,6 +44,9 @@ namespace osu.Game.Screens.Play.HUD
private readonly Container counterContainer; private readonly Container counterContainer;
[Resolved]
private ISkinSource skin { get; set; }
/// <summary> /// <summary>
/// Hides the combo counter internally without affecting its <see cref="SkinnableInfo"/>. /// Hides the combo counter internally without affecting its <see cref="SkinnableInfo"/>.
/// </summary> /// </summary>
@ -118,12 +121,9 @@ namespace osu.Game.Screens.Play.HUD
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(ScoreProcessor scoreProcessor, ISkinSource skin) private void load(ScoreProcessor scoreProcessor)
{ {
Current.BindTo(scoreProcessor.Combo); Current.BindTo(scoreProcessor.Combo);
// Since layout depends on combo font height we need to update it during skin change
skin.SourceChanged += updateLayout;
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -133,9 +133,11 @@ namespace osu.Game.Screens.Play.HUD
((IHasText)displayedCountSpriteText).Text = formatCount(Current.Value); ((IHasText)displayedCountSpriteText).Text = formatCount(Current.Value);
((IHasText)popOutCount).Text = formatCount(Current.Value); ((IHasText)popOutCount).Text = formatCount(Current.Value);
updateLayout();
Current.BindValueChanged(combo => updateCount(combo.NewValue == 0), true); Current.BindValueChanged(combo => updateCount(combo.NewValue == 0), true);
// Since layout depends on combo font height we need to update it during skin change
skin.SourceChanged += updateLayout;
updateLayout();
} }
private void updateLayout() private void updateLayout()
@ -290,5 +292,13 @@ namespace osu.Game.Screens.Play.HUD
double difference = currentValue > newValue ? currentValue - newValue : newValue - currentValue; double difference = currentValue > newValue ? currentValue - newValue : newValue - currentValue;
return difference * rolling_duration; return difference * rolling_duration;
} }
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
if (skin != null)
skin.SourceChanged -= updateLayout;
}
} }
} }