diff --git a/DungeonShooting_ExcelTool/ExcelGenerator.cs b/DungeonShooting_ExcelTool/ExcelGenerator.cs index 6ee11ed..b400039 100644 --- a/DungeonShooting_ExcelTool/ExcelGenerator.cs +++ b/DungeonShooting_ExcelTool/ExcelGenerator.cs @@ -7,11 +7,7 @@ { private const string CodeOutPath = "src/config/"; private const string JsonOutPath = "resource/config/"; -#if DEBUG private const string ExcelFilePath = "excelFile"; -#else - private const string ExcelFilePath = "excel/excelFile"; -#endif private static HashSet _excelNames = new HashSet(); @@ -62,15 +58,23 @@ public Dictionary ColumnType = new Dictionary(); public List> DataList = new List>(); } - + public static bool ExportExcel() { + return ExportExcel(ExcelFilePath, JsonOutPath, CodeOutPath); + } + + public static bool ExportExcel(string excelFilePath, string jsonOutPath, string codeOutPath) + { Console.WriteLine("当前路径: " + Environment.CurrentDirectory); + Console.WriteLine("excel路径: " + excelFilePath); + Console.WriteLine("json输出路径: " + jsonOutPath); + Console.WriteLine("cs代码输出路径: " + codeOutPath); try { var excelDataList = new List(); - var directoryInfo = new DirectoryInfo(ExcelFilePath); + var directoryInfo = new DirectoryInfo(excelFilePath); if (directoryInfo.Exists) { var fileInfos = directoryInfo.GetFiles(); @@ -101,29 +105,29 @@ return true; } - if (Directory.Exists(CodeOutPath)) + if (Directory.Exists(codeOutPath)) { - Directory.Delete(CodeOutPath, true); + Directory.Delete(codeOutPath, true); } - if (Directory.Exists(JsonOutPath)) + if (Directory.Exists(jsonOutPath)) { - Directory.Delete(JsonOutPath, true); + Directory.Delete(jsonOutPath, true); } - Directory.CreateDirectory(CodeOutPath); - Directory.CreateDirectory(JsonOutPath); + Directory.CreateDirectory(codeOutPath); + Directory.CreateDirectory(jsonOutPath); //保存配置和代码 foreach (var excelData in excelDataList) { - File.WriteAllText(CodeOutPath + "ExcelConfig_" + excelData.TableName + ".cs", excelData.OutCode); + File.WriteAllText(codeOutPath + "ExcelConfig_" + excelData.TableName + ".cs", excelData.OutCode); var config = new JsonSerializerOptions(); config.WriteIndented = true; - File.WriteAllText(JsonOutPath + excelData.TableName + ".json", JsonSerializer.Serialize(excelData.DataList, config)); + File.WriteAllText(jsonOutPath + excelData.TableName + ".json", JsonSerializer.Serialize(excelData.DataList, config)); } //生成加载代码 var code = GeneratorInitCode(excelDataList); - File.WriteAllText(CodeOutPath + "ExcelConfig.cs", code); + File.WriteAllText(codeOutPath + "ExcelConfig.cs", code); } catch (Exception e) { diff --git a/DungeonShooting_ExcelTool/Program.cs b/DungeonShooting_ExcelTool/Program.cs index 142920d..d6384c0 100644 --- a/DungeonShooting_ExcelTool/Program.cs +++ b/DungeonShooting_ExcelTool/Program.cs @@ -4,7 +4,17 @@ public static void Main(string[] args) { Console.WriteLine("准备导出excel表..."); - if (ExcelGenerator.ExportExcel()) + bool success; + if (args.Length >= 3) + { + success = ExcelGenerator.ExportExcel(args[0], args[1], args[2]); + } + else + { + success = ExcelGenerator.ExportExcel(); + } + + if (success) { Console.WriteLine("excel表导出成功!"); } diff --git a/DungeonShooting_Godot/excel/DungeonShooting_ExcelTool.dll b/DungeonShooting_Godot/excel/DungeonShooting_ExcelTool.dll index c2ed8e7..d8ba4b8 100644 --- a/DungeonShooting_Godot/excel/DungeonShooting_ExcelTool.dll +++ b/DungeonShooting_Godot/excel/DungeonShooting_ExcelTool.dll Binary files differ diff --git a/DungeonShooting_Godot/excel/DungeonShooting_ExcelTool.exe b/DungeonShooting_Godot/excel/DungeonShooting_ExcelTool.exe index c623fc8..bb1931a 100644 --- a/DungeonShooting_Godot/excel/DungeonShooting_ExcelTool.exe +++ b/DungeonShooting_Godot/excel/DungeonShooting_ExcelTool.exe Binary files differ diff --git a/DungeonShooting_Godot/excel/DungeonShooting_ExcelTool.pdb b/DungeonShooting_Godot/excel/DungeonShooting_ExcelTool.pdb index 3b1e68d..a963cf3 100644 --- a/DungeonShooting_Godot/excel/DungeonShooting_ExcelTool.pdb +++ b/DungeonShooting_Godot/excel/DungeonShooting_ExcelTool.pdb Binary files differ diff --git a/DungeonShooting_Godot/src/framework/generator/ExcelGenerator.cs b/DungeonShooting_Godot/src/framework/generator/ExcelGenerator.cs index 9558609..26d9357 100644 --- a/DungeonShooting_Godot/src/framework/generator/ExcelGenerator.cs +++ b/DungeonShooting_Godot/src/framework/generator/ExcelGenerator.cs @@ -11,7 +11,10 @@ public static void ExportExcel() { var arr = new Array(); - OS.Execute("excel/DungeonShooting_ExcelTool.exe", new string[0], arr); + var excelPath = "excel/excelFile/"; + var jsonPath = "resource/config/"; + var codePath = "src/config/"; + OS.Execute("excel/DungeonShooting_ExcelTool.exe", new string[] { excelPath, jsonPath, codePath }, arr); foreach (var message in arr) { GD.Print(message);