예제 #1
0
파일: ExpForm.cs 프로젝트: weimingtom/pap2
        private void btnSelect_Click(object sender, EventArgs e)
        {
            this.radioConstSel.Checked = true;
            ConstExp cexp    = this.comboBoxConst.SelectedItem as ConstExp;
            string   dbvalue = "";

            if (cexp != null)
            {
                dbvalue = cexp.DBValue;
            }
            string strLua = this.m_exp.ReturnType.QueryScript;

            object[] oRet = LuaManager.GetLuaManager().OnValueEdit(strLua, this.m_exp.ReturnType.QueryScript, dbvalue);
            if (oRet.Length > 0 && ((bool)oRet[0]))
            {
                if (oRet.Length > 1)
                {
                    ConstExp ce = new ConstExp(oRet[1].ToString(), this.m_exp.ReturnType);
                    this.comboBoxConst.Items.Clear();
                    this.comboBoxConst.Items.Add(ce);
                    this.comboBoxConst.SelectedItem = ce;
                    this.comboBoxConst.Enabled      = true;
                }
            }
        }
예제 #2
0
 //从数据库中重读Exp的未序列化信息
 public static void ReloadExp(Exp exp)
 {
     if (exp is ConstExp)
     {
         ConstExp cexp = exp as ConstExp;
         cexp.Reload();
         cexp.ReturnType.Reload();
     }
     if (exp is ObjectExp)
     {
         ObjectExp oexp = exp as ObjectExp;
         oexp.ReturnType.Reload();
         oexp.Parent.Reload();
     }
     if (exp is ActionExp)
     {
         ActionExp aexp = exp as ActionExp;
         aexp.API.Reload();
         aexp.ReturnType.Reload();
         foreach (Exp ex in aexp.API.ArgValues)
         {
             ReloadExp(ex);
         }
     }
 }
예제 #3
0
        //选中菜单
        void mi_Click(object sender, EventArgs e)
        {
            MenuItem mi = sender as MenuItem;

            object[] objs   = mi.Tag as object[];
            int      nAsPos = Convert.ToInt32(objs[0].ToString());
            ConstExp exp    = objs[1] as ConstExp;

            ModifyExp(nAsPos, exp);
        }
예제 #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);
 }
예제 #5
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[] { });
            }
        }
예제 #6
0
        //扫描表达式的常量,保存到本图引用列表
        public static void ScanConstantIntoHistory(Exp exp)
        {
            //保存结构:
            // ht_history = { type_id : ht }
            // ht = { dbvalue : const_exp }
            Hashtable ht_history = CacheManager.GetCacheManager().Global_Args_Table;

            if (exp is ConstExp)
            {
                ConstExp cexp = exp as ConstExp;
                if (!ht_history.ContainsKey(cexp.ReturnType.DBID))
                {
                    Hashtable ht = new Hashtable();
                    ht.Add(cexp.DBValue, cexp);
                    ht_history.Add(cexp.ReturnType.DBID, ht);
                }
                else
                {
                    Hashtable ht = ht_history[cexp.ReturnType.DBID] as Hashtable;
                    if (!ht.ContainsKey(cexp.DBValue))
                    {
                        ht.Add(cexp.DBValue, cexp);
                    }
                }
            }
            if (exp is ObjectExp)
            {
                //do nothing
            }
            if (exp is ActionExp)
            {
                ActionExp aexp = exp as ActionExp;
                foreach (Exp ex in aexp.API.ArgValues)
                {
                    ScanConstantIntoHistory(ex);
                }
            }
        }
예제 #7
0
파일: ExpForm.cs 프로젝트: weimingtom/pap2
        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);
        }
예제 #8
0
파일: ExpForm.cs 프로젝트: viticm/pap2
 private void btnSelect_Click(object sender, EventArgs e)
 {
     this.radioConstSel.Checked = true;
     ConstExp cexp = this.comboBoxConst.SelectedItem as ConstExp;
     string dbvalue = "";
     if(cexp != null)
     {
         dbvalue = cexp.DBValue;
     }
     string strLua = this.m_exp.ReturnType.QueryScript;
     object[] oRet = LuaManager.GetLuaManager().OnValueEdit(strLua, this.m_exp.ReturnType.QueryScript, dbvalue);
     if(oRet.Length > 0 && ((bool)oRet[0]))
     {
         if(oRet.Length > 1)
         {
             ConstExp ce = new ConstExp(oRet[1].ToString(), this.m_exp.ReturnType);
             this.comboBoxConst.Items.Clear();
             this.comboBoxConst.Items.Add(ce);
             this.comboBoxConst.SelectedItem = ce;
             this.comboBoxConst.Enabled = true;
         }
     }
 }
