Exemplo n.º 1
0
    public void Add(IEditorCommand cmd)
    {
        if (cmd == null)
        {
            return;
        }

        //移除当前命令之后的所有已执行命令
        int removeNum = cmdList.Count - currCount;

        if (removeNum > 0)
        {
            cmdList.RemoveRange(currCount, removeNum);
        }

        //Modify by liteng for MoveAtlas At 2014/1/4
        NotifyBeforeCmdExecute(cmd, removeNum);

        cmd.Execute();

        //Modify by liteng for MoveAtlas At 2014/1/4
        NotifyAfterCmdExecute(cmd, removeNum);


        if (cmd.DontSaved || useUnityUndo)
        {//命令本身为只执行不保存的或只使用Unity Undo
            cmdList.Add(cmd);
            currCount++;
        }

        NotifyChange();
    }
Exemplo n.º 2
0
 public void NotifyAfterCmdExecute(IEditorCommand cmd, int removeCmdCount)
 {
     if (onAfterCmdExecute != null)
     {
         onAfterCmdExecute(cmd, removeCmdCount);
     }
 }
 //Modify by liteng for MoveAtlas At 2014/1/4
 public void OnAfterCmdExecute(IEditorCommand cmd, int removeCmdCount)
 {
     if (!HasEditTarget())
     {
         return;
     }
     SpecialEffectEditorUtility.MarkSpecialEffectDirty(GetEditTarget().RealSpe);
 }
    /*
     * 对Command函数的响应函数
     */
    //Modify by liteng for MoveAtlas At 2014/1/4
    public void OnBeforeCmdExecute(IEditorCommand cmd, int removeCmdCount)
    {
        if (!HasEditTarget())
        {
            return;
        }

        //GetEditTarget()._DebugPrintElemTimes();
        SpecialEffectEditorUtility.UndoRecordSpecialEffect(cmd, GetEditTarget().RealSpe);
    }
Exemplo n.º 5
0
        /// <summary>
        /// Is responsible for the correct work off of the key the user pressed.
        /// </summary>
        /// <param name="sender">The sending object.</param>
        /// <param name="eventArgs">The key the user pressed.</param>
        /// <exception cref="ArgumentNullException">
        /// If eventArgs is null.
        /// </exception>
        public void UseKey(object sender, OnKeyPressedEventArgs eventArgs)
        {
            if (eventArgs == null)
            {
                throw new ArgumentNullException();
            }

            ConsoleKeyInfo cki = eventArgs.KeyInfo;

            switch (cki.Key)
            {
            case ConsoleKey.Enter:
                if (!string.IsNullOrWhiteSpace(this.handler.Text))
                {
                    IEditorCommand command = this.parser.Parse(this.handler.Text);
                    this.errorMessage.Message = string.Empty;

                    if (command == null)
                    {
                        this.errorMessage.Message = "This is not a valid command.";
                    }
                    else
                    {
                        try
                        {
                            this.handler.Text = string.Empty;
                            this.handler.Accept(command);
                            this.user.Accept(command);
                        }
                        catch
                        {
                            this.errorMessage.Accept(command);
                        }
                    }
                }

                if (this.user.EditingIsFinished)
                {
                    this.keyBoardWatcher.OnKeyPressed -= this.UseKey;
                    this.InitializeExecution();
                    this.keyBoardWatcher.OnKeyPressed += this.CheckIfExecutionersFinished;
                }

                break;

            default:
                this.errorMessage.Message = string.Empty;
                this.handler.Start(cki);
                break;
            }

            this.handler.Accept(this.editorRenderer);
            this.errorMessage.Accept(this.editorRenderer);
        }
Exemplo n.º 6
0
        public void ExecuteCommand(IEditorCommand command)
        {
            _compositionChangedByCommand = true;
            var args = ConstructCommandArgs();

            if (command.CanExecute(args))
            {
                command.Execute(args);
            }
            _compositionChangedByCommand = false;
        }
Exemplo n.º 7
0
        public void Do(IEditorCommand cmd)
        {
            cmd.Do();
            UndoStack.Push(cmd);
            RedoStack.Clear();

            if (cmd.IsDestructive)
            {
                EditCount++;
            }
        }
Exemplo n.º 8
0
        public void Do(Material targetMaterial, IEditorCommand command)
        {
            if (targetMaterial is null)
            {
                return;
            }

            Commanders[targetMaterial].Do(command);
            if (command.IsDestructive)
            {
                IsSended = false;
            }

            UpdateDraw?.Invoke();
        }
    public void Execute(IEditorCommand cmd)
    {
        if (cmd == null)
        {
            return;
        }

        cmd.Execute();

        if (currCmdIndx == -1)
        {
            cmdList.Clear();
        }
        else
        {
            cmdList.RemoveRange(currCmdIndx + 1, cmdList.Count - currCmdIndx - 1);
        }

        cmdList.Add(cmd);
        currCmdIndx++;
    }
    public static void UndoRecordSpecialEffect(IEditorCommand cmd, SpecialEffect spe)
    {
        if (Application.isPlaying)
        {
            return;
        }

        List <UnityEngine.Object> objList = new List <UnityEngine.Object>();

        foreach (var e in spe.elems)
        {
            objList.Add(e);
        }
        objList.Add(spe);

#if UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || UNITY_5_1
        Undo.RegisterCompleteObjectUndo(objList.ToArray(), cmd.Name);
#else
        Undo.RecordObjects(objList.ToArray(), cmd.Name);
#endif
    }
Exemplo n.º 11
0
 private void ExtensionRegistered(IEditorCommand command)
 {
     Commands.Add(command);
 }
Exemplo n.º 12
0
        public bool CanCommandExecute(IEditorCommand command)
        {
            var args = ConstructCommandArgs();

            return(command.CanExecute(args));
        }
Exemplo n.º 13
0
 public void ExecuteCommand(IEditorCommand command)
 {
     // dummy
 }
Exemplo n.º 14
0
 public bool CanCommandExecute(IEditorCommand command) => false;