mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 03:15:45 +08:00
Add missing UpdateHitObject calls and move local to usages (not via bindables)
This commit is contained in:
parent
5d55f00139
commit
ef092de9ba
@ -436,8 +436,12 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
// Apply the start time at the newly snapped-to position
|
// Apply the start time at the newly snapped-to position
|
||||||
double offset = result.Time.Value - draggedObject.StartTime;
|
double offset = result.Time.Value - draggedObject.StartTime;
|
||||||
|
|
||||||
foreach (HitObject obj in SelectionHandler.SelectedHitObjects)
|
foreach (HitObject obj in SelectionHandler.SelectedHitObjects)
|
||||||
|
{
|
||||||
obj.StartTime += offset;
|
obj.StartTime += offset;
|
||||||
|
Beatmap.UpdateHitObject(obj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -392,6 +392,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
repeatHitObject.RepeatCount = proposedCount;
|
repeatHitObject.RepeatCount = proposedCount;
|
||||||
|
beatmap.UpdateHitObject(hitObject);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IHasDuration endTimeHitObject:
|
case IHasDuration endTimeHitObject:
|
||||||
@ -401,10 +402,9 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
endTimeHitObject.Duration = snappedTime - hitObject.StartTime;
|
endTimeHitObject.Duration = snappedTime - hitObject.StartTime;
|
||||||
|
beatmap.UpdateHitObject(hitObject);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
beatmap.UpdateHitObject(hitObject);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,8 +89,6 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
private IList mutableHitObjects => (IList)PlayableBeatmap.HitObjects;
|
private IList mutableHitObjects => (IList)PlayableBeatmap.HitObjects;
|
||||||
|
|
||||||
private readonly HashSet<HitObject> pendingUpdates = new HashSet<HitObject>();
|
|
||||||
|
|
||||||
private bool isBatchApplying;
|
private bool isBatchApplying;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -150,7 +148,16 @@ namespace osu.Game.Screens.Edit
|
|||||||
/// <param name="hitObject">The <see cref="HitObject"/> to update.</param>
|
/// <param name="hitObject">The <see cref="HitObject"/> to update.</param>
|
||||||
public void UpdateHitObject([NotNull] HitObject hitObject)
|
public void UpdateHitObject([NotNull] HitObject hitObject)
|
||||||
{
|
{
|
||||||
pendingUpdates.Add(hitObject);
|
if (isBatchApplying)
|
||||||
|
batchPendingUpdates.Add(hitObject);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
beatmapProcessor?.PreProcess();
|
||||||
|
processHitObject(hitObject);
|
||||||
|
beatmapProcessor?.PostProcess();
|
||||||
|
|
||||||
|
HitObjectUpdated?.Invoke(hitObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -220,6 +227,8 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
private readonly List<HitObject> batchPendingDeletes = new List<HitObject>();
|
private readonly List<HitObject> batchPendingDeletes = new List<HitObject>();
|
||||||
|
|
||||||
|
private readonly HashSet<HitObject> batchPendingUpdates = new HashSet<HitObject>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Apply a batch of operations in one go, without performing Pre/Postprocessing each time.
|
/// Apply a batch of operations in one go, without performing Pre/Postprocessing each time.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -237,14 +246,17 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
foreach (var h in batchPendingDeletes) processHitObject(h);
|
foreach (var h in batchPendingDeletes) processHitObject(h);
|
||||||
foreach (var h in batchPendingInserts) processHitObject(h);
|
foreach (var h in batchPendingInserts) processHitObject(h);
|
||||||
|
foreach (var h in batchPendingUpdates) processHitObject(h);
|
||||||
|
|
||||||
beatmapProcessor?.PostProcess();
|
beatmapProcessor?.PostProcess();
|
||||||
|
|
||||||
foreach (var h in batchPendingDeletes) HitObjectRemoved?.Invoke(h);
|
foreach (var h in batchPendingDeletes) HitObjectRemoved?.Invoke(h);
|
||||||
foreach (var h in batchPendingInserts) HitObjectAdded?.Invoke(h);
|
foreach (var h in batchPendingInserts) HitObjectAdded?.Invoke(h);
|
||||||
|
foreach (var h in batchPendingUpdates) HitObjectUpdated?.Invoke(h);
|
||||||
|
|
||||||
batchPendingDeletes.Clear();
|
batchPendingDeletes.Clear();
|
||||||
batchPendingInserts.Clear();
|
batchPendingInserts.Clear();
|
||||||
|
batchPendingUpdates.Clear();
|
||||||
|
|
||||||
isBatchApplying = false;
|
isBatchApplying = false;
|
||||||
}
|
}
|
||||||
@ -254,28 +266,6 @@ namespace osu.Game.Screens.Edit
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Clear() => RemoveRange(HitObjects.ToArray());
|
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 processHitObject(HitObject hitObject) => hitObject.ApplyDefaults(ControlPointInfo, BeatmapInfo.BaseDifficulty);
|
||||||
|
|
||||||
private void trackStartTime(HitObject hitObject)
|
private void trackStartTime(HitObject hitObject)
|
||||||
@ -322,7 +312,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
public void UpdateBeatmap()
|
public void UpdateBeatmap()
|
||||||
{
|
{
|
||||||
foreach (var h in HitObjects)
|
foreach (var h in HitObjects)
|
||||||
pendingUpdates.Add(h);
|
batchPendingUpdates.Add(h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user