예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        /// <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));
        }