Пример #1
0
 public static void EndUndoGroup()
 {
     if (m_undoStack.Count > 0)
     {
         BTUndoGroup oldGroup = m_undoStack.Peek() as BTUndoGroup;
         if (oldGroup != null && oldGroup.IsOpen)
         {
             if (oldGroup.IsEmpty)
             {
                 m_undoStack.Pop();
             }
             else
             {
                 oldGroup.Close();
             }
         }
     }
 }
Пример #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 BeginUndoGroup(string title)
        {
            if (m_undoStack.Count > 0)
            {
                BTUndoGroup oldGroup = m_undoStack.Peek() as BTUndoGroup;
                if (oldGroup != null && oldGroup.IsOpen)
                {
                    Debug.LogWarningFormat("You have to call BTUndoSystem.EndUndoGroup before begining a new group. Old group is '{0}', new group is '{1}'", oldGroup.Title, title);
                    if (oldGroup.IsEmpty)
                    {
                        m_undoStack.Pop();
                    }
                    else
                    {
                        oldGroup.Close();
                    }
                }
            }

            BTUndoGroup group = new BTUndoGroup(title);

            m_undoStack.Push(group);
        }