Пример #1
0
 /// <summary>
 /// Push a new state onto the undo/redo buffer, will erase anything after the current undo.
 /// This will use the passed states for undo and redo.
 /// </summary>
 public void pushUndoState(LayerState undoState, LayerState redoState)
 {
     if (!undoState.isTheSameAs(redoState)) //This uses the slightly unreliable isTheSameAs function, but worse case scenerio we end up with a duplicate undo.
     {
         undoRedoBuffers[activeStateName].pushAndSkip(new TwoWayDelegateCommand <LayerState, LayerState>(redoState, undoState, new TwoWayDelegateCommand <LayerState, LayerState> .Funcs()
         {
             ExecuteFunc = state =>
             {
                 state.apply();
                 if (OnRedo != null)
                 {
                     OnRedo.Invoke(this);
                 }
             },
             UndoFunc = state =>
             {
                 state.apply();
                 if (OnUndo != null)
                 {
                     OnUndo.Invoke(this);
                 }
             }
         }));
         if (OnUndoRedoChanged != null)
         {
             OnUndoRedoChanged.Invoke(this);
         }
     }
 }
Пример #2
0
 /// <summary>
 /// Push a new state onto the undo/redo buffer, will erase anything after the current undo.
 /// This will use the passed states for undo and redo.
 /// </summary>
 public void pushUndoState(CameraPosition undoState, CameraPosition redoState)
 {
     //Make sure the undo and redo states are sufficiently different, otherwise ignore this new entry
     if ((undoState.Translation - redoState.Translation).length2() > 0.001 || (undoState.LookAt - redoState.LookAt).length2() > 0.001)
     {
         undoRedoBuffer.pushAndSkip(new TwoWayDelegateCommand <CameraPosition, CameraPosition>(redoState, undoState, new TwoWayDelegateCommand <CameraPosition, CameraPosition> .Funcs()
         {
             ExecuteFunc = state =>
             {
                 this.setPosition(state, GuiFrameworkCamerasInterface.CameraTransitionTime);
                 if (OnRedo != null)
                 {
                     OnRedo.Invoke(this);
                 }
             },
             UndoFunc = state =>
             {
                 this.setPosition(state, GuiFrameworkCamerasInterface.CameraTransitionTime);
                 if (OnUndo != null)
                 {
                     OnUndo.Invoke(this);
                 }
             }
         }));
         if (OnUndoRedoChanged != null)
         {
             OnUndoRedoChanged.Invoke(this);
         }
     }
 }
Пример #3
0
        public static void Undo(string stackId)
        {
            Stack <UndoObject> stack = null;

            if (undos.TryGetValue(stackId, out stack))
            {
                if (stack.Count > 0)
                {
                    var p = stack.Pop();

                    Task.Run(async() =>
                    {
                        await p.Undo(r =>
                        {
                            if (r != null)
                            {
                                AddRedo(r);
                            }
                        });
                    });

                    if (OnUndo != null)
                    {
                        OnUndo.Invoke(stackId, stack.Count);
                    }
                }
            }
        }
 /// <summary>
 /// Push a new state onto the undo/redo buffer, will erase anything after the current undo.
 /// This will use the passed states for undo and redo.
 /// </summary>
 public void pushUndoState(MusclePosition undoPosition, MusclePosition redoPosition)
 {
     poseUndoRedoBuffer.pushAndSkip(new TwoWayDelegateCommand <MusclePosition, MusclePosition>(redoPosition, undoPosition, new TwoWayDelegateCommand <MusclePosition, MusclePosition> .Funcs()
     {
         ExecuteFunc = position =>
         {
             position.preview();
             if (OnRedo != null)
             {
                 OnRedo.Invoke(this);
             }
         },
         UndoFunc = position =>
         {
             position.preview();
             if (OnUndo != null)
             {
                 OnUndo.Invoke(this);
             }
         }
     }));
     if (OnUndoRedoChanged != null)
     {
         OnUndoRedoChanged.Invoke(this);
     }
 }
Пример #5
0
 public static void OnUndoInvoke(object sender = null)
 {
     if (OnUndo != null)
     {
         OnUndo.Invoke(null, EventArgs.Empty);
     }
 }
Пример #6
0
 protected override void Rollback()
 {
     Console.WriteLine($"Rollbacking {this}");
     IsDone = false;
     OnUndo?.Invoke();
     Console.WriteLine($"Rollbacked {this}");
 }
Пример #7
0
 protected override void UndoAction()
 {
     Console.WriteLine($"Undoing {this}");
     done = false;
     OnUndo?.Invoke();
     Console.WriteLine($"Undone {this}");
 }
    void UndoCurrentAction()
    {
        if (actionsMade[currentUndoStepIndex].isDone)
        {
            actionsMade[currentUndoStepIndex].Undo();
            OnUndo?.Invoke();

            CheckButtonsInteractability();
        }
    }
Пример #9
0
 /// <summary>
 /// Reverts the state of all objects in the object list to the previous state.
 /// </summary>
 public void Undo()
 {
     undoIndex--;
     OnUndo?.Invoke(this, new UndoRedoEventArgs(undoIndex));
     string[] objects = new string[programObjects.Count]; //Used for saving the current state of the objects to the objectStates list.
     for (int i = 0; i < objects.Length; i++)
     {
         objects[i] = programObjects[i].ToString();
     }
     objectStates.Add(objects);
 }
Пример #10
0
    public void Undo(HistoryActionContainer actionContainer)
    {
        redoList.Add(actionContainer);
        undoList.Remove(actionContainer);
        actionContainer.action.Result.Undo();

        if (OnUndo != null)
        {
            OnUndo.Invoke(actionContainer);
        }
    }
        public void Undo()
        {
            LevelEditorLogger.Log("Undo");

            if (counter > 0)
            {
                counter--;
                IUndoAction action = actionHistory[counter];
                action.Undo(this);

                OnUndo?.Invoke(action);
            }
        }
Пример #12
0
        public static void Undo(string stackId)
        {
            Stack <UndoObject> stack = null;

            if (undos.TryGetValue(stackId, out stack))
            {
                if (stack.Count > 0)
                {
                    var p = stack.Pop();
                    var r = p.Undo();

                    AddRedo(r);

                    if (OnUndo != null)
                    {
                        OnUndo.Invoke(stackId, stack.Count);
                    }
                }
            }
        }
Пример #13
0
        public void Undo()
        {
            if (undoStack.Count > 0)
            {
                string       currentExp = InputField.text;
                StateHistory popped     = undoStack.Pop();
                InputField.text = string.Join("", undoStack.Reverse().Select(s => s.ExpressionPart));

                OnUndo?.Invoke(currentExp.Substring(InputField.text.Length));

                if (popped.PushState != null)
                {
                    PopState(true);
                }
                if (popped.PopState != null)
                {
                    PushState(popped.PopState);
                }

                DisableInvalidButtons();
                SetDebugText();
            }
        }