예제 #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
        /// <summary>
        /// Performs an Undo operation, i.e. reverts the last action on the stack.
        /// </summary>
        public static void Undo()
        {
            UndoRedoAction action = PrevAction;

            if (action == null)
            {
                return;
            }
            actionIndex--;
            action.Undo();
            OnStackChanged();
        }
예제 #5
0
        /// <summary>
        /// Performs a Redo operation, i.e. applies the next action on the stack.
        /// </summary>
        public static void Redo()
        {
            UndoRedoAction action = NextAction;

            if (action == null)
            {
                return;
            }
            actionIndex++;
            action.Do();
            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;
		}
        public override void Append(UndoRedoAction action, bool performAction)
        {
            base.Append(action, performAction);
            EditTilesetAutoTileItemAction castAction = action as EditTilesetAutoTileItemAction;

            if (performAction)
            {
                castAction.backupTileInput = this.backupTileInput;
                castAction.Do();
            }

            // Copy the new actions tile input over to this one and adjust the masking
            this.tileInput.Count = Math.Max(this.tileInput.Count, castAction.tileInput.Count);
            this.tileInputMask.Count = this.tileInput.Count;
            for (int i = 0; i < castAction.tileInput.Count; i++)
            {
                if (!castAction.tileInputMask[i]) continue;
                this.tileInput[i] = castAction.tileInput[i];
                this.tileInputMask[i] = true;
            }

            // Adjust the backup length to fit the new tile input length
            this.backupTileInput.Count = this.autoTile.TileInput.Count;
        }
예제 #8
0
 /// <summary>
 /// Determines whether the specified action could be merged with this one.
 /// </summary>
 /// <param name="action"></param>
 /// <returns></returns>
 public virtual bool CanAppend(UndoRedoAction action)
 {
     return false;
 }
예제 #9
0
 /// <summary>
 /// Merges the specified action with this one and performs it before doing so, if requested.
 /// </summary>
 /// <param name="action"></param>
 /// <param name="performAction"></param>
 public virtual void Append(UndoRedoAction action, bool performAction)
 {
 }
예제 #10
0
 /// <summary>
 /// Merges the specified action with this one and performs it before doing so, if requested.
 /// </summary>
 /// <param name="action"></param>
 /// <param name="performAction"></param>
 public virtual void Append(UndoRedoAction action, bool performAction)
 {
 }
예제 #11
0
 /// <summary>
 /// Determines whether the specified action could be merged with this one.
 /// </summary>
 /// <param name="action"></param>
 /// <returns></returns>
 public virtual bool CanAppend(UndoRedoAction action)
 {
     return(false);
 }
예제 #12
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();
			}
		}
예제 #13
0
 /// <summary>
 /// Performs the specified user operation and puts it on the Undo / Redo stack.
 /// </summary>
 /// <param name="action"></param>
 public static void Do(UndoRedoAction action)
 {
     AppendAction(action, true);
 }
 public override bool CanAppend(UndoRedoAction action)
 {
     EditTilesetAutoTileItemAction castAction = action as EditTilesetAutoTileItemAction;
     if (castAction == null) return false;
     if (castAction.autoTile != this.autoTile) return false;
     return true;
 }
예제 #15
0
		public static void Do(UndoRedoAction action)
		{
			AppendAction(action, true);
		}
예제 #16
0
		public override bool CanAppend(UndoRedoAction action)
		{
			return action is RotateCamViewObjAction && base.CanAppend(action);
		}
예제 #17
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();
            }
        }
예제 #18
0
 public override bool CanAppend(UndoRedoAction action)
 {
     EditTilesetTileInputAction castAction = action as EditTilesetTileInputAction;
     if (castAction == null) return false;
     if (castAction.tileset != this.tileset) return false;
     return true;
 }