/// <summary> /// Return SplayCode to the last captured state. /// </summary> public void Undo() { if (stateStack.Count != 0) { UndoState oldState = stateStack[stateStack.Count - 1]; stateStack.RemoveAt(stateStack.Count - 1); BlockManager.Instance.LoadBlockStates(oldState.BlockStates); } }
/// <summary> /// Captures the current state of SplayCode. Call this before /// proceeding on an action that should be undoable. /// </summary> public void SaveState() { UndoState newState = new UndoState(BlockManager.Instance.BlockList); if (stateStack.Count >= UNDO_LIMIT) { stateStack.RemoveAt(0); } stateStack.Add(newState); }