From ef092de9baaf3bde1e50abf5441fcefd847b6007 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 8 Oct 2020 16:56:55 +0900 Subject: [PATCH] Add missing UpdateHitObject calls and move local to usages (not via bindables) --- .../Compose/Components/BlueprintContainer.cs | 4 ++ .../Timeline/TimelineHitObjectBlueprint.cs | 4 +- osu.Game/Screens/Edit/EditorBeatmap.cs | 42 +++++++------------ 3 files changed, 22 insertions(+), 28 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs index 970e16d1c3..addb970e8a 100644 --- a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs @@ -436,8 +436,12 @@ namespace osu.Game.Screens.Edit.Compose.Components { // Apply the start time at the newly snapped-to position double offset = result.Time.Value - draggedObject.StartTime; + foreach (HitObject obj in SelectionHandler.SelectedHitObjects) + { obj.StartTime += offset; + Beatmap.UpdateHitObject(obj); + } } return true; diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineHitObjectBlueprint.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineHitObjectBlueprint.cs index f0757a3dda..6c3bcfae32 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineHitObjectBlueprint.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineHitObjectBlueprint.cs @@ -392,6 +392,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline return; repeatHitObject.RepeatCount = proposedCount; + beatmap.UpdateHitObject(hitObject); break; case IHasDuration endTimeHitObject: @@ -401,10 +402,9 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline return; endTimeHitObject.Duration = snappedTime - hitObject.StartTime; + beatmap.UpdateHitObject(hitObject); break; } - - beatmap.UpdateHitObject(hitObject); } } diff --git a/osu.Game/Screens/Edit/EditorBeatmap.cs b/osu.Game/Screens/Edit/EditorBeatmap.cs index fb75d91d16..d02841a95f 100644 --- a/osu.Game/Screens/Edit/EditorBeatmap.cs +++ b/osu.Game/Screens/Edit/EditorBeatmap.cs @@ -89,8 +89,6 @@ namespace osu.Game.Screens.Edit private IList mutableHitObjects => (IList)PlayableBeatmap.HitObjects; - private readonly HashSet pendingUpdates = new HashSet(); - private bool isBatchApplying; /// @@ -150,7 +148,16 @@ namespace osu.Game.Screens.Edit /// The to update. public void UpdateHitObject([NotNull] HitObject hitObject) { - pendingUpdates.Add(hitObject); + if (isBatchApplying) + batchPendingUpdates.Add(hitObject); + else + { + beatmapProcessor?.PreProcess(); + processHitObject(hitObject); + beatmapProcessor?.PostProcess(); + + HitObjectUpdated?.Invoke(hitObject); + } } /// @@ -220,6 +227,8 @@ namespace osu.Game.Screens.Edit private readonly List batchPendingDeletes = new List(); + private readonly HashSet batchPendingUpdates = new HashSet(); + /// /// Apply a batch of operations in one go, without performing Pre/Postprocessing each time. /// @@ -237,14 +246,17 @@ namespace osu.Game.Screens.Edit foreach (var h in batchPendingDeletes) processHitObject(h); foreach (var h in batchPendingInserts) processHitObject(h); + foreach (var h in batchPendingUpdates) processHitObject(h); beatmapProcessor?.PostProcess(); foreach (var h in batchPendingDeletes) HitObjectRemoved?.Invoke(h); foreach (var h in batchPendingInserts) HitObjectAdded?.Invoke(h); + foreach (var h in batchPendingUpdates) HitObjectUpdated?.Invoke(h); batchPendingDeletes.Clear(); batchPendingInserts.Clear(); + batchPendingUpdates.Clear(); isBatchApplying = false; } @@ -254,28 +266,6 @@ namespace osu.Game.Screens.Edit /// public void Clear() => RemoveRange(HitObjects.ToArray()); - protected override void Update() - { - base.Update(); - - // debounce updates as they are common and may come from input events, which can run needlessly many times per update frame. - if (pendingUpdates.Count > 0) - { - beatmapProcessor?.PreProcess(); - - foreach (var hitObject in pendingUpdates) - processHitObject(hitObject); - - beatmapProcessor?.PostProcess(); - - // explicitly needs to be fired after PostProcess - foreach (var hitObject in pendingUpdates) - HitObjectUpdated?.Invoke(hitObject); - - pendingUpdates.Clear(); - } - } - private void processHitObject(HitObject hitObject) => hitObject.ApplyDefaults(ControlPointInfo, BeatmapInfo.BaseDifficulty); private void trackStartTime(HitObject hitObject) @@ -322,7 +312,7 @@ namespace osu.Game.Screens.Edit public void UpdateBeatmap() { foreach (var h in HitObjects) - pendingUpdates.Add(h); + batchPendingUpdates.Add(h); } } }