Skip to content

Commit

Permalink
(WIP) inject proto and techtree
Browse files Browse the repository at this point in the history
  • Loading branch information
valorad committed Nov 24, 2020
1 parent 98dcaeb commit 9a9e05f
Showing 1 changed file with 67 additions and 33 deletions.
100 changes: 67 additions & 33 deletions tools/xml-inject/App/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -50,18 +51,14 @@ 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();
targetReader.Dispose();

}

string basePath = AppDomain.CurrentDomain.BaseDirectory;

public void InjectAbilities() {

InjectXMLToBottom(new InjectXMLParams() {
Expand Down Expand Up @@ -129,47 +126,84 @@ 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)

// Inject techtreey.xml (Add new content + Edit exixting node)

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}");
}

}

}
Expand Down

0 comments on commit 9a9e05f

Please # to comment.