Beispiel #1
0
        protected void BuildVariableBlocks()
        {
            Transform parent = mRootList[Define.VARIABLE_CATEGORY_NAME].transform;

            //build createVar button
            GameObject obj = GameObject.Instantiate(BlockViewSettings.Get().PrefabBtnCreateVar);

            obj.transform.SetParent(parent, false);
            obj.GetComponentInChildren <Image>().color = mConfig.GetBlockCategory(Define.VARIABLE_CATEGORY_NAME).Color;
            obj.GetComponent <Button>().onClick.AddListener(() =>
            {
                DialogFactory.CreateDialog("variable_name");
            });

            List <VariableModel> allVars = mWorkspace.GetAllVariables();

            if (allVars.Count == 0)
            {
                return;
            }

            CreateVariableHelperViews();

            //list all variable getter views
            foreach (VariableModel variable in mWorkspace.GetAllVariables())
            {
                CreateVariableGetterView(variable.Name);
            }
        }
Beispiel #2
0
        protected override void RegisterTouchEvent()
        {
            m_BtnLabel.onClick.AddListener(() =>
            {
                mMenuGroup.SetActive(true);
            });

            m_BtnSelect.onClick.AddListener(() =>
            {
                mMenuGroup.SetActive(false);
                DialogFactory.CreateFieldDialog <FieldDropdownDialog>(mField);
            });

            m_BtnRename.onClick.AddListener(() =>
            {
                mMenuGroup.SetActive(false);
                //pop a rename panel
                VariableNameDialog dialog = DialogFactory.CreateDialog("variable_name") as VariableNameDialog;
                dialog.Rename(m_Label.text);
            });

            m_BtnDelete.onClick.AddListener(() =>
            {
                mMenuGroup.SetActive(false);
                mField.SourceBlock.Workspace.DeleteVariable(m_Label.text);
            });
        }
 protected override void RegisterTouchEvent()
 {
     m_Button.onClick.AddListener(() =>
     {
         //open corresponding settings dialog
         DialogFactory.CreateFieldDialog(mField);
     });
 }
Beispiel #4
0
        private void RegisterUIEvents()
        {
            //show mutator editor
            var mutatorEntry = ViewTransform.Find("Mutator_entry");

            if (mutatorEntry != null)
            {
                mutatorEntry.GetComponent <Button>().onClick.AddListener(() =>
                                                                         DialogFactory.CreateMutatorDialog(mBlock)
                                                                         );
            }
        }
        public void UpdateStatus(InterpreterUpdateState args)
        {
            switch (args.Type)
            {
            case InterpreterUpdateState.RunBlock:
            {
                mRunningBlocks.Push(args.RunningBlock);
                mRunBlockView = BlocklyUI.WorkspaceView.GetBlockView(args.RunningBlock);
                break;
            }

            case InterpreterUpdateState.FinishBlock:
            {
                if (mRunningBlocks.Count > 0 && mRunningBlocks.Peek() == args.RunningBlock)
                {
                    mRunningBlocks.Pop();
                    if (mRunningBlocks.Count > 0)
                    {
                        mRunBlockView = BlocklyUI.WorkspaceView.GetBlockView(mRunningBlocks.Peek());
                    }
                }
                break;
            }

            case InterpreterUpdateState.Stop:
            {
                enabled = false;
                mRunningBlocks.Clear();
                mRunBlockView = null;
                break;
            }

            case InterpreterUpdateState.Error:
            {
                if (!string.IsNullOrEmpty(args.Msg))
                {
                    MsgDialog dialog = DialogFactory.CreateDialog("message") as MsgDialog;
                    dialog.SetMsg(args.Msg);
                    Action closeEvent = () =>
                    {
                        MessageManager.Instance.SendMessage("", MSG_TYPE.CODE_END);
                    };
                    dialog.AddCloseEvent(closeEvent);
                }
                enabled = false;
                mRunningBlocks.Clear();
                mRunBlockView = null;
                break;
            }
            }
        }
Beispiel #6
0
        public void UpdateStatus(InterpreterUpdateState args)
        {
            switch (args.Type)
            {
            case InterpreterUpdateState.RunBlock:
            {
                mRunningBlocks.Push(args.RunningBlock);
                mRunBlockView = BlocklyUI.WorkspaceView.GetBlockView(args.RunningBlock);
                break;
            }

            case InterpreterUpdateState.FinishBlock:
            {
                if (mRunningBlocks.Count > 0 && mRunningBlocks.Peek() == args.RunningBlock)
                {
                    mRunningBlocks.Pop();
                    if (mRunningBlocks.Count > 0)
                    {
                        mRunBlockView = BlocklyUI.WorkspaceView.GetBlockView(mRunningBlocks.Peek());
                    }
                }
                break;
            }

            case InterpreterUpdateState.Stop:
            {
                enabled = false;
                mRunningBlocks.Clear();
                mRunBlockView = null;
                break;
            }

            case InterpreterUpdateState.Error:
            {
                if (!string.IsNullOrEmpty(args.Msg))
                {
                    MsgDialog dialog = DialogFactory.CreateDialog("message") as MsgDialog;
                    dialog.SetMsg(args.Msg);
                }
                enabled = false;
                mRunningBlocks.Clear();
                mRunBlockView = null;
                break;
            }
            }
        }