完善一下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;
} }
@ -74,6 +79,9 @@ namespace BFEditor.Resource
match = reg.Match(content); match = reg.Match(content);
} }
if (match != Match.Empty) if (match != Match.Empty)
{
index = content.IndexOf("Logger.log");
if (index < 0)
{ {
LuaCheckResult checkResult; LuaCheckResult checkResult;
checkResult.content = content; checkResult.content = content;
@ -84,6 +92,7 @@ namespace BFEditor.Resource
} }
} }
} }
}
if (checkOverAction != null) if (checkOverAction != null)
checkOverAction(ResultList.Count == 0); checkOverAction(ResultList.Count == 0);
} }