public override bool HandleFlip(Direction direction, bool flipOverOrigin) { if (SelectedItems.Count == 0) { return(false); } // This could be implemented in the future if there's a requirement for it. if (direction == Direction.Vertical) { return(false); } var selectionRange = CatchHitObjectUtils.GetPositionRange(SelectedItems); bool changed = false; EditorBeatmap.PerformOnSelection(h => { if (h is CatchHitObject catchObject) { changed |= handleFlip(selectionRange, catchObject, flipOverOrigin); } }); return(changed); }
protected override void OnSelectionChanged() { base.OnSelectionChanged(); var selectionRange = CatchHitObjectUtils.GetPositionRange(SelectedItems); SelectionBox.CanFlipX = selectionRange.Length > 0 && SelectedItems.Any(h => h is CatchHitObject && !(h is BananaShower)); SelectionBox.CanReverse = SelectedItems.Count > 1 || SelectedItems.Any(h => h is JuiceStream); }
public override bool HandleFlip(Direction direction) { var selectionRange = CatchHitObjectUtils.GetPositionRange(SelectedItems); bool changed = false; EditorBeatmap.PerformOnSelection(h => { if (h is CatchHitObject catchObject) { changed |= handleFlip(selectionRange, catchObject); } }); return(changed); }
/// <summary> /// Limit positional movement of the objects by the constraint that moved objects should stay in bounds. /// </summary> /// <param name="deltaX">The positional movement.</param> /// <param name="movingObjects">The objects to be moved.</param> /// <returns>The positional movement with the restriction applied.</returns> private float limitMovement(float deltaX, IEnumerable <HitObject> movingObjects) { var range = CatchHitObjectUtils.GetPositionRange(movingObjects); // To make an object with position `x` stay in bounds after `deltaX` movement, `0 <= x + deltaX <= WIDTH` should be satisfied. // Subtracting `x`, we get `-x <= deltaX <= WIDTH - x`. // We only need to apply the inequality to extreme values of `x`. float lowerBound = -range.Min; float upperBound = CatchPlayfield.WIDTH - range.Max; // The inequality may be unsatisfiable if the objects were already out of bounds. // In that case, don't move objects at all. if (lowerBound > upperBound) { return(0); } return(Math.Clamp(deltaX, lowerBound, upperBound)); }