Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 public void AddAction(int tick, RecordableAction action)
 {
     if (!_actions.ContainsKey(tick))
     {
         _actions.Add(tick, new List <RecordableAction>());
     }
     _actions[tick].Add(action);
 }
Ejemplo n.º 4
0
 public string RedoText()
 {
     if (ActionIndex < Actions.Count)
     {
         return("Redo " + RecordableAction.ActionName(Actions[ActionIndex].ActionType));
     }
     else
     {
         return("Redo");
     }
 }
Ejemplo n.º 5
0
 public string UndoText()
 {
     if (ActionIndex > 0)
     {
         return("Undo " + RecordableAction.ActionName(Actions[ActionIndex - 1].ActionType));
     }
     else
     {
         return("Undo");
     }
 }
Ejemplo n.º 6
0
 private void RecordTick()
 {
     foreach (ActionRecorder recorder in _recorders)
     {
         RecordableAction action = recorder.Record();
         if (action != null)
         {
             _data.AddAction(_currentTick, action);
         }
     }
 }
Ejemplo n.º 7
0
            /// <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);
                }
            }
Ejemplo n.º 8
0
 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);
         }
     }
 }
Ejemplo n.º 9
0
 public Command(RecordableAction act, RecordableAction undo)
 {
     _Do   = act;
     _Undo = undo;
 }
Ejemplo n.º 10
0
        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);
        }