public static XmlLoadingResult LoadXml(string xmlFile) { try { var path = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); path = Path.Combine(path, xmlFile); using (var stream = File.OpenRead(path)) { XmlSerializer s = new XmlSerializer(typeof(XmlDataSet)); var fileData = s.Deserialize(stream) as XmlDataSet; var unknownPerks = new XmlPerkGroup { Name = "Unknown", Perks = new List <XmlNamedVector4>() }; fileData.PerkGroups.Add(unknownPerks); var unknownItems = new XmlItemGroup { Name = "Unknown", Items = new List <XmlItem>(), Category = ItemCategories.Unknown }; fileData.ItemGroups.Add(unknownItems); _files.Add(xmlFile, fileData); if (_files.Count == 1) { Select(xmlFile); } // Sanity check: ensure the XML files have a certain level of completeness. switch (xmlFile) { case XmlData.Files.Vanilla: if (!fileData.Flags.Any(x => x.ID == 1279 && x.Name == "GAME_END")) { return(XmlLoadingResult.InvalidFile); } break; case XmlData.Files.Revamp: if (!fileData.Flags.Any(x => x.ID == 1279 && x.Name == "GAME_END")) { return(XmlLoadingResult.InvalidFile); } if (fileData.Body.LowerBodyTypes.Any(x => x.ID == 24 && x.Name == "Deertaur")) { return(XmlLoadingResult.InvalidFile); } if (!fileData.Body.LowerBodyTypes.Any(x => x.ID == 25 && x.Name == "Salamander")) { return(XmlLoadingResult.InvalidFile); } if (!fileData.PerkGroups.Any(x => x.Name == "Tier 1" && x.Perks.Any(p => p.Name == "Iron Fists 3"))) { return(XmlLoadingResult.InvalidFile); } if (!fileData.PerkGroups.Any(x => x.Name == "Events" && x.Perks.Any(p => p.Name == "Lustserker"))) { return(XmlLoadingResult.InvalidFile); } break; case XmlData.Files.Xianxia: if (!fileData.Flags.Any(x => x.ID == 1279 && x.Name == "GAME_END")) { return(XmlLoadingResult.InvalidFile); } // FIXME: Add additional Xianxia tests, if necessary. break; } return(XmlLoadingResult.Success); } } catch (UnauthorizedAccessException) { return(XmlLoadingResult.NoPermission); } catch (SecurityException) { return(XmlLoadingResult.NoPermission); } catch (FileNotFoundException) { return(XmlLoadingResult.MissingFile); } }
public static XmlLoadingResult LoadXml(string xmlFile) { try { var path = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); path = Path.Combine(path, xmlFile); using (var stream = File.OpenRead(path)) { XmlSerializer s = new XmlSerializer(typeof(XmlDataSet)); var fileData = s.Deserialize(stream) as XmlDataSet; var unknownPerks = new XmlPerkGroup { Name = "Unknown", Perks = new List<XmlNamedVector4>() }; fileData.PerkGroups.Add(unknownPerks); var unknownItems = new XmlItemGroup { Name = "Unknown", Items = new List<XmlItem>(), Category = ItemCategories.Unknown }; fileData.ItemGroups.Add(unknownItems); _files.Add(xmlFile, fileData); if (_files.Count == 1) Select(xmlFile); return XmlLoadingResult.Success; } } catch (UnauthorizedAccessException) { return XmlLoadingResult.NoPermission; } catch (SecurityException) { return XmlLoadingResult.NoPermission; } catch (FileNotFoundException) { return XmlLoadingResult.MissingFile; } }
public static XmlLoadingResult LoadXml(string xmlFile) { try { var path = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); path = Path.Combine(path, xmlFile); using (var stream = File.OpenRead(path)) { XmlSerializer s = new XmlSerializer(typeof(XmlDataSet)); var fileData = s.Deserialize(stream) as XmlDataSet; var unknownPerks = new XmlPerkGroup { Name = "Unknown", Perks = new List<XmlNamedVector4>() }; fileData.PerkGroups.Add(unknownPerks); var unknownItems = new XmlItemGroup { Name = "Unknown", Items = new List<XmlItem>(), Category = ItemCategories.Unknown }; fileData.ItemGroups.Add(unknownItems); _files.Add(xmlFile, fileData); if (_files.Count == 1) Select(xmlFile); // Sanity check: ensure the XML files have a certain level of completeness. switch (xmlFile) { case XmlData.Files.CoC: if (!fileData.Flags.Any(x => x.ID == 1279 && x.Name == "GAME_END")) return XmlLoadingResult.InvalidFile; break; case XmlData.Files.RevampMod: if (!fileData.Flags.Any(x => x.ID == 1279 && x.Name == "GAME_END")) return XmlLoadingResult.InvalidFile; if (fileData.Body.LowerBodyTypes.Any(x => x.ID == 24 && x.Name == "Deertaur")) return XmlLoadingResult.InvalidFile; if (!fileData.Body.LowerBodyTypes.Any(x => x.ID == 25 && x.Name == "Salamander")) return XmlLoadingResult.InvalidFile; if (!fileData.PerkGroups.Any(x => x.Name == "Tier 1" && x.Perks.Any(p => p.Name == "Iron Fists 3"))) return XmlLoadingResult.InvalidFile; if (!fileData.PerkGroups.Any(x => x.Name == "Events" && x.Perks.Any(p => p.Name == "Lustserker"))) return XmlLoadingResult.InvalidFile; break; } return XmlLoadingResult.Success; } } catch (UnauthorizedAccessException) { return XmlLoadingResult.NoPermission; } catch (SecurityException) { return XmlLoadingResult.NoPermission; } catch (FileNotFoundException) { return XmlLoadingResult.MissingFile; } }
public ItemGroupVM(GameVM game, XmlItemGroup group, ItemSlotVM slot) { _game = game; Name = group.Name; Items = new UpdatableCollection<ItemVM>(group.Items.Where(x => Match(x, _game.ItemSearchText)).OrderBy(x => x.Name).Select(x => new ItemVM(slot, x))); }