Skip to content

Commit

Permalink
Fix toggling hit animations on the editor not applying immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed May 12, 2022
1 parent 5f2d9bf commit 10e41d0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions osu.Game.Rulesets.Osu/Edit/DrawableOsuEditorRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Lists;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Rulesets.Mods;
Expand Down Expand Up @@ -46,15 +47,23 @@ public OsuEditorPlayfield()
HitPolicy = new AnyOrderHitPolicy();
}

private readonly WeakList<DrawableHitObject> drawableHitObjects = new WeakList<DrawableHitObject>();

[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
hitAnimations = config.GetBindable<bool>(OsuSetting.EditorHitAnimations);
hitAnimations.BindValueChanged(_ =>
{
foreach (var d in drawableHitObjects) d.RefreshStateTransforms();
});
}

protected override void OnNewDrawableHitObject(DrawableHitObject d)
{
d.ApplyCustomUpdateState += updateState;

drawableHitObjects.Add(d);
}

private void updateState(DrawableHitObject hitObject, ArmedState state)
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ private void clearExistingStateTransforms()
/// <summary>
/// Reapplies the current <see cref="ArmedState"/>.
/// </summary>
protected void RefreshStateTransforms() => updateState(State.Value, true);
public void RefreshStateTransforms() => updateState(State.Value, true);

/// <summary>
/// Apply (generally fade-in) transforms leading into the <see cref="HitObject"/> start time.
Expand Down

0 comments on commit 10e41d0

Please sign in to comment.