123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- using System;
- using System.Diagnostics;
- using System.IO;
- namespace ResBuilder
- {
- class Program
- {
- const string luaFileRoot = @"UIEdit\res\ui_edit\lua";
- const string defLuaJitExePath = @"luajit\luajit.exe";
- const string uiConvertBinExe = @"UIEdit\2binnp.bat";
- const string uiRoot = @"UIEdit\res";
- const string uiXmlFileRootRelative = @"ui_edit\xmds_ui";
- const string uiResFileRootRelative = @"ui_edit\res";
- const string editorDataRoot = @"../data";
- static void Main(string[] args)
- {
- var root = "./";
- if (string.IsNullOrEmpty(root))
- {
- Console.WriteLine("error:找不到GameEditors目录!");
- Console.ReadKey();
- return;
- }
- var outPath = Path.Combine(root, "resBuilder/out/bin");
- var tmpPath = Path.Combine(root, "resBuilder/tmp");
- if (Directory.Exists(outPath))
- {
- Directory.Delete(outPath, true);
- }
- Directory.CreateDirectory(outPath);
- try
- {
- foreach (var argv in args)
- {
- Program.SetConfig(argv.Trim());
- }
-
- if (IsDoLua)
- {
- var luaSrcRoot = Path.Combine(root, luaFileRoot);
- var luaProcessedRoot = Path.Combine(outPath, "scr");
- var luaJitExePath = Path.Combine(root, defLuaJitExePath);
- Console.WriteLine("start -> process lua...");
- var luaProc = new LuaProcessor(luaSrcRoot, luaProcessedRoot, tmpPath, luaJitExePath);
- luaProc.Execute();
- Console.WriteLine(" end -> process lua...");
- if (IsPackLuaBin)
- {
- Console.WriteLine("start -> pack lua...");
- var luaBinPacker = new LuaBinPacker(luaProcessedRoot, outPath);
- luaBinPacker.Pack();
- Directory.Delete(luaProcessedRoot, true);
- Console.WriteLine(" end -> pack lua...");
- }
- }
-
- if (IsDoGameData)
- {
- Console.WriteLine("start -> pack editor ...");
- var editPacker = new EditorBinPacker(
- Path.Combine(root, editorDataRoot),
- outPath);
- editPacker.Pack();
- Console.WriteLine(" end -> pack editor data ...");
- }
-
- if (IsUIConvertBin)
- {
- Console.WriteLine("start -> ui convert bin ...");
- StartProcess(Path.Combine(root, uiConvertBinExe));
- Console.WriteLine(" end -> ui convert bin ...");
- }
-
- if (IsPackUIXml )
- {
- Console.WriteLine("start -> pack ui xml...");
- var uiXmlPacker = new UIXmlPacker(
- Path.Combine(root, uiRoot, uiXmlFileRootRelative),
- outPath, true);
- uiXmlPacker.Pack();
- Console.WriteLine(" end -> pack ui xml...");
- }
-
- if (IsDoUIRes)
- {
- var uiResOutPath = Path.Combine(root, "resBuilder/out");
- Console.WriteLine("start -> process ui res...");
- var urProc = new UIResProcessor(Path.Combine(root , uiRoot), uiResOutPath , uiResFileRootRelative);
- urProc.Execute();
- Console.WriteLine(" end -> process ui res...");
- if (IsPackUiRes)
- {
-
-
-
-
-
-
- }
- }
- }
- catch (Exception e)
- {
- var color = Console.ForegroundColor;
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine(e.Message);
- Console.WriteLine(e.StackTrace);
- Console.ForegroundColor = color;
- }
- if (IsPauseOnFinish)
- {
- Console.WriteLine("press any key to exit!");
- Console.ReadKey();
- }
- }
- public static bool IsPauseOnFinish = true;
- public static bool IsDoLua = false;
- public static bool IsJitLuaBytes = false;
- public static bool IsZipLuaBytes = false;
- public static bool IsPackLuaBin = false;
- public static bool IsDoGameData = true;
- public static bool IsPackUIXml = false;
- public static bool IsUIConvertBin = false;
- public static bool IsDoUIRes = false;
- public static bool IsPackUiRes = false;
- static void SetConfig(string arg)
- {
- if (arg.Equals("-!lua", StringComparison.OrdinalIgnoreCase))
- {
- IsDoLua = false;
- }
- else if (arg.Equals("-luajit", StringComparison.OrdinalIgnoreCase))
- {
- IsJitLuaBytes = true;
- }
- else if (arg.Equals("-luazip", StringComparison.OrdinalIgnoreCase))
- {
- IsZipLuaBytes = true;
- }
- else if (arg.Equals("-luapack", StringComparison.OrdinalIgnoreCase))
- {
- IsPackLuaBin = true;
- }
- else if (arg.Equals("-!gamedata", StringComparison.OrdinalIgnoreCase))
- {
- IsDoGameData = false;
- }
- else if (arg.Equals("-uixmlpack", StringComparison.OrdinalIgnoreCase))
- {
- IsPackUIXml = true;
- }
- else if (arg.Equals("-!uiconvertbin", StringComparison.OrdinalIgnoreCase))
- {
- IsUIConvertBin = false;
- }
- else if (arg.Equals("-!uires", StringComparison.OrdinalIgnoreCase))
- {
- IsDoUIRes = false;
- }
- else if (arg.Equals("-uirespack", StringComparison.OrdinalIgnoreCase))
- {
- IsPackUiRes = true;
- }
- else if (arg.Equals("-np", StringComparison.OrdinalIgnoreCase))
- {
- IsPauseOnFinish = false;
- }
- }
- public static void StartProcess(string luajitPath, string args = null)
- {
- var start = new ProcessStartInfo(luajitPath);
- start.WorkingDirectory = Path.GetDirectoryName(luajitPath);
- start.CreateNoWindow = false;
- start.UseShellExecute = false;
- start.RedirectStandardInput = false;
- start.RedirectStandardOutput = false;
- if (args != null)
- {
- start.Arguments = args;
- }
- var pro = Process.Start(start);
- pro.WaitForExit();
- }
- }
- }
|