diff --git a/GK6X/Program.cs b/GK6X/Program.cs index 8f73cda..570f234 100644 --- a/GK6X/Program.cs +++ b/GK6X/Program.cs @@ -512,12 +512,20 @@ private static void UpdateDataFiles(string srcDir) } } + // Create a merged 'driver' directory containing all the data from all distributors (for the WebGUI) + string combinedDriverDir = Path.Combine(srcDir, "driver_combined"); + srcDir = GetDriverDir(srcDir); if (string.IsNullOrEmpty(srcDir)) { return; } + if (!Directory.Exists(combinedDriverDir)) + { + Directory.CreateDirectory(combinedDriverDir); + } + string dstDir = Path.Combine(Program.BasePath, "Data"); string leDir = Path.Combine(srcDir, "res", "data", "le"); string deviceDir = Path.Combine(srcDir, "device"); @@ -547,16 +555,20 @@ private static void UpdateDataFiles(string srcDir) string additionalDeviceDir = Path.Combine(additionalDir, "device"); if (Directory.Exists(additionalDeviceDir)) { - CopyFilesRecursively(new DirectoryInfo(additionalDeviceDir), new DirectoryInfo(Path.Combine(dstDir, "device"))); + CopyFilesRecursively(new DirectoryInfo(additionalDeviceDir), new DirectoryInfo(Path.Combine(dstDir, "device")), false); string additionalModelListFile = Path.Combine(additionalDeviceDir, "modellist.json"); if (File.Exists(additionalModelListFile)) { ReadModelList(additionalModelListFile, models); } } + + CopyFilesRecursively(new DirectoryInfo(additionalDir), new DirectoryInfo(combinedDriverDir), true); } CMFile.DumpLighting(leDir, Path.Combine(dstDir, "lighting")); - CopyFilesRecursively(new DirectoryInfo(deviceDir), new DirectoryInfo(Path.Combine(dstDir, "device"))); + CopyFilesRecursively(new DirectoryInfo(deviceDir), new DirectoryInfo(Path.Combine(dstDir, "device")), false); + + CopyFilesRecursively(new DirectoryInfo(srcDir), new DirectoryInfo(combinedDriverDir), true); // Combine modellist.json files ReadModelList(modelListFile, models); @@ -662,26 +674,29 @@ private static string CleanJson(string json) return result.ToString(); } - private static void CopyFilesRecursively(DirectoryInfo source, DirectoryInfo target) + private static void CopyFilesRecursively(DirectoryInfo source, DirectoryInfo target, bool all) { string[] extensions = { "json", "js" }; foreach (DirectoryInfo dir in source.GetDirectories()) { // "res" folder contains some data we don't want - if (dir.Name != "res") + if (all || dir.Name != "res") { // Remove the special case folder (TODO: Make this more generic) - CopyFilesRecursively(dir, target.CreateSubdirectory(dir.Name.Replace("(风控)", string.Empty))); + CopyFilesRecursively(dir, target.CreateSubdirectory(dir.Name.Replace("(风控)", string.Empty)), all); } } foreach (FileInfo file in source.GetFiles()) { - if (extensions.Contains(file.Extension.ToLower().TrimStart(new char[] { '.' }))) + if (all || extensions.Contains(file.Extension.ToLower().TrimStart(new char[] { '.' }))) { - file.CopyTo(Path.Combine(target.FullName, file.Name), true); + if (!file.Name.Contains("剑灵") && !file.Name.Contains("逆战")) + { + file.CopyTo(Path.Combine(target.FullName, file.Name), true); + } } } - if (target.GetFiles().Length == 0) + if (!all && target.GetFiles().Length == 0) { target.Delete(); } diff --git a/GK6X/WebGUI.cs b/GK6X/WebGUI.cs index b83c8f2..0ab2d4d 100644 --- a/GK6X/WebGUI.cs +++ b/GK6X/WebGUI.cs @@ -33,8 +33,14 @@ public static void Run() } if (server.IsRunning) { - Process.Start(url); - //Process.Start("chrome", "--incognito " + url); + try + { + Process.Start(url); + //Process.Start("chrome", "--incognito " + url); + } + catch + { + } } }