示例#1
0
 public ActionListForm(ActionExp[] aexpList, GameEvent evt)
 {
     if (evt == null) throw new Exception("动作列表中传入的事件为空");
     this.m_evt = evt;
     this.actionExpList = aexpList;
     if (this.actionExpList == null)
     {
         this.actionExpList = new ActionExp[0];
     }
     InitializeComponent();
 }
示例#2
0
文件: ExpControl.cs 项目: viticm/pap2
        //根据事件显示标签
        public void SetComboText(GameEvent gameEvent)
        {
            Trace.Assert(gameEvent != null);

            //造一个假的ActionExp
            ActionExp aexp = new ActionExp();
            aexp.API = gameEvent.GetEventAPI();

            //继续显示
            SetComboText(aexp, gameEvent);
            this.m_showThisEvent = false;
        }
示例#3
0
文件: Program.cs 项目: viticm/pap2
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //定义事件
            GameEvent evt = new GameEvent(2);

            //创建一个空的表达式
            Exp exp = ExpManager.CreateNewExp(TypeDefine.NilType);

            //手工创建一个完整的表达式
            ActionExp expa = new ActionExp();
            expa.ReturnType = exp.ReturnType;
            expa.strText = "设置 使用者 等于 true";
            expa.API = new GameAPI(1);
            expa.API.ArgValues[0] = evt.GetArgExp(1);
            expa.API.ArgValues[1] = new ConstExp("true",TypeDefine.BoolType);

            Application.Run(new ExpForm(expa, evt, true, expa.ReturnType, null));
        }
示例#4
0
 public ActionData(ActionExp[] aexpList)
 {
     this.ActionExpArray = aexpList;
 }
示例#5
0
文件: Program.cs 项目: viticm/pap2
 public override object Clone()
 {
     ActionExp exp = new ActionExp();
     exp.API = (GameAPI)this.API.Clone();
     exp.ReturnType = this.ReturnType;
     exp.strText = this.strText;
     exp.strFullText = this.strFullText;
     return exp;
 }
示例#6
0
文件: Program.cs 项目: viticm/pap2
 //创建一个空动作表达式
 public static ActionExp CreateNewActionExp(GameAPIDefine apidefine)
 {
     ActionExp expAction = new ActionExp();
     expAction.API = new GameAPI(apidefine.DBID);
     expAction.ReturnType = expAction.API.ReturnType;
     return expAction;
 }
示例#7
0
文件: ExpControl.cs 项目: viticm/pap2
        //根据表达式显示标签
        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;
                    }
                }
            }

        }