Ejemplo n.º 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);
 }
Ejemplo n.º 2
0
 //根据返回值获取API列表,不是某返回值的API
 public static GameAPIDefine[] GetAPIDefineListExceptReturnType(TypeDefine type)
 {
     int[] api_id_list = DBManager.DataBaseManager.GetDataBaseManager().GetAPIs_Except_RetType(type.DBID);
     if (api_id_list == null) return null;
     GameAPIDefine[] ret = new GameAPIDefine[api_id_list.Length];
     for(int i = 0; i < ret.Length; i++)
     {
         ret[i] = new GameAPIDefine(api_id_list[i]);
     }
     return ret;
 }
Ejemplo n.º 3
0
 //根据返回值获取API列表,不是某返回值的API
 public static GameAPIDefine[] GetAPIDefineListExceptReturnType(TypeDefine type)
 {
     int[] api_id_list = DBManager.DataBaseManager.GetDataBaseManager().GetAPIs_Except_RetType(type.DBID);
     if (api_id_list == null)
     {
         return(null);
     }
     GameAPIDefine[] ret = new GameAPIDefine[api_id_list.Length];
     for (int i = 0; i < ret.Length; i++)
     {
         ret[i] = new GameAPIDefine(api_id_list[i]);
     }
     return(ret);
 }
Ejemplo n.º 4
0
 //根据返回值取常数列表
 public static ConstExp[] GetConstExpByReturnType(TypeDefine type)
 {
     string[] value_list = DBManager.DataBaseManager.GetDataBaseManager().GetConstDBValuesByRetType(type.DBID);
     if (value_list == null)
     {
         return(null);
     }
     ConstExp[] ret = new ConstExp[value_list.Length];
     for (int i = 0; i < ret.Length; i++)
     {
         ret[i] = new ConstExp(value_list[i], type);
     }
     return(ret);
 }
Ejemplo n.º 5
0
        //左击链接
        void link_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            LinkLabel link = sender as LinkLabel;

            if (link.LinkColor == Color.Gray)
            {
                return;                                         //灰色不响应
            }
            Hashtable  ht              = link.Tag as Hashtable;
            Exp        expEdit         = ht["exp"] as Exp;
            int        nAsPos          = Convert.ToInt32(ht["pos"].ToString());
            TypeDefine require_retType = null;

            if (expEdit != null)
            {
                require_retType = expEdit.ReturnType;
            }
            ExpForm expForm = new ExpForm(expEdit, this.m_eventDefine, m_showThisEvent, require_retType, this.VExp);

            //校准坐标
            expForm.Location = PointToScreen(new Point(link.Location.X, link.Location.Y + link.Height));
            int tx = expForm.Location.X;
            int ty = expForm.Location.Y;

            if (tx + expForm.Width > Screen.PrimaryScreen.Bounds.Width)
            {
                tx = tx - expForm.Width + link.Width;
            }
            if (ty + expForm.Height > Screen.PrimaryScreen.Bounds.Height)
            {
                ty = ty - expForm.Height - link.Height;
            }
            expForm.Location = new Point(tx, ty);
            //弹出窗口
            DialogResult dr = expForm.ShowDialog();

            if (dr == DialogResult.OK)
            {
                ExpManager.ScanConstantIntoHistory(expForm.RusultExp);          //把常数添加至历史
                ModifyExp(nAsPos, expForm.RusultExp);
            }
        }
Ejemplo n.º 6
0
        //扫描引用列表,根据常数类型返回常数列表
        public static ConstExp[] ScanConstantFromHistory(TypeDefine type)
        {
            Hashtable ht_history = CacheManager.GetCacheManager().Global_Args_Table;

            if (ht_history == null)
            {
                return new ConstExp[] { }
            }
            ;
            if (ht_history.ContainsKey(type.DBID))
            {
                Hashtable ht = ht_history[type.DBID] as Hashtable;

                ConstExp[] exps = new ConstExp[ht.Count];
                ht.Values.CopyTo(exps, 0);
                return(exps);
            }
            else
            {
                return(new ConstExp[] { });
            }
        }
