aboutsummaryrefslogtreecommitdiff
path: root/BatchGrfToJson/Program.cs
diff options
context:
space:
mode:
Diffstat (limited to 'BatchGrfToJson/Program.cs')
-rw-r--r--BatchGrfToJson/Program.cs19
1 files changed, 19 insertions, 0 deletions
diff --git a/BatchGrfToJson/Program.cs b/BatchGrfToJson/Program.cs
new file mode 100644
index 0000000..4c8793f
--- /dev/null
+++ b/BatchGrfToJson/Program.cs
@@ -0,0 +1,19 @@
+// See https://aka.ms/new-console-template for more information
+using System.Text.Json;
+using OMI.Formats.GameRule;
+using OMI.Workers.GameRule;
+
+string dir = args[0];
+string[] files = Directory.GetFiles(dir, "*.grf", SearchOption.TopDirectoryOnly);
+
+foreach(string filename in files) {
+ GameRuleFileReader reader = new GameRuleFileReader(0);
+ GameRuleFile grf = reader.FromFile(filename);
+
+ var options = new JsonSerializerOptions();
+ options.WriteIndented = true;
+ var json = JsonSerializer.Serialize(grf.Root.ChildRules, options);
+
+ File.WriteAllText(filename+".json", json);
+ Console.WriteLine("Processed "+filename);
+} \ No newline at end of file