Skip to content

Commit

Permalink
add drag n drop
Browse files Browse the repository at this point in the history
update HKX2Library
  • Loading branch information
ret2end committed Jan 16, 2023
1 parent bad093d commit 02d3b39
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion HKX2Library
Submodule HKX2Library updated 609 files
15 changes: 13 additions & 2 deletions hkxconv/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,24 @@ internal class Program
{
static async Task<int> 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<ConvertFormat>(name: "-v", description: "Convert format.", getDefaultValue: () => ConvertFormat.xml);
var verboseOpt = new Option<bool>(name: "--verbose", description: "verbose", getDefaultValue: () => false);
var ignoreErrorOpt = new Option<bool>(name: "--ignore-cast-error", description: "ignore fail to cast error(output will missing data. use with caution.)", getDefaultValue: () => false);
var ignoreErrorOpt = new Option<bool>(name: "--ignore-cast-error", description: "ignore fail to cast error(output may missing data. use with caution.)", getDefaultValue: () => false);
var inputDirArg = new Argument<FileSystemInfo>("Input dir or file");
var outputDirArg = new Argument<FileSystemInfo>("Output dir or file", getDefaultValue: () => new DirectoryInfo("."));

Expand All @@ -32,7 +44,6 @@ static async Task<int> Main(string[] args)
{
cmd.Convert.ToFormat(input, output, format, verbose, ignoreErrorOpt);
}, convertFormatOpt, verboseOpt, ignoreErrorOpt, inputDirArg, outputDirArg);

return await rootCommand.InvokeAsync(args);
}
}
Expand Down
3 changes: 1 addition & 2 deletions hkxconv/cmd/Convert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ public enum ConvertFormat
{
xml = 0,
hkx = 1,
//win32 = 2,
}
public class Convert
{
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 02d3b39

Please sign in to comment.