public static PathingCategory FromNanoXmlNode(NanoXmlNode categoryNode, PathingCategory parent) { string categoryName = categoryNode.GetAttribute(MARKERCATEGORY_NAME_ATTR)?.Value; // Can't define a marker category without a name if (string.IsNullOrEmpty(categoryName)) { return(null); } var subjCategory = parent.Contains(categoryName) // We're extending an existing category ? parent[categoryName] // We're adding a new category : parent.GetOrAddCategoryFromNamespace(categoryName); subjCategory.DisplayName = categoryNode.GetAttribute(MARKERCATEGORY_DISPLAYNAME_ATTR)?.Value; subjCategory.IsSeparator = categoryNode.GetAttribute(MARKERCATEGORY_ISSEPARATOR_ATTR)?.Value == "1"; subjCategory.DefaultToggle = categoryNode.GetAttribute(MARKERCATEGORY_DEFAULTTOGGLE_ATTR)?.Value != "0"; subjCategory.SetAttributes(AttributeBuilder.FromNanoXmlNode(categoryNode)); if (parent.Namespace == "Tactical.GuildMission.Bounty") { subjCategory.SetAttributes(new PathableAttributeCollection(new List <PathableAttribute> { new PathableAttribute("IconFile", "Data\\Bounty.png") })); } return(subjCategory); }
public static PathingCategory FromNanoXmlNode(NanoXmlNode categoryNode, PathingCategory parent) { string categoryName = categoryNode.GetAttribute(MARKERCATEGORY_NAME_ATTR)?.Value; // Can't define a marker category without a name. if (string.IsNullOrEmpty(categoryName)) { // TODO: Log markercategory has no name. return(null); } var subjCategory = parent.Contains(categoryName) // We're extending an existing category. ? parent[categoryName] // We're adding a new category. : parent.GetOrAddCategoryFromNamespace(categoryName); subjCategory.LoadedFromPack = true; // Have to ensure we only override if the attributes exist in case we're overwriting an existing category. if (categoryNode.TryGetAttribute(MARKERCATEGORY_DISPLAYNAME_ATTR, out var displayNameAttr)) { subjCategory.DisplayName = displayNameAttr.Value; } if (categoryNode.TryGetAttribute(MARKERCATEGORY_ISSEPARATOR_ATTR, out var isSeparatorAttr)) { subjCategory.IsSeparator = isSeparatorAttr.Value == "1"; } if (categoryNode.TryGetAttribute(MARKERCATEGORY_DEFAULTTOGGLE_ATTR, out var defaultToggleAttr)) { subjCategory.DefaultToggle = defaultToggleAttr.Value != "0"; } // Remove redundant attributes now kept track of by the pathable itself. categoryNode.Attributes.RemoveAll(attr => new[] { MARKERCATEGORY_NAME_ATTR, //MARKERCATEGORY_DISPLAYNAME_ATTR, MARKERCATEGORY_ISSEPARATOR_ATTR, MARKERCATEGORY_DEFAULTTOGGLE_ATTR }.Contains(attr.Name)); subjCategory.SetAttributes(PathablePrototypeAttributeBuilder.FromNanoXmlNode(categoryNode)); return(subjCategory); }
public static PathingCategory FromNanoXmlNode(NanoXmlNode categoryNode, PathingCategory parent) { string categoryName = categoryNode.GetAttribute(MARKERCATEGORY_NAME_ATTR)?.Value; // Can't define a marker category without a name if (string.IsNullOrEmpty(categoryName)) { return(null); } var subjCategory = parent.Contains(categoryName) // We're extending an existing category ? parent[categoryName] // We're adding a new category : parent.GetOrAddCategoryFromNamespace(categoryName); subjCategory.DisplayName = categoryNode.GetAttribute(MARKERCATEGORY_DISPLAYNAME_ATTR)?.Value; subjCategory.SetAttributes(AttributeBuilder.FromNanoXmlNode(categoryNode)); return(subjCategory); }
public static PathingCategory FromXmlNode(XmlNode categoryNode, PathingCategory parent) { string categoryName = categoryNode.Attributes["name"]?.Value; // Can't define a marker category without a name if (string.IsNullOrEmpty(categoryName)) { return(null); } var subjCategory = parent.Contains(categoryName) // We're extending an existing category ? parent[categoryName] // We're adding a new category : parent.GetOrAddCategoryFromNamespace(categoryName); subjCategory.DisplayName = categoryNode.Attributes["DisplayName"]?.Value; subjCategory.SourceXmlNode = categoryNode; return(subjCategory); }