Esempio n. 1
0
        public void IgnoresOff()
        {
            var colorPicker = Object.FindObjectOfType <ColorPicker>();
            var painter     = Object.FindObjectOfType <PaintSelectedObjects>();

            var eventsContainer = BeatmapObjectContainerCollection.GetCollectionForType(BeatmapObject.Type.EVENT);
            var root            = eventsContainer.transform.root;
            var eventPlacement  = root.GetComponentInChildren <EventPlacement>();

            var noteA = new MapEvent(2, 1, 0);

            eventPlacement.queuedData  = noteA;
            eventPlacement.queuedValue = eventPlacement.queuedData._value;
            eventPlacement.RoundedTime = eventPlacement.queuedData._time;
            eventPlacement.ApplyToMap();

            SelectionController.Select(noteA);

            colorPicker.CurrentColor = Color.red;
            painter.Paint();

            Assert.AreEqual(1, eventsContainer.LoadedObjects.Count);
            Assert.AreEqual(2, eventsContainer.UnsortedObjects[0]._time);
            Assert.AreEqual(1, ((MapEvent)eventsContainer.UnsortedObjects[0])._type);
            Assert.AreEqual(true, eventsContainer.UnsortedObjects[0]._customData == null || !eventsContainer.UnsortedObjects[0]._customData.HasKey("_color"));
        }
Esempio n. 2
0
        public void TweakValue()
        {
            var actionContainer     = Object.FindObjectOfType <BeatmapActionContainer>();
            var containerCollection = BeatmapObjectContainerCollection.GetCollectionForType(BeatmapObject.Type.EVENT);

            if (containerCollection is EventsContainer eventsContainer)
            {
                var root            = eventsContainer.transform.root;
                var eventPlacement  = root.GetComponentInChildren <EventPlacement>();
                var inputController = root.GetComponentInChildren <BeatmapEventInputController>();

                var eventA = new MapEvent(2, MapEvent.EVENT_TYPE_LEFT_LASERS_SPEED, 2);

                eventPlacement.queuedData             = eventA;
                eventPlacement.queuedValue            = eventPlacement.queuedData._value;
                eventPlacement.RoundedTime            = eventPlacement.queuedData._time;
                eventPlacement.PlacePrecisionRotation = true;
                eventPlacement.ApplyToMap();
                eventPlacement.PlacePrecisionRotation = false;

                if (eventsContainer.LoadedContainers[eventA] is BeatmapEventContainer containerA)
                {
                    inputController.TweakValue(containerA, 1);
                }

                CheckEvent(eventsContainer, 0, 2, MapEvent.EVENT_TYPE_LEFT_LASERS_SPEED, 3);

                // Undo invert
                actionContainer.Undo();

                CheckEvent(eventsContainer, 0, 2, MapEvent.EVENT_TYPE_LEFT_LASERS_SPEED, 2);
            }
        }
    public IEnumerator CompleteDelete(T obj)
    {
        yield return(null);

        BeatmapObjectContainerCollection.GetCollectionForType(obj.objectData.beatmapType)
        .DeleteObject(obj.objectData, true, true, "Deleted by the user.");
    }
    public void Paint()
    {
        List <BeatmapAction> allActions = new List <BeatmapAction>();

        foreach (var obj in SelectionController.SelectedObjects)
        {
            if (obj is BeatmapBPMChange || obj is BeatmapCustomEvent)
            {
                continue;                                                       //These should probably not be colored.
            }
            var beforePaint = BeatmapObject.GenerateCopy(obj);
            if (DoPaint(obj))
            {
                allActions.Add(new BeatmapObjectModifiedAction(obj, obj, beforePaint, "a", true));
            }
        }

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

        foreach (var unique in SelectionController.SelectedObjects.DistinctBy(x => x.beatmapType))
        {
            BeatmapObjectContainerCollection.GetCollectionForType(unique.beatmapType).RefreshPool(true);
        }

        BeatmapActionContainer.AddAction(new ActionCollectionAction(allActions, true, true, "Painted a selection of objects."));
    }
