示例#1
0
        private bool handleFlip(PositionRange selectionRange, CatchHitObject hitObject, bool flipOverOrigin)
        {
            switch (hitObject)
            {
            case BananaShower _:
                return(false);

            case JuiceStream juiceStream:
                juiceStream.OriginalX = getFlippedPosition(juiceStream.OriginalX);

                foreach (var point in juiceStream.Path.ControlPoints)
                {
                    point.Position *= new Vector2(-1, 1);
                }

                EditorBeatmap.Update(juiceStream);
                return(true);

            default:
                hitObject.OriginalX = getFlippedPosition(hitObject.OriginalX);
                return(true);
            }

            float getFlippedPosition(float original) => flipOverOrigin ? CatchPlayfield.WIDTH - original : selectionRange.GetFlippedPosition(original);
        }
示例#2
0
 public void SetRimState(bool state)
 {
     EditorBeatmap.PerformOnSelection(h =>
     {
         if (h is Hit taikoHit)
         {
             taikoHit.Type = state ? HitType.Rim : HitType.Centre;
             EditorBeatmap.Update(h);
         }
     });
 }
 private void addBlueprintStep(double time, float x, SliderPath sliderPath, double velocity) => AddStep("add selection blueprint", () =>
 {
     hitObject = new JuiceStream
     {
         StartTime = time,
         X         = x,
         Path      = sliderPath,
     };
     EditorBeatmap.Difficulty.SliderMultiplier = velocity;
     EditorBeatmap.Add(hitObject);
     EditorBeatmap.Update(hitObject);
     Assert.That(hitObject.Velocity, Is.EqualTo(velocity));
     AddBlueprint(new JuiceStreamSelectionBlueprint(hitObject));
 });
        /// <summary>
        /// Set the new combo state of all selected <see cref="HitObject"/>s.
        /// </summary>
        /// <param name="state">Whether to set or unset.</param>
        /// <exception cref="InvalidOperationException">Throws if any selected object doesn't implement <see cref="IHasComboInformation"/></exception>
        public void SetNewCombo(bool state)
        {
            EditorBeatmap.PerformOnSelection(h =>
            {
                var comboInfo = h as IHasComboInformation;

                if (comboInfo == null || comboInfo.NewCombo == state)
                {
                    return;
                }

                comboInfo.NewCombo = state;
                EditorBeatmap.Update(h);
            });
        }
示例#5
0
        public void SetStrongState(bool state)
        {
            EditorBeatmap.PerformOnSelection(h =>
            {
                if (!(h is Hit taikoHit))
                {
                    return;
                }

                if (taikoHit.IsStrong != state)
                {
                    taikoHit.IsStrong = state;
                    EditorBeatmap.Update(taikoHit);
                }
            });
        }
示例#6
0
        public override bool HandleMovement(MoveSelectionEvent moveEvent)
        {
            foreach (var h in EditorBeatmap.SelectedHitObjects.OfType <TauHitObject>())
            {
                if (h is HardBeat)
                {
                    continue;
                }

                h.Angle = ScreenSpaceDrawQuad.Centre.GetDegreesFromPosition(moveEvent.ScreenSpacePosition);

                EditorBeatmap?.Update(h);
            }

            return(true);
        }
示例#7
0
        public void SetStrongState(bool state)
        {
            var hits = EditorBeatmap.SelectedHitObjects.OfType <Hit>();

            EditorBeatmap.BeginChange();

            foreach (var h in hits)
            {
                if (h.IsStrong != state)
                {
                    h.IsStrong = state;
                    EditorBeatmap.Update(h);
                }
            }

            EditorBeatmap.EndChange();
        }
