Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public static void UnpackPathable(NanoXmlNode pathableNode, PathableResourceManager pathableResourceManager, PathingCategory rootCategory)
        {
            switch (pathableNode.Name.ToLowerInvariant())
            {
            case ELEMENT_POITYPE_POI:
                var poiAttributes = AttributeBuilder.FromNanoXmlNode(pathableNode);

                var newPoiMarker = new Pathables.TacOMarkerPathable(poiAttributes, pathableResourceManager, rootCategory);

                if (newPoiMarker.SuccessfullyLoaded)
                {
                    MarkersAndPathsModule.ModuleInstance._currentReader.RegisterPathable(newPoiMarker);
                }
                else
                {
                    Logger.Warn("Failed to load marker: {markerInfo}", poiAttributes);
                }
                break;

            case ELEMENT_POITYPE_TRAIL:
                var trailAttributes = AttributeBuilder.FromNanoXmlNode(pathableNode);

                var newPathTrail = new Pathables.TacOTrailPathable(trailAttributes, pathableResourceManager, rootCategory);

                if (newPathTrail.SuccessfullyLoaded)
                {
                    MarkersAndPathsModule.ModuleInstance._currentReader.RegisterPathable(newPathTrail);
                }
                else
                {
                    Logger.Warn("Failed to load trail: {trailInfo}", trailAttributes);
                }
                break;

            case ELEMENT_POITYPE_ROUTE:
                var poiNodes = pathableNode.SelectNodes("poi");

                foreach (var poiNode in poiNodes)
                {
                    UnpackPathable(poiNode, pathableResourceManager, rootCategory);
                }

                break;

            default:
                Logger.Warn("Tried to pack {pathableNodeName} as a POI!", pathableNode.Name);
                break;
            }
        }
Exemplo n.º 3
0
        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);
        }