Esempio n. 5
0
        public void MirrorWallNE()
        {
            var container = BeatmapObjectContainerCollection.GetCollectionForType(BeatmapObject.Type.OBSTACLE);

            if (container is ObstaclesContainer wallsContainer)
            {
                var root          = wallsContainer.transform.root;
                var wallPlacement = root.GetComponentInChildren <ObstaclePlacement>();
                wallPlacement.RefreshVisuals();

                var wallA = new BeatmapObstacle(2, BeatmapNote.LINE_INDEX_FAR_LEFT, BeatmapObstacle.VALUE_FULL_BARRIER, 1, 2, JSON.Parse("{\"_position\": [-1.5, 0]}"));

                wallPlacement.queuedData  = wallA;
                wallPlacement.RoundedTime = wallPlacement.queuedData._time;
                wallPlacement.instantiatedContainer.transform.localScale = new Vector3(0, 0, wallPlacement.queuedData._duration * EditorScaleController.EditorScale);
                wallPlacement.ApplyToMap(); // Starts placement
                wallPlacement.ApplyToMap(); // Completes placement

                SelectionController.Select(wallA);

                _mirror.Mirror();
                WallTest.CheckWall(wallsContainer, 0, 2, BeatmapNote.LINE_INDEX_MID_RIGHT, BeatmapObstacle.VALUE_FULL_BARRIER, 1, 2, JSON.Parse("{\"_position\": [-0.5, 0]}"));

                // Undo mirror
                _actionContainer.Undo();
                WallTest.CheckWall(wallsContainer, 0, 2, BeatmapNote.LINE_INDEX_FAR_LEFT, BeatmapObstacle.VALUE_FULL_BARRIER, 1, 2, JSON.Parse("{\"_position\": [-1.5, 0]}"));
            }
        }
Esempio n. 6
0
        public void MirrorProp()
        {
            var container = BeatmapObjectContainerCollection.GetCollectionForType(BeatmapObject.Type.EVENT);

            if (container is EventsContainer eventsContainer)
            {
                var root           = eventsContainer.transform.root;
                var eventPlacement = root.GetComponentInChildren <EventPlacement>();

                var eventA = new MapEvent(2, MapEvent.EVENT_TYPE_BACK_LASERS, MapEvent.LIGHT_VALUE_RED_FADE, JSON.Parse("{\"_lightID\": 2}"));

                eventPlacement.queuedData  = eventA;
                eventPlacement.queuedValue = eventPlacement.queuedData._value;
                eventPlacement.RoundedTime = eventPlacement.queuedData._time;
                eventPlacement.ApplyToMap();

                SelectionController.Select(eventA);

                eventsContainer.EventTypeToPropagate = eventA._type;
                eventsContainer.PropagationEditing   = EventsContainer.PropMode.Light;

                _mirror.Mirror();
                // I'm sorry if you're here after changing the prop mapping for default env
                EventTest.CheckEvent(eventsContainer, 0, 2, MapEvent.EVENT_TYPE_BACK_LASERS, MapEvent.LIGHT_VALUE_BLUE_FADE, JSON.Parse("{\"_lightID\": 9}"));

                // Undo mirror
                _actionContainer.Undo();
                EventTest.CheckEvent(eventsContainer, 0, 2, MapEvent.EVENT_TYPE_BACK_LASERS, MapEvent.LIGHT_VALUE_RED_FADE, JSON.Parse("{\"_lightID\": 2}"));

                eventsContainer.PropagationEditing = EventsContainer.PropMode.Off;
            }
        }
Esempio n. 7
0
        public void ModifyEvent()
        {
            var actionContainer = Object.FindObjectOfType <BeatmapActionContainer>();
            var collection      = BeatmapObjectContainerCollection.GetCollectionForType(BeatmapObject.Type.BPM_CHANGE);

            if (collection is BPMChangesContainer bpmCollection)
            {
                var bpmChange = new BeatmapBPMChange(50, 10);
                bpmCollection.SpawnObject(bpmChange);

                if (bpmCollection.LoadedContainers[bpmChange] is BeatmapBPMChangeContainer container)
                {
                    BeatmapBPMChangeInputController.ChangeBPM(container, "60");
                }

                Assert.AreEqual(1, bpmCollection.LoadedObjects.Count);
                CheckBPM(bpmCollection, 0, 10, 60);

                actionContainer.Undo();

                Assert.AreEqual(1, bpmCollection.LoadedObjects.Count);
                CheckBPM(bpmCollection, 0, 10, 50);

                actionContainer.Redo();

                Assert.AreEqual(1, bpmCollection.LoadedObjects.Count);
                CheckBPM(bpmCollection, 0, 10, 60);
            }
        }
 private void LevelLoaded()
 {
     noteAppearance.UpdateColor(redNote.color, blueNote.color);
     foreach (BeatmapObjectContainer con in BeatmapObjectContainerCollection.GetCollectionForType(BeatmapObject.Type.NOTE).LoadedContainers)
     {
         BeatmapNote note = (con.objectData as BeatmapNote);
         if (note._type != BeatmapNote.NOTE_TYPE_BOMB)
         {
             Color color = note._type == BeatmapNote.NOTE_TYPE_A ? redNote.color : blueNote.color;
             if (note._customData?.HasKey("_color") ?? false)
             {
                 color = note._customData["_color"];
             }
             (con as BeatmapNoteContainer).SetColor(color);
         }
     }
     foreach (BeatmapObjectContainer con in events.LoadedContainers)
     {
         eventAppearance.SetEventAppearance(con as BeatmapEventContainer, true, platform);
     }
     foreach (BeatmapObjectContainer con in obstacles.LoadedContainers)
     {
         obstacleAppearance.SetObstacleAppearance(con as BeatmapObstacleContainer, platform);
     }
 }
