From 3e7f12dd5bdc57f303471c758df6df0473abb136 Mon Sep 17 00:00:00 2001 From: sowgro Date: Sun, 18 May 2025 03:28:57 -0400 Subject: Initial commit --- BatchGrfToJson/BatchGrfToJson.csproj | 10 ++++++++++ BatchGrfToJson/Program.cs | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 BatchGrfToJson/BatchGrfToJson.csproj create mode 100644 BatchGrfToJson/Program.cs (limited to 'BatchGrfToJson') diff --git a/BatchGrfToJson/BatchGrfToJson.csproj b/BatchGrfToJson/BatchGrfToJson.csproj new file mode 100644 index 0000000..2f4fc77 --- /dev/null +++ b/BatchGrfToJson/BatchGrfToJson.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + 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 -- cgit v1.2.3