public override bool CanAppend(UndoRedoAction action)
		{
			CamViewObjAction castAction = action as CamViewObjAction;
			if (castAction == null) return false;
			if (castAction.postPerform != this.postPerform) return false;
			return castAction.targetObj.SetEqual(this.targetObj);
		}
		public override void Append(UndoRedoAction action, bool performAction)
		{
			base.Append(action, performAction);
			MoveCamViewObjAction moveAction = action as MoveCamViewObjAction;
			if (performAction)
			{
				moveAction.backupPos = this.backupPos;
				moveAction.Do();
			}
			this.moveBy += moveAction.moveBy;
		}
		public override void Append(UndoRedoAction action, bool performAction)
		{
			base.Append(action, performAction);
			ScaleCamViewObjAction moveAction = action as ScaleCamViewObjAction;
			if (performAction)
			{
				moveAction.backupPos = this.backupPos;
				moveAction.backupScale = this.backupScale;
				moveAction.Do();
			}
			this.scaleBy *= moveAction.scaleBy;
		}
Exemple #4
0
        public static void Redo()
        {
            UndoRedoAction action = NextAction;

            if (action == null)
            {
                return;
            }
            actionIndex++;
            action.Do();
            OnStackChanged();
        }
Exemple #5
0
        public static void Undo()
        {
            UndoRedoAction action = PrevAction;

            if (action == null)
            {
                return;
            }
            actionIndex--;
            action.Undo();
            OnStackChanged();
        }
		public override void Append(UndoRedoAction action, bool performAction)
		{
			base.Append(action, performAction);
			RotateCamViewObjAction moveAction = action as RotateCamViewObjAction;
			if (performAction)
			{
				moveAction.backupPos = this.backupPos;
				moveAction.backupAngle = this.backupAngle;
				moveAction.Do();
			}
			this.turnBy += moveAction.turnBy;
		}
		public override bool CanAppend(UndoRedoAction action)
		{
			return action is ScaleCamViewObjAction && base.CanAppend(action);
		}
Exemple #8
0
 public static void Do(UndoRedoAction action)
 {
     AppendAction(action, true);
 }
Exemple #9
0
 public virtual void Append(UndoRedoAction action, bool performAction)
 {
 }
Exemple #10
0
 public virtual bool CanAppend(UndoRedoAction action)
 {
     return(false);
 }
Exemple #11
0
        private static void AppendAction(UndoRedoAction action, bool performAction)
        {
            if (action.IsVoid)
            {
                return;
            }
            if (macroBeginCount > 0)
            {
                UndoRedoAction prev = macroList.Count > 0 ? macroList[macroList.Count - 1] : null;
                if (prev != null && prev.CanAppend(action))
                {
                    prev.Append(action, performAction);
                }
                else
                {
                    macroList.Add(action);
                    if (performAction)
                    {
                        action.Do();
                    }
                }
            }
            else
            {
                if (Sandbox.IsActive)
                {
                    if (performAction)
                    {
                        action.Do();
                    }
                    return;
                }

                bool hadNext = false;
                if (actionStack.Count - actionIndex - 1 > 0)
                {
                    actionStack.RemoveRange(actionIndex + 1, actionStack.Count - actionIndex - 1);
                    hadNext = true;
                }

                UndoRedoAction prev = PrevAction;
                if (!lastActionFinished && !hadNext && prev != null && prev.CanAppend(action))
                {
                    prev.Append(action, performAction);
                }
                else
                {
                    lastActionFinished = false;
                    actionStack.Add(action);
                    actionIndex++;
                    if (performAction)
                    {
                        action.Do();
                    }
                }

                if (actionStack.Count > maxActions)
                {
                    actionIndex -= actionStack.Count - maxActions;
                    actionStack.RemoveRange(0, actionStack.Count - maxActions);
                }

                OnStackChanged();
            }
        }
		public static void Do(UndoRedoAction action)
		{
			AppendAction(action, true);
		}
		public virtual void Append(UndoRedoAction action, bool performAction) {}
		public virtual bool CanAppend(UndoRedoAction action)
		{
			return false;
		}
		private static void AppendAction(UndoRedoAction action, bool performAction)
		{
			if (action.IsVoid) return;
			if (macroBeginCount > 0)
			{
				UndoRedoAction prev = macroList.Count > 0 ? macroList[macroList.Count - 1] : null;
				if (prev != null && prev.CanAppend(action))
				{
					prev.Append(action, performAction);
				}
				else
				{
					macroList.Add(action);
					if (performAction) action.Do();
				}
			}
			else
			{
				if (Sandbox.IsActive)
				{
					if (performAction) action.Do();
					return;
				}

				bool hadNext = false;
				if (actionStack.Count - actionIndex - 1 > 0)
				{
					actionStack.RemoveRange(actionIndex + 1, actionStack.Count - actionIndex - 1);
					hadNext = true;
				}

				UndoRedoAction prev = PrevAction;
				if (!lastActionFinished && !hadNext && prev != null && prev.CanAppend(action))
				{
					prev.Append(action, performAction);
				}
				else
				{
					lastActionFinished = false;
					actionStack.Add(action);
					actionIndex++;
					if (performAction) action.Do();
				}

				if (actionStack.Count > maxActions)
				{
					actionIndex -= actionStack.Count - maxActions;
					actionStack.RemoveRange(0, actionStack.Count - maxActions);
				}

				OnStackChanged();
			}
		}