Пример #1
0
 //通用,完整参数版
 public ExpForm(Exp exp, GameEvent gameEvent, bool showThisEvent, TypeDefine requireRetType, VarExp vexp)
 {
     this.m_showThisEvent = showThisEvent;
     this.m_requireRetType = requireRetType;
     this.VExp = vexp;
     ExpForm_Show(exp, gameEvent);
 }
Пример #2
0
        public void ExpForm_Show(Exp exp, GameEvent gameEvent)
        {
            System.Diagnostics.Debug.Assert(exp != null);
            System.Diagnostics.Debug.Assert(gameEvent != null);

            InitializeComponent();

            this.expControl1.VExp = this.VExp;

            enableAPIListChange = false;

            this.m_eventDefine = gameEvent;
            this.m_exp = exp.Clone() as Exp;
            if(exp.ReturnType == null)
            {
                this.Text = "任意表达式";
            }
            else
            {
                this.Text = exp.ReturnType.ToString() + " 表达式";
            }

            this.DialogResult = DialogResult.Cancel;

            // 刷新功能列表
            GameAPIDefine[] ret;
            if(this.m_requireRetType == null) // 表达式类型未知,用于条件判断中输入未知类型的节点用。
            {
                // 获取所有有返回值的API
                // ret = ExpManager.GetAPIDefineListExceptReturnType(TypeDefine.NilType); 如果只能选有返回值的API的话,那么几乎每个有返回值API都要做一个无返回值的版本才能在动作组里没选到,
                // 这样会带来很大的维护工作量,所以修正为可以选择所有的API。
                ret = ExpManager.GetAPIDefine_All();

                this.radioConst.Enabled = false;
                this.radioConstSel.Enabled = false;
                this.comboBoxConst.Enabled = false;
                this.txtConst.Enabled = false;
                this.btnSelect.Enabled = false;

                this.comboBoxAPI.TabIndex = 2;
            }
            else
            {
                // 专用API列出来
                ret = ExpManager.GetAPIDefineByReturnType(exp.ReturnType);
            }

            if (ret != null)
            {
                comboBoxAPI.Items_AddRange(Helper.SortByToString(ret));
            }

            // 刷新常数列表
            if (exp.ReturnType != null)
            {
                if (exp.ReturnType.isEnum)
                {
                    this.txtConst.Enabled = false;
                    this.radioConst.Enabled = false;
                    ConstExp[] const_ret = ExpManager.GetConstExpByReturnType(exp.ReturnType);
                    if (const_ret != null) comboBoxConst.Items.AddRange(const_ret);
                    if (comboBoxConst.Items.Count > 0)
                        comboBoxConst.SelectedItem = comboBoxConst.Items[0];
                    if (!exp.ReturnType.ContainsValueEdit)
                        this.btnSelect.Enabled = false;
                }
                else
                {
                    this.comboBoxConst.Enabled = false;
                    this.radioConstSel.Enabled = false;
                    this.btnSelect.Enabled = false;
                    if (exp.ReturnType.ContainsValueEdit)
                        this.btnInput.Enabled = true;
                }
            }

            //刷新本事件列表
            if(this.m_showThisEvent)
            {
                for (int i = 0; i < gameEvent.ArgList.Length; i++)
                {
                    if (exp.ReturnType == null || gameEvent.ArgList[i].ArgType.DBID == exp.ReturnType.DBID)
                    {
                        comboBoxEventArg.Items.Add(gameEvent.GetArgExp(i + 1));
                    }

                    if (comboBoxEventArg.Items.Count > 0)
                        comboBoxEventArg.SelectedItem = comboBoxEventArg.Items[0];
                }
                //对任意类型的支持,在这里可以选到
                if (this.VExp != null)
                {
                    if (exp.ReturnType == null || this.VExp.ReturnType== null || this.VExp.ReturnType.DBID == exp.ReturnType.DBID)
                    {
                        comboBoxEventArg.Items.Add(this.VExp);
                    }
                }
            }

            //灰掉某些东东
            if (comboBoxAPI.Items_Count == 0)
            {
                //灰掉API
                comboBoxAPI.Enabled = false;
                radioExp.Enabled = false;
            }
            //灰掉常数
            if (comboBoxConst.Items.Count == 0)// && exp.ReturnType.m_isEnum)
                comboBoxConst.Enabled = false;
            if (exp.ReturnType == null || !exp.ReturnType.isDuplicate)
                txtConst.Enabled = false;
            if (txtConst.Enabled == false && comboBoxConst.Enabled == false)
                radioConst.Enabled = false;
            //灰掉本事件
            if (comboBoxEventArg.Items.Count == 0)
            {
                comboBoxEventArg.Enabled = false;
                radioEventArg.Enabled = false;
            }

            //自动选中API
            if (m_exp is ActionExp)
            {
                foreach (GameAPIDefine apidefine in comboBoxAPI.Items_All)
                {
                    if (apidefine.DBID == (m_exp as ActionExp).API.DBID)
                    {
                        
                        this.comboBoxAPI.Text = apidefine.ToString() + " ";
                        //this.comboBoxAPI.Items;
                        break;
                    }
                }

                this.expControl1.SetComboText(m_exp as ActionExp, this.m_eventDefine);
                this.expControl1.VExp = this.VExp;
                this.radioExp.Checked = true;
                //this.expControl1.Focus();
                this.m_FousedControl = this.expControl1;
            }

            //自动选中常数
            if (m_exp is ConstExp)
            {
                ConstExp conExp = m_exp as ConstExp;
                if (conExp.ReturnType.isEnum)
                {
                    if(conExp.ReturnType.ContainsValueEdit) //使用lua脚本编辑
                    {
                        this.comboBoxConst.Items.Clear();
                        this.comboBoxConst.Items.Add(conExp);
                        this.comboBoxConst.SelectedItem = conExp;
                        //this.comboBoxConst.Enabled = true;
                    }
                    else                                    //使用下拉菜单编辑
                    {
                        foreach (ConstExp ex in comboBoxConst.Items)
                        {
                            if (ex.DBValue == conExp.DBValue)
                            {
                                this.comboBoxConst.SelectedItem = ex;
                                break;
                            }
                        }
                        if (this.comboBoxConst.SelectedItem == null && comboBoxConst.Items.Count > 0)
                            comboBoxConst.SelectedItem = comboBoxConst.Items[0];
                    }
                    this.radioConstSel.Checked = true;
                    this.m_FousedControl = this.radioConstSel;
                }
                else
                {
                    this.txtConst.Text = m_exp.strText;
                    this.radioConst.Checked = true;
                    //this.radioConst.Focus();
                    //this.txtConst.Focus();
                    this.m_FousedControl = this.txtConst;
                }
            }



            //自动选中本事件
            if (m_exp is ObjectExp)
            {
                ObjectExp oExp = m_exp as ObjectExp;
                foreach (ObjectExp ex in comboBoxEventArg.Items)
                {
                    if (ex.AsEventArgPos == oExp.AsEventArgPos)
                    {
                        this.comboBoxEventArg.SelectedItem = ex;
                        break;
                    }
                }
                this.radioEventArg.Checked = true;
                //this.comboBoxEventArg.Focus();
                this.m_FousedControl = this.comboBoxEventArg;
            }

            //自动选中无类型变量
            if (m_exp is VarExp)
            {
                foreach (Exp ex in  comboBoxEventArg.Items)
                {
                    if (ex is VarExp)
                    {
                        this.comboBoxEventArg.SelectedItem = ex;
                    }

                }
                this.radioEventArg.Checked = true;
                this.m_FousedControl = this.comboBoxEventArg;
            }


            if (!this.radioConst.Checked && !this.radioEventArg.Checked && !this.radioEventArg.Checked && !this.radioExp.Checked)
            {
                this.radioConst.Checked = true;
                this.m_FousedControl = txtConst;
            }
            enableAPIListChange = true;

            this.comboBoxAPI.SelectedIndexChanged += new System.EventHandler(this.comboBoxAPI_SelectedIndexChanged);
        }
Пример #3
0
 public override object Clone()
 {
     VarExp e = new VarExp();
     e.ReturnType = this.ReturnType;
     e.strText = this.strText;
     return e;
 }