示例#1
0
 public void AddUndoState(BTUndoState undoState)
 {
     if (m_isOpen && m_content.Count < MAX_UNDO_STEPS)
     {
         m_content.Add(undoState);
     }
 }
示例#2
0
        public static void RegisterUndo(BTUndoState undoState)
        {
            if (undoState != null && undoState.CanUndo)
            {
                if (m_undoStack.Count > 0)
                {
                    BTUndoGroup topGroup = m_undoStack.Peek() as BTUndoGroup;
                    if (topGroup != null && topGroup.IsOpen)
                    {
                        topGroup.AddUndoState(undoState);
                        m_redoStack.Clear();
                        return;
                    }
                }

                m_undoStack.Push(undoState);
                m_redoStack.Clear();
            }
        }
示例#3
0
        public static void Undo()
        {
            if (m_undoStack.Count > 0)
            {
                BTUndoState undoState = m_undoStack.Pop();
                if (undoState.CanUndo)
                {
                    undoState.Undo();
                    if (undoState.CanRedo)
                    {
                        m_redoStack.Push(undoState);
                    }
                }

                while (m_undoStack.Count > 0 && !m_undoStack.Peek().CanUndo)
                {
                    m_undoStack.Pop();
                }
            }
        }
示例#4
0
        public static GenericMenu CreateGraphContextMenu(BTEditorGraph graph)
        {
            GenericMenu menu = new GenericMenu();

            if (BTUndoSystem.CanUndo && !graph.ReadOnly)
            {
                BTUndoState topUndo = BTUndoSystem.PeekUndo();
                menu.AddItem(new GUIContent(string.Format("Undo \"{0}\"", topUndo.Title)), false, () => BTUndoSystem.Undo());
            }
            else
            {
                menu.AddDisabledItem(new GUIContent("Undo"));
            }

            if (BTUndoSystem.CanRedo && !graph.ReadOnly)
            {
                BTUndoState topRedo = BTUndoSystem.PeekRedo();
                menu.AddItem(new GUIContent(string.Format("Redo \"{0}\"", topRedo.Title)), false, () => BTUndoSystem.Redo());
            }
            else
            {
                menu.AddDisabledItem(new GUIContent("Redo"));
            }

            menu.AddSeparator("");

            if (!graph.ReadOnly)
            {
                menu.AddItem(new GUIContent("Select All"), false, () => graph.SelectEntireGraph());
            }
            else
            {
                menu.AddDisabledItem(new GUIContent("Select All"));
            }

            menu.AddItem(new GUIContent("Delete All Breakpoints"), false, () => graph.DeleteAllBreakpoints());

            return(menu);
        }