Exemple #1
0
        private void btnEditor_Click(object sender, EventArgs e)
        {
            string strFolder  = Application.StartupPath.TrimEnd(new char[] { '\\' });
            string strCfg     = Helper.FileToString(strFolder + @"\Plugins\LuaCheck\setting.cfg");
            string strUserCfg = Helper.FileToString(strFolder + @"\Plugins\LuaCheck\_setting.cfg");

            //strCfg = "哈哈,int,123,|是否允许开启,list,false;true,|";
            //strUserCfg = "456,true";

            string[] astrUserCfg = strUserCfg.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            string[] astrCfg     = strCfg.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);

            //读取用户配置,并改写strCfg
            if (astrUserCfg.Length == astrCfg.Length)
            {
                strCfg = "";
                for (int i = 0; i < astrCfg.Length; i++)
                {
                    string   strItem = astrCfg[i];
                    string[] asItem  = strItem.Split(new char[] { ',' });
                    if (asItem.Length != 4)
                    {
                        return;
                    }
                    if (asItem[1] == "list")
                    {
                        string strList = asItem[2].Trim(new char[] { ';' });
                        strList   = ";" + strList + ";";
                        strList   = astrUserCfg[i] + strList.Replace(";" + astrUserCfg[i] + ";", ";");
                        asItem[2] = strList;
                    }
                    else
                    {
                        asItem[2] = astrUserCfg[i];
                    }
                    astrCfg[i] = string.Join(",", asItem) + ",";
                }
                strCfg = string.Join("|", astrCfg) + "|";
            }

            string[]  asp1 = { "|" };
            ModelForm mf   = new ModelForm(strCfg.Split(asp1, StringSplitOptions.RemoveEmptyEntries));

            if (mf.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            List <string> list = mf.InputList;

            Helper.GameLuaEditorSetting = string.Join(",", list.ToArray());
            Helper.WriteStringToFile(Helper.GameLuaEditorSetting, strFolder + @"\Plugins\LuaCheck\_setting.cfg");
        }
