public bool Redo(MouseTool mouse) { RecordableAction action = Actions[ActionIndex]; int index = 0; if (action is DrawAction daction) { SelectedSheet = daction.Sheet; SelectedSheet.Sketch.Redo(mouse, daction); } else if (action is VariablesAction vaction) { Variables.Deserialize(vaction.After, ref index); } else if (action is SheetAction saction) { if (saction.ActionType == RecordableAction.ActionTypes.AddSheet) { } else if (saction.ActionType == RecordableAction.ActionTypes.DeleteSheet) { } else { throw new Exception("Unknown sheet action to redo."); } } else { throw new Exception("Not supported action to redo."); } ActionIndex++; return(ActionIndex < Actions.Count); }
public bool Undo(MouseTool mouse) { ActionIndex--; RecordableAction action = Actions[ActionIndex]; int index = 0; if (action is DrawAction daction) { controls.view.SelectedNode = daction.Sheet.sheetTree; SelectedSheet.Sketch.Undo(mouse, daction); } else if (action is VariablesAction vaction) { Variables.Deserialize(vaction.Before, ref index); } else if (action is SheetAction saction) { if (saction.ActionType == RecordableAction.ActionTypes.AddSheet) { } else if (saction.ActionType == RecordableAction.ActionTypes.DeleteSheet) { } else { throw new Exception("Unknown sheet action to undo."); } } else { throw new Exception("Not supported action to undo."); } return(ActionIndex > 0); }
public void AddAction(int tick, RecordableAction action) { if (!_actions.ContainsKey(tick)) { _actions.Add(tick, new List <RecordableAction>()); } _actions[tick].Add(action); }
public string RedoText() { if (ActionIndex < Actions.Count) { return("Redo " + RecordableAction.ActionName(Actions[ActionIndex].ActionType)); } else { return("Redo"); } }
public string UndoText() { if (ActionIndex > 0) { return("Undo " + RecordableAction.ActionName(Actions[ActionIndex - 1].ActionType)); } else { return("Undo"); } }
private void RecordTick() { foreach (ActionRecorder recorder in _recorders) { RecordableAction action = recorder.Record(); if (action != null) { _data.AddAction(_currentTick, action); } } }
/// <summary> /// アクションを記憶する /// </summary> /// <param name="act">進んだときの一処理</param> /// <param name="undo">戻ったときの状態</param> public static void Record(RecordableAction act, RecordableAction undo) { lock (Lock) //排他制御 { Command cmd = new Command(act, undo); cmd.ExecuteAction(); State newState = new State(); //前へ戻る処理に代入 newState.PrevCommand = cmd; //追加 AddNewState(newState); } }
public static void Record(RecordableAction act, RecordableAction undo) { lock (Lock) { var cmd = new Command(act, undo); cmd.executeAction(); if (Transacting) { TransCommand.AddCommand(cmd); } else { var newState = new State(); newState.PrevCommand = cmd; AddNewState(newState); } } }
public Command(RecordableAction act, RecordableAction undo) { _Do = act; _Undo = undo; }
internal bool Use(Player player, Transform transform, ProjectileShotDirection direction, out RecordableAction resultingAction) { if (Uses > 0) { PlayerShot shot = new PlayerShot(PowerupType, player, transform.Pos.Xy, direction); shot.Do(); resultingAction = shot; Uses--; return(true); } resultingAction = null; return(false); }