static void Main(string[] args) { //Support UTF-8 Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); //Parse event file var parsed = CWTools.Parser.CKParser.parseEventFile("./testevent.txt"); var eventFile = parsed.GetResult(); //"Process" result into nicer format var processed = CK2Process.processEventFile(eventFile); //Find interesting event var myEvent = processed.Events.FirstOrDefault(x => x.ID == "test.1"); //Add is_triggered_only = true var leaf = new Leaf("is_triggered_only", Value.NewBool(true)); myEvent.AllChildren.Add(Child.NewLeafC(leaf)); // or // myEvent.AllChildren.Add(Leaf.Create("is_triggered_only", Value.NewBool(true))); //Output var output = processed.ToRaw; Console.WriteLine(CKPrinter.printKeyValueList(output, 0)); PrintfModule .PrintFormatLine( new PrintfFormat <FSharpFunc <FSharpList <Statement>, Unit>, TextWriter, Unit, Unit, FSharpList <Statement> >("%A")) .Invoke(output); }
static void Main(string[] args) { //Support UTF-8 Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); //Parse event file // var parsed = CWTools.Parser.CKParser.parseEventFile("./testevent.txt"); var text2 = File.ReadAllText("./testevent2.txt"); var parsed2 = CWTools.CSharp.Parsers.ParseScriptFile("testevent2.txt", text2); var eventFile2 = parsed2.GetError(); Console.WriteLine(eventFile2.ErrorMessage); //Parse event file // var parsed = CWTools.Parser.CKParser.parseEventFile("./testevent.txt"); var text = File.ReadAllText("./testevent.txt"); var parsed = CWTools.CSharp.Parsers.ParseScriptFile("testevent.txt", text); var eventFile = parsed.GetResult(); //"Process" result into nicer format // var processed = CK2Process.processEventFile(eventFile); var processed = CWTools.CSharp.Parsers.ProcessStatements("testevent.txt", "./testevent.txt", eventFile); //Find interesting event var myEvent = processed.Nodes.FirstOrDefault(x => x.TagText("id") == "test.1"); //Add is_triggered_only = true var leaf = new Leaf(KeyValueItem.NewKeyValueItem(Key.NewKey("is_triggered_only"), Value.NewBool(true), Operator.Equals), FSharpOption <range> .None); myEvent.AllChildren.Add(Child.NewLeafC(leaf)); // or // myEvent.AllChildren.Add(Leaf.Create("is_triggered_only", Value.NewBool(true))); //Output var output = processed.ToRaw; Console.WriteLine(CKPrinter.api.prettyPrintStatement.Invoke(output)); Console.WriteLine(output.PrettyPrint()); PrintfModule .PrintFormatLine( new PrintfFormat <FSharpFunc <Statement, Unit>, TextWriter, Unit, Unit, Statement>("%A")) .Invoke(output); var test = processed.Nodes.FirstOrDefault().ToRaw; Console.WriteLine(CKPrinter.api.prettyPrintStatement.Invoke(test)); }
static void Main(string[] args) { //Support UTF-8 Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); //Parse event file // var parsed = CWTools.Parser.CKParser.parseEventFile("./testevent.txt"); var text2 = File.ReadAllText("./testevent2.txt"); var parsed2 = CWTools.CSharp.Parsers.ParseScriptFile("testevent2.txt", text2); var eventFile2 = parsed2.GetError(); Console.WriteLine(eventFile2.ErrorMessage); //Parse event file // var parsed = CWTools.Parser.CKParser.parseEventFile("./testevent.txt"); var text = File.ReadAllText("./testevent.txt"); var parsed = CWTools.CSharp.Parsers.ParseScriptFile("testevent.txt", text); var eventFile = parsed.GetResult(); //"Process" result into nicer format // var processed = CK2Process.processEventFile(eventFile); var processed = CWTools.CSharp.Parsers.ProcessStatements("testevent.txt", "./testevent.txt", eventFile); //Find interesting event var myEvent = processed.Nodes.FirstOrDefault(x => x.TagText("id") == "test.1"); //Add is_triggered_only = true var leaf = new Leaf(KeyValueItem.NewKeyValueItem(Key.NewKey("is_triggered_only"), Value.NewBool(true), Operator.Equals), FSharpOption <range> .None); myEvent.AllChildren.Add(Child.NewLeafC(leaf)); // or // myEvent.AllChildren.Add(Leaf.Create("is_triggered_only", Value.NewBool(true))); //Output var output = processed.ToRaw; Console.WriteLine(CKPrinter.api.prettyPrintStatement.Invoke(output)); Console.WriteLine(output.PrettyPrint()); PrintfModule .PrintFormatLine( new PrintfFormat <FSharpFunc <Statement, Unit>, TextWriter, Unit, Unit, Statement>("%A")) .Invoke(output); var test = processed.Nodes.FirstOrDefault().ToRaw; Console.WriteLine(CKPrinter.api.prettyPrintStatement.Invoke(test)); var folders = CWTools.Utilities.Utils.getAllFoldersUnion(new List <string> { @"C:\Users\Thomas\Git\cwtools-stellaris-config" }); var files = folders.SelectMany(folder => Directory.EnumerateFiles(folder)) .Where(f => Path.GetExtension(f) == ".cwt" || Path.GetExtension(f) == ".log") .Select(f => Tuple.Create(f, File.ReadAllText(f))); var(rules, types, enums, complexenums, values) = CWTools.CSharp.Helpers.LoadAndInitializeFromConfigFiles(files, CWTools.Common.Game.STL); var typeInfo = Helpers.GetTypesInFile("events/testevent.txt", processed, types); PrintfModule .PrintFormatLine( new PrintfFormat <FSharpFunc <IReadOnlyDictionary <string, IReadOnlyCollection <CWTools.Common.NewScope.TypeDefInfo> >, Unit>, TextWriter, Unit, Unit, IReadOnlyDictionary <string, IReadOnlyCollection <CWTools.Common.NewScope.TypeDefInfo> > >("%A")) .Invoke(typeInfo); Console.WriteLine(typeInfo.ToString()); }