Esempio n. 9
0
        public void UpdateNoteDirection()
        {
            var actionContainer     = Object.FindObjectOfType <BeatmapActionContainer>();
            var containerCollection = BeatmapObjectContainerCollection.GetCollectionForType(BeatmapObject.Type.NOTE);

            if (containerCollection is NotesContainer notesContainer)
            {
                var root            = notesContainer.transform.root;
                var notePlacement   = root.GetComponentInChildren <NotePlacement>();
                var inputController = root.GetComponentInChildren <BeatmapNoteInputController>();

                var noteA = new BeatmapNote(2, BeatmapNote.NOTE_TYPE_A, BeatmapNote.LINE_INDEX_FAR_LEFT, BeatmapNote.LINE_LAYER_BOTTOM, BeatmapNote.NOTE_CUT_DIRECTION_LEFT);

                notePlacement.queuedData  = noteA;
                notePlacement.RoundedTime = notePlacement.queuedData._time;
                notePlacement.ApplyToMap();

                if (notesContainer.LoadedContainers[noteA] is BeatmapNoteContainer containerA)
                {
                    inputController.UpdateNoteDirection(containerA, true);
                }

                CheckNote(notesContainer, 0, 2, BeatmapNote.NOTE_TYPE_A, BeatmapNote.LINE_INDEX_FAR_LEFT, BeatmapNote.LINE_LAYER_BOTTOM, BeatmapNote.NOTE_CUT_DIRECTION_UP_LEFT);

                // Undo direction
                actionContainer.Undo();

                CheckNote(notesContainer, 0, 2, BeatmapNote.NOTE_TYPE_A, BeatmapNote.LINE_INDEX_FAR_LEFT, BeatmapNote.LINE_LAYER_BOTTOM, BeatmapNote.NOTE_CUT_DIRECTION_LEFT);
            }
        }
Esempio n. 10
0
    /// <summary>
    /// Pastes any copied objects into the map, selecting them immediately.
    /// </summary>
    public void Paste(bool triggersAction = true)
    {
        DeselectAll();
        HashSet <BeatmapObjectContainer> pasted = new HashSet <BeatmapObjectContainer>();

        foreach (BeatmapObject data in CopiedObjects)
        {
            if (data == null)
            {
                continue;
            }
            float         newTime = data._time + atsc.CurrentBeat;
            BeatmapObject newData = BeatmapObject.GenerateCopy(data);
            newData._time = newTime;
            BeatmapObjectContainer pastedContainer = BeatmapObjectContainerCollection.GetCollectionForType(newData.beatmapType).SpawnObject(newData, out _);
            pastedContainer.UpdateGridPosition();
            Select(pastedContainer, true, false, false);
            pasted.Add(pastedContainer);
        }
        if (triggersAction)
        {
            BeatmapActionContainer.AddAction(new SelectionPastedAction(pasted, CopiedObjects, atsc.CurrentBeat));
        }
        SelectionPastedEvent?.Invoke(pasted);
        RefreshSelectionMaterial(false);
        RefreshMap();
        tracksManager.RefreshTracks();

        if (eventPlacement.objectContainerCollection.PropagationEditing)
        {
            eventPlacement.objectContainerCollection.PropagationEditing = eventPlacement.objectContainerCollection.PropagationEditing;
        }
        Debug.Log("Pasted!");
    }
Esempio n. 11
0
        public void ShiftInTime()
        {
            var notesContainer = BeatmapObjectContainerCollection.GetCollectionForType(BeatmapObject.Type.NOTE);
            var root           = notesContainer.transform.root;

            var noteA = new BeatmapNote
            {
                _time = 2,
                _type = BeatmapNote.NOTE_TYPE_A
            };

            notesContainer.SpawnObject(noteA);

            var noteB = new BeatmapNote
            {
                _time = 3,
                _type = BeatmapNote.NOTE_TYPE_A
            };

            notesContainer.SpawnObject(noteB);

            SelectionController.Select(noteB, false, false, false);

            var selectionController = root.GetComponentInChildren <SelectionController>();

            selectionController.MoveSelection(-2);

            notesContainer.DeleteObject(noteB);

            Assert.AreEqual(1, notesContainer.LoadedContainers.Count);
            Assert.AreEqual(1, notesContainer.LoadedObjects.Count);
        }
