aboutsummaryrefslogtreecommitdiff
path: root/BatchGrfToJson/Program.cs
blob: 4c8793fa925558ec52abed54cf6752ab05115b18 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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);
}