Example #1
0
    public static void ApplyAction(SongObject songObject)
    {
        ChartEditor editor = ChartEditor.Instance;
        Song        song   = editor.currentSong;
        Chart       chart  = editor.currentChart;

        songObject = songObject.Clone();    // Add a new version of the object

        switch (songObject.classID)
        {
        case (int)SongObject.ID.Note:
            Note note = songObject as Note;
            chart.Add(note);

            foreach (Note chordNote in note.chord)
            {
                if (chordNote.controller)
                {
                    chordNote.controller.SetDirty();
                }
            }

            Note next = note.nextSeperateNote;
            if (next != null)
            {
                foreach (Note chordNote in next.chord)
                {
                    if (chordNote.controller)
                    {
                        chordNote.controller.SetDirty();
                    }
                }
            }
            break;

        case (int)SongObject.ID.Starpower:
            Starpower sp = songObject as Starpower;
            chart.Add(sp, false);
            SongEditAdd.SetNotesDirty(sp, editor.currentChart.chartObjects);
            break;

        case (int)SongObject.ID.ChartEvent:
            chart.Add(songObject as ChartObject, false);
            break;

        case (int)SongObject.ID.Section:
        case (int)SongObject.ID.Event:
            song.Add(songObject as Event, false);
            break;

        case (int)SongObject.ID.BPM:
            song.Add(songObject as SyncTrack, false);
            ChartEditor.Instance.songObjectPoolManager.SetAllPoolsDirty();
            break;

        case (int)SongObject.ID.TimeSignature:
            song.Add(songObject as SyncTrack, false);
            break;
        }
    }
Example #2
0
    public override void RevokeSongEditCommand()
    {
        List <SongObject> overwriteList = new List <SongObject>();

        SongEditAdd.ApplyAction(songObjects, overwriteList, extendedSustainsEnabled);
        Debug.Assert(overwriteList.Count <= 0, "SongEditDelete revoke overwrote an object. Should be adding an object that was deleted.");

        overwriteList.Clear();

        SongEditAdd.ApplyAction(overwrittenSongObjects, overwriteList, extendedSustainsEnabled);
        Debug.AssertFormat(overwriteList.Count == overwrittenSongObjects.Count, "SongEditDelete revoke overwrite invalid. OverwriteList = {0}, overwritten = {1}", overwriteList.Count, overwrittenSongObjects.Count);
        overwrittenSongObjects.Clear();
    }
    void CloneInto(SongObject objectToCopyInto, SongObject objectToCopyFrom)
    {
        Chart chart = ChartEditor.Instance.currentChart;

        switch ((SongObject.ID)objectToCopyInto.classID)
        {
        case SongObject.ID.Note:
            (objectToCopyInto as Note).CopyFrom((objectToCopyFrom as Note));
            break;

        case SongObject.ID.Starpower:
            SongEditAdd.SetNotesDirty(objectToCopyInto as Starpower, chart.chartObjects);
            SongEditAdd.SetNotesDirty(objectToCopyFrom as Starpower, chart.chartObjects);
            (objectToCopyInto as Starpower).CopyFrom((objectToCopyFrom as Starpower));
            break;

        case SongObject.ID.ChartEvent:
            AddAndInvokeSubAction(new DeleteAction(objectToCopyInto), subActions);
            AddAndInvokeSubAction(new AddAction(objectToCopyFrom), subActions);
            break;

        case SongObject.ID.BPM:
            (objectToCopyInto as BPM).CopyFrom((objectToCopyFrom as BPM));
            ChartEditor.Instance.songObjectPoolManager.SetAllPoolsDirty();
            break;

        case SongObject.ID.TimeSignature:
            (objectToCopyInto as TimeSignature).CopyFrom((objectToCopyFrom as TimeSignature));
            break;

        case SongObject.ID.Event:
            AddAndInvokeSubAction(new DeleteAction(objectToCopyInto), subActions);
            AddAndInvokeSubAction(new AddAction(objectToCopyFrom), subActions);
            break;

        case SongObject.ID.Section:
            (objectToCopyInto as Section).CopyFrom((objectToCopyFrom as Section));
            break;

        default:
            Debug.LogError("Object to modify not supported.");
            break;
        }

        if (objectToCopyInto.controller)
        {
            objectToCopyInto.controller.SetDirty();
        }
    }
    public void CompleteMoveAction()
    {
        SongEditAdd addAction = new SongEditAdd(movingSongObjects);

        fullCommands.Add(addAction);

        BatchedSongEditCommand moveAction = new BatchedSongEditCommand(fullCommands);

        editor.commandStack.Pop();
        editor.commandStack.Push(moveAction);

        editor.selectedObjectsManager.TryFindAndSelectSongObjects(movingSongObjects);

        Reset();
    }