mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 21:52:55 +08:00
Fix traceable mod not working on skin change
This commit is contained in:
parent
7c2884700e
commit
527ab1a72f
@ -55,13 +55,8 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
break;
|
||||
|
||||
case DrawableSlider slider:
|
||||
slider.AccentColour.BindValueChanged(_ =>
|
||||
{
|
||||
//will trigger on skin change.
|
||||
((PlaySliderBody)slider.Body.Drawable).AccentColour = slider.AccentColour.Value.Opacity(0);
|
||||
((PlaySliderBody)slider.Body.Drawable).BorderColour = slider.AccentColour.Value;
|
||||
}, true);
|
||||
|
||||
slider.Body.OnSkinChanged += () => applySliderState(slider);
|
||||
applySliderState(slider);
|
||||
break;
|
||||
|
||||
case DrawableSpinner spinner:
|
||||
@ -70,5 +65,11 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void applySliderState(DrawableSlider slider)
|
||||
{
|
||||
((PlaySliderBody)slider.Body.Drawable).AccentColour = slider.AccentColour.Value.Opacity(0);
|
||||
((PlaySliderBody)slider.Body.Drawable).BorderColour = slider.AccentColour.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,11 @@ namespace osu.Game.Skinning
|
||||
/// </summary>
|
||||
public abstract class SkinReloadableDrawable : CompositeDrawable
|
||||
{
|
||||
/// <summary>
|
||||
/// Invoked when <see cref="CurrentSkin"/> has changed.
|
||||
/// </summary>
|
||||
public event Action OnSkinChanged;
|
||||
|
||||
/// <summary>
|
||||
/// The current skin source.
|
||||
/// </summary>
|
||||
@ -43,12 +48,18 @@ namespace osu.Game.Skinning
|
||||
private void onChange() =>
|
||||
// schedule required to avoid calls after disposed.
|
||||
// note that this has the side-effect of components only performing a skin change when they are alive.
|
||||
Scheduler.AddOnce(() => SkinChanged(CurrentSkin, allowDefaultFallback));
|
||||
Scheduler.AddOnce(skinChanged);
|
||||
|
||||
protected override void LoadAsyncComplete()
|
||||
{
|
||||
base.LoadAsyncComplete();
|
||||
skinChanged();
|
||||
}
|
||||
|
||||
private void skinChanged()
|
||||
{
|
||||
SkinChanged(CurrentSkin, allowDefaultFallback);
|
||||
OnSkinChanged?.Invoke();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -66,6 +77,8 @@ namespace osu.Game.Skinning
|
||||
|
||||
if (CurrentSkin != null)
|
||||
CurrentSkin.SourceChanged -= onChange;
|
||||
|
||||
OnSkinChanged = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user