コード例 #1
0
        private void ContextMenuItemClickHandler(MenuButton sender)
        {
            switch (_editPanel.CurrentTool)
            {
            case EditTools.Add:
            {
                if (_addTool.IsAddBlock)
                {
                    _addTool.AddBlockOnContextMenuItem(sender);
                }
                else
                {
                    _addTool.AddVariableOnContextMenuItem(sender);
                }
            }
            break;

            case EditTools.Cursor:
            {
                _cursorTool.CursorOnContextMenuItem(sender);
            }
            break;
            }
        }
コード例 #2
0
 private void MenuButtonClickHandler(MenuButton button)
 {
     OnButtonClick?.Invoke(button);
 }
コード例 #3
0
        public void CursorOnContextMenuItem(MenuButton sender)
        {
            switch (_setLabelSteps)
            {
            case SetLabelSteps.ChoiceLabelType:
            {
                _activeLabelType = _labelTypeMenuButtons[sender];
                _setLabelSteps   = SetLabelSteps.SetValue;

                _contextMenu.ClearContextMenu();
                if (_activeLabelType == ActiveLabelType.Variable)
                {
                    SetLabelVariableMenuItems();
                }
                else if (_activeLabelType == ActiveLabelType.Expression)
                {
                    if (_setLabelTarget.ValueType == ValueType.Bool)
                    {
                        _setLabelTarget.Value = new LogicExpression();
                    }
                    else
                    {
                        _setLabelTarget.Value = new Expression();
                    }

                    if (_setLabelTarget.Value.Parent == null)
                    {
                        _setLabelValueUi.Value = _setLabelTarget.Value;
                    }
                    _setLabelValueUi.RebuildAnValue();

                    _contextMenu.gameObject.SetActive(false);
                    _setLabelSteps = SetLabelSteps.SetTarget;
                }
                else if (_activeLabelType == ActiveLabelType.Constant)
                {
                    _mainController.SetValueFromDialog(_setLabelValueUi, _setLabelTarget.Value);

                    _contextMenu.gameObject.SetActive(false);
                    _setLabelSteps = SetLabelSteps.SetTarget;
                }
                else if (_activeLabelType == ActiveLabelType.Operation)
                {
                    if (_setLabelTarget.LabelType == ActiveLabelType.Condition)
                    {
                        SetRelationMenuItems();
                    }
                    else
                    {
                        if (_setLabelTarget.ValueType == ValueType.Bool)
                        {
                            SetLogicOperationMenuItems();
                        }
                        else
                        {
                            SetNumberOperationMenuItems();
                        }
                    }

                    _setLabelSteps = SetLabelSteps.SetValue;
                }
                else if (_activeLabelType == ActiveLabelType.Condition)
                {
                    _setLabelTarget.Value = new Condition();

                    if (_setLabelTarget.Value.Parent == null)
                    {
                        _setLabelValueUi.Value = _setLabelTarget.Value;
                    }
                    _setLabelValueUi.RebuildAnValue();

                    _contextMenu.gameObject.SetActive(false);
                    _setLabelSteps = SetLabelSteps.SetTarget;
                }
            }
            break;

            case SetLabelSteps.SetValue:
            {
                if (_activeLabelType == ActiveLabelType.Operation)
                {
                    if (_setLabelTarget.LabelType == ActiveLabelType.Condition)
                    {
                        Condition condition = _setLabelTarget.Value as Condition;
                        condition.Relation = _relationMenuButtons[sender];
                    }
                    else
                    {
                        if (_setLabelTarget.ValueType == ValueType.Bool)
                        {
                            LogicExpression logicExpression = _setLabelTarget.Value as LogicExpression;
                            logicExpression.Operation = _logicOperationMenuButtons[sender];
                        }
                        else
                        {
                            Expression numberExpression = _setLabelTarget.Value as Expression;
                            numberExpression.Operation = _numberOperationMenuButtons[sender];
                        }
                    }

                    _setLabelValueUi.RebuildAnValue();
                }
                else if (_activeLabelType == ActiveLabelType.Variable)
                {
                    if (_isSetedLabelVariable)
                    {
                        _setLabelTarget.Value = _labelVariableMenuButtons[sender];
                        _setVariableBlock.SetBlock.Variable = _labelVariableMenuButtons[sender];

                        _setVariableBlock.RefreshParameter();
                    }
                    else
                    {
                        _setLabelTarget.Value = _labelVariableMenuButtons[sender];

                        if (_setLabelTarget.Value.Parent == null)
                        {
                            _setLabelValueUi.Value = _setLabelTarget.Value;
                        }
                        _setLabelValueUi.RebuildAnValue();
                    }
                }

                _contextMenu.gameObject.SetActive(false);
                _setLabelSteps = SetLabelSteps.SetTarget;
            }
            break;
            }
        }