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(); }
public void BatchPerform(OgmoAction action) { if (action == null) { return; } batch.Add(action); action.Do(); }
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); } }