I had an idea for an xml concatenate utility to assist with updating mods to new versions of Fallen Enchantress as well as making mods compatible with other mods. Is this something that would be helpful?
The idea is when you mod an XML file, you make a new XML file of the same name (in a different directory) that only contains your changes (as well as the hierarchical nodes above those changes). The Concatenate utility will combine this change file with the main file from the Fallen Enchantress directory. So if FE had a file that looked like:
Code: xml
- <?xml version="1.0" encoding="utf-8"?>
- <ElementalDefinitions>
- <ElementalDefs>
- <RandomPlacementRequirementDef InternalName="ResourceHoard_Rediculous">
- <ObjectType>ResourceHoard</ObjectType>
- <DisplayName>Rediculous</DisplayName>
- <ObjectsPerLandTile>0.14</ObjectsPerLandTile>
- <DistanceBetweenObjects>2</DistanceBetweenObjects>
- <DistanceBetweenObjectTypes>2</DistanceBetweenObjectTypes>
- <MaxObjectsPerSector>0</MaxObjectsPerSector>
- </RandomPlacementRequirementDef>
- </ElementalDefs>
- </ElementalDefinitions>
... and you wanted to turn down the ObjectsPerLandTile, you would create a file that looks like:
Code: xml
- <?xml version="1.0" encoding="utf-8"?>
- <ElementalDefinitions>
- <ElementalDefs>
- <RandomPlacementRequirementDef InternalName="ResourceHoard_Rediculous">
- <ObjectsPerLandTile>0.10</ObjectsPerLandTile>
- </RandomPlacementRequirementDef>
- </ElementalDefs>
- </ElementalDefinitions>
Then whenever a new version of FE is released, you would run the concatenate utility and it would generate a new XML file with all the information from the original but the changes from the change file. This also works with integrating changes from multiple change files, or you can set the FE base directory to point to the xml files from another mod and try to make your mod compatible with the other (no guarantees).
It works on the following principles:
- For each XML file in the FE directory, it will check to see if a matching filename exists in the change file directories. It will run the concatenate on any files with matching names.
- It uses the original XML file as the base. At a minimum it will contain all the fields from the original file.
- A unique node is identified by its position in the hierarchy, its name, and its attribute.
- For each node in the change file, it will try to find the same node in the xml file based on the above criteria. If that node has no child nodes, it will replace the innertext (0.14 in the above example) with the innertext from the change file (0.10).
- If the node is not found in original file, it will create a new node.
- Resultant files are saved in the selected target directory.
At this point, I thought it would be a good excercise to learn how to use the XML classes in .NET (it requires .NET Framework 4.0 to be installed, btw), so I went ahead and built it. But I didn't do any real testing, so there are probably bugs. I thought I'd go ahead and make it available, and if this ends up being useful to people I might come back sometime and work out whatever kinks are found.
In case it isn't obvious, I have no affiliation with Stardock, and this application is "Use at own risk," meaning by using this you agree not to hold me responsible for any damages caused by this application.
*Edit*
It occurs to me that it's easy to miss the "External Link" link at the top of this post, so here's the link again: https://dl.dropbox.com/u/35106869/XMLConcatenate.zip
This was created safe, but one should always run a virus scan on any files downloaded anyway.