diff --git a/HKX2Library b/HKX2Library index 5ebd913..5156f4f 160000 --- a/HKX2Library +++ b/HKX2Library @@ -1 +1 @@ -Subproject commit 5ebd913bc4f188bf196a043178568a1e26b7ea49 +Subproject commit 5156f4f21fa04fad31ab39b07db83053941e09a5 diff --git a/hkxconv/Program.cs b/hkxconv/Program.cs index ef09739..99d45e4 100644 --- a/hkxconv/Program.cs +++ b/hkxconv/Program.cs @@ -8,12 +8,24 @@ internal class Program { static async Task Main(string[] args) { + if (args.Length == 1 && File.Exists(args[0])) + { + // drag n drop + var filePath = args[0]; + var ext = Path.GetExtension(filePath); + args = ext switch + { + ".xml" => new[] { "convert", "-v", "hkx", filePath }, + ".hkx" => new[] { "convert", "-v", "xml", filePath }, + _ => args + }; + } var rootCommand = new RootCommand("Tool for convert HKX file to XML"); var convertFormatOpt = new Option(name: "-v", description: "Convert format.", getDefaultValue: () => ConvertFormat.xml); var verboseOpt = new Option(name: "--verbose", description: "verbose", getDefaultValue: () => false); - var ignoreErrorOpt = new Option(name: "--ignore-cast-error", description: "ignore fail to cast error(output will missing data. use with caution.)", getDefaultValue: () => false); + var ignoreErrorOpt = new Option(name: "--ignore-cast-error", description: "ignore fail to cast error(output may missing data. use with caution.)", getDefaultValue: () => false); var inputDirArg = new Argument("Input dir or file"); var outputDirArg = new Argument("Output dir or file", getDefaultValue: () => new DirectoryInfo(".")); @@ -32,7 +44,6 @@ static async Task Main(string[] args) { cmd.Convert.ToFormat(input, output, format, verbose, ignoreErrorOpt); }, convertFormatOpt, verboseOpt, ignoreErrorOpt, inputDirArg, outputDirArg); - return await rootCommand.InvokeAsync(args); } } diff --git a/hkxconv/cmd/Convert.cs b/hkxconv/cmd/Convert.cs index 8a1a641..816dc5d 100644 --- a/hkxconv/cmd/Convert.cs +++ b/hkxconv/cmd/Convert.cs @@ -6,7 +6,6 @@ public enum ConvertFormat { xml = 0, hkx = 1, - //win32 = 2, } public class Convert { @@ -98,7 +97,7 @@ public static int ConvertTo(FileInfo inFile, FileInfo outFile, ConvertFormat for else if (format == ConvertFormat.hkx && Path.HasExtension(".xml")) { var xd = new XmlDeserializer(); - IHavokObject rootObject = xd.Deserialize(inFile.OpenRead(), header); + IHavokObject rootObject = xd.Deserialize(inFile.OpenRead(), header, ignoreError); var bw = new BinaryWriterEx(outFile.Create()); var s = new PackFileSerializer();