1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-05 09:42:54 +08:00

Convert more stuff to command proxies

This commit is contained in:
Marvin Schürz 2024-10-11 02:58:23 +02:00
parent 4ec51b9a74
commit bf195c06fe
3 changed files with 10 additions and 9 deletions

View File

@ -24,7 +24,6 @@ using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Commands;
using osu.Game.Screens.Edit.Commands.Proxies;
using osu.Game.Screens.Edit.Compose;
using osuTK;
@ -563,6 +562,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
int i = 0;
double time = HitObject.StartTime;
var beatmapProxy = editorBeatmap.AsCommandProxy(commandHandler);
while (!Precision.DefinitelyBigger(time, HitObject.GetEndTime(), 1))
{
// positionWithRepeats is a fractional number in the range of [0, HitObject.SpanCount()]
@ -575,19 +576,19 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
Vector2 position = HitObject.Position + HitObject.Path.PositionAt(pathPosition);
commandHandler.SafeSubmit(new AddHitObjectCommand(editorBeatmap, new HitCircle
beatmapProxy.Add(new HitCircle
{
StartTime = time,
Position = position,
NewCombo = i == 0 && HitObject.NewCombo,
Samples = HitObject.HeadCircle.Samples.Select(s => s.With()).ToList()
}));
});
i += 1;
time = HitObject.StartTime + i * streamSpacing;
}
editorBeatmap.AsCommandProxy(commandHandler).Remove(HitObject);
beatmapProxy.Remove(HitObject);
commandHandler?.Commit();
}

View File

@ -16,7 +16,6 @@ using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.UI;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Commands;
using osu.Game.Screens.Edit.Commands.Proxies;
using osu.Game.Screens.Edit.Compose.Components;
using osu.Game.Utils;
@ -113,7 +112,8 @@ namespace osu.Game.Rulesets.Osu.Edit
foreach (var (ho, originalState) in objectsInScale)
{
commandHandler.SafeSubmit(new SetPositionCommand(ho, GeometryUtils.GetScaledPosition(scale, actualOrigin, originalState.Position, axisRotation)));
ho.AsCommandProxy(commandHandler)
.SetPosition(GeometryUtils.GetScaledPosition(scale, actualOrigin, originalState.Position, axisRotation));
}
}

View File

@ -27,7 +27,7 @@ using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Commands;
using osu.Game.Screens.Edit.Commands.Proxies;
using osu.Game.Screens.Edit.Components.RadioButtons;
using osu.Game.Screens.Edit.Components.TernaryButtons;
using osu.Game.Screens.Edit.Compose;
@ -499,14 +499,14 @@ namespace osu.Game.Rulesets.Edit
if (commit)
{
commandHandler.SafeSubmit(new AddHitObjectCommand(EditorBeatmap, hitObject), true);
EditorBeatmap.AsCommandProxy(commandHandler).Add(hitObject);
if (autoSeekOnPlacement.Value && EditorClock.CurrentTime < hitObject.StartTime)
EditorClock.SeekSmoothlyTo(hitObject.StartTime);
}
}
public void Delete(HitObject hitObject) => commandHandler.SafeSubmit(new RemoveHitObjectCommand(EditorBeatmap, hitObject));
public void Delete(HitObject hitObject) => EditorBeatmap.AsCommandProxy(commandHandler).Remove(hitObject);
#endregion