Exemple #1
0
        /// <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);
        }
Exemple #2
0
        /// <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);
        }