Ejemplo n.º 7
0
 public ArgsDefine(string name, TypeDefine type, string DefaultValue)
 {
     this.ArgName      = name;
     this.ArgType      = type;
     this.DefaultValue = DefaultValue;
 }
Ejemplo n.º 8
0
        //根据表达式显示标签
        public void SetComboText(ActionExp expAction, GameEvent gameEvent)
        {
            Trace.Assert(expAction != null);
            Trace.Assert(gameEvent != null);
            this.m_eventDefine = gameEvent;
            this.m_actionExp   = expAction;
            GameAPI api = expAction.API;

            this.Controls.Clear();
            isReady                 = true;
            m_actionExp.strText     = "";
            m_actionExp.strFullText = "";

            string strComboText = "}" + api.combText;

            string[] tmp = strComboText.Split(new string[] { "{" }, StringSplitOptions.None);
            for (int i = -1; i < tmp.Length - 1; i++)
            {
                string[] strcs = tmp[i + 1].Split(new string[] { "}" }, StringSplitOptions.None);

                //添加热文本
                if (strcs[0] != "")
                {
                    LinkLabel link = new LinkLabel();
                    link.Margin   = new System.Windows.Forms.Padding(0);
                    link.AutoSize = true;
                    link.Tag      = new Hashtable();
                    int nReali = Convert.ToInt32(strcs[0].ToString()) - 1;

                    TypeDefine typed = api.ArgList[nReali].ArgType;
                    if (typed.isEnum || typed.DBID == FixedValueProvider.TYPE_STRING_ID)
                    {
                        //右键菜单
                        ConstExp[] exps = ExpManager.ScanConstantFromHistory(typed);
                        if (exps.Length > 0)
                        {
                            link.ContextMenu = new ContextMenu();
                            for (int it = 0; it < exps.Length; it++)
                            {
                                MenuItem mi = new MenuItem(exps[it].ToString());
                                mi.Tag    = new object[] { nReali, exps[it] };
                                mi.Click += new EventHandler(mi_Click);
                                link.ContextMenu.MenuItems.Add(mi);
                            }
                        }
                    }

                    if (/*api.ArgValues.Count <= i || */ api.ArgValues[nReali] == null)
                    {
                        link.Text      = "<" + api.ArgList[nReali].ArgName + ">";
                        link.LinkColor = Color.Red;
                        (link.Tag as Hashtable)["exp"] = ExpManager.CreateNewExp(api.ArgList[nReali].ArgType);
                        (link.Tag as Hashtable)["pos"] = nReali;
                        isReady = false;
                    }
                    else
                    {
                        link.Text      = api.ArgValues[nReali].ToString();
                        link.LinkColor = Color.Blue;
                        (link.Tag as Hashtable)["exp"] = api.ArgValues[nReali];
                        (link.Tag as Hashtable)["pos"] = nReali;
                    }

                    link.MouseClick     += new MouseEventHandler(link_MouseClick);
                    link.PreviewKeyDown += new PreviewKeyDownEventHandler(link_PreviewKeyDown);
                    this.Controls.Add(link);

                    //追加到显示内容区域
                    //if(link.Text.Length > 25)
                    //    m_actionExp.strText += link.Text.Substring(0,23) + "...";
                    //else
                    //    m_actionExp.strText += link.Text + "";
                    m_actionExp.strText     += link.Text;
                    m_actionExp.strFullText += link.Text;
                }

                //正常文本
                if (strcs[1] != "")
                {
                    Label l = new Label();
                    l.Margin   = new System.Windows.Forms.Padding(0);
                    l.AutoSize = true;
                    l.Text     = strcs[1];
                    this.Controls.Add(l);
                    m_actionExp.strText     += l.Text + "";
                    m_actionExp.strFullText += l.Text;
                    l.Text = l.Text.Replace("\r\n", "");
                }
            }

            //添加换行
            Control br = new Label();

            br.Width  = this.Width - 23;
            br.Height = 0;
            this.Controls.Add(br);

            //添加Tip注释
            Control ltip = new Label();

            ltip.Text      = "\r\n" + expAction.API.strTip;
            ltip.ForeColor = Color.Gray;
            ltip.AutoSize  = true;
            this.Controls.Add(ltip);

            //专门处理比较API
            if (expAction.API.DBID == FixedValueProvider.COMPARE_API_ID)
            {
                LinkLabel left    = this.Controls[0] as LinkLabel;
                LinkLabel right   = this.Controls[2] as LinkLabel;
                Hashtable htleft  = left.Tag as Hashtable;
                Hashtable htright = right.Tag as Hashtable;
                if (left.LinkColor == Color.Red)
                {
                    //左值类型清空
                    htleft["exp"] = ExpManager.CreateUnknownExp();

                    //右侧变灰
                    right.LinkColor = Color.Gray;
                }
                else
                {
                    //右侧的类型跟左侧走
                    (htright["exp"] as Exp).ReturnType = (htleft["exp"] as Exp).ReturnType;

                    //右侧变红
                    if ((htright["exp"] as Exp).strText == null)
                    {
                        right.LinkColor = Color.Red;
                    }
                }
            }
        }
