aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsowgro <tpoke.ferrari@gmail.com>2025-05-18 03:28:57 -0400
committersowgro <tpoke.ferrari@gmail.com>2025-05-18 03:28:57 -0400
commit3e7f12dd5bdc57f303471c758df6df0473abb136 (patch)
tree6a4f03778db3fd3f68ba161df6c9e7ca4df5fc3d
downloadGrfToJson-3e7f12dd5bdc57f303471c758df6df0473abb136.tar.gz
GrfToJson-3e7f12dd5bdc57f303471c758df6df0473abb136.tar.bz2
GrfToJson-3e7f12dd5bdc57f303471c758df6df0473abb136.zip
Initial commit
-rw-r--r--.gitignore5
-rw-r--r--BatchGrfToJson/BatchGrfToJson.csproj10
-rw-r--r--BatchGrfToJson/Program.cs19
-rw-r--r--GrfToJson.sln8
4 files changed, 42 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..add57be
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+bin/
+obj/
+/packages/
+riderModule.iml
+/_ReSharper.Caches/ \ No newline at end of file
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 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <OutputType>Exe</OutputType>
+ <TargetFramework>net8.0</TargetFramework>
+ <ImplicitUsings>enable</ImplicitUsings>
+ <Nullable>enable</Nullable>
+ </PropertyGroup>
+
+</Project>
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
diff --git a/GrfToJson.sln b/GrfToJson.sln
new file mode 100644
index 0000000..a55ff74
--- /dev/null
+++ b/GrfToJson.sln
@@ -0,0 +1,8 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+EndGlobal