Esempio n. 12
0
        public void MirrorRotation()
        {
            var rotationCb = Object.FindObjectOfType <RotationCallbackController>();

            rotationCb.Start();

            var container = BeatmapObjectContainerCollection.GetCollectionForType(BeatmapObject.Type.EVENT);

            if (container is EventsContainer eventsContainer)
            {
                var root           = eventsContainer.transform.root;
                var eventPlacement = root.GetComponentInChildren <EventPlacement>();

                var eventA = new MapEvent(2, MapEvent.EVENT_TYPE_LATE_ROTATION, MapEvent.LIGHT_VALUE_TO_ROTATION_DEGREES.ToList().IndexOf(45), JSON.Parse("{\"_rotation\": 33}"));

                eventPlacement.queuedData  = eventA;
                eventPlacement.queuedValue = eventPlacement.queuedData._value;
                eventPlacement.RoundedTime = eventPlacement.queuedData._time;
                eventPlacement.ApplyToMap();

                SelectionController.Select(eventA);

                _mirror.Mirror();
                EventTest.CheckEvent(eventsContainer, 0, 2, MapEvent.EVENT_TYPE_LATE_ROTATION, MapEvent.LIGHT_VALUE_TO_ROTATION_DEGREES.ToList().IndexOf(-45), JSON.Parse("{\"_rotation\": -33}"));

                // Undo mirror
                _actionContainer.Undo();
                EventTest.CheckEvent(eventsContainer, 0, 2, MapEvent.EVENT_TYPE_LATE_ROTATION, MapEvent.LIGHT_VALUE_TO_ROTATION_DEGREES.ToList().IndexOf(45), JSON.Parse("{\"_rotation\": 33}"));
            }
        }
Esempio n. 13
0
        public void MirrorWallME()
        {
            var container = BeatmapObjectContainerCollection.GetCollectionForType(BeatmapObject.Type.OBSTACLE);

            if (container is ObstaclesContainer wallsContainer)
            {
                var root          = wallsContainer.transform.root;
                var wallPlacement = root.GetComponentInChildren <ObstaclePlacement>();
                wallPlacement.RefreshVisuals();

                // What the actual f**k - example from mirroring in MMA2
                //{"_time":1.5,"_lineIndex":1446,"_type":595141,"_duration":0.051851850003004074,"_width":2596}
                //{"_time":1.5,"_lineIndex":2958,"_type":595141,"_duration":0.051851850003004074,"_width":2596}
                var wallA = new BeatmapObstacle(2, 1446, 595141, 1, 2596);

                wallPlacement.queuedData  = wallA;
                wallPlacement.RoundedTime = wallPlacement.queuedData._time;
                wallPlacement.instantiatedContainer.transform.localScale = new Vector3(0, 0, wallPlacement.queuedData._duration * EditorScaleController.EditorScale);
                wallPlacement.ApplyToMap(); // Starts placement
                wallPlacement.ApplyToMap(); // Completes placement

                SelectionController.Select(wallA);

                _mirror.Mirror();
                WallTest.CheckWall(wallsContainer, 0, 2, 2958, 595141, 1, 2596);

                // Undo mirror
                _actionContainer.Undo();
                WallTest.CheckWall(wallsContainer, 0, 2, 1446, 595141, 1, 2596);
            }
        }
Esempio n. 14
0
    /// <summary>
    /// Copies the current selection for later Pasting.
    /// </summary>
    /// <param name="cut">Whether or not to delete the original selection after copying them.</param>
    public void Copy(bool cut = false)
    {
        if (!HasSelectedObjects())
        {
            return;
        }
        CopiedObjects.Clear();
        float firstTime = SelectedObjects.OrderBy(x => x._time).First()._time;

        foreach (BeatmapObject data in SelectedObjects)
        {
            BeatmapObjectContainerCollection collection = BeatmapObjectContainerCollection.GetCollectionForType(data.beatmapType);
            if (collection.LoadedContainers.TryGetValue(data, out BeatmapObjectContainer con))
            {
                con.SetOutlineColor(instance.copiedColor);
            }
            BeatmapObject copy = BeatmapObject.GenerateCopy(data);
            copy._time -= firstTime;
            CopiedObjects.Add(copy);
        }
        if (cut)
        {
            Delete();
        }
        var bpmChanges = BeatmapObjectContainerCollection.GetCollectionForType <BPMChangesContainer>(BeatmapObject.Type.BPM_CHANGE);
        BeatmapBPMChange lastBPMChange = bpmChanges.FindLastBPM(atsc.CurrentBeat, true);

        copiedBPM = lastBPMChange?._BPM ?? atsc.song.beatsPerMinute;
    }
