mirror of
https://github.com/ppy/osu.git
synced 2024-12-05 09:42:54 +08:00
refactor to alternative extension method
This commit is contained in:
parent
cb5be12f47
commit
b710742d2f
@ -115,7 +115,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
return;
|
||||
|
||||
if (segment.Count > 3)
|
||||
changeHandler.SafeSubmit(new PathControlPointTypeChange(first, PathType.BEZIER));
|
||||
new PathControlPointTypeChange(first, PathType.BEZIER).Submit(changeHandler);
|
||||
|
||||
if (segment.Count != 3)
|
||||
return;
|
||||
@ -123,7 +123,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
ReadOnlySpan<Vector2> points = segment.Select(p => p.Position).ToArray();
|
||||
RectangleF boundingBox = PathApproximator.CircularArcBoundingBox(points);
|
||||
if (boundingBox.Width >= 640 || boundingBox.Height >= 480)
|
||||
changeHandler.SafeSubmit(new PathControlPointTypeChange(first, PathType.BEZIER));
|
||||
new PathControlPointTypeChange(first, PathType.BEZIER).Submit(changeHandler);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -370,11 +370,11 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
int thirdPointIndex = indexInSegment + 2;
|
||||
|
||||
if (pointsInSegment.Count > thirdPointIndex + 1)
|
||||
changeHandler.SafeSubmit(new PathControlPointTypeChange(pointsInSegment[thirdPointIndex], pointsInSegment[0].Type));
|
||||
new PathControlPointTypeChange(pointsInSegment[thirdPointIndex], pointsInSegment[0].Type).Submit(changeHandler);
|
||||
}
|
||||
|
||||
changeHandler.SafeSubmit(new ExpectedDistanceChange(hitObject.Path, null));
|
||||
changeHandler.SafeSubmit(new PathControlPointTypeChange(p.ControlPoint, type));
|
||||
new ExpectedDistanceChange(hitObject.Path, null).Submit(changeHandler);
|
||||
new PathControlPointTypeChange(p.ControlPoint, type).Submit(changeHandler);
|
||||
}
|
||||
|
||||
EnsureValidPathTypes();
|
||||
@ -382,7 +382,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
if (hitObject.Path.Distance < originalDistance)
|
||||
hitObject.SnapTo(distanceSnapProvider, changeHandler);
|
||||
else
|
||||
changeHandler.SafeSubmit(new ExpectedDistanceChange(hitObject.Path, originalDistance));
|
||||
new ExpectedDistanceChange(hitObject.Path, originalDistance).Submit(changeHandler);
|
||||
|
||||
changeHandler?.EndChange();
|
||||
}
|
||||
@ -425,8 +425,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
|
||||
Vector2 movementDelta = Parent!.ToLocalSpace(result?.ScreenSpacePosition ?? newHeadPosition) - hitObject.Position;
|
||||
|
||||
changeHandler.SafeSubmit(new PositionChange(hitObject, hitObject.Position + movementDelta));
|
||||
changeHandler.SafeSubmit(new StartTimeChange(hitObject, result?.Time ?? hitObject.StartTime));
|
||||
new PositionChange(hitObject, hitObject.Position + movementDelta).Submit(changeHandler);
|
||||
new StartTimeChange(hitObject, result?.Time ?? hitObject.StartTime).Submit(changeHandler);
|
||||
|
||||
for (int i = 1; i < hitObject.Path.ControlPoints.Count; i++)
|
||||
{
|
||||
@ -436,7 +436,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
// All other selected control points (if any) will move together with the head point
|
||||
// (and so they will not move at all, relative to each other).
|
||||
if (!selectedControlPoints.Contains(controlPoint))
|
||||
changeHandler.SafeSubmit(new PathControlPointPositionChange(controlPoint, controlPoint.Position - movementDelta));
|
||||
new PathControlPointPositionChange(controlPoint, controlPoint.Position - movementDelta).Submit(changeHandler);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -449,7 +449,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
{
|
||||
PathControlPoint controlPoint = controlPoints[i];
|
||||
if (selectedControlPoints.Contains(controlPoint))
|
||||
changeHandler.SafeSubmit(new PathControlPointPositionChange(controlPoint, dragStartPositions[i] + movementDelta));
|
||||
new PathControlPointPositionChange(controlPoint, dragStartPositions[i] + movementDelta).Submit(changeHandler);
|
||||
}
|
||||
}
|
||||
|
||||
@ -459,10 +459,10 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
if (!hitObject.Path.HasValidLength)
|
||||
{
|
||||
for (int i = 0; i < hitObject.Path.ControlPoints.Count; i++)
|
||||
changeHandler.SafeSubmit(new PathControlPointPositionChange(hitObject.Path.ControlPoints[i], oldControlPoints[i]));
|
||||
new PathControlPointPositionChange(hitObject.Path.ControlPoints[i], oldControlPoints[i]).Submit(changeHandler);
|
||||
|
||||
changeHandler.SafeSubmit(new PositionChange(hitObject, oldPosition));
|
||||
changeHandler.SafeSubmit(new StartTimeChange(hitObject, oldStartTime));
|
||||
new PositionChange(hitObject, oldPosition).Submit(changeHandler);
|
||||
new StartTimeChange(hitObject, oldStartTime).Submit(changeHandler);
|
||||
// Snap the path length again to undo the invalid length.
|
||||
hitObject.SnapTo(distanceSnapProvider, changeHandler);
|
||||
return;
|
||||
@ -470,7 +470,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
|
||||
// Maintain the path types in case they got defaulted to bezier at some point during the drag.
|
||||
for (int i = 0; i < hitObject.Path.ControlPoints.Count; i++)
|
||||
changeHandler.SafeSubmit(new PathControlPointTypeChange(hitObject.Path.ControlPoints[i], dragPathTypes[i]));
|
||||
new PathControlPointTypeChange(hitObject.Path.ControlPoints[i], dragPathTypes[i]).Submit(changeHandler);
|
||||
|
||||
EnsureValidPathTypes();
|
||||
}
|
||||
|
@ -280,9 +280,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
||||
if (Precision.AlmostEquals(proposedDistance, HitObject.Path.Distance) && Precision.AlmostEquals(proposedVelocity, HitObject.SliderVelocityMultiplier))
|
||||
return;
|
||||
|
||||
changeHandler.SafeSubmit(new SliderVelocityMultiplierChange(HitObject, proposedVelocity));
|
||||
changeHandler.SafeSubmit(new ExpectedDistanceChange(HitObject.Path, proposedDistance));
|
||||
changeHandler.SafeSubmit(new QueueUpdateHitObject(editorBeatmap, HitObject));
|
||||
new SliderVelocityMultiplierChange(HitObject, proposedVelocity).Submit(changeHandler);
|
||||
new ExpectedDistanceChange(HitObject.Path, proposedDistance).Submit(changeHandler);
|
||||
new QueueUpdateHitObject(editorBeatmap, HitObject).Submit(changeHandler);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -304,7 +304,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
||||
if (Precision.AlmostBigger(segmentEnds[segmentIndex], 1, 1E-3))
|
||||
{
|
||||
sliderPath.ControlPoints.SubmitRemoveRange(i + 1, sliderPath.ControlPoints.Count - i - 1, changeHandler);
|
||||
changeHandler.SafeSubmit(new PathControlPointTypeChange(sliderPath.ControlPoints[^1], null));
|
||||
new PathControlPointTypeChange(sliderPath.ControlPoints[^1], null).Submit(changeHandler);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -439,7 +439,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
||||
var pathControlPoint = new PathControlPoint { Position = position };
|
||||
|
||||
// Move the control points from the insertion index onwards to make room for the insertion
|
||||
changeHandler.SafeSubmit(new InsertPathControlPointChange(HitObject.Path.ControlPoints, insertionIndex, pathControlPoint));
|
||||
new InsertPathControlPointChange(HitObject.Path.ControlPoints, insertionIndex, pathControlPoint).Submit(changeHandler);
|
||||
|
||||
ControlPointVisualiser?.EnsureValidPathTypes();
|
||||
|
||||
@ -459,9 +459,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
||||
// The first control point in the slider must have a type, so take it from the previous "first" one
|
||||
// Todo: Should be handled within SliderPath itself
|
||||
if (c == controlPoints[0] && controlPoints.Count > 1 && controlPoints[1].Type == null)
|
||||
changeHandler.SafeSubmit(new PathControlPointTypeChange(controlPoints[1], controlPoints[0].Type));
|
||||
new PathControlPointTypeChange(controlPoints[1], controlPoints[0].Type).Submit(changeHandler);
|
||||
|
||||
changeHandler.SafeSubmit(new RemovePathControlPointChange(HitObject.Path.ControlPoints, c));
|
||||
new RemovePathControlPointChange(HitObject.Path.ControlPoints, c).Submit(changeHandler);
|
||||
}
|
||||
|
||||
ControlPointVisualiser?.EnsureValidPathTypes();
|
||||
@ -480,9 +480,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
||||
// So the slider needs to be offset by this amount instead, and all control points offset backwards such that the path is re-positioned at (0, 0)
|
||||
Vector2 first = controlPoints[0].Position;
|
||||
foreach (var c in controlPoints)
|
||||
changeHandler.SafeSubmit(new PathControlPointPositionChange(c, c.Position - first));
|
||||
new PathControlPointPositionChange(c, c.Position - first).Submit(changeHandler);
|
||||
|
||||
changeHandler.SafeSubmit(new PositionChange(HitObject, HitObject.Position + first));
|
||||
new PositionChange(HitObject, HitObject.Position + first).Submit(changeHandler);
|
||||
}
|
||||
|
||||
private void splitControlPoints(List<PathControlPoint> controlPointsToSplitAt)
|
||||
@ -526,18 +526,18 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
||||
};
|
||||
|
||||
// Increase the start time of the slider before adding the new slider so the new slider is immediately inserted at the correct index and internal state remains valid.
|
||||
changeHandler.SafeSubmit(new StartTimeChange(HitObject, HitObject.StartTime + split_gap));
|
||||
new StartTimeChange(HitObject, HitObject.StartTime + split_gap).Submit(changeHandler);
|
||||
|
||||
changeHandler.SafeSubmit(new AddHitObjectChange(editorBeatmap, newSlider));
|
||||
new AddHitObjectChange(editorBeatmap, newSlider).Submit(changeHandler);
|
||||
|
||||
changeHandler.SafeSubmit(new NewComboChange(HitObject, false));
|
||||
changeHandler.SafeSubmit(new ExpectedDistanceChange(HitObject.Path, HitObject.Path.ExpectedDistance.Value - newSlider.Path.CalculatedDistance));
|
||||
changeHandler.SafeSubmit(new StartTimeChange(HitObject, HitObject.StartTime + newSlider.SpanDuration));
|
||||
new NewComboChange(HitObject, false).Submit(changeHandler);
|
||||
new ExpectedDistanceChange(HitObject.Path, HitObject.Path.ExpectedDistance.Value - newSlider.Path.CalculatedDistance).Submit(changeHandler);
|
||||
new StartTimeChange(HitObject, HitObject.StartTime + newSlider.SpanDuration).Submit(changeHandler);
|
||||
|
||||
// In case the remainder of the slider has no length left over, give it length anyways so we don't get a 0 length slider.
|
||||
if (HitObject.Path.ExpectedDistance.Value <= Precision.DOUBLE_EPSILON)
|
||||
{
|
||||
changeHandler.SafeSubmit(new ExpectedDistanceChange(HitObject.Path, null));
|
||||
new ExpectedDistanceChange(HitObject.Path, null).Submit(changeHandler);
|
||||
}
|
||||
}
|
||||
|
||||
@ -545,9 +545,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
||||
// As a final step, we must reset its control points to have an origin of (0,0).
|
||||
Vector2 first = controlPoints[0].Position;
|
||||
foreach (var c in controlPoints)
|
||||
changeHandler.SafeSubmit(new PathControlPointPositionChange(c, c.Position - first));
|
||||
new PathControlPointPositionChange(c, c.Position - first).Submit(changeHandler);
|
||||
|
||||
changeHandler.SafeSubmit(new PositionChange(HitObject, HitObject.Position + first));
|
||||
new PositionChange(HitObject, HitObject.Position + first).Submit(changeHandler);
|
||||
}
|
||||
|
||||
private void convertToStream()
|
||||
@ -575,19 +575,19 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
||||
|
||||
Vector2 position = HitObject.Position + HitObject.Path.PositionAt(pathPosition);
|
||||
|
||||
changeHandler.SafeSubmit(new AddHitObjectChange(editorBeatmap, new HitCircle
|
||||
new AddHitObjectChange(editorBeatmap, new HitCircle
|
||||
{
|
||||
StartTime = time,
|
||||
Position = position,
|
||||
NewCombo = i == 0 && HitObject.NewCombo,
|
||||
Samples = HitObject.HeadCircle.Samples.Select(s => s.With()).ToList()
|
||||
}));
|
||||
}).Submit(changeHandler);
|
||||
|
||||
i += 1;
|
||||
time = HitObject.StartTime + i * streamSpacing;
|
||||
}
|
||||
|
||||
changeHandler.SafeSubmit(new RemoveHitObjectChange(editorBeatmap, HitObject));
|
||||
new RemoveHitObjectChange(editorBeatmap, HitObject).Submit(changeHandler);
|
||||
|
||||
changeHandler?.EndChange();
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
|
||||
// this will potentially move the selection out of bounds...
|
||||
foreach (var h in hitObjects)
|
||||
changeHandler.SafeSubmit(new PositionChange(h, h.Position + localDelta));
|
||||
new PositionChange(h, h.Position + localDelta).Submit(changeHandler);
|
||||
|
||||
// but this will be corrected.
|
||||
moveSelectionInBounds();
|
||||
@ -111,12 +111,12 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
foreach (var h in hitObjects)
|
||||
{
|
||||
if (moreThanOneObject)
|
||||
changeHandler.SafeSubmit(new StartTimeChange(h, endTime - (h.GetEndTime() - startTime)));
|
||||
new StartTimeChange(h, endTime - (h.GetEndTime() - startTime)).Submit(changeHandler);
|
||||
|
||||
if (h is Slider slider)
|
||||
{
|
||||
slider.Path.Reverse(out Vector2 offset, changeHandler);
|
||||
changeHandler.SafeSubmit(new PositionChange(slider, slider.Position + offset));
|
||||
new PositionChange(slider, slider.Position + offset).Submit(changeHandler);
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
hitObjects = hitObjects.OrderBy(obj => obj.StartTime).ToList();
|
||||
|
||||
for (int i = 0; i < hitObjects.Count; ++i)
|
||||
changeHandler.SafeSubmit(new NewComboChange(hitObjects[i], newComboOrder[i]));
|
||||
new NewComboChange(hitObjects[i], newComboOrder[i]).Submit(changeHandler);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -173,7 +173,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
|
||||
if (!Precision.AlmostEquals(flippedPosition, h.Position))
|
||||
{
|
||||
changeHandler.SafeSubmit(new PositionChange(h, flippedPosition));
|
||||
new PositionChange(h, flippedPosition).Submit(changeHandler);
|
||||
didFlip = true;
|
||||
}
|
||||
|
||||
@ -182,7 +182,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
didFlip = true;
|
||||
|
||||
foreach (var cp in slider.Path.ControlPoints)
|
||||
changeHandler.SafeSubmit(new PathControlPointPositionChange(cp, GeometryUtils.GetFlippedPosition(flipAxis, controlPointFlipQuad, cp.Position)));
|
||||
new PathControlPointPositionChange(cp, GeometryUtils.GetFlippedPosition(flipAxis, controlPointFlipQuad, cp.Position)).Submit(changeHandler);
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,7 +212,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
delta.Y -= quad.BottomRight.Y - DrawHeight;
|
||||
|
||||
foreach (var h in hitObjects)
|
||||
changeHandler.SafeSubmit(new PositionChange(h, h.Position + delta));
|
||||
new PositionChange(h, h.Position + delta).Submit(changeHandler);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -251,7 +251,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
|
||||
if (mergedHitObject.Path.ControlPoints.Count == 0)
|
||||
{
|
||||
changeHandler.SafeSubmit(new InsertPathControlPointChange(mergedHitObject.Path.ControlPoints, mergedHitObject.Path.ControlPoints.Count, new PathControlPoint(Vector2.Zero, PathType.LINEAR)));
|
||||
new InsertPathControlPointChange(mergedHitObject.Path.ControlPoints, mergedHitObject.Path.ControlPoints.Count, new PathControlPoint(Vector2.Zero, PathType.LINEAR)).Submit(changeHandler);
|
||||
}
|
||||
|
||||
// Merge all the selected hit objects into one slider path.
|
||||
@ -265,12 +265,12 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
float distanceToLastControlPoint = Vector2.Distance(mergedHitObject.Path.ControlPoints[^1].Position, offset);
|
||||
|
||||
// Calculate the distance required to travel to the expected distance of the merging slider.
|
||||
changeHandler.SafeSubmit(new ExpectedDistanceChange(mergedHitObject.Path, mergedHitObject.Path.CalculatedDistance + distanceToLastControlPoint + hasPath.Path.Distance));
|
||||
new ExpectedDistanceChange(mergedHitObject.Path, mergedHitObject.Path.CalculatedDistance + distanceToLastControlPoint + hasPath.Path.Distance).Submit(changeHandler);
|
||||
|
||||
// Remove the last control point if it sits exactly on the start of the next control point.
|
||||
if (Precision.AlmostEquals(distanceToLastControlPoint, 0))
|
||||
{
|
||||
changeHandler.SafeSubmit(new RemovePathControlPointChange(mergedHitObject.Path.ControlPoints, mergedHitObject.Path.ControlPoints.Count - 1));
|
||||
new RemovePathControlPointChange(mergedHitObject.Path.ControlPoints, mergedHitObject.Path.ControlPoints.Count - 1).Submit(changeHandler);
|
||||
}
|
||||
|
||||
mergedHitObject.Path.ControlPoints.SubmitAddRange(hasPath.Path.ControlPoints.Select(o => new PathControlPoint(o.Position + offset, o.Type)), changeHandler);
|
||||
@ -281,11 +281,11 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
// Turn the last control point into a linear type if this is the first merging circle in a sequence, so the subsequent control points can be inherited path type.
|
||||
if (!lastCircle)
|
||||
{
|
||||
changeHandler.SafeSubmit(new PathControlPointTypeChange(mergedHitObject.Path.ControlPoints.Last(), PathType.LINEAR));
|
||||
new PathControlPointTypeChange(mergedHitObject.Path.ControlPoints.Last(), PathType.LINEAR).Submit(changeHandler);
|
||||
}
|
||||
|
||||
changeHandler.SafeSubmit(new InsertPathControlPointChange(mergedHitObject.Path.ControlPoints, mergedHitObject.Path.ControlPoints.Count, new PathControlPoint(selectedMergeableObject.Position - mergedHitObject.Position)));
|
||||
changeHandler.SafeSubmit(new ExpectedDistanceChange(mergedHitObject.Path, null));
|
||||
new InsertPathControlPointChange(mergedHitObject.Path.ControlPoints, mergedHitObject.Path.ControlPoints.Count, new PathControlPoint(selectedMergeableObject.Position - mergedHitObject.Position)).Submit(changeHandler);
|
||||
new ExpectedDistanceChange(mergedHitObject.Path, null).Submit(changeHandler);
|
||||
lastCircle = true;
|
||||
}
|
||||
}
|
||||
@ -295,17 +295,17 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
{
|
||||
foreach (var selectedMergeableObject in mergeableObjects.Skip(1))
|
||||
{
|
||||
changeHandler.SafeSubmit(new RemoveHitObjectChange(EditorBeatmap, selectedMergeableObject));
|
||||
new RemoveHitObjectChange(EditorBeatmap, selectedMergeableObject).Submit(changeHandler);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var selectedMergeableObject in mergeableObjects)
|
||||
{
|
||||
changeHandler.SafeSubmit(new RemoveHitObjectChange(EditorBeatmap, selectedMergeableObject));
|
||||
new RemoveHitObjectChange(EditorBeatmap, selectedMergeableObject).Submit(changeHandler);
|
||||
}
|
||||
|
||||
changeHandler.SafeSubmit(new AddHitObjectChange(EditorBeatmap, mergedHitObject));
|
||||
new AddHitObjectChange(EditorBeatmap, mergedHitObject).Submit(changeHandler);
|
||||
}
|
||||
|
||||
// Make sure the merged hitobject is selected.
|
||||
|
@ -80,7 +80,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
|
||||
foreach (var ho in objectsInRotation)
|
||||
{
|
||||
changeHandler.SafeSubmit(new PositionChange(ho, GeometryUtils.RotatePointAroundOrigin(originalPositions[ho], actualOrigin, rotation)));
|
||||
new PositionChange(ho, GeometryUtils.RotatePointAroundOrigin(originalPositions[ho], actualOrigin, rotation)).Submit(changeHandler);
|
||||
|
||||
if (ho is IHasPath withPath)
|
||||
{
|
||||
@ -88,9 +88,8 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
|
||||
for (int i = 0; i < withPath.Path.ControlPoints.Count; ++i)
|
||||
{
|
||||
changeHandler.SafeSubmit(new PathControlPointPositionChange(withPath.Path.ControlPoints[i],
|
||||
GeometryUtils.RotatePointAroundOrigin(originalPath[i], Vector2.Zero, rotation))
|
||||
);
|
||||
new PathControlPointPositionChange(withPath.Path.ControlPoints[i],
|
||||
GeometryUtils.RotatePointAroundOrigin(originalPath[i], Vector2.Zero, rotation)).Submit(changeHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
|
||||
foreach (var (ho, originalState) in objectsInScale)
|
||||
{
|
||||
changeHandler.SafeSubmit(new PositionChange(ho, GeometryUtils.GetScaledPosition(scale, actualOrigin, originalState.Position, axisRotation)));
|
||||
new PositionChange(ho, GeometryUtils.GetScaledPosition(scale, actualOrigin, originalState.Position, axisRotation)).Submit(changeHandler);
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,17 +168,16 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
// Maintain the path types in case they were defaulted to bezier at some point during scaling
|
||||
for (int i = 0; i < slider.Path.ControlPoints.Count; i++)
|
||||
{
|
||||
changeHandler.SafeSubmit(new PathControlPointPositionChange(slider.Path.ControlPoints[i],
|
||||
GeometryUtils.GetScaledPosition(scale, Vector2.Zero, originalInfo.PathControlPointPositions[i], axisRotation))
|
||||
);
|
||||
changeHandler.SafeSubmit(new PathControlPointTypeChange(slider.Path.ControlPoints[i], originalInfo.PathControlPointTypes[i]));
|
||||
new PathControlPointPositionChange(slider.Path.ControlPoints[i],
|
||||
GeometryUtils.GetScaledPosition(scale, Vector2.Zero, originalInfo.PathControlPointPositions[i], axisRotation)).Submit(changeHandler);
|
||||
new PathControlPointTypeChange(slider.Path.ControlPoints[i], originalInfo.PathControlPointTypes[i]).Submit(changeHandler);
|
||||
}
|
||||
|
||||
// Snap the slider's length to the current beat divisor
|
||||
// to calculate the final resulting duration / bounding box before the final checks.
|
||||
slider.SnapTo(snapProvider, changeHandler);
|
||||
|
||||
changeHandler.SafeSubmit(new PositionChange(slider, GeometryUtils.GetScaledPosition(scale, origin, originalInfo.Position, axisRotation)));
|
||||
new PositionChange(slider, GeometryUtils.GetScaledPosition(scale, origin, originalInfo.Position, axisRotation)).Submit(changeHandler);
|
||||
|
||||
//if sliderhead or sliderend end up outside playfield, revert scaling.
|
||||
Quad scaledQuad = GeometryUtils.GetSurroundingQuad(new OsuHitObject[] { slider });
|
||||
@ -189,10 +188,10 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
|
||||
for (int i = 0; i < slider.Path.ControlPoints.Count; i++)
|
||||
{
|
||||
changeHandler.SafeSubmit(new PathControlPointPositionChange(slider.Path.ControlPoints[i], originalInfo.PathControlPointPositions[i]));
|
||||
new PathControlPointPositionChange(slider.Path.ControlPoints[i], originalInfo.PathControlPointPositions[i]).Submit(changeHandler);
|
||||
}
|
||||
|
||||
changeHandler.SafeSubmit(new PositionChange(slider, originalInfo.Position));
|
||||
new PositionChange(slider, originalInfo.Position).Submit(changeHandler);
|
||||
|
||||
// Snap the slider's length again to undo the potentially-invalid length applied by the previous snap.
|
||||
slider.SnapTo(snapProvider, changeHandler);
|
||||
@ -298,7 +297,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
delta.Y -= quad.BottomRight.Y - OsuPlayfield.BASE_SIZE.Y;
|
||||
|
||||
foreach (var (h, _) in objectsInScale!)
|
||||
changeHandler.SafeSubmit(new PositionChange(h, h.Position + delta));
|
||||
new PositionChange(h, h.Position + delta).Submit(changeHandler);
|
||||
}
|
||||
|
||||
private struct OriginalHitObjectState
|
||||
|
@ -499,14 +499,14 @@ namespace osu.Game.Rulesets.Edit
|
||||
|
||||
if (commit)
|
||||
{
|
||||
changeHandler.SafeSubmit(new AddHitObjectChange(EditorBeatmap, hitObject));
|
||||
new AddHitObjectChange(EditorBeatmap, hitObject).Submit(changeHandler);
|
||||
|
||||
if (autoSeekOnPlacement.Value && EditorClock.CurrentTime < hitObject.StartTime)
|
||||
EditorClock.SeekSmoothlyTo(hitObject.StartTime);
|
||||
}
|
||||
}
|
||||
|
||||
public void Delete(HitObject hitObject) => changeHandler.SafeSubmit(new RemoveHitObjectChange(EditorBeatmap, hitObject));
|
||||
public void Delete(HitObject hitObject) => new RemoveHitObjectChange(EditorBeatmap, hitObject).Submit(changeHandler);
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Objects
|
||||
where THitObject : HitObject, IHasPath
|
||||
{
|
||||
double newDistance = snapProvider?.FindSnappedDistance(hitObject, (float)hitObject.Path.CalculatedDistance, DistanceSnapTarget.Start) ?? hitObject.Path.CalculatedDistance;
|
||||
changeHandler.SafeSubmit(new ExpectedDistanceChange(hitObject.Path, newDistance));
|
||||
new ExpectedDistanceChange(hitObject.Path, newDistance).Submit(changeHandler);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -38,7 +38,7 @@ namespace osu.Game.Rulesets.Objects
|
||||
|
||||
// Inherited points after a linear point, as well as the first control point if it inherited,
|
||||
// should be treated as linear points, so their types are temporarily changed to linear.
|
||||
inheritedLinearPoints.ForEach(p => changeHandler.SafeSubmit(new PathControlPointTypeChange(p, PathType.LINEAR)));
|
||||
inheritedLinearPoints.ForEach(p => new PathControlPointTypeChange(p, PathType.LINEAR).Submit(changeHandler));
|
||||
|
||||
double[] segmentEnds = sliderPath.GetSegmentEnds().ToArray();
|
||||
|
||||
@ -51,11 +51,11 @@ namespace osu.Game.Rulesets.Objects
|
||||
segmentEnds = segmentEnds[..^1];
|
||||
}
|
||||
|
||||
changeHandler.SafeSubmit(new RemovePathControlPointChange(controlPoints, controlPoints.Count - 1));
|
||||
new RemovePathControlPointChange(controlPoints, controlPoints.Count - 1).Submit(changeHandler);
|
||||
}
|
||||
|
||||
// Restore original control point types.
|
||||
inheritedLinearPoints.ForEach(p => changeHandler.SafeSubmit(new PathControlPointTypeChange(p, null)));
|
||||
inheritedLinearPoints.ForEach(p => new PathControlPointTypeChange(p, null).Submit(changeHandler));
|
||||
|
||||
// Recalculate middle perfect curve control points at the end of the slider path.
|
||||
if (controlPoints.Count >= 3 && controlPoints[^3].Type == PathType.PERFECT_CURVE && controlPoints[^2].Type == null && segmentEnds.Any())
|
||||
@ -66,7 +66,7 @@ namespace osu.Game.Rulesets.Objects
|
||||
var circleArcPath = new List<Vector2>();
|
||||
sliderPath.GetPathToProgress(circleArcPath, lastSegmentStart / lastSegmentEnd, 1);
|
||||
|
||||
changeHandler.SafeSubmit(new PathControlPointPositionChange(controlPoints[^2], circleArcPath[circleArcPath.Count / 2]));
|
||||
new PathControlPointPositionChange(controlPoints[^2], circleArcPath[circleArcPath.Count / 2]).Submit(changeHandler);
|
||||
}
|
||||
|
||||
sliderPath.reverseControlPoints(out positionalOffset, changeHandler);
|
||||
@ -101,7 +101,7 @@ namespace osu.Game.Rulesets.Objects
|
||||
else if (p.Type != null)
|
||||
(p.Type, lastType) = (lastType, p.Type);
|
||||
|
||||
changeHandler.SafeSubmit(new InsertPathControlPointChange(sliderPath.ControlPoints, 0, p));
|
||||
new InsertPathControlPointChange(sliderPath.ControlPoints, 0, p).Submit(changeHandler);
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ namespace osu.Game.Rulesets.Objects
|
||||
public static void SubmitRemoveRange(this BindableList<PathControlPoint> controlPoints, int startIndex, int count, NewBeatmapEditorChangeHandler? changeHandler)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
changeHandler.SafeSubmit(new RemovePathControlPointChange(controlPoints, startIndex));
|
||||
new RemovePathControlPointChange(controlPoints, startIndex).Submit(changeHandler);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -120,7 +120,7 @@ namespace osu.Game.Rulesets.Objects
|
||||
public static void SubmitAddRange(this BindableList<PathControlPoint> controlPoints, IEnumerable<PathControlPoint> points, NewBeatmapEditorChangeHandler? changeHandler)
|
||||
{
|
||||
foreach (var point in points)
|
||||
changeHandler.SafeSubmit(new InsertPathControlPointChange(controlPoints, controlPoints.Count, point));
|
||||
new InsertPathControlPointChange(controlPoints, controlPoints.Count, point).Submit(changeHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -92,8 +92,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
Beatmap.PerformOnSelection(obj =>
|
||||
{
|
||||
changeHandler.SafeSubmit(new StartTimeChange(obj, obj.StartTime + offset));
|
||||
changeHandler.SafeSubmit(new QueueUpdateHitObject(Beatmap, obj));
|
||||
new StartTimeChange(obj, obj.StartTime + offset).Submit(changeHandler);
|
||||
new QueueUpdateHitObject(Beatmap, obj).Submit(changeHandler);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -124,7 +124,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
|
||||
// handle positional change etc.
|
||||
foreach (var blueprint in SelectionBlueprints)
|
||||
changeHandler.SafeSubmit(new QueueUpdateHitObject(Beatmap, blueprint.Item));
|
||||
new QueueUpdateHitObject(Beatmap, blueprint.Item).Submit(changeHandler);
|
||||
}
|
||||
|
||||
protected override bool OnDoubleClick(DoubleClickEvent e)
|
||||
|
@ -1,18 +0,0 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Game.Screens.Edit.Changes;
|
||||
|
||||
namespace osu.Game.Screens.Edit
|
||||
{
|
||||
public static class NewBeatmapEditorChangeHandlerExtension
|
||||
{
|
||||
public static void SafeSubmit(this NewBeatmapEditorChangeHandler? manager, IRevertibleChange command, bool commitImmediately = false)
|
||||
{
|
||||
if (manager != null)
|
||||
manager.Submit(command, commitImmediately);
|
||||
else
|
||||
command.Apply();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user