Fix toggling hit animations on the editor not applying immediately

This commit is contained in:
Dean Herbert
2022-05-12 17:36:35 +09:00
parent 5f2d9bf04c
commit 10e41d018a
2 changed files with 10 additions and 1 deletions

View File

@ -6,6 +6,7 @@ using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Lists;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
@ -46,15 +47,23 @@ namespace osu.Game.Rulesets.Osu.Edit
HitPolicy = new AnyOrderHitPolicy(); HitPolicy = new AnyOrderHitPolicy();
} }
private readonly WeakList<DrawableHitObject> drawableHitObjects = new WeakList<DrawableHitObject>();
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuConfigManager config) private void load(OsuConfigManager config)
{ {
hitAnimations = config.GetBindable<bool>(OsuSetting.EditorHitAnimations); hitAnimations = config.GetBindable<bool>(OsuSetting.EditorHitAnimations);
hitAnimations.BindValueChanged(_ =>
{
foreach (var d in drawableHitObjects) d.RefreshStateTransforms();
});
} }
protected override void OnNewDrawableHitObject(DrawableHitObject d) protected override void OnNewDrawableHitObject(DrawableHitObject d)
{ {
d.ApplyCustomUpdateState += updateState; d.ApplyCustomUpdateState += updateState;
drawableHitObjects.Add(d);
} }
private void updateState(DrawableHitObject hitObject, ArmedState state) private void updateState(DrawableHitObject hitObject, ArmedState state)

View File

@ -448,7 +448,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
/// <summary> /// <summary>
/// Reapplies the current <see cref="ArmedState"/>. /// Reapplies the current <see cref="ArmedState"/>.
/// </summary> /// </summary>
protected void RefreshStateTransforms() => updateState(State.Value, true); public void RefreshStateTransforms() => updateState(State.Value, true);
/// <summary> /// <summary>
/// Apply (generally fade-in) transforms leading into the <see cref="HitObject"/> start time. /// Apply (generally fade-in) transforms leading into the <see cref="HitObject"/> start time.