Ejemplo n.º 1
0
        public void Perform(OgmoAction action)
        {
            if (action == null)
            {
                return;
            }

            //If a batch is in progress, stop it!
            EndBatch();

            //If you're over the undo limit, chop off an action
            while (UndoStack.Count >= Properties.Settings.Default.UndoLimit)
            {
                UndoStack.RemoveFirst();
            }

            //If the level is so-far unchanged, change it and store that fact
            if (!Level.Changed)
            {
                action.LevelWasChanged = false;
                Level.Changed          = true;
            }

            //Add the action to the undo stack and then do it!
            UndoStack.AddLast(action);
            action.Do();

            //Clear the redo stack
            RedoStack.Clear();
        }
Ejemplo n.º 2
0
        public void BatchPerform(OgmoAction action)
        {
            if (action == null)
            {
                return;
            }

            batch.Add(action);
            action.Do();
        }
Ejemplo n.º 3
0
        public void Redo()
        {
            if (RedoStack.Count > 0)
            {
                //Remove it
                OgmoAction action = RedoStack.Last.Value;
                RedoStack.RemoveLast();

                //Redo it
                action.Do();

                //Mark level as changed
                Level.Changed = true;

                //Add it to the undo stack
                UndoStack.AddLast(action);
            }
        }
Ejemplo n.º 4
0
        public void Undo()
        {
            if (UndoStack.Count > 0)
            {
                //Remove it
                OgmoAction action = UndoStack.Last.Value;
                UndoStack.RemoveLast();

                //Undo it
                action.Undo();

                //Roll back level changed flag
                Level.Changed = action.LevelWasChanged;

                //Add it to the redo stack
                RedoStack.AddLast(action);
            }
        }