Esempio n. 15
0
    public void MoveSelection(float beats, bool snapObjects = false)
    {
        List <BeatmapAction> allActions = new List <BeatmapAction>();

        foreach (BeatmapObject data in SelectedObjects)
        {
            BeatmapObjectContainerCollection collection = BeatmapObjectContainerCollection.GetCollectionForType(data.beatmapType);
            BeatmapObject original = BeatmapObject.GenerateCopy(data);

            collection.LoadedObjects.Remove(data);
            data._time += beats;
            if (snapObjects)
            {
                data._time = Mathf.Round(beats / (1f / atsc.gridMeasureSnapping)) * (1f / atsc.gridMeasureSnapping);
            }
            collection.LoadedObjects.Add(data);

            if (collection.LoadedContainers.TryGetValue(data, out BeatmapObjectContainer con))
            {
                con.UpdateGridPosition();
            }

            if (collection is NotesContainer notesContainer)
            {
                notesContainer.RefreshSpecialAngles(original, false, false);
                notesContainer.RefreshSpecialAngles(data, false, false);
            }

            allActions.Add(new BeatmapObjectModifiedAction(data, data, original, "", true));
        }
        BeatmapActionContainer.AddAction(new ActionCollectionAction(allActions, true, true, "Shifted a selection of objects."));
        BeatmapObjectContainerCollection.RefreshAllPools();
    }
Esempio n. 16
0
        public void ModifiedAction()
        {
            var actionContainer = Object.FindObjectOfType <BeatmapActionContainer>();
            var notesContainer  = BeatmapObjectContainerCollection.GetCollectionForType(BeatmapObject.Type.NOTE);
            var root            = notesContainer.transform.root;

            var noteA = new BeatmapNote
            {
                _time = 2,
                _type = BeatmapNote.NOTE_TYPE_A
            };

            notesContainer.SpawnObject(noteA);

            SelectionController.Select(noteA);

            var selectionController = root.GetComponentInChildren <SelectionController>();

            // Default precision is 3dp, but in editor it's 6dp so check 7dp
            selectionController.MoveSelection(-0.0000001f);

            actionContainer.Undo();

            Assert.AreEqual(1, notesContainer.LoadedObjects.Count);
            Assert.AreEqual(2, notesContainer.UnsortedObjects[0]._time);

            actionContainer.Redo();

            Assert.AreEqual(1, notesContainer.LoadedObjects.Count);
            Assert.AreEqual(1.9999999f, notesContainer.UnsortedObjects[0]._time);
        }
 public void UpdateBlueNote()
 {
     BeatSaberSongContainer.Instance.difficultyData.colorRight = blueNote.color = picker.CurrentColor.WithAlpha(1);
     noteAppearance.UpdateColor(redNote.color, blueNote.color);
     BeatmapObjectContainerCollection.GetCollectionForType(BeatmapObject.Type.NOTE).RefreshPool(true);
     CustomColorsUpdatedEvent?.Invoke();
 }
 public void ResetObstacles()
 {
     BeatSaberSongContainer.Instance.difficultyData.obstacleColor = null;
     obstacleAppearance.defaultObstacleColor = obstacle.color = platform.defaultColors.ObstacleColor;
     BeatmapObjectContainerCollection.GetCollectionForType(BeatmapObject.Type.OBSTACLE).RefreshPool(true);
     CustomColorsUpdatedEvent?.Invoke();
 }
Esempio n. 19
0
        public void MirrorNoteNE()
        {
            var notesContainer = BeatmapObjectContainerCollection.GetCollectionForType(BeatmapObject.Type.NOTE);
            var root           = notesContainer.transform.root;
            var notePlacement  = root.GetComponentInChildren <NotePlacement>();

            var noteA = new BeatmapNote
            {
                _time         = 2,
                _type         = BeatmapNote.NOTE_TYPE_A,
                _lineIndex    = BeatmapNote.LINE_INDEX_FAR_LEFT,
                _lineLayer    = BeatmapNote.LINE_LAYER_BOTTOM,
                _customData   = JSON.Parse("{\"_position\": [-1, 0]}"),
                _cutDirection = BeatmapNote.NOTE_CUT_DIRECTION_LEFT
            };

            notePlacement.queuedData  = noteA;
            notePlacement.RoundedTime = notePlacement.queuedData._time;
            notePlacement.ApplyToMap();

            SelectionController.Select(noteA);

            _mirror.Mirror();
            NoteTest.CheckNote(notesContainer, 0, 2, BeatmapNote.NOTE_TYPE_B, BeatmapNote.LINE_INDEX_FAR_LEFT, BeatmapNote.LINE_LAYER_BOTTOM, BeatmapNote.NOTE_CUT_DIRECTION_RIGHT, JSON.Parse("{\"_position\": [1, 0]}"));

            // Undo mirror
            _actionContainer.Undo();
            NoteTest.CheckNote(notesContainer, 0, 2, BeatmapNote.NOTE_TYPE_A, BeatmapNote.LINE_INDEX_FAR_LEFT, BeatmapNote.LINE_LAYER_BOTTOM, BeatmapNote.NOTE_CUT_DIRECTION_LEFT, JSON.Parse("{\"_position\": [-1, 0]}"));
        }
