//通用,完整参数版 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); }
private void buttonX1_Click(object sender, EventArgs e) { /* if ((this.selectedEvent!= null) && (this.comboBox1.SelectedItem != null) && this.selectedEvent.DBID == (this.comboBox1.SelectedItem as GameEvent).DBID) { this.Close(); return; }*/ this.selectedEvent = this.comboBox1.Items_SelectedItem as GameEvent; if (this.radioButtonCustom.Checked && expControl1.ActionExp != null) { if (this.expControl1.GetReady) this.m_strText = expControl1.ActionExp.ToString(); else { MessageBox.Show("请输入完整", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else this.m_strText = selectedEvent.ToString(); this.DialogResult = DialogResult.OK; this.Close(); }
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(); }
//获取事件列表 public static GameEvent[] GetGameEventList() { int[] event_id_list = DBManager.DataBaseManager.GetDataBaseManager().GetEvents(); if (event_id_list == null) return null; GameEvent[] ret = new GameEvent[event_id_list.Length]; for (int i = 0; i < ret.Length; i++) { ret[i] = new GameEvent(event_id_list[i]); } return ret; }
//根据事件显示标签 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; }
public ConditionForm(Exp actexp, GameEvent gameEvent, List<Exp> ConditionList) { InitializeComponent(); this.m_actexp = actexp; this.m_elist = ConditionList; this.m_gameEvent = gameEvent; this.textBoxX1.Text = m_actexp.ToString(); this.listBox1.Items.AddRange(ConditionList.ToArray()); }
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)); }
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); }
public ObjectExp(GameEvent parent, int pos, TypeDefine retuenType) { this.Parent = parent; this.AsEventArgPos = pos; this.ReturnType = retuenType; this.strText = this.Parent.ArgList[AsEventArgPos].ArgName; }
public object Clone() { GameEvent gevent = new GameEvent(this.DBID); gevent.m_eventAPI = this.m_eventAPI.Clone() as EventAPI; return gevent; }
//根据表达式显示标签 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; } } } }