Пример #1
0
        public void Add(UR_ICommand p_cmd, bool p_isAlreadyExecuted)
        {
            if (p_cmd != null)
            {
                if (!p_isAlreadyExecuted)
                {
                    p_cmd.Execute();
                }

                if (m_undoCommands.Count > 0)
                {
                    UR_ICommand lastCmd      = m_undoCommands[m_undoCommands.Count - 1];
                    long        lastCmdBytes = lastCmd.GetStoredBytes();
                    if (lastCmd.CombineWithNext(p_cmd))
                    {
                        ClearRedoCommands();
                        m_commandsStoredBytes += lastCmd.GetStoredBytes() - lastCmdBytes;
                        LimitMemoryUsage();
                        return;                         // commands are combined now
                    }
                }
                m_undoCommands.Add(p_cmd);
                ClearRedoCommands();
                m_commandsStoredBytes += p_cmd.GetStoredBytes();
                LimitMemoryUsage();
            }
            else
            {
                Debug.LogError("UR_CommandMgr: Add: p_cmd is null!");
            }
        }
Пример #2
0
 public bool Redo()
 {
     if (IsRedoable)
     {
         UR_ICommand cmd = m_redoCommands[m_redoCommands.Count - 1];
         m_redoCommands.RemoveAt(m_redoCommands.Count - 1);
         m_commandsStoredBytes -= cmd.GetStoredBytes();
         cmd.Execute();
         m_commandsStoredBytes += cmd.GetStoredBytes();
         m_undoCommands.Add(cmd);
         return(true);
     }
     else
     {
         return(false);
     }
 }