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; }
/// <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(); }
/// <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(); }
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; }
/// <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; }
/// <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) { }
/// <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); }
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(); } }
/// <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; }
public static void Do(UndoRedoAction action) { AppendAction(action, true); }
public override bool CanAppend(UndoRedoAction action) { return action is RotateCamViewObjAction && base.CanAppend(action); }
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 override bool CanAppend(UndoRedoAction action) { EditTilesetTileInputAction castAction = action as EditTilesetTileInputAction; if (castAction == null) return false; if (castAction.tileset != this.tileset) return false; return true; }