Esempio n. 20
0
 // Start is called before the first frame update
 void Start()
 {
     objectContainerCollections.Add(BeatmapObjectContainerCollection.GetCollectionForType(BeatmapObject.Type.NOTE));
     objectContainerCollections.Add(BeatmapObjectContainerCollection.GetCollectionForType(BeatmapObject.Type.OBSTACLE));
     BeatmapObjectContainer.FlaggedForDeletionEvent += FlaggedForDeletion;
     Settings.NotifyBySettingName("RotateTrack", UpdateRotateTrack);
 }
Esempio n. 21
0
        public void MirrorGradient()
        {
            var container = BeatmapObjectContainerCollection.GetCollectionForType(BeatmapObject.Type.EVENT);

            if (container is EventsContainer eventsContainer)
            {
                var root           = eventsContainer.transform.root;
                var eventPlacement = root.GetComponentInChildren <EventPlacement>();

                var eventA = new MapEvent(2, MapEvent.EVENT_TYPE_BACK_LASERS, MapEvent.LIGHT_VALUE_RED_FADE, JSON.Parse("{\"_lightGradient\": {\"_duration\": 1, \"_startColor\": [1, 0, 0, 1], \"_endColor\": [0, 1, 0, 1], \"_easing\": \"easeLinear\"}}"));

                eventPlacement.queuedData  = eventA;
                eventPlacement.queuedValue = eventPlacement.queuedData._value;
                eventPlacement.RoundedTime = eventPlacement.queuedData._time;
                eventPlacement.ApplyToMap();

                SelectionController.Select(eventA);

                _mirror.Mirror();
                EventTest.CheckEvent(eventsContainer, 0, 2, MapEvent.EVENT_TYPE_BACK_LASERS, MapEvent.LIGHT_VALUE_BLUE_FADE, JSON.Parse("{\"_lightGradient\": {\"_duration\": 1, \"_startColor\": [0, 1, 0, 1], \"_endColor\": [1, 0, 0, 1], \"_easing\": \"easeLinear\"}}"));

                // Undo mirror
                _actionContainer.Undo();
                EventTest.CheckEvent(eventsContainer, 0, 2, MapEvent.EVENT_TYPE_BACK_LASERS, MapEvent.LIGHT_VALUE_RED_FADE, JSON.Parse("{\"_lightGradient\": {\"_duration\": 1, \"_startColor\": [1, 0, 0, 1], \"_endColor\": [0, 1, 0, 1], \"_easing\": \"easeLinear\"}}"));
            }
        }
Esempio n. 22
0
        public void JsonMerge()
        {
            var eventContainer = BeatmapObjectContainerCollection.GetCollectionForType(BeatmapObject.Type.EVENT);
            var nodeEditor     = Object.FindObjectOfType <NodeEditorController>();
            var inputField     = nodeEditor.GetComponentInChildren <TMP_InputField>();

            var eventA = new MapEvent(2, MapEvent.EVENT_TYPE_BACK_LASERS, MapEvent.LIGHT_VALUE_OFF, JSON.Parse(@"{""matches"":{""i"":1,""s"":""s"",""b"":true,""a"":[1,2]},""differs"":{""i"":1,""s"":""s"",""b"":true,""a"":[1,2]},""typeDiffer"":{""i"":1,""s"":""s"",""o"":{},""a"":[1,2]},""lenDiffer"":[1]}"));

            eventContainer.SpawnObject(eventA);

            var eventB = new MapEvent(2, MapEvent.EVENT_TYPE_LEFT_LASERS, MapEvent.LIGHT_VALUE_OFF, JSON.Parse(@"{""matches"":{""i"":1,""s"":""s"",""b"":true,""a"":[1,2]},""differs"":{""i"":2,""s"":""t"",""b"":false,""a"":[2,2]},""typeDiffer"":{""i"":{},""s"":[],""o"":true,""a"":1},""lenDiffer"":[1,2]}"));

            eventContainer.SpawnObject(eventB);

            var eventC = new MapEvent(2, MapEvent.EVENT_TYPE_RIGHT_LASERS, MapEvent.LIGHT_VALUE_OFF);

            eventContainer.SpawnObject(eventC);

            SelectionController.Select(eventC);
            Assert.AreEqual("{\n  \"_time\" : 2,\n  \"_type\" : 3,\n  \"_value\" : 0\n}", inputField.text);

            SelectionController.Select(eventA);
            Assert.AreEqual("{\n  \"_time\" : 2,\n  \"_type\" : 0,\n  \"_value\" : 0,\n  \"_customData\" : {\n    \"matches\" : {\n      \"i\" : 1,\n      \"s\" : \"s\",\n      \"b\" : true,\n      \"a\" : [\n        1,\n        2\n      ]\n    },\n    \"differs\" : {\n      \"i\" : 1,\n      \"s\" : \"s\",\n      \"b\" : true,\n      \"a\" : [\n        1,\n        2\n      ]\n    },\n    \"typeDiffer\" : {\n      \"i\" : 1,\n      \"s\" : \"s\",\n      \"o\" : {\n      },\n      \"a\" : [\n        1,\n        2\n      ]\n    },\n    \"lenDiffer\" : [\n      1\n    ]\n  }\n}", inputField.text);

            SelectionController.Select(eventB, true);
            Assert.AreEqual("{\n  \"_time\" : 2,\n  \"_type\" : -,\n  \"_value\" : 0,\n  \"_customData\" : {\n    \"matches\" : {\n      \"i\" : 1,\n      \"s\" : \"s\",\n      \"b\" : true,\n      \"a\" : [\n        1,\n        2\n      ]\n    },\n    \"differs\" : {\n      \"i\" : -,\n      \"s\" : -,\n      \"b\" : -,\n      \"a\" : [\n        -,\n        2\n      ]\n    },\n    \"typeDiffer\" : {\n    }\n  }\n}", inputField.text);
        }