示例#8
0
        /// <summary>
        /// Set the new combo state of all selected <see cref="HitObject"/>s.
        /// </summary>
        /// <param name="state">Whether to set or unset.</param>
        /// <exception cref="InvalidOperationException">Throws if any selected object doesn't implement <see cref="IHasComboInformation"/></exception>
        public void SetNewCombo(bool state)
        {
            EditorBeatmap.BeginChange();

            foreach (var h in EditorBeatmap.SelectedHitObjects)
            {
                if (!(h is IHasComboInformation comboInfo) || comboInfo.NewCombo == state)
                {
                    continue;
                }

                comboInfo.NewCombo = state;
                EditorBeatmap.Update(h);
            }

            EditorBeatmap.EndChange();
        }
        public void TestUpdateFromHitObject()
        {
            double[] times     = { 100, 300 };
            float[]  positions = { 200, 200 };
            addBlueprintStep(times, positions);

            AddStep("update hit object path", () =>
            {
                hitObject.Path = new SliderPath(PathType.PerfectCurve, new[]
                {
                    Vector2.Zero,
                    new Vector2(100, 100),
                    new Vector2(0, 200),
                });
                EditorBeatmap.Update(hitObject);
            });
            AddAssert("path is updated", () => getVertices().Count > 2);
        }
示例#10
0
            /// <summary>
            /// Nudge the current selection by the specified multiple of beat divisor lengths,
            /// based on the timing at the first object in the selection.
            /// </summary>
            /// <param name="amount">The direction and count of beat divisor lengths to adjust.</param>
            private void nudgeSelection(int amount)
            {
                var selected = EditorBeatmap.SelectedHitObjects;

                if (selected.Count == 0)
                {
                    return;
                }

                var    timingPoint = EditorBeatmap.ControlPointInfo.TimingPointAt(selected.First().StartTime);
                double adjustment  = timingPoint.BeatLength / EditorBeatmap.BeatDivisor * amount;

                EditorBeatmap.PerformOnSelection(h =>
                {
                    h.StartTime += adjustment;
                    EditorBeatmap.Update(h);
                });
            }
示例#11
0
        public override bool HandleMovement(MoveSelectionEvent <HitObject> moveEvent)
        {
            foreach (var h in EditorBeatmap.SelectedHitObjects.OfType <TauHitObject>())
            {
                if (h is HardBeat)
                {
                    continue;
                }

                var currentMousePos = moveEvent.Blueprint.ScreenSpaceSelectionPoint + moveEvent.ScreenSpaceDelta;

                h.Angle = ScreenSpaceDrawQuad.Centre.GetDegreesFromPosition(currentMousePos);

                EditorBeatmap?.Update(h);
            }

            return(true);
        }
示例#12
0
        public override bool HandleReverse()
        {
            double selectionStartTime = SelectedItems.Min(h => h.StartTime);
            double selectionEndTime   = SelectedItems.Max(h => h.GetEndTime());

            EditorBeatmap.PerformOnSelection(hitObject =>
            {
                hitObject.StartTime = selectionEndTime - (hitObject.GetEndTime() - selectionStartTime);

                if (hitObject is JuiceStream juiceStream)
                {
                    juiceStream.Path.Reverse(out Vector2 positionalOffset);
                    juiceStream.OriginalX        += positionalOffset.X;
                    juiceStream.LegacyConvertedY += positionalOffset.Y;
                    EditorBeatmap.Update(juiceStream);
                }
            });
            return(true);
        }
示例#13
0
        private bool handleFlip(PositionRange selectionRange, CatchHitObject hitObject)
        {
            switch (hitObject)
            {
            case BananaShower _:
                return(false);

            case JuiceStream juiceStream:
                juiceStream.OriginalX = selectionRange.GetFlippedPosition(juiceStream.OriginalX);

                foreach (var point in juiceStream.Path.ControlPoints)
                {
                    point.Position.Value *= new Vector2(-1, 1);
                }

                EditorBeatmap.Update(juiceStream);
                return(true);

            default:
                hitObject.OriginalX = selectionRange.GetFlippedPosition(hitObject.OriginalX);
                return(true);
            }
        }