Ejemplo n.º 9
0
 public ObjectExp(GameEvent parent, int pos, TypeDefine retuenType)
 {
     this.Parent = parent;
     this.AsEventArgPos = pos;
     this.ReturnType = retuenType;
     this.strText = this.Parent.ArgList[AsEventArgPos].ArgName;
 }
Ejemplo n.º 10
0
        public virtual void Reload()
        {
            if (this.DBID == 0) return;
            //读取API信息
            object[] objs = DBManager.DataBaseManager.GetDataBaseManager().GetAPIDefine(this.DBID);
            if (objs == null) return;
            this.strText = objs[0].ToString();
            this.combText = objs[1].ToString();
            this.ReturnType = new TypeDefine(Convert.ToInt32(objs[2].ToString()));
            this.strName = objs[3].ToString();
            this.isAsyn = (bool)objs[4];
            this.strTip = objs[5].ToString();

            //读取API参数定义
            DataTable dt = DBManager.DataBaseManager.GetDataBaseManager().GetAPIDefineArg(this.DBID);
            if (dt == null) 
            {
                this.ArgList = new ArgsDefine[0]; return; 
            }
            this.ArgList = new ArgsDefine[dt.Rows.Count];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                this.ArgList[i] = new ArgsDefine(dt.Rows[i]["name"].ToString(),
                       new TypeDefine(Convert.ToInt32(dt.Rows[i]["type"].ToString())),
                       dt.Rows[i]["default"].ToString());
            }
        }
Ejemplo n.º 11
0
 public ConstExp(string DBValue, TypeDefine typeDefine)
 {
     this.ReturnType = typeDefine;
     this.DBValue = DBValue;
     this.Reload();
 }
Ejemplo n.º 12
0
 public ArgsDefine(string name, TypeDefine type, string DefaultValue)
 {
     this.ArgName = name; 
     this.ArgType = type;
     this.DefaultValue = DefaultValue;
 }
Ejemplo n.º 13
0
 //扫描引用列表,根据常数类型返回常数列表
 public static ConstExp[] ScanConstantFromHistory(TypeDefine type)
 {
     Hashtable ht_history = CacheManager.GetCacheManager().Global_Args_Table;
     if (ht_history == null)
         return new ConstExp[] { };
     if(ht_history.ContainsKey(type.DBID))
     {
         Hashtable ht = ht_history[type.DBID] as Hashtable;
         ConstExp[] exps = new ConstExp[ht.Count];
         ht.Values.CopyTo(exps, 0);
         return exps;
     }
     else
     {
         return new ConstExp[] { };
     }
 }
Ejemplo n.º 14
0
 //创建一个空表达式
 public static Exp CreateNewExp(TypeDefine returnType)
 {
     Exp e = new Exp();
     e.ReturnType = returnType;
     return e;
 }
Ejemplo n.º 15
0
 //根据返回值取常数列表
 public static ConstExp[] GetConstExpByReturnType(TypeDefine type)
 {
     string[] value_list = DBManager.DataBaseManager.GetDataBaseManager().GetConstDBValuesByRetType(type.DBID);
     if (value_list == null) return null;
     ConstExp[] ret = new ConstExp[value_list.Length];
     for (int i = 0; i < ret.Length; i++)
     {
         ret[i] = new ConstExp(value_list[i], type);
     }
     return ret;
 }