Esempio n. 23
0
        public void JsonApply()
        {
            var eventContainer = BeatmapObjectContainerCollection.GetCollectionForType(BeatmapObject.Type.EVENT);
            var nodeEditor     = Object.FindObjectOfType <NodeEditorController>();
            var inputField     = nodeEditor.GetComponentInChildren <TMP_InputField>();

            var eventA = new MapEvent(2, MapEvent.EVENT_TYPE_BACK_LASERS, MapEvent.LIGHT_VALUE_OFF, JSON.Parse(@"{""matches"":{""i"":1,""s"":""s"",""b"":true,""a"":[1,2]},""differs"":{""i"":1,""s"":""s"",""b"":true,""a"":[1,2]},""typeDiffer"":{""i"":1,""s"":""s"",""o"":{},""a"":[1,2]},""lenDiffer"":[1],""updatedLenDiffer"":[1],""updated"":{""i"":1,""s"":""s"",""b"":true,""a"":[1,2]},""updatedDiffer"":{""i"":1,""s"":""s"",""b"":true,""a"":[1,2]},""updatedTypeDiffer"":{""i"":1,""s"":""s"",""o"":{},""a"":[1,2]}}"));

            eventContainer.SpawnObject(eventA);

            var eventB = new MapEvent(2, MapEvent.EVENT_TYPE_LEFT_LASERS, MapEvent.LIGHT_VALUE_OFF, JSON.Parse(@"{""matches"":{""i"":1,""s"":""s"",""b"":true,""a"":[1,2]},""differs"":{""i"":2,""s"":""t"",""b"":false,""a"":[2,2]},""typeDiffer"":{""i"":{},""s"":[],""o"":true,""a"":1},""lenDiffer"":[1,2],""updatedLenDiffer"":[1,2],""updated"":{""i"":1,""s"":""s"",""b"":true,""a"":[1,2]},""updatedDiffer"":{""i"":2,""s"":""t"",""b"":false,""a"":[2,2]},""updatedTypeDiffer"":{""i"":{},""s"":[],""o"":true,""a"":1}}"));

            eventContainer.SpawnObject(eventB);

            SelectionController.Select(eventA);
            SelectionController.Select(eventB, true);

            nodeEditor.NodeEditor_EndEdit(@"{""_time"": -, ""_type"": -, ""_value"": -, ""_customData"": {""matches"":{},""differs"":{},""typeDiffer"":{},""updatedLenDiffer"":[1],""updated"":{""i"":4,""s"":""q"",""b"":false,""a"":[3,2]},""updatedDiffer"":{""i"":4,""s"":""q"",""b"":false,""a"":[3,2]},""updatedTypeDiffer"":{""i"":1,""s"":""s"",""o"":{},""a"":[1,2]}}}");

            Assert.AreEqual("{\n  \"_time\" : 2,\n  \"_type\" : -,\n  \"_value\" : 0,\n  \"_customData\" : {\n    \"matches\" : {\n    },\n    \"differs\" : {\n    },\n    \"typeDiffer\" : {\n    },\n    \"updatedLenDiffer\" : [\n      1\n    ],\n    \"updated\" : {\n      \"i\" : 4,\n      \"s\" : \"q\",\n      \"b\" : false,\n      \"a\" : [\n        3,\n        2\n      ]\n    },\n    \"updatedDiffer\" : {\n      \"i\" : 4,\n      \"s\" : \"q\",\n      \"b\" : false,\n      \"a\" : [\n        3,\n        2\n      ]\n    },\n    \"updatedTypeDiffer\" : {\n      \"i\" : 1,\n      \"s\" : \"s\",\n      \"o\" : {\n      },\n      \"a\" : [\n        1,\n        2\n      ]\n    }\n  }\n}", inputField.text);

            // Objects have been recreated, pick them up from the selection controller
            var events = SelectionController.SelectedObjects.ToArray();

            Assert.AreEqual("{\"_time\":2,\"_type\":0,\"_value\":0,\"_customData\":{\"matches\":{},\"differs\":{},\"typeDiffer\":{\"i\":1,\"s\":\"s\",\"o\":{},\"a\":[1,2]},\"lenDiffer\":[1],\"updatedLenDiffer\":[1],\"updated\":{\"i\":4,\"s\":\"q\",\"b\":false,\"a\":[3,2]},\"updatedDiffer\":{\"i\":4,\"s\":\"q\",\"b\":false,\"a\":[3,2]},\"updatedTypeDiffer\":{\"i\":1,\"s\":\"s\",\"o\":{},\"a\":[1,2]}}}", events[0].ConvertToJSON().ToString());
            Assert.AreEqual("{\"_time\":2,\"_type\":2,\"_value\":0,\"_customData\":{\"matches\":{},\"differs\":{},\"typeDiffer\":{\"i\":{},\"s\":[],\"o\":true,\"a\":1},\"lenDiffer\":[1,2],\"updatedLenDiffer\":[1],\"updated\":{\"i\":4,\"s\":\"q\",\"b\":false,\"a\":[3,2]},\"updatedDiffer\":{\"i\":4,\"s\":\"q\",\"b\":false,\"a\":[3,2]},\"updatedTypeDiffer\":{\"i\":1,\"s\":\"s\",\"o\":{},\"a\":[1,2]}}}", events[1].ConvertToJSON().ToString());
        }
