コード例 #1
0
ファイル: ClearLSForm.cs プロジェクト: weimingtom/pap2
        /// <summary>
        /// 清理并导出所有文件
        /// </summary>
        /// <param name="sender">事件发送者</param>
        /// <param name="e">事件参数</param>
        private void bClearAndExport_Click(object sender, EventArgs e)
        {
            List <TreeNode> nodeList = new List <TreeNode>();

            foreach (TreeNode node in MainForm.CurrentMainForm.tree.Nodes["scripts"].Nodes)
            {
                if (node.Text == "Map")
                {
                    foreach (TreeNode sceneNode in node.Nodes)
                    {
                        nodeList.Add(sceneNode);
                    }
                }
                else
                {
                    nodeList.Add(node);
                }
            }

            ProgressForm pForm = new ProgressForm(1, nodeList.Count);

            pForm.Show();
            int index = 1;

            foreach (TreeNode node in nodeList)
            {
                string classification = node.Text;
                bool   sceneScript    = (node.Parent.Text == "Map");

                pForm.ShowProgress(index, string.Format("导出{0}分类下的LS数据表...", classification));
                index++;

                string tableName = "SCENE_STRING_TABLE";
                string fileName  = string.Format(@"scripts\Map\{0}\include\scenestrings.ls", classification);

                if (!sceneScript)
                {
                    tableName = string.Format("{0}_STRING_TABLE", classification.ToUpper());
                    fileName  = string.Format(@"scripts\{0}\include\strings.ls", classification);
                }

                DataRow[] lsRows  = GetValidStringDataRow(classification, sceneScript);
                string    content = CodeConvert.ConvertLsFileContent(lsRows, tableName);

                fileName = Path.Combine(Helper.ClientPath, fileName);
                Helper.WriteStringToFile(content, fileName);
            }

            MessageBox.Show("LS文件导出成功!", "导出所有LS文件",
                            MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
コード例 #2
0
ファイル: DataBaseManager.cs プロジェクト: uvbs/FullSource
        /// <summary>
        /// 转换脚本内容
        /// </summary>
        /// <param name="scriptPath">脚本路径</param>
        /// <param name="scriptContent">脚本内容</param>
        /// <returns>转换后的脚本内容</returns>
        private string DecodeScriptContent(string scriptPath, string scriptContent)
        {
            string classification = GetClassification(scriptPath);

            InitLsTable(classification);
            InitLsHashTable();

            string tableName = "SCENE_STRING_TABLE";

            if (!IsScriptInMap(scriptPath) && !scriptContent.Contains("SCENE_STRING_TABLE")) // 兼容旧格式
            {
                tableName = string.Format("{0}_STRING_TABLE", classification.ToUpper());
            }

            string newContent = CodeConvert.Decode(scriptContent, lsHashtable, tableName);

            return(newContent);
        }
コード例 #3
0
ファイル: ClearLSForm.cs プロジェクト: weimingtom/pap2
        /// <summary>
        /// 获取指定分类里所有没有使用过的LS字符串
        /// </summary>
        /// <param name="classification">分类</param>
        /// <returns>LS字符串</returns>
        private List <string> GetUnuseStringList(string classification)
        {
            List <string> unuseStringList = new List <string>();
            string        content;
            List <string> scriptList = new List <string>(); // 脚本链表

            string condition = string.Format(@"path LIKE 'scripts\Map\{0}\%'", classification);

            if (!checkBoxX1.Checked) // 非场景分类下的字符串
            {
                condition = string.Format(@"path LIKE 'scripts\{0}%'", classification);
            }

            DataRow[] scriptRows = scriptTable.Select(condition);

            foreach (DataRow r in scriptRows)
            {
                string id = r["id"].ToString();
                content = dataBaseManager.GetScriptData(id);
                List <string> list = CodeConvert.GetStringList(content);

                foreach (string s in list)
                {
                    if (!scriptList.Contains(s))
                    {
                        scriptList.Add(s);
                    }
                }
            }

            DataRow[] lsRows = lsTable.Select(string.Format("classification = '{0}'", classification));

            foreach (DataRow r in lsRows)
            {
                content = r["content"].ToString();

                if (!scriptList.Contains(content))
                {
                    unuseStringList.Add(content);
                }
            }

            return(unuseStringList);
        }
コード例 #4
0
ファイル: DataBaseManager.cs プロジェクト: uvbs/FullSource
        /// <summary>
        /// 转换脚本内容
        /// </summary>
        /// <param name="scriptPath">脚本路径</param>
        /// <param name="scriptContent">脚本内容</param>
        /// <returns>转换后的脚本内容</returns>
        private string EncodeScriptContent(string scriptPath, string scriptContent)
        {
            Hashtable contentHashtable = new Hashtable(); // 记录脚本内容和对应id的hash表
            string    classification   = GetClassification(scriptPath);

            InitLsTable(classification);
            InitLsHashTable();

            foreach (object o in lsHashtable.Keys)
            {
                contentHashtable[lsHashtable[o]] = o;
            }

            // 将脚本中的中文字符串取出,与ls文件对比,并更新ls文件
            List <string> varList     = CodeConvert.GetStringList(scriptContent);
            List <string> contentList = new List <string>();

            foreach (DataRow dataRow in lsTable.Rows)
            {
                contentList.Add(dataRow["content"].ToString());
            }

            foreach (string s in varList)
            {
                if (!contentList.Contains(s))
                {
                    contentHashtable[s] = SaveLsFileData(s, classification);
                }
            }

            string tableName = "SCENE_STRING_TABLE";

            if (!IsScriptInMap(scriptPath))
            {
                tableName = string.Format("{0}_STRING_TABLE", classification.ToUpper());
            }

            string newContent = CodeConvert.Encode(scriptContent, contentHashtable, tableName);

            return(newContent);
        }
コード例 #5
0
ファイル: DataBaseManager.cs プロジェクト: uvbs/FullSource
        /// <summary>
        /// 输出脚本和ls文件
        /// </summary>
        /// <param name="idList">脚本id链表</param>
        /// <returns>脚本和ls文件hash表</returns>
        public Hashtable OutputScriptData(List <string> idList, bool exportCondenseString)
        {
            Hashtable fileTable = null;

            try
            {
                if (conn.State == ConnectionState.Closed) // 打开sql连接
                {
                    conn.Open();
                }

                if (idList.Count > 0)                                       // 导出文件数大于零
                {
                    fileTable = new Hashtable();                            // 文件
                    List <string> classificationList = new List <string>(); // 分类链表
                    string        sqlString          = string.Format("SELECT * FROM {0}", "sys_script_lsfile");
                    DataTable     lsTable            = GetDataTable(sqlString);

                    // 导出文件
                    foreach (string id in idList)
                    {
                        sqlString = string.Format("SELECT * FROM {0} WHERE id = {1}",
                                                  "sys_script_script", id);
                        DataTable scriptTable = GetDataTable(sqlString);

                        if (scriptTable.Rows.Count > 0)
                        {
                            string path = scriptTable.Rows[0]["path"].ToString();

                            if (scriptTable.Rows[0]["data"] is DBNull)
                            {
                                fileTable[path] = "";
                                continue;
                            }

                            string data           = DecodeScriptData(((byte[])scriptTable.Rows[0]["data"]));
                            string classification = GetClassification(scriptTable.Rows[0]["path"].ToString());

                            // 导出ls文件
                            DataRow[] lsRows = lsTable.Select(string.Format("classification = '{0}'", classification));

                            if (lsRows.Length > 0 && !classificationList.Contains(classification))
                            {
                                string tableName = "SCENE_STRING_TABLE";

                                if (!path.StartsWith(@"scripts\Map"))
                                {
                                    tableName = string.Format("{0}_STRING_TABLE", classification.ToUpper());
                                    fileTable[string.Format(@"scripts\{0}\include\strings.ls", classification)] = CodeConvert.ConvertLsFileContent(lsRows, tableName);
                                }
                                else
                                {
                                    fileTable[string.Format(@"scripts\Map\{0}\include\scenestrings.ls", classification)] = CodeConvert.ConvertLsFileContent(lsRows, tableName);
                                }

                                classificationList.Add(classification);
                            }

                            fileTable[path] = data;
                        }
                    }
                }
            }
            catch (SqlException ex)
            {
                MessageBox.Show("在导出脚本文件时产生sql异常: " + ex.ToString());
            }
            finally
            {
                if (conn.State == ConnectionState.Open) // 关闭sql连接
                {
                    conn.Close();
                }
            }

            return(fileTable);
        }