1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 21:43:22 +08:00

Fix traceable mod not working on skin change

This commit is contained in:
smoogipoo 2019-12-17 19:49:13 +09:00
parent 7c2884700e
commit 527ab1a72f
2 changed files with 22 additions and 8 deletions

View File

@ -55,13 +55,8 @@ namespace osu.Game.Rulesets.Osu.Mods
break; break;
case DrawableSlider slider: case DrawableSlider slider:
slider.AccentColour.BindValueChanged(_ => slider.Body.OnSkinChanged += () => applySliderState(slider);
{ applySliderState(slider);
//will trigger on skin change.
((PlaySliderBody)slider.Body.Drawable).AccentColour = slider.AccentColour.Value.Opacity(0);
((PlaySliderBody)slider.Body.Drawable).BorderColour = slider.AccentColour.Value;
}, true);
break; break;
case DrawableSpinner spinner: case DrawableSpinner spinner:
@ -70,5 +65,11 @@ namespace osu.Game.Rulesets.Osu.Mods
break; break;
} }
} }
private void applySliderState(DrawableSlider slider)
{
((PlaySliderBody)slider.Body.Drawable).AccentColour = slider.AccentColour.Value.Opacity(0);
((PlaySliderBody)slider.Body.Drawable).BorderColour = slider.AccentColour.Value;
}
} }
} }

View File

@ -12,6 +12,11 @@ namespace osu.Game.Skinning
/// </summary> /// </summary>
public abstract class SkinReloadableDrawable : CompositeDrawable public abstract class SkinReloadableDrawable : CompositeDrawable
{ {
/// <summary>
/// Invoked when <see cref="CurrentSkin"/> has changed.
/// </summary>
public event Action OnSkinChanged;
/// <summary> /// <summary>
/// The current skin source. /// The current skin source.
/// </summary> /// </summary>
@ -43,12 +48,18 @@ namespace osu.Game.Skinning
private void onChange() => private void onChange() =>
// schedule required to avoid calls after disposed. // 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. // 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() protected override void LoadAsyncComplete()
{ {
base.LoadAsyncComplete(); base.LoadAsyncComplete();
skinChanged();
}
private void skinChanged()
{
SkinChanged(CurrentSkin, allowDefaultFallback); SkinChanged(CurrentSkin, allowDefaultFallback);
OnSkinChanged?.Invoke();
} }
/// <summary> /// <summary>
@ -66,6 +77,8 @@ namespace osu.Game.Skinning
if (CurrentSkin != null) if (CurrentSkin != null)
CurrentSkin.SourceChanged -= onChange; CurrentSkin.SourceChanged -= onChange;
OnSkinChanged = null;
} }
} }
} }