Esempio n. 24
0
 public override void Redo(BeatmapActionContainer.BeatmapActionParams param)
 {
     foreach (BeatmapObjectContainer obj in containers)
     {
         BeatmapObjectContainerCollection.GetCollectionForType(obj.objectData.beatmapType).DeleteObject(obj, false, Comment);
     }
     param.tracksManager.RefreshTracks();
 }
Esempio n. 25
0
 public override void Redo(BeatmapActionContainer.BeatmapActionParams param)
 {
     foreach (BeatmapObject obj in Data)
     {
         BeatmapObjectContainerCollection.GetCollectionForType(obj.beatmapType).DeleteObject(obj, false, false);
     }
     RefreshPools(Data);
 }
 public override void Undo(BeatmapActionContainer.BeatmapActionParams param)
 {
     base.Undo(param);
     if (conflictingObject != null)
     {
         BeatmapObjectContainerCollection.GetCollectionForType(conflictingObject.beatmapType).SpawnObject(conflictingObject, false, true);
     }
 }
Esempio n. 27
0
 public override void Undo(BeatmapActionContainer.BeatmapActionParams param)
 {
     foreach (BeatmapObject obj in Data)
     {
         BeatmapObjectContainerCollection.GetCollectionForType(obj.beatmapType)?.SpawnObject(obj, refreshesPool: false);
     }
     RefreshPools(Data);
 }
Esempio n. 28
0
 public override void Undo(BeatmapActionContainer.BeatmapActionParams param)
 {
     foreach (BeatmapObjectContainer obj in pastedObjects)
     {
         BeatmapObjectContainerCollection.GetCollectionForType(obj.objectData.beatmapType).DeleteObject(obj, false);
     }
     SelectionController.CopiedObjects = pastedData;
     param.tracksManager.RefreshTracks();
 }
 public void OnUpdateSwingArcVisualizer(InputAction.CallbackContext context)
 {
     if (KeybindsController.AnyCriticalKeys)
     {
         return;
     }
     (BeatmapObjectContainerCollection.GetCollectionForType(BeatmapObject.Type.NOTE) as NotesContainer)
     .UpdateSwingArcVisualizer();
 }
 public void OnUpdateSwingArcVisualizer(InputAction.CallbackContext context)
 {
     if (!context.performed)
     {
         return;
     }
     (BeatmapObjectContainerCollection.GetCollectionForType(BeatmapObject.Type.NOTE) as NotesContainer)
     .UpdateSwingArcVisualizer();
 }