示例#1
0
    public bool Undo(ChartEditor editor)
    {
        if (canUndo)
        {
            ChartEditor.isDirty = true;
            float frame = timestamps[historyPoint];

            int        actionsUndone = 0;
            SongObject setPos        = null;
            while (historyPoint >= 0 && Mathf.Abs(timestamps[historyPoint] - frame) < ACTION_WINDOW_TIME)
            {
                for (int i = actionList[historyPoint].Length - 1; i >= 0; --i)
                {
                    setPos = actionList[historyPoint][i].Revoke(editor);
                    ++actionsUndone;
                }

                --historyPoint;
            }

            editor.currentChart.UpdateCache();
            editor.currentSong.UpdateCache();
            editor.FixUpBPMAnchors();
            if (Toolpane.currentTool != Toolpane.Tools.Note)
            {
                editor.currentSelectedObject = null;
            }

            if (setPos.tick < editor.currentSong.WorldYPositionToTick(editor.visibleStrikeline.position.y) || setPos.tick > editor.maxPos)
            {
                editor.movement.SetPosition(setPos.tick);
            }

            if (setPos.GetType().IsSubclassOf(typeof(ChartObject)))
            {
                if (Globals.viewMode == Globals.ViewMode.Song)          // Placing local object while in chart view
                {
                    editor.toolPanel.ToggleSongViewMode(false);
                }
            }
            else if (Globals.viewMode == Globals.ViewMode.Chart)        // Placing global object while in local view
            {
                editor.toolPanel.ToggleSongViewMode(true);
            }

            Debug.Log("Undo: " + actionsUndone + " actions");
            return(true);
        }

        Debug.Log("Undo: 0 actions");

        return(false);
    }
示例#2
0
    public bool Redo(ChartEditor editor)
    {
        if (canRedo)
        {
            ChartEditor.isDirty = true;
            float      frame         = timestamps[historyPoint + 1];
            int        actionsUndone = 0;
            SongObject setPos        = null;

            while (historyPoint + 1 < actionList.Count && Mathf.Abs(timestamps[historyPoint + 1] - frame) < ACTION_WINDOW_TIME)
            {
                ++historyPoint;
                for (int i = 0; i < actionList[historyPoint].Length; ++i)
                {
                    setPos = actionList[historyPoint][i].Invoke(editor);
                    ++actionsUndone;
                }
            }

            editor.currentChart.UpdateCache();
            editor.currentSong.UpdateCache();
            editor.FixUpBPMAnchors();
            if (Toolpane.currentTool != Toolpane.Tools.Note)
            {
                editor.currentSelectedObject = null;
            }

            if (setPos.tick < editor.currentSong.WorldYPositionToTick(editor.visibleStrikeline.position.y) || setPos.tick > editor.maxPos)
            {
                editor.movement.SetPosition(setPos.tick);
            }

            Debug.Log("Redo: " + actionsUndone + " actions");
            return(true);
        }

        Debug.Log("Redo: 0 actions");

        return(false);
    }