Пример #1
0
        private void btnExp_Click(object sender, EventArgs e)
        {
            ExpForm expform = new ExpForm(this.m_actexp, this.m_gameEvent, true, null, null);

            expform.StartPosition = FormStartPosition.CenterParent;
            if (expform.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (this.m_actexp.ReturnType != null && this.m_actexp.ReturnType.DBID != expform.RusultExp.ReturnType.DBID)
                {
                    //清空连接线
                    this.listBox1.Items.Clear();
                }
                this.m_actexp          = expform.RusultExp;
                this.m_Vexp.ReturnType = this.m_actexp.ReturnType;      //可变类型的返回值和表达式一致
                this.textBoxX1.Text    = this.m_actexp.ToString();
                this.m_bChanged        = true;
            }
            else
            {
                return;
            }

            //自动添加分支
            if (this.m_actexp != null && this.m_actexp.ReturnType != null)
            {
                //尝试添加枚举的所有类型
                if (this.m_actexp.ReturnType.isEnum)
                {
                    ConstExp[] cexpArray = ExpManager.GetConstExpByReturnType(this.m_actexp.ReturnType);
                    if (cexpArray != null)
                    {
                        foreach (ConstExp cexp in cexpArray)
                        {
                            ActionExp expa = ExpManager.CreateNewActionExp(new GameAPIDefine(FixedValueProvider.COMPARE_API_ID));
                            expa.API.ArgValues[0] = m_Vexp;           //左值为可变类型
                            expa.API.ArgValues[1] = cexp;             //右值为常数值
                            expa.strText          = m_Vexp.ToString() + "==" + cexp.ToString();
                            if (!listBox1.Items.Contains(expa))
                            {
                                this.listBox1.Items.Add(expa);
                                this.m_bChanged = true;
                            }
                        }
                    }
                }

                //尝试添加OpenWindow的选项
                if (this.m_actexp is ActionExp)
                {
                    ActionExp aexp = this.m_actexp as ActionExp;
                    if (aexp.API.DBID == FixedValueProvider.OPENWINDOW_ID) //多选项窗口
                    {
                        Exp dialogExp = aexp.API.ArgValues[2];             //第三个参数
                        if (dialogExp is ConstExp)                         //如果格式文本输入的是常数才处理
                        {
                            string strDialog = (dialogExp as ConstExp).DBValue;
                            Regex  reg       = new Regex(@"(?!=<)\$[^>]*(?=>)");
                            foreach (Match mat in  reg.Matches(strDialog))
                            {
                                string    strSelection = mat.Value.TrimStart(new char[] { '$', 'C', ' ' });
                                ActionExp expa         = ExpManager.CreateNewActionExp(new GameAPIDefine(FixedValueProvider.COMPARE_API_ID));
                                expa.API.ArgValues[0] = m_Vexp;           //左值为可变类型
                                ConstExp cexp = new ConstExp(strSelection, new TypeDefine(FixedValueProvider.TYPE_STRING_ID));
                                m_Vexp.ReturnType     = cexp.ReturnType;
                                expa.API.ArgValues[1] = cexp;             //右值为字符串
                                expa.strText          = m_Vexp.ToString() + "==" + cexp.ToString();
                                if (!listBox1.Items.Contains(expa))
                                {
                                    this.listBox1.Items.Add(expa);
                                    this.m_bChanged = true;
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
 public override string ToString()
 {
     return("( " + VarExp.ToString() + " )");
 }