From 20ce6493261756872df33a001db7e20ed40d1a26 Mon Sep 17 00:00:00 2001 From: OliBomby Date: Sun, 13 Oct 2024 01:07:02 +0200 Subject: [PATCH] fix lacking hitobject updates in undo history --- .../Blueprints/Sliders/SliderSelectionBlueprint.cs | 2 +- .../Edit/Commands/Proxies/CommandProxyExtensions.cs | 3 +++ .../Compose/Components/EditorBlueprintContainer.cs | 12 ++++++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderSelectionBlueprint.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderSelectionBlueprint.cs index 4f20e7b294a2..f24ddd242fb9 100644 --- a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderSelectionBlueprint.cs +++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderSelectionBlueprint.cs @@ -283,7 +283,7 @@ private void adjustLength(double proposedDistance, bool adjustVelocity) Proxy.SetSliderVelocityMultiplier(proposedVelocity); Proxy.Path().SetExpectedDistance(proposedDistance); - editorBeatmap?.Update(HitObject); + editorBeatmap?.AsCommandProxy(commandHandler).Update(HitObject); } /// diff --git a/osu.Game/Screens/Edit/Commands/Proxies/CommandProxyExtensions.cs b/osu.Game/Screens/Edit/Commands/Proxies/CommandProxyExtensions.cs index 6b1b55be3835..8ba4ec59d65d 100644 --- a/osu.Game/Screens/Edit/Commands/Proxies/CommandProxyExtensions.cs +++ b/osu.Game/Screens/Edit/Commands/Proxies/CommandProxyExtensions.cs @@ -110,6 +110,9 @@ public static CommandProxy Add(this CommandProxy p public static CommandProxy Remove(this CommandProxy proxy, HitObject hitObject) => proxy.Submit(new RemoveHitObjectCommand(proxy.Target, hitObject)); + public static CommandProxy Update(this CommandProxy proxy, HitObject hitObject) => + proxy.Submit(new UpdateHitObjectCommand(proxy.Target, hitObject)); + #endregion } } diff --git a/osu.Game/Screens/Edit/Compose/Components/EditorBlueprintContainer.cs b/osu.Game/Screens/Edit/Compose/Components/EditorBlueprintContainer.cs index 378d378be3df..a3b4c43af13a 100644 --- a/osu.Game/Screens/Edit/Compose/Components/EditorBlueprintContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/EditorBlueprintContainer.cs @@ -15,6 +15,7 @@ using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Drawables; +using osu.Game.Screens.Edit.Commands.Proxies; namespace osu.Game.Screens.Edit.Compose.Components { @@ -26,6 +27,9 @@ public partial class EditorBlueprintContainer : BlueprintContainer [Resolved] protected EditorBeatmap Beatmap { get; private set; } + [Resolved(canBeNull: true)] + private EditorCommandHandler commandHandler { get; set; } + protected readonly HitObjectComposer Composer; private HitObjectUsageEventBuffer usageEventBuffer; @@ -88,8 +92,8 @@ protected override bool ApplySnapResult(SelectionBlueprint[] blueprin { Beatmap.PerformOnSelection(obj => { - obj.StartTime += offset; - Beatmap.Update(obj); + obj.AsCommandProxy(commandHandler).SetStartTime(obj.StartTime + offset); + Beatmap.AsCommandProxy(commandHandler).Update(obj); }); } } @@ -119,8 +123,8 @@ protected override void DragOperationCompleted() base.DragOperationCompleted(); // handle positional change etc. - foreach (var blueprint in SelectionBlueprints) - Beatmap.Update(blueprint.Item); + foreach (var blueprint in SelectionHandler.SelectedBlueprints) + Beatmap.AsCommandProxy(commandHandler).Update(blueprint.Item); } protected override bool OnDoubleClick(DoubleClickEvent e)