diff --git a/tools/xml-inject/App/Program.cs b/tools/xml-inject/App/Program.cs index 9c98e78..8aa65d0 100644 --- a/tools/xml-inject/App/Program.cs +++ b/tools/xml-inject/App/Program.cs @@ -29,11 +29,12 @@ class InjectXMLParams { class Injection { - public void InjectXMLToBottom(InjectXMLParams settings) { - - var xmlSettings = new XmlReaderSettings(); - xmlSettings.IgnoreComments = true; + string basePath = AppDomain.CurrentDomain.BaseDirectory; + XmlReaderSettings xmlSettings = new XmlReaderSettings() { + IgnoreComments = true, + }; + public void InjectXMLToBottom(InjectXMLParams settings) { XmlReader sourceReader = XmlReader.Create(settings.SourceFilePath, xmlSettings); var source = new XmlDocument(); @@ -50,9 +51,7 @@ public void InjectXMLToBottom(InjectXMLParams settings) { } Directory.CreateDirectory(settings.OutputFolder); - string outputPath = Path.GetFullPath(Path.Combine(settings.OutputFolder, settings.OutputFileName)); - File.WriteAllText(outputPath, target.OuterXml); sourceReader.Dispose(); @@ -60,8 +59,6 @@ public void InjectXMLToBottom(InjectXMLParams settings) { } - string basePath = AppDomain.CurrentDomain.BaseDirectory; - public void InjectAbilities() { InjectXMLToBottom(new InjectXMLParams() { @@ -129,6 +126,64 @@ public void InjectI18nStrings() { } + public void InjectProtos() { + + XmlReader reader = XmlReader.Create(Path.GetFullPath(Path.Combine(".", "workbench", "src", "protoy.xml"), basePath), xmlSettings); + var source = new XmlDocument(); + source.Load(reader); + + reader = XmlReader.Create(Path.GetFullPath(Path.Combine(".", "workbench", "in", "protoy.xml"), basePath), xmlSettings); + var target = new XmlDocument(); + target.Load(reader); + + + // Offering explorers the privileges to build Hero Structures + + var explorerStore = new XmlDocument(); // TODO: Write this map + + // Town Center can build wagons to deploy the Hero Structures + + XmlNode townCenter = target.SelectSingleNode("/proto/unit@id='294'"); + + // Attach the new units to the bottom + + + + + string outputFolder = Path.GetFullPath(Path.Combine(".", "workbench", "out"), basePath); + Directory.CreateDirectory(outputFolder); + string outputPath = Path.GetFullPath(Path.Combine(outputFolder, "protoy.xml")); + File.WriteAllText(outputPath, target.OuterXml); + + reader.Dispose(); + } + + public void InjectTechtrees() { + + XmlReader reader = XmlReader.Create(Path.GetFullPath(Path.Combine(".", "workbench", "src", "techtreey.xml"), basePath), xmlSettings); + var source = new XmlDocument(); + source.Load(reader); + + reader = XmlReader.Create(Path.GetFullPath(Path.Combine(".", "workbench", "in", "techtreey.xml"), basePath), xmlSettings); + var target = new XmlDocument(); + target.Load(reader); + + // Countries enable their own heroes + var civStore = new XmlDocument(); // TODO: Write this map + + // Attach the new techs to the bottom + + + + + string outputFolder = Path.GetFullPath(Path.Combine(".", "workbench", "out"), basePath); + Directory.CreateDirectory(outputFolder); + string outputPath = Path.GetFullPath(Path.Combine(outputFolder, "techtreey.xml")); + File.WriteAllText(outputPath, target.OuterXml); + + reader.Dispose(); + + } // Inject protoy.xml (Add new content + Edit exixting node) @@ -136,40 +191,19 @@ public void InjectI18nStrings() { public Injection() { - // Inject abilities/abilities.xml (Just add new content to bottom) try { - InjectAbilities(); + // InjectAbilities(); + // InjectPowers(); + // InjectI18nStrings(); + InjectProtos(); } catch (System.Exception e) { Console.WriteLine($"Error!: {e}"); } - - - // Inject abilities/powers.xml (Just add new content to bottom) - try - { - InjectPowers(); - } - catch (System.Exception e) - { - Console.WriteLine($"Error!: {e}"); - } - - // Inject strings/English/stringtabley.xml (Just add new content to bottom) - // Inject strings/SimplifiedChinese/stringtabley.xml (Just add new content to bottom) - try - { - InjectI18nStrings(); - } - catch (System.Exception e) - { - Console.WriteLine($"Error!: {e}"); - } - } }