mirror of
https://github.com/ppy/osu.git
synced 2025-03-10 21:40:34 +08:00
Fix skin SourceChanged
event never being unbound
This commit is contained in:
parent
c18128e974
commit
e8d20fb402
@ -3,6 +3,7 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Rulesets.Mania.Skinning;
|
||||
@ -22,15 +23,12 @@ namespace osu.Game.Rulesets.Mania.UI.Components
|
||||
private void load(IScrollingInfo scrollingInfo)
|
||||
{
|
||||
Direction.BindTo(scrollingInfo.Direction);
|
||||
Direction.BindValueChanged(onDirectionChanged);
|
||||
Direction.BindValueChanged(_ => UpdateHitPosition(), true);
|
||||
|
||||
skin.SourceChanged += onSkinChanged;
|
||||
|
||||
UpdateHitPosition();
|
||||
}
|
||||
|
||||
private void onSkinChanged() => UpdateHitPosition();
|
||||
private void onDirectionChanged(ValueChangedEvent<ScrollingDirection> direction) => UpdateHitPosition();
|
||||
|
||||
protected virtual void UpdateHitPosition()
|
||||
{
|
||||
@ -42,5 +40,13 @@ namespace osu.Game.Rulesets.Mania.UI.Components
|
||||
? new MarginPadding { Top = hitPosition }
|
||||
: new MarginPadding { Bottom = hitPosition };
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
if (skin.IsNotNull())
|
||||
skin.SourceChanged -= onSkinChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user