Skip to content

Commit

Permalink
Added compatibility for .frdt files
Browse files Browse the repository at this point in the history
Also cleaned up the code a little
  • Loading branch information
Lexevolution committed Jan 26, 2024
1 parent 59ff123 commit 9443a42
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
11 changes: 4 additions & 7 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static bool ToJSON(Dictionary<string, Assembly> libraries)
{
OpenFileDialog ofd = new OpenFileDialog()
{
Filter = "Resonite DataTree File (*.brson;*.lz4bson;*.7zbson)|*.brson;*.lz4bson;*.7zbson",
Filter = "Resonite DataTree File (*.frdt;*.brson;*.lz4bson;*.7zbson)|*.frdt;*.brson;*.lz4bson;*.7zbson",
Title = "Choose a DataTree file for conversion",
CheckFileExists = true,
CheckPathExists = true,
Expand Down Expand Up @@ -124,13 +124,10 @@ static bool ToJSON(Dictionary<string, Assembly> libraries)
StreamWriter fileStream = File.CreateText(save.FileName);

libraries.TryGetValue("Newtonsoft.Json", out Assembly NewtonsoftJson);
Console.WriteLine(NewtonsoftJson.GetTypes());
ConstructorInfo aaaaaa = NewtonsoftJson.GetType("Newtonsoft.Json.JsonTextWriter").GetConstructor(new Type[] {typeof(TextWriter)});
object testy = aaaaaa.Invoke(new object[] { fileStream });
//object testy = NewtonsoftJson.GetType("JsonTextWriter").GetConstructor(new Type[] { NewtonsoftJson.GetType("Newtonsoft.Json.JsonTextWriter") }).Invoke(null, new object[] { fileStream });
//JsonTextWriter test = new JsonTextWriter(fileStream);
ConstructorInfo jsonTextWriterConstructor = NewtonsoftJson.GetType("Newtonsoft.Json.JsonTextWriter").GetConstructor(new Type[] {typeof(TextWriter)});
object jsonTextWriter = jsonTextWriterConstructor.Invoke(new object[] { fileStream });
var writemethod = dataTreeConverter.GetMethod("Write", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
writemethod.Invoke(null, new object[] { convert, testy });
writemethod.Invoke(null, new object[] { convert, jsonTextWriter });

fileStream.Dispose();
fileStream.Close();
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Resonite DataTree Converter

This Windows tool allows you to convert any Resonite DataTree object file (.brson, .7zbson, .lz4bson) to JSON and vice-versa.
This Windows tool allows you to convert any Resonite DataTree object file (.frdt, .brson, .7zbson, .lz4bson) to JSON and vice-versa.
(To save a json file back to .frdt, save it as any other file type, then rename the extension. Yes, that is how it works.)

This tool uses Resonite's libraries to convert them, so it sohuld hopefully work for the forseeable future. This tool saves the location that you selected for Resonite in `%LOCALAPPDATA%/Lexevolution/Resonite DataTree Converter/app.config`.

0 comments on commit 9443a42

Please sign in to comment.