Skip to content

Commit 11dadfa

Browse files
committed
Modified PluginDecompiler to use an XML for settings (and automatically generate it if missing)
Added SharpZipLib.dll to make compiling easier
1 parent f3807f7 commit 11dadfa

2 files changed

Lines changed: 46 additions & 21 deletions

File tree

ICSharpCode.SharpZipLib.dll

188 KB
Binary file not shown.

PluginDecompiler/Program.cs

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,54 @@
77
using System.IO;
88
using System.IO.MemoryMappedFiles;
99
using Microsoft.Win32;
10+
using System.Xml.Linq;
11+
using System.Reflection;
1012

1113
class Program
1214
{
1315
static void Main(string[] args)
1416
{
15-
if (File.Exists("PluginSearchLocations.csv"))
17+
bool useFormIDStartPoint = false;
18+
uint formIDStartPoint = 0;
19+
20+
if (!File.Exists("PluginDecompilerConfig.xml"))
1621
{
17-
using (FileStream stream = new FileStream("PluginSearchLocations.csv", FileMode.Open, FileAccess.Read))
18-
using (StreamReader reader = new StreamReader(stream))
19-
{
20-
string line;
21-
string file;
22-
bool recursive;
22+
XDocument configXML = new XDocument();
23+
XElement settingsRoot = new XElement("Settings");
24+
XElement ele;
25+
string localDirectory = Path.GetDirectoryName( Assembly.GetExecutingAssembly().Location );
2326

24-
while(!reader.EndOfStream)
25-
{
26-
line = reader.ReadLine();
27-
var split = line.Split(',');
28-
if (split.Count() > 0)
29-
{
30-
file = split[0];
31-
if (split.Count() > 1)
32-
recursive = Boolean.Parse(split[1]);
33-
else
34-
recursive = false;
27+
configXML.Add(settingsRoot);
3528

36-
ElderScrollsPlugin.pluginLocations.Add(new KeyValuePair<string, bool>(file, recursive));
37-
}
38-
}
29+
ele = new XElement("PluginSearchLocations");
30+
ele.Add(new XComment("A list of places where PluginDecompiler should search for parent plugins."));
31+
ele.Add(new XComment("Element (\"LocalDirectory\" in the example below) name does not matter."));
32+
ele.Add(new XComment("Directory is an absoulte file path, Recursive (true/false) is whether or not it should search sub folders for plugins (great for Mod Organizer users)."));
33+
ele.Add(new XElement("LocalDirectory", new XElement("Directory", localDirectory), new XElement("Recursive", false)));
34+
settingsRoot.Add(ele);
35+
36+
ele = new XElement("FormIDStartPoint");
37+
ele.Add(new XComment("PluginDecompiler can tell the GECK and FNVEdit to start numbering formIDs at a specific point."));
38+
ele.Add(new XComment("This is good for collaboration and group projects to minimize formID conflicts when adding new forms."));
39+
ele.Add(new XComment("Enabled is a simple true/false value. StartPoint is read as a hexidecimal number, limited to 6 digits."));
40+
ele.Add(new XElement("Enabled", false));
41+
ele.Add(new XElement("StartPoint", "000000"));
42+
settingsRoot.Add(ele);
43+
44+
configXML.Save("PluginDecompilerConfig.xml");
45+
}
46+
else
47+
{
48+
XDocument configXML = XDocument.Load("PluginDecompilerConfig.xml");
49+
50+
foreach (XElement ele in configXML.Element("Settings").Element("PluginSearchLocations").Elements())
51+
{
52+
if (ele.Element("Directory") != null && ele.Element("Recursive") != null)
53+
ElderScrollsPlugin.pluginLocations.Add(new KeyValuePair<string, bool>(ele.Element("Directory").Value, ele.Element("Recursive").ToBoolean()));
3954
}
55+
56+
useFormIDStartPoint = configXML.Element("Settings").Element("FormIDStartPoint").Element("Enabled").ToBoolean();
57+
formIDStartPoint = UInt32.Parse(configXML.Element("Settings").Element("FormIDStartPoint").Element("StartPoint").Value, System.Globalization.NumberStyles.HexNumber);
4058
}
4159

4260
foreach (string file in args)
@@ -53,6 +71,13 @@ static void Main(string[] args)
5371
else
5472
outFile = Path.ChangeExtension(file, "esp");
5573

74+
if (useFormIDStartPoint)
75+
{
76+
var header = plugin.Header.Record as ESPSharp.Records.Header;
77+
header.FileHeader.NextObjectID = formIDStartPoint;
78+
plugin.Header = new RecordView(header);
79+
}
80+
5681
using (FileStream stream = new FileStream(outFile, FileMode.Create, FileAccess.ReadWrite))
5782
using (ESPWriter writer = new ESPWriter(stream))
5883
{

0 commit comments

Comments
 (0)