2016-03-29 12:11:58 -07:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Xml;
|
2016-03-18 01:17:39 -07:00
|
|
|
|
|
2016-03-28 02:06:14 -07:00
|
|
|
|
namespace WoD.Helper
|
2016-03-18 01:17:39 -07:00
|
|
|
|
{
|
|
|
|
|
|
class Remapping
|
|
|
|
|
|
{
|
2016-03-29 12:11:58 -07:00
|
|
|
|
public static Dictionary<string, string> MAME = new Dictionary<string, string>();
|
|
|
|
|
|
public static Dictionary<string, string> NoIntro = new Dictionary<string, string>();
|
|
|
|
|
|
public static Dictionary<string, string> Redump = new Dictionary<string, string>();
|
|
|
|
|
|
public static Dictionary<string, string> TOSEC = new Dictionary<string, string>();
|
|
|
|
|
|
public static Dictionary<string, string> TruRip = new Dictionary<string, string>();
|
2016-03-18 01:17:39 -07:00
|
|
|
|
|
|
|
|
|
|
public static void CreateRemappings()
|
|
|
|
|
|
{
|
2016-03-29 12:11:58 -07:00
|
|
|
|
// Create array of dictionary names
|
|
|
|
|
|
string[] remappings =
|
|
|
|
|
|
{
|
|
|
|
|
|
"MAME", "NoIntro", "Redump", "TOSEC", "TruRip",
|
|
|
|
|
|
};
|
2016-03-18 01:17:39 -07:00
|
|
|
|
|
2016-03-29 12:11:58 -07:00
|
|
|
|
// Loop through and add all remappings
|
|
|
|
|
|
foreach (string remapping in remappings)
|
|
|
|
|
|
{
|
|
|
|
|
|
RemappingHelper(remapping);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-03-18 01:17:39 -07:00
|
|
|
|
|
2016-03-29 12:11:58 -07:00
|
|
|
|
private static void RemappingHelper(string mapping)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Read in remapping from file
|
|
|
|
|
|
XmlDocument doc = new XmlDocument();
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
doc.LoadXml(File.ReadAllText("Mappings/" + mapping + ".xml"));
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (XmlException ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
Console.WriteLine(mapping + " remappings could not be loaded! " + ex.ToString());
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2016-03-18 01:17:39 -07:00
|
|
|
|
|
2016-03-29 12:11:58 -07:00
|
|
|
|
// Get the mappings parent node
|
|
|
|
|
|
XmlNode node = doc.FirstChild;
|
|
|
|
|
|
while (node.Name != "mappings")
|
|
|
|
|
|
{
|
|
|
|
|
|
node = node.NextSibling;
|
|
|
|
|
|
}
|
2016-03-18 01:17:39 -07:00
|
|
|
|
|
2016-03-29 12:11:58 -07:00
|
|
|
|
// Get the first mapping node
|
|
|
|
|
|
node = node.FirstChild;
|
|
|
|
|
|
while (node.NodeType != XmlNodeType.Element && node.Name != "mapping")
|
|
|
|
|
|
{
|
|
|
|
|
|
node = node.NextSibling;
|
|
|
|
|
|
}
|
2016-03-18 01:17:39 -07:00
|
|
|
|
|
2016-03-29 12:11:58 -07:00
|
|
|
|
// Now read in the mappings
|
|
|
|
|
|
while (node != null && node.Name == "mapping")
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (mapping)
|
|
|
|
|
|
{
|
|
|
|
|
|
case "MAME":
|
|
|
|
|
|
MAME.Add(node.Attributes["from"].Value, node.Attributes["to"].Value);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "NoIntro":
|
|
|
|
|
|
NoIntro.Add(node.Attributes["from"].Value, node.Attributes["to"].Value);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "Redump":
|
|
|
|
|
|
Redump.Add(node.Attributes["from"].Value, node.Attributes["to"].Value);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "TOSEC":
|
|
|
|
|
|
TOSEC.Add(node.Attributes["from"].Value, node.Attributes["to"].Value);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "TruRip":
|
|
|
|
|
|
TruRip.Add(node.Attributes["from"].Value, node.Attributes["to"].Value);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2016-03-18 01:17:39 -07:00
|
|
|
|
|
2016-03-29 12:11:58 -07:00
|
|
|
|
// Get the next node and skip over anything that's not an element
|
|
|
|
|
|
node = node.NextSibling;
|
2016-03-18 01:17:39 -07:00
|
|
|
|
|
2016-03-29 12:11:58 -07:00
|
|
|
|
if (node == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2016-03-18 01:17:39 -07:00
|
|
|
|
|
2016-03-29 12:11:58 -07:00
|
|
|
|
while (node.NodeType != XmlNodeType.Element && node.Name != "mapping")
|
|
|
|
|
|
{
|
|
|
|
|
|
node = node.NextSibling;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-03-18 01:17:39 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|