Exemple #2
0
        private void btnEditor_Click(object sender, EventArgs e)
        {
            string strFolder    = Application.StartupPath.TrimEnd(new char[] { '\\' });
            string strCfg       = Helper.FileToString(strFolder + @"\Plugins\LuaCheck\setting.cfg");
            string strUserCfg   = Helper.FileToString(strFolder + @"\Plugins\LuaCheck\_setting.cfg");

            //strCfg = "哈哈,int,123,|是否允许开启,list,false;true,|";
            //strUserCfg = "456,true";

            string[] astrUserCfg = strUserCfg.Split(new string[] { "," },  StringSplitOptions.RemoveEmptyEntries);
            string[] astrCfg = strCfg.Split(new string[] { "|" },  StringSplitOptions.RemoveEmptyEntries);

            //读取用户配置,并改写strCfg
            if(astrUserCfg.Length == astrCfg.Length)
            {
                strCfg = "";
                for(int i = 0; i < astrCfg.Length; i++)
                {
                    string strItem = astrCfg[i];
                    string[] asItem = strItem.Split(new char[] { ',' });
                    if (asItem.Length != 4) return;
                    if(asItem[1] == "list")
                    {
                        string strList = asItem[2].Trim(new char[] { ';' });
                        strList = ";" + strList + ";";
                        strList = astrUserCfg[i] + strList.Replace(";" + astrUserCfg[i] + ";", ";");
                        asItem[2] = strList;
                    }
                    else
                    {
                        asItem[2] = astrUserCfg[i];
                    }
                    astrCfg[i] = string.Join(",", asItem) + ",";
                }
                strCfg = string.Join("|", astrCfg) + "|";
            }

            string[] asp1 = { "|" };
            ModelForm mf = new ModelForm(strCfg.Split(asp1, StringSplitOptions.RemoveEmptyEntries));
            if (mf.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            List<string> list = mf.InputList;
            Helper.GameLuaEditorSetting = string.Join(",", list.ToArray());
            Helper.WriteStringToFile(Helper.GameLuaEditorSetting, strFolder + @"\Plugins\LuaCheck\_setting.cfg");
        }
Exemple #3
0
        /// <summary>
        /// 新建文件
        /// </summary>
        /// <param name="sender">事件发送者</param>
        /// <param name="e">事件参数</param>
        private void cmdTreePhFolder_newFile_Click(object sender, EventArgs e)
        {
            if (treePh.SelectedNode != null)
            {
                // 开始和lua交互
                string strFullPath = treePh.SelectedNode.FullPath;
                Lua plua = new Lua();
                object[] oRet = null;
                
                plua.DoString(DataBaseManager.GetDataBaseManager().GetScriptData(this.getFileIDsFromPath("Template")[0].ToString()));
                LuaFunction fun = plua.GetFunction("LoadParms");

                if (fun != null)
                {
                    object[] args = { strFullPath };
                    oRet = fun.Call(args);

                    if (oRet == null)
                    {
                        return;
                    }
                }                            
                
                string strControls = oRet[0] as string;

                // 孙韬返回的内容
                object[] strParms;

                // 文件名
                string strName = "";
                string[] asp1 = { "|" };
                ModelForm mf = new ModelForm(strControls.Split(asp1, StringSplitOptions.RemoveEmptyEntries));

                if (mf.ShowDialog() == DialogResult.OK)
                {
                    List<string> list = mf.InputList;

                    if (list.Count >= 2)
                    {
                        strParms = list.ToArray();
                        strName = strParms[1] as string;

                        string strCode = "";
                        fun = plua.GetFunction("LoadScript");

                        if (fun != null)
                        {
                            oRet = fun.Call(strParms);
                            strCode = oRet[0] as string;
                        }
                        else
                        {
                            return;
                        }                

                        // 交互完毕
                        if (string.IsNullOrEmpty(strName))
                        {
                            return;
                        }

                        if (CheckNodeExist(treePh.SelectedNode, strName))
                        {
                            MessageBox.Show("当前树结点已经存在!", "新建文件",
                                            MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }

                        Hashtable infoTable = new Hashtable();
                        infoTable["type"] = "file";

                        // 存数据库
                        DataBaseManager dbm = DataBaseManager.GetDataBaseManager();
                        string strPath = treePh.SelectedNode.FullPath;
                        string[] asp = { "\\" };
                        string[] as_Path = strPath.Split(asp, StringSplitOptions.RemoveEmptyEntries);

                        if (as_Path.Length < 2 && as_Path[0] == "scripts")
                        {
                            MessageBox.Show("暂时不支持在其他地图以外的目录建文件", "新建文件", 
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }

                        string id = dbm.CreateScriptData(string.Format("{0}\\{1}", strPath, strName));

                        if (id == null)
                        {
                            MessageBox.Show("新建文件失败!", "新建文件", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        else
                        {
                            // 新建成功,更新树缓存
                            treePh.Tag = dbm.GetScriptInformation();
                        }

                        infoTable["id"] = id;
                        infoTable["scriptType"] = "databaseFile";
                        TreeNode newNode = treePh.SelectedNode.Nodes.Add(strName, strName);
                        newNode.ImageKey = "file";
                        newNode.SelectedImageKey = "file";
                        newNode.Tag = infoTable;
                        newNode.ContextMenuStrip = this.popTreePh_File;
                        treePh.SelectedNode.Expand();
                        treePh.SelectedNode = newNode;
                        
                        // 模拟点击节点
                        this.treePh_NodeMouseDoubleClick(this, new TreeNodeMouseClickEventArgs(newNode, MouseButtons.Left, 2, 1, 1));

                        EditForm fe = this.ActiveMdiChild as EditForm;
                        
                        // 模板内容写入
                        if (fe != null)
                        {
                            fe.luaEditBox.Text = strCode;
                        } 
                    } 
                }                
            }        
        }