private static void Extract(string name, string[] ignore = null) { DisplayMessage("Generating files for " + name + "..."); #if !DEBUG try { #endif var xml = new XDocument(new XDeclaration("1.0", "utf-8", null), new XElement(name)); var lua = new LuaFile(name); foreach (var obj in model[name]) { if (!IsValidName(ignore ?? new string[] {}, obj)) { continue; } var xmlelement = new XElement("o"); foreach (var pair in obj) { //TODO: Level dictionaries are currently messed up on XML output if (pair.Key.StartsWith("_")) { continue; } if (!(pair.Value is string) && pair.Value is IEnumerable) { xmlelement.SetAttributeValue(pair.Key, LuaAttribute.MakeValue(pair.Value)); } else { xmlelement.SetAttributeValue(pair.Key, pair.Value); } } xml.Root.Add(xmlelement); lua.Add(obj); } xml.Root.ReplaceNodes(xml.Root.Elements().OrderBy(e => (uint)((int?)e.Attribute("id") ?? 0))); xml.Save(Path.Combine("resources", "xml", FormattableString.Invariant($"{name}.xml"))); lua.Save(); #if !DEBUG } catch { DisplayError(); throw; } #endif DisplaySuccess(); }
private static void Extract(string name, string[] ignore = null) { DisplayMessage("Generating files for " + name + "..."); #if !DEBUG try { #endif XDocument xml = new XDocument(new XDeclaration("1.0", "utf-8", null), new XElement(name)); LuaFile lua = new LuaFile(name); foreach (dynamic obj in model[name]) { if (IsValidName(ignore ?? new string[] { }, obj)) { XElement xmlelement = new XElement("o"); foreach (var pair in obj) { //TODO: Level dictionaries are currently messed up on XML output xmlelement.SetAttributeValue(pair.Key, pair.Value); } xml.Root.Add(xmlelement); lua.Add(obj); } } xml.Root.ReplaceNodes(xml.Root.Elements().OrderBy(e => (uint)((int?)e.Attribute("id") ?? 0))); xml.Save(Path.Combine("resources", "xml", string.Format(CultureInfo.InvariantCulture, "{0}.xml", name))); lua.Save(); #if !DEBUG } catch { DisplayError(); throw; } #endif DisplaySuccess(); }
private static void Extract(string name, string[] ignore = null) { DisplayMessage("Generating files for " + name + "..."); #if !DEBUG try { #endif XDocument xml = new XDocument(new XDeclaration("1.0", "utf-8", null), new XElement(name)); LuaFile lua = new LuaFile(name); foreach (dynamic obj in model[name]) { if (IsValidName(ignore ?? new string[] { }, obj)) { XElement xmlelement = new XElement("o"); foreach (var pair in obj) { //TODO: Level dictionaries are currently messed up on XML output xmlelement.SetAttributeValue(pair.Key, pair.Value); } xml.Root.Add(xmlelement); lua.Add(obj); } } xml.Root.ReplaceNodes(xml.Root.Elements().OrderBy(e => (uint)((int?)e.Attribute("id") ?? 0))); xml.Save(Path.Combine("resources", "xml", string.Format(CultureInfo.InvariantCulture, "{0}.xml", name))); lua.Save(); #if !DEBUG } catch { DisplayError(); throw; } #endif DisplaySuccess(); }
private static void Extract(string name, string[] ignore = null) { DisplayMessage("Generating files for " + name + "..."); #if !DEBUG try { #endif var xml = new XDocument(new XDeclaration("1.0", "utf-8", null), new XElement(name)); if (xml.Root == null) { throw new InvalidDataException("fixes.xml file corrupted."); } var lua = new LuaFile(name); foreach (var obj in model[name]) { if (!IsValidName(ignore ?? new string[] {}, obj)) { continue; } var xmlelement = new XElement("o"); foreach (var pair in obj) { //TODO: Level dictionaries are currently messed up on XML output xmlelement.SetAttributeValue(pair.Key, pair.Value); } xml.Root.Add(xmlelement); lua.Add(obj); } xml.Root.ReplaceNodes(xml.Root.Elements().OrderBy(e => (uint)((int?)e.Attribute("id") ?? 0))); xml.Save(Path.Combine("resources", "xml", FormattableString.Invariant($"{name}.xml"))); lua.Save(); #if !DEBUG } catch { DisplayError(); throw; } #endif DisplaySuccess(); }