Example #1
0
 void Update()
 {
     if (_fileQueue != null && _fileQueue.Count > 0)
     {
         for (int i = 0; i < NUM_PER_FRAME && _fileQueue.Count > 0; i++)
         {
             newScriptLines.AddRange(FindChineseTool.GetScriptLines(_fileQueue.Dequeue()));
         }
         if (_fileQueue.Count == 0)
         {
             state = OptStatus.Complete;
         }
         else
         {
             state = OptStatus.Doing;
         }
     }
     if (state == OptStatus.Doing)
     {
         EditorUtility.DisplayProgressBar("Searching..." + (_maxFileNum - _fileQueue.Count) + "/" + _maxFileNum, name, (float)(_maxFileNum - _fileQueue.Count) / (float)_maxFileNum);
     }
     else
     {
         EditorUtility.ClearProgressBar();
     }
 }
Example #2
0
 ScriptLineVo GetOldLine(string text)
 {
     for (int i = 0; i < scriptMapLines.Count; i++)
     {
         text = FindChineseTool.replaceWord(text, ",", DOT);
         if (scriptMapLines[i].orgText.Contains(text))
         {
             return(scriptMapLines[i]);
         }
     }
     return(null);
 }
Example #3
0
    void SaveMapFile(string path, bool merge)
    {
        if (merge && !MergeLines())//合并
        {
            Debug.Log("没有变动无需保存");
            state = OptStatus.None;
            return;
        }
        StringBuilder sb = new StringBuilder();

        sb.Append("id"); sb.Append(",");
        sb.Append("path"); sb.Append(",");
        sb.Append("line"); sb.Append(",");
        sb.Append("zh_cn"); sb.Append(",");
        sb.Append("zh_tw"); sb.Append("\n");
        List <ScriptLineVo> lines = scriptMapLines;
        List <string>       texts = new List <string>();

        for (int i = 0; i < lines.Count; i++)
        {
            ScriptLineVo line = lines[i];
            sb.Append(line.id);
            sb.Append(",");
            sb.Append(line.path);
            sb.Append(",");
            sb.Append(line.lineNum);
            sb.Append(",");
            line.orgText[0] = FindChineseTool.replaceWord(line.orgText[0], ",", DOT);
            sb.Append(line.orgText[0]);
            sb.Append(",");
            if (line.zh_tw == null)
            {
                sb.Append(LangguageTools.To_zh_tc(line.orgText[0]));
            }
            else
            {
                sb.Append(line.zh_tw);
            }
            sb.Append("\n");
        }
        if (File.Exists(path))
        {
            File.Delete(path);
        }
        FileUitl.SaveUTF8TextFile(path, sb.ToString());
        Debug.Log("保存成功!");
        if (merge)
        {
            state = OptStatus.None;
        }
    }
Example #4
0
 void OnGUI()
 {
     EditorGUILayout.Space();
     _scritpPath = EditorGUILayout.TextField("代码路径", _scritpPath);
     _devPath    = EditorGUILayout.TextField("VS2013路径", _devPath);
     _csvPath    = EditorGUILayout.TextField("CSV路径", _csvPath);
     if (state == OptStatus.None && GUILayout.Button("加载映射表", GUILayout.Width(200)))
     {
         if (File.Exists(_csvPath))
         {
             scriptMapLines = FindChineseTool.OpenSciptLines(_csvPath, ref _last_s_id);
         }
         else
         {
             scriptMapLines = new List <ScriptLineVo>();
         }
         _last_s_id = _last_s_id == 0 ? 100000 : _last_s_id;
         state      = OptStatus.Ready;
     }
     if ((state == OptStatus.Ready || state == OptStatus.Complete) && GUILayout.Button("扫描包含中文的代码", GUILayout.Width(200)))
     {
         state          = OptStatus.Start;
         newScriptLines = new List <ScriptLineVo>();
         DoSearch(Application.dataPath + _scritpPath);
     }
     //if (state == OptStatus.Complete && GUILayout.Button("生成代码国际化映射表", GUILayout.Width(200)))
     {
         //SaveMapFile(_csvPath,true);
     }
     //if (scriptMapLines != null && GUILayout.Button("批量替换中文代码", GUILayout.Width(200)))
     {
         //ReplaceScript();
     }
     if (scriptMapLines != null && GUILayout.Button("重新生成正式映射文件", GUILayout.Width(200)))
     {
         reSaveOfficialMapFile(Application.dataPath + _appPath);
     }
     if (scriptMapLines != null)
     {
         temp_id   = EditorGUILayout.TextField("ID", temp_id);
         tempZh_cn = EditorGUILayout.TextField("简体", tempZh_cn);
         EditorGUILayout.BeginHorizontal();
         if (GUILayout.Button("查看id对应的中文"))
         {
             int id = int.Parse(temp_id);
             if (id > 100000)
             {
                 ScriptLineVo line = GetLine(id);
                 if (line != null)
                 {
                     tempZh_cn = line.orgText[0];
                 }
                 else
                 {
                     Debug.Log("条目找不到");
                 }
             }
         }
         if (GUILayout.Button("保存对应ID的条目"))
         {
             int id = int.Parse(temp_id);
             if (id > 100000 && !string.IsNullOrEmpty(tempZh_cn))
             {
                 ScriptLineVo line = GetLine(id);
                 if (line == null)
                 {
                     ScriptLineVo oldLine = GetOldLine(tempZh_cn);
                     if (oldLine == null)
                     {
                         line    = new ScriptLineVo("", "", "");
                         line.id = id;
                         line.orgText.Add(tempZh_cn);
                         line.zh_cn = tempZh_cn;
                         scriptMapLines.Add(line);
                         SaveMapFile(_csvPath, false);
                         Debug.Log("新增条目");
                     }
                     else
                     {
                         Debug.LogError("该条目已经存在 id为:" + oldLine.id);
                         this.ShowNotification(new GUIContent("该条目已经存在 id为:" + oldLine.id));
                     }
                 }
                 else
                 {
                     line.orgText[0] = tempZh_cn;
                     line.zh_tw      = null;
                     Debug.Log("修改条目");
                     SaveMapFile(_csvPath, false);
                 }
             }
         }
         EditorGUILayout.EndHorizontal();
     }
     ShowOtherLines();
 }