完善一下lua脚本中文检查工具

This commit is contained in:
chenxi 2023-06-20 20:19:05 +08:00
parent 86949e1dc5
commit 165b3e332e

View File

@ -21,11 +21,12 @@ namespace BFEditor.Resource
private static string excludeDir = Application.dataPath + "/Developer/lua/app/config"; private static string excludeDir = Application.dataPath + "/Developer/lua/app/config";
private const char DOUBLE_QUOTES = '"'; private const char DOUBLE_QUOTES = '"';
private const char SINGLE_QUOTE = '\''; private const char SINGLE_QUOTE = '\'';
public static List<LuaCheckResult> ResultList = new List<LuaCheckResult>(); public static List<LuaCheckResult> ResultList = new List<LuaCheckResult>();
// private static Regex reg = new Regex(@".*[\u4e00-\u9fa5]+"); // 汉字 // private static Regex reg = new Regex(@".*[\u4e00-\u9fa5]+"); // 汉字
private static Regex reg = new Regex(@".*[\u0391-\uffe5]+"); //双字节字符(汉字+符号) private static Regex reg = new Regex(@".*[\u0391-\uffe5]+"); //双字节字符(汉字+符号)
private static HashSet<string> ExcludeFileName = new HashSet<string> {
"first_text.lua", "gm_const.lua", "dev_tool_list_ui.lua", "gm_tool_ui.lua"
};
public static void CheckAll(Action<bool> checkOverAction) public static void CheckAll(Action<bool> checkOverAction)
{ {
Clear(); Clear();
@ -39,7 +40,11 @@ namespace BFEditor.Resource
{ {
continue; continue;
} }
if (fileInfo.DirectoryName.Contains(excludeDir)) if (fileInfo.DirectoryName.Replace("\\", "/").Contains(excludeDir))
{
continue;
}
if (ExcludeFileName.Contains(fileInfo.Name))
{ {
continue; continue;
} }
@ -75,11 +80,15 @@ namespace BFEditor.Resource
} }
if (match != Match.Empty) if (match != Match.Empty)
{ {
LuaCheckResult checkResult; index = content.IndexOf("Logger.log");
checkResult.content = content; if (index < 0)
checkResult.line = string.Format("第{0}行:", lineNum); {
checkResult.path = fileInfo.FullName; LuaCheckResult checkResult;
ResultList.Add(checkResult); checkResult.content = content;
checkResult.line = string.Format("第{0}行:", lineNum);
checkResult.path = fileInfo.FullName;
ResultList.Add(checkResult);
}
} }
} }
} }