コード例 #1
0
		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);
		}
コード例 #2
0
		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;
		}
コード例 #3
0
		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;
		}
コード例 #4
0
ファイル: UndoRedoManager.cs プロジェクト: Banbury/duality
        public static void Redo()
        {
            UndoRedoAction action = NextAction;

            if (action == null)
            {
                return;
            }
            actionIndex++;
            action.Do();
            OnStackChanged();
        }
コード例 #5
0
ファイル: UndoRedoManager.cs プロジェクト: Banbury/duality
        public static void Undo()
        {
            UndoRedoAction action = PrevAction;

            if (action == null)
            {
                return;
            }
            actionIndex--;
            action.Undo();
            OnStackChanged();
        }
コード例 #6
0
		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;
		}
コード例 #7
0
		public override bool CanAppend(UndoRedoAction action)
		{
			return action is ScaleCamViewObjAction && base.CanAppend(action);
		}
コード例 #8
0
ファイル: UndoRedoManager.cs プロジェクト: Banbury/duality
 public static void Do(UndoRedoAction action)
 {
     AppendAction(action, true);
 }
コード例 #9
0
ファイル: UndoRedoManager.cs プロジェクト: Banbury/duality
 public virtual void Append(UndoRedoAction action, bool performAction)
 {
 }
コード例 #10
0
ファイル: UndoRedoManager.cs プロジェクト: Banbury/duality
 public virtual bool CanAppend(UndoRedoAction action)
 {
     return(false);
 }
コード例 #11
0
ファイル: UndoRedoManager.cs プロジェクト: Banbury/duality
        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();
            }
        }
コード例 #12
0
		public static void Do(UndoRedoAction action)
		{
			AppendAction(action, true);
		}
コード例 #13
0
		public virtual void Append(UndoRedoAction action, bool performAction) {}
コード例 #14
0
		public virtual bool CanAppend(UndoRedoAction action)
		{
			return false;
		}
コード例 #15
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();
			}
		}