예제 #9
0
파일: Main.cs 프로젝트: viticm/pap2
        /// <summary>
        /// 挂脚本
        /// </summary>
        /// <param name="constExp">表达式对象</param>
        /// <returns>是否挂接成功</returns>
        public bool SetScript(ConstExp constExp)
        {
            string FileName = "";
            StringBuilder Content = new StringBuilder();
            string Sql = "";
            Content.AppendLine("--" + constExp.ToString());
            Content.AppendLine("Include('scripts/flowlib/api.lua')");
            Content.AppendLine("Include('scripts/flowlib/event_dispatch.lua')");
            Content.AppendLine("using('EventDispatch')");

            switch (constExp.ReturnType.DBID)
            {
                case 13:    //道具模板
                    #region 道具生成

                    //生成文件
                    FileName = Path.Combine(this.m_rootdir, @"scripts\flowlib\catcher\item\" + constExp.DBValue.Replace(",", "_") + ".lua");
                    Content.Append(string.Format(@"
function OnUse(player, item)
	local sta, err = pcall(function() EventDispatch.AOnUse('{0}', player, item) end)
	if err then
		print('err: ' .. err)
	end
	return false, false
end
", constExp.DBValue));
                    //写数据库
                    if (!constExp.DBValue.Contains(","))
                        return false;
                    string r1 = constExp.DBValue.Split(new char[] { ',' })[0];
                    string r2 = constExp.DBValue.Split(new char[] { ',' })[1];
                    string sql = "";
                    switch(r1)
                    {
                        case "5":
                            {
                                sql = "Other";
                                break;
                            }
                        case "6":
                            {
                                sql = "item_Custom_Weapon";
                                break;
                            }
                        case "7":
                            {
                                sql = "item_Custom_Armor";                                
                                break;
                            }
                        case "8":
                            {
                                sql = "Custom_Trinket";                                
                                break;
                            }
                    }

                    if (!exportTableList.Contains(sql))
                    {
                        exportTableList.Add(sql);
                    }                    

                    sql = string.Format("update [{0}] set scriptname='scripts\\flowlib\\catcher\\item\\{1}.lua' where id='{2}'", sql, constExp.DBValue.Replace(",", "_"), r2);
                    Sql = sql;
                    #endregion
                    break;
                case 20:    //NPC模板
                    #region NPC模板
                    //生成文件
                    FileName = Path.Combine(this.m_rootdir, @"scripts\flowlib\catcher\npc\" + constExp.DBValue + ".lua");
                    Content.Append(string.Format(@"
function OnDialogue(npc, player)
    local gotevent = false
    local sta, err = pcall(function() gotevent = EventDispatch.AOnDialogue('{0}', npc, player) end)
    if err then
	    print('err: ' .. err)
    end
    if not gotevent then
	  	player.OpenWindow(TARGET.NPC, npc.dwID,
                  npc.GetAutoDialogString(player.dwID)
                  )
    end
end;

function OnDeath(npc, killer)
    local sta, err = pcall(function() EventDispatch.AOnDeath('{0}', npc) end)     --任何情况下的死亡
    if err then
        print('err: ' .. err)
    end
    if not killer then
        sta, err = pcall(function() EventDispatch.AOnNaturalDeath('{0}', npc) end)   --自然死亡
        if err then
            print('err: ' .. err)
        end
    elseif IsPlayer(killer) then
        sta, err = pcall(function() EventDispatch.AOnDeathByPlayer('{0}', npc, killer) end)  --被player杀死的
        if err then
            print('err: ' .. err)
        end   
    else
        sta, err = pcall(function() EventDispatch.AOnDeathByNpc('{0}', npc, killer) end)     --被NPC杀死的
        if err then
            print('err: ' .. err)
        end        
    end    
end;
", constExp.DBValue));

                    //写数据库
                    Sql = string.Format("update NpcTemplate set scriptname='scripts\\flowlib\\catcher\\npc\\{0}.lua' where id='{0}'", constExp.DBValue);
                    
                    //检查实体覆盖模板的问题
                    string strResult = "";

                    if (this.m_inis == null)
                    {
                        string mapname = this.m_mapname;
                        string iniFileName = Path.Combine(this.m_rootdir,
                            @"data\source\maps\" + mapname + "\\" + mapname + ".Map.Logical");
                        if (!File.Exists(iniFileName)) break;
                        this.m_inis = new IniStructure();
                        this.m_inis = IniStructure.ReadIni(iniFileName);
                    }
                    
                    if (m_inis == null) break;
                    int nNpcNumber = Convert.ToInt32(m_inis.GetValue("MAIN", "NumNPC").ToString());

                    for (int i = 0; i < nNpcNumber; i++)
                    {
                        string szName = m_inis.GetValue("NPC" + i.ToString(), "szName");
                        string dwScriptID = m_inis.GetValue("NPC" + i.ToString(), "dwScriptID");
                        string nTempleteID = m_inis.GetValue("NPC" + i.ToString(), "nTempleteID");
                        string nX = m_inis.GetValue("NPC" + i.ToString(), "nX");
                        string nY = m_inis.GetValue("NPC" + i.ToString(), "nY");
                        string nZ = m_inis.GetValue("NPC" + i.ToString(), "nZ");
                        if (nTempleteID == constExp.DBValue && dwScriptID != "00000000")
                        {
                            strResult += string.Format("{4} 的 {0}({1},{2},{3}) 在场景编辑器已经挂接了脚本,自动挂接是通过写模板实现的,所以流程图对于这个实体将无效。", szName, nX, nY, nZ, this.m_mapname) + "\r\n";
                        }
                    }
                    if(strResult != "")
                    {
                        MessageBox.Show(strResult, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }

                    if (!exportTableList.Contains("NpcTemplate"))
                    {
                        exportTableList.Add("NpcTemplate");
                    }     

                    #endregion
                    break;
                case 21:    //任务模板
                    #region 任务模板
                    //生成文件
                    FileName = Path.Combine(this.m_rootdir, @"scripts\flowlib\catcher\quest\" + constExp.DBValue + ".lua");
                    Content.Append(string.Format(@"
function OnAcceptQuest(player)
	local sta, err = pcall(function() EventDispatch.AOnAcceptQuest('{0}', player, '{0}') end)
	if err then
		print('err: ' .. err)
	end
end;

function OnFinishQuest(player)
	local sta, err = pcall(function() EventDispatch.AOnFinishQuest('{0}', player, '{0}') end)
	if err then
		print('err: ' .. err)
	end
end;

function OnCancelQuest(player)
	local sta, err = pcall(function() EventDispatch.AOnCancelQuest('{0}', player, '{0}') end)
	if err then
		print('err: ' .. err)
	end
end;
", constExp.DBValue));
                    //写数据库
                    Sql = string.Format("update tbl_quests set scriptname='scripts\\flowlib\\catcher\\quest\\{0}.lua' where questid='{0}'", constExp.DBValue);

                    if (!exportTableList.Contains("tbl_quests"))
                    {
                        exportTableList.Add("tbl_quests");
                    }     

                    #endregion
                    break;
                case 35:    //Doodad模板
                    #region Doodad模板
                    //生成文件
                    FileName = Path.Combine(this.m_rootdir, @"scripts\flowlib\catcher\doodad\" + constExp.DBValue + ".lua");
                    Content.Append(string.Format(@"
function OnOpen(doodad, player)
    local gotevent = false
    local sta, err = pcall(function() gotevent = EventDispatch.AOnOpen('{0}', doodad, player) end)
    if err then
	    print('err: ' .. err)
    end
    if not gotevent then
	  	--做默认的事情
    end
	return false
end;

function OnBreak(doodad, player)
    local gotevent = false
    local sta, err = pcall(function() gotevent = EventDispatch.AOnBreak('{0}', doodad, player) end)
    if err then
	    print('err: ' .. err)
    end
end;

function OnPick(doodad, player)
    local gotevent = false
    local sta, err = pcall(function() gotevent = EventDispatch.AOnPick('{0}', doodad, player) end)
    if err then
	    print('err: ' .. err)
    end
end;

", constExp.DBValue));
                    //写数据库
                    Sql = string.Format("update tbl_doodad set script='scripts\\flowlib\\catcher\\doodad\\{0}.lua' where id='{0}'", constExp.DBValue);
                    
                    //实体覆盖模板
                    strResult = "";
                    if (this.m_inis == null)
                    {
                        string mapname = this.m_mapname;
                        string iniFileName = Path.Combine(this.m_rootdir,
                            @"data\source\maps\" + mapname + "\\" + mapname + ".Map.Logical");
                        if (!File.Exists(iniFileName)) break;
                        this.m_inis = new IniStructure();
                        this.m_inis = IniStructure.ReadIni(iniFileName);
                    }
                    if (m_inis == null) break;
                    nNpcNumber = Convert.ToInt32(m_inis.GetValue("MAIN", "NumDoodad").ToString());

                    for (int i = 0; i < nNpcNumber; i++)
                    {
                        string szName = m_inis.GetValue("Doodad" + i.ToString(), "szName");
                        string dwScriptID = m_inis.GetValue("Doodad" + i.ToString(), "dwScriptID");
                        string nTempleteID = m_inis.GetValue("Doodad" + i.ToString(), "nTempleteID");
                        string nX = m_inis.GetValue("Doodad" + i.ToString(), "nX");
                        string nY = m_inis.GetValue("Doodad" + i.ToString(), "nY");
                        string nZ = m_inis.GetValue("Doodad" + i.ToString(), "nZ");
                        if (nTempleteID == constExp.DBValue && dwScriptID != "00000000")
                        {
                            strResult += string.Format("{4} 的 {0}({1},{2},{3}) 在场景编辑器已经挂接了脚本,自动挂接是通过写模板实现的,所以流程图对于这个实体将无效。", szName, nX, nY, nZ, this.m_mapname) + "\r\n";
                        }
                    }
                    if (strResult != "")
                    {
                        MessageBox.Show(strResult, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }

                    if (!exportTableList.Contains("tbl_doodad"))
                    {
                        exportTableList.Add("tbl_doodad");
                    }

                    #endregion
                    break;
                case 36:    //Trap模板
                    #region Trap模板
                    string[] list = constExp.DBValue.Split(new char[] { ',' });
                    //生成文件
                    FileName = Path.Combine(this.m_rootdir, @"scripts\flowlib\catcher\trap\" + list[0] + ".map." + list[1] + ".lua");
                    Content.Append(string.Format(@"
function OnEnterTrap(player, cell)
	local sta, err = pcall(function() EventDispatch.AOnEnterTrap('{0}', player, cell, '{0}') end)
	if err then
		print('err: ' .. err)
	end
end;

function OnLeaveTrap(player, oldCell)
	local sta, err = pcall(function() EventDispatch.AOnLeaveTrap('{0}', player, oldCell, '{0}') end)
	if err then
		print('err: ' .. err)
	end
end;

", constExp.DBValue));
                    #endregion
                    break;
                case 39:    //地图模板
                    SetSceneScript();
                    return true;
                default:
                    throw new Exception("目前不支持[" + constExp.ToString() + "]类型的捕获器挂接");
            }
            if (saveFile != null)
            {
                saveFile(FileName, Content.ToString());            //导出lua文件
            }

            /*
            if (executeSQLCommand != null && Sql != "")
            {
                executeSQLCommand(Sql);
            }
            */ 

            return true;
        }
예제 #10
0
파일: Program.cs 프로젝트: viticm/pap2
 public override object Clone()
 {
     ConstExp exp = new ConstExp();
     exp.DBValue = this.DBValue;
     exp.ReturnType = this.ReturnType;
     exp.strText = this.strText;
     return exp;
 }
예제 #11
0
파일: Program.cs 프로젝트: viticm/pap2
 //扫描引用列表,根据常数类型返回常数列表
 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[] { };
     }
 }
예제 #12
0
파일: Program.cs 프로젝트: viticm/pap2
 //根据返回值取常数列表
 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;
 }
예제 #13
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;
                                }
                            }
                        }
                    }
                }
            }
        }