Inheritance: Microsoft.Xna.Framework.Content.Pipeline.ContentItem
Exemplo n.º 1
0
        public static SGDeContent.DataTypes.Game Process(Content input, ContentProcessorContext context)
        {
            Game game = new Game();

            bool hasFirstRun = false;

            foreach (XmlNode component in input.document.DocumentElement)
            {
                //Handle the Game component (resources)
                if (ContentTagManager.TagMatches("IMPORT_GAME_ELEMENT", component.Name, input.Version))
                {
                    #region Game

                    foreach (XmlNode gameComponent in component)
                    {
                        if (ContentTagManager.TagMatches("GAME_GAME_MAPS", gameComponent.Name, input.Version))
                        {
                            #region Maps

                            foreach (XmlNode map in gameComponent)
                            {
                                int id = int.Parse(ContentTagManager.GetXMLAtt("GENERAL_ID", input.Version, map).Value);
                                if (game.MapIDs.Contains(id))
                                {
                                    throw new InvalidContentException(string.Format(Messages.Game_MapIDExists, id));
                                }
                                game.MapIDs.Add(id);
                                string innerText = SGDEProcessor.GetInnerText(map.ChildNodes[0]);
                                if (string.IsNullOrWhiteSpace(innerText))
                                {
                                    //Actual map
                                    game.Maps.Add(MapProcessor.Process(map.ChildNodes[0], input.Version, context));
                                }
                                else
                                {
                                    //Map reference
                                    string mapRef = innerText;
                                    if (!mapRef.EndsWith(".sgde", StringComparison.OrdinalIgnoreCase))
                                    {
                                        throw new InvalidContentException(Messages.Game_MapRefNotSGDE);
                                    }
                                    game.Maps.Add(Utils.CompileExternal<Map>(mapRef, context));
                                }
                            }

                            #endregion
                        }
                    }

                    #endregion
                }
                //Handle the Settings component (game description)
                else if (ContentTagManager.TagMatches("GAME_SETTINGS", component.Name, input.Version))
                {
                    #region Setting

                    #region SpriteSheet

                    XmlAttribute at = ContentTagManager.GetXMLAtt("GAME_SETTINGS_SPRITESHEET", input.Version, component);
                    string sPath;
                    if (at != null)
                    {
                        //Specific SpriteSheet
                        sPath = at.Value;
                    }
                    else
                    {
                        //Default SpriteSheet
                        sPath = ContentTagManager.GetTagValue("GAME_SETTINGS_SPRITESHEET", input.Version) + ".sgde";
                    }
                    game.SpriteSheet = Utils.CompileExternal<SpriteSheet>(sPath, context);
                    LoadSpriteTypes(sPath, context);

                    #endregion

                    foreach (XmlNode settingComponent in component)
                    {
                        if (ContentTagManager.TagMatches("GAME_SETTINGS_MAPLIST", settingComponent.Name, input.Version))
                        {
                            #region Map List

                            int index = 0;
                            foreach (XmlNode map in settingComponent)
                            {
                                if (ContentTagManager.TagMatches("GAME_SETTINGS_MAPLIST_MAP", map.Name, input.Version))
                                {
                                    int id = int.Parse(ContentTagManager.GetXMLAtt("GENERAL_ID", input.Version, map).Value);
                                    if (!game.MapIDs.Contains(id))
                                    {
                                        throw new InvalidContentException(string.Format(Messages.Game_MapIDNotExist, id));
                                    }
                                    at = ContentTagManager.GetXMLAtt("GAME_SETTINGS_MAPLIST_MAP_INITIALMAP", input.Version, map);
                                    if (at != null)
                                    {
                                        if (bool.Parse(at.Value))
                                        {
                                            if (hasFirstRun)
                                            {
                                                throw new InvalidContentException(Messages.Game_TooManyInitialMaps);
                                            }
                                            hasFirstRun = true;
                                            game.FirstRun = index;
                                        }
                                    }
                                    //Don't do any checks because maps can repeat
                                    game.MapOrderId.Add(id);
                                    at = ContentTagManager.GetXMLAtt("GAME_SETTINGS_MAPLIST_MAP_NAME", input.Version, map);
                                    if (at != null)
                                    {
                                        game.MapOrderName.Add(at.Value);
                                    }
                                    else
                                    {
                                        game.MapOrderName.Add(null);
                                    }
                                    index++;

                                    #region Settings

                                    SGDE.Content.DataTypes.MapSettings settings = null;
                                    foreach (XmlNode mapSet in map)
                                    {
                                        if (ContentTagManager.TagMatches("GAME_SETTINGS_MAPLIST_MAP_CAMERA", mapSet.Name, input.Version))
                                        {
                                            #region Camera Settings

                                            at = ContentTagManager.GetXMLAtt("GENERAL_X", input.Version, mapSet);
                                            if (at != null)
                                            {
                                                if (settings == null)
                                                {
                                                    settings = new SGDE.Content.DataTypes.MapSettings();
                                                }
                                                settings.CameraPosition = new Microsoft.Xna.Framework.Vector2(float.Parse(at.Value), 0);
                                            }
                                            at = ContentTagManager.GetXMLAtt("GENERAL_Y", input.Version, mapSet);
                                            if (at != null)
                                            {
                                                if (settings == null)
                                                {
                                                    settings = new SGDE.Content.DataTypes.MapSettings();
                                                }
                                                if (settings.CameraPosition.HasValue)
                                                {
                                                    settings.CameraPosition = new Microsoft.Xna.Framework.Vector2(settings.CameraPosition.Value.X, float.Parse(at.Value));
                                                }
                                                else
                                                {
                                                    settings.CameraPosition = new Microsoft.Xna.Framework.Vector2(0, float.Parse(at.Value));
                                                }
                                            }

                                            foreach (XmlNode cameraSet in mapSet)
                                            {
                                                if (ContentTagManager.TagMatches("GAME_SETTINGS_MAPLIST_MAP_CAMERA_ROTATION", cameraSet.Name, input.Version))
                                                {
                                                    #region Rotation

                                                    at = ContentTagManager.GetXMLAtt("GENERAL_VALUE", input.Version, mapSet);
                                                    if (at != null)
                                                    {
                                                        if (settings == null)
                                                        {
                                                            settings = new SGDE.Content.DataTypes.MapSettings();
                                                        }
                                                        settings.CameraRotation = float.Parse(at.Value);
                                                    }

                                                    #endregion
                                                }
                                                else if (ContentTagManager.TagMatches("GAME_SETTINGS_MAPLIST_MAP_CAMERA_SCALE", cameraSet.Name, input.Version))
                                                {
                                                    #region Scale

                                                    at = ContentTagManager.GetXMLAtt("GENERAL_X", input.Version, mapSet);
                                                    if (at != null)
                                                    {
                                                        if (settings == null)
                                                        {
                                                            settings = new SGDE.Content.DataTypes.MapSettings();
                                                        }
                                                        settings.CameraScale = new Microsoft.Xna.Framework.Vector2(float.Parse(at.Value), 1);
                                                    }
                                                    at = ContentTagManager.GetXMLAtt("GENERAL_Y", input.Version, mapSet);
                                                    if (at != null)
                                                    {
                                                        if (settings == null)
                                                        {
                                                            settings = new SGDE.Content.DataTypes.MapSettings();
                                                        }
                                                        if (settings.CameraScale.HasValue)
                                                        {
                                                            settings.CameraScale = new Microsoft.Xna.Framework.Vector2(settings.CameraPosition.Value.X, float.Parse(at.Value));
                                                        }
                                                        else
                                                        {
                                                            settings.CameraScale = new Microsoft.Xna.Framework.Vector2(1, float.Parse(at.Value));
                                                        }
                                                    }

                                                    #endregion
                                                }
                                                else if (ContentTagManager.TagMatches("GAME_SETTINGS_MAPLIST_MAP_CAMERA_BOUNDS", cameraSet.Name, input.Version))
                                                {
                                                    #region Bounds

                                                    at = ContentTagManager.GetXMLAtt("GAME_SETTINGS_MAPLIST_MAP_CAMERA_BOUNDS_HP", input.Version, mapSet);
                                                    if (at != null)
                                                    {
                                                        if (settings == null)
                                                        {
                                                            settings = new SGDE.Content.DataTypes.MapSettings();
                                                        }
                                                        settings.CameraBounds = new Microsoft.Xna.Framework.Vector4(float.Parse(at.Value), float.PositiveInfinity, float.NegativeInfinity, float.NegativeInfinity);
                                                    }
                                                    at = ContentTagManager.GetXMLAtt("GAME_SETTINGS_MAPLIST_MAP_CAMERA_BOUNDS_VP", input.Version, mapSet);
                                                    if (at != null)
                                                    {
                                                        if (settings == null)
                                                        {
                                                            settings = new SGDE.Content.DataTypes.MapSettings();
                                                        }
                                                        if (settings.CameraBounds.HasValue)
                                                        {
                                                            settings.CameraBounds = new Microsoft.Xna.Framework.Vector4(settings.CameraBounds.Value.X, float.Parse(at.Value), float.NegativeInfinity, float.NegativeInfinity);
                                                        }
                                                        else
                                                        {
                                                            settings.CameraBounds = new Microsoft.Xna.Framework.Vector4(float.PositiveInfinity, float.Parse(at.Value), float.NegativeInfinity, float.NegativeInfinity);
                                                        }
                                                    }
                                                    at = ContentTagManager.GetXMLAtt("GAME_SETTINGS_MAPLIST_MAP_CAMERA_BOUNDS_HN", input.Version, mapSet);
                                                    if (at != null)
                                                    {
                                                        if (settings == null)
                                                        {
                                                            settings = new SGDE.Content.DataTypes.MapSettings();
                                                        }
                                                        if (settings.CameraBounds.HasValue)
                                                        {
                                                            settings.CameraBounds = new Microsoft.Xna.Framework.Vector4(settings.CameraBounds.Value.X, settings.CameraBounds.Value.Y, float.Parse(at.Value), float.NegativeInfinity);
                                                        }
                                                        else
                                                        {
                                                            settings.CameraBounds = new Microsoft.Xna.Framework.Vector4(float.PositiveInfinity, float.PositiveInfinity, float.Parse(at.Value), float.NegativeInfinity);
                                                        }
                                                    }
                                                    at = ContentTagManager.GetXMLAtt("GAME_SETTINGS_MAPLIST_MAP_CAMERA_BOUNDS_VN", input.Version, mapSet);
                                                    if (at != null)
                                                    {
                                                        if (settings == null)
                                                        {
                                                            settings = new SGDE.Content.DataTypes.MapSettings();
                                                        }
                                                        if (settings.CameraBounds.HasValue)
                                                        {
                                                            settings.CameraBounds = new Microsoft.Xna.Framework.Vector4(settings.CameraBounds.Value.X, settings.CameraBounds.Value.Y, settings.CameraBounds.Value.Z, float.Parse(at.Value));
                                                        }
                                                        else
                                                        {
                                                            settings.CameraBounds = new Microsoft.Xna.Framework.Vector4(float.PositiveInfinity, float.PositiveInfinity, float.NegativeInfinity, float.Parse(at.Value));
                                                        }
                                                    }
                                                    if (settings != null)
                                                    {
                                                        if (settings.CameraBounds.HasValue)
                                                        {
                                                            Microsoft.Xna.Framework.Vector4 four = settings.CameraBounds.Value;
                                                            if (float.IsNaN(four.X) || float.IsNaN(four.Y) || float.IsNaN(four.Z) || float.IsNaN(four.W))
                                                            {
                                                                throw new ArgumentException(Messages.Game_CameraBoundsNaN);
                                                            }
                                                        }
                                                    }

                                                    #endregion
                                                }
                                            }

                                            #endregion
                                        }
                                        else if (ContentTagManager.TagMatches("GAME_SETTINGS_MAPLIST_MAP_ORDER", mapSet.Name, input.Version))
                                        {
                                            #region Order

                                            at = ContentTagManager.GetXMLAtt("GAME_SETTINGS_MAPLIST_MAP_ORDER_CENTRAL", input.Version, mapSet);
                                            if (at != null)
                                            {
                                                if (settings == null)
                                                {
                                                    settings = new SGDE.Content.DataTypes.MapSettings();
                                                }
                                                settings.CentralOrder = int.Parse(at.Value);
                                            }
                                            at = ContentTagManager.GetXMLAtt("GAME_SETTINGS_MAPLIST_MAP_ORDER_SEPERATION", input.Version, mapSet);
                                            if (at != null)
                                            {
                                                if (settings == null)
                                                {
                                                    settings = new SGDE.Content.DataTypes.MapSettings();
                                                }
                                                settings.OrderSeperation = float.Parse(at.Value);
                                            }

                                            #endregion
                                        }
                                    }
                                    game.MapSettings.Add(settings);

                                    #endregion
                                }
                            }

                            #endregion
                        }
                        else if (ContentTagManager.TagMatches("GAME_SETTINGS_DEFSETTINGS", settingComponent.Name, input.Version))
                        {
                            #region Default Game Settings

                            foreach (XmlNode gameSettingComponent in settingComponent)
                            {
                                if (ContentTagManager.TagMatches("GAME_SETTINGS_DEFSETTINGS_SCREEN", gameSettingComponent.Name, input.Version))
                                {
                                    #region Screen

                                    //Any platform
                                    at = ContentTagManager.GetXMLAtt("GAME_SETTINGS_DEFSETTINGS_SCREEN_FULLSCREEN", input.Version, gameSettingComponent);
                                    if (at != null)
                                    {
                                        //Ignored on Xbox
                                        game.Fullscreen = bool.Parse(at.Value);
                                    }
                                    at = ContentTagManager.GetXMLAtt("GAME_SETTINGS_DEFSETTINGS_SCREEN_VSYNC", input.Version, gameSettingComponent);
                                    if (at != null)
                                    {
                                        game.VSync = bool.Parse(at.Value);
                                    }
                                    at = ContentTagManager.GetXMLAtt("GAME_SETTINGS_DEFSETTINGS_SCREEN_MULTISAMPLE", input.Version, gameSettingComponent);
                                    if (at != null)
                                    {
                                        game.Multisample = bool.Parse(at.Value);
                                    }
                                    //Platform specific
                                    switch (context.TargetPlatform)
                                    {
                                        case TargetPlatform.WindowsPhone:
                                            //TODO: Not sure what resoultion this should be built for or if this should be like Windows.
                                        case TargetPlatform.Windows:
                                            at = ContentTagManager.GetXMLAtt("GENERAL_WIDTH", input.Version, gameSettingComponent);
                                            if (at != null)
                                            {
                                                game.Width = int.Parse(at.Value);
                                            }
                                            at = ContentTagManager.GetXMLAtt("GENERAL_HEIGHT", input.Version, gameSettingComponent);
                                            if (at != null)
                                            {
                                                game.Height = int.Parse(at.Value);
                                            }
                                            break;
                                        case TargetPlatform.Xbox360:
                                            game.Width = 1280;
                                            game.Height = 720;
                                            game.Fullscreen = true;
                                            //game.VSync = false; //Default value
                                            //game.Multisample = true; //It's built into the chip, so why should you disable it?
                                            break;
                                        default:
                                            context.Logger.LogWarning(null, null, Messages.Game_UnknownTarget, context.TargetPlatform);
                                            break;
                                    }

                                    #endregion
                                }
                                else if (ContentTagManager.TagMatches("GAME_SETTINGS_DEFSETTINGS_GAME", gameSettingComponent.Name, input.Version))
                                {
                                    #region Game

                                    //Any platform
                                    at = ContentTagManager.GetXMLAtt("GAME_SETTINGS_DEFSETTINGS_GAME_FIXEDTIME", input.Version, gameSettingComponent);
                                    if (at != null)
                                    {
                                        game.FixedTime = bool.Parse(at.Value);
                                    }
                                    at = ContentTagManager.GetXMLAtt("GAME_SETTINGS_DEFSETTINGS_GAME_FRAMETIME", input.Version, gameSettingComponent);
                                    if (at != null)
                                    {
                                        if (!TimeSpan.TryParse(at.Value, out game.FrameTime) && (game.FixedTime.HasValue && game.FixedTime.Value))
                                        {
                                            context.Logger.LogWarning(null, null, Messages.Game_BadFrameTime);
                                            game.FixedTime = false;
                                        }
                                    }

                                    //Platform specific
                                    switch (context.TargetPlatform)
                                    {
                                        case TargetPlatform.Windows:
                                            at = ContentTagManager.GetXMLAtt("GAME_SETTINGS_DEFSETTINGS_GAME_MOUSEVISIBLE", input.Version, gameSettingComponent);
                                            if (at != null)
                                            {
                                                game.MouseVisible = bool.Parse(at.Value);
                                            }
                                            break;
                                        case TargetPlatform.WindowsPhone:
                                            at = ContentTagManager.GetXMLAtt("GAME_SETTINGS_DEFSETTINGS_GAME_ORIENTATION", input.Version, gameSettingComponent);
                                            if (at != null)
                                            {
                                                game.Orientation = Utils.ParseEnum<Microsoft.Xna.Framework.DisplayOrientation>(at.Value, Microsoft.Xna.Framework.DisplayOrientation.Default, context.Logger);
                                            }
                                            break;
                                    }
                                    switch(context.TargetPlatform)
                                    {
                                        case TargetPlatform.Windows:
                                        case TargetPlatform.WindowsPhone:
                                            at = ContentTagManager.GetXMLAtt("GAME_SETTINGS_DEFSETTINGS_GAME_WINDOWRESIZEABLE", input.Version, gameSettingComponent);
                                            if (at != null)
                                            {
                                                game.WindowResize = bool.Parse(at.Value);
                                                if (game.WindowResize)
                                                {
                                                    context.Logger.LogWarning(null, null, Messages.Game_WindowResizeable);
                                                }
                                            }
                                            at = ContentTagManager.GetXMLAtt("GAME_SETTINGS_DEFSETTINGS_GAME_TITLE", input.Version, gameSettingComponent);
                                            if (at != null)
                                            {
                                                game.Title = at.Value;
                                            }
                                            break;
                                    }

                                    #endregion
                                }
                            }

                            #endregion
                        }
                    }

                    #endregion
                }
            }

            game.Sort();

            return game;
        }
Exemplo n.º 2
0
 public static Entity Process(Content input, ContentProcessorContext context)
 {
     return Process(ContentTagManager.GetXMLNode("IMPORT_ENTITIY_ELEMENT", input.Version, input.document.DocumentElement), input.Version, context);
 }
Exemplo n.º 3
0
        public static SpriteSheet Process(Content input, ContentProcessorContext context, bool compile)
        {
            SpriteSheet map = new SpriteSheet();
            foreach (XmlNode spriteMaps in input.document.DocumentElement)
            {
                if (ContentTagManager.TagMatches("IMPORT_SPRITESHEET_ELEMENT", spriteMaps.Name, input.Version))
                {
                    #region SpriteMaps

                    foreach (XmlNode smap in spriteMaps)
                    {
                        if (ContentTagManager.TagMatches("SPRITESHEET_MAP", smap.Name, input.Version))
                        {
                            #region SpriteMap

                            XmlAttribute at = ContentTagManager.GetXMLAtt("SPRITESHEET_MAP_NAME", input.Version, smap);
                            if (at != null)
                            {
                                map.Names.Add(at.Value);
                            }
                            else
                            {
                                map.Names.Add(null);
                            }
                            at = ContentTagManager.GetXMLAtt("GENERAL_ID", input.Version, smap);
                            if (at == null)
                            {
                                throw new InvalidContentException(Messages.SpriteSheet_RequiresID);
                            }
                            map.TextureIDs.Add(int.Parse(at.Value));
                            bool hasSource = false;
                            foreach (XmlNode mapComponent in smap)
                            {
                                if (ContentTagManager.TagMatches("SPRITESHEET_MAP_COMP_SOURCE", mapComponent.Name, input.Version))
                                {
                                    hasSource = true;
                                    if (compile)
                                    {
                                        if (SpriteSheetProcessor.SpriteSheetTypes == null)
                                        {
                                            //For one reason or another, SpriteSheetProcessor.SpriteSheetTypes doesn't always end up getting created. Do this to create it
                                            SpriteSheetProcessor.SpriteSheetTypes = new Dictionary<int, SpriteType>();
                                            Process(input, context, false);
                                        }
                                        switch (SpriteSheetProcessor.SpriteSheetTypes[map.TextureIDs[map.TextureIDs.Count - 1]])
                                        {
                                            case SpriteType.Bitmap:
                                                map.Textures.Add(Utils.CompileExternal<TextureContent, TextureContent, TextureContent, Microsoft.Xna.Framework.Content.Pipeline.TextureImporter, Microsoft.Xna.Framework.Content.Pipeline.Processors.TextureProcessor>(SGDEProcessor.GetInnerText(mapComponent), context));
                                                break;
                                            case SpriteType.SVG:
                                                map.Textures.Add(Utils.CompileExternal<Content, ProcessedContent, SGDeContent.DataTypes.Sprites.SVG.SVGfx, SVGImport, SVGProcessor>(SGDEProcessor.GetInnerText(mapComponent), context));
                                                break;
                                            default:
                                                throw new InvalidContentException(Messages.SpriteSheet_UnknownType);
                                        }
                                    }
                                    else
                                    {
                                        //This only happens when types are being looked up
                                        SpriteSheetProcessor.SpriteSheetTypes.Add(map.TextureIDs[map.TextureIDs.Count - 1], GetType(SGDEProcessor.GetInnerText(mapComponent)));
                                    }
                                }
                                else if (ContentTagManager.TagMatches("SPRITESHEET_MAP_COMP_ANIMATION", mapComponent.Name, input.Version))
                                {
                                    if (compile)
                                    {
                                        Animation animation = AnimationProcessor.Process(mapComponent, input.Version, context);
                                        if (!animation.BuiltIn)
                                        {
                                            throw new InvalidContentException(Messages.SpriteSheet_AnimationMustBeInternal);
                                        }
                                        map.AnimationSets.Add(animation.Sets);
                                    }
                                }
                            }
                            if (map.AnimationSets.Count != map.TextureIDs.Count)
                            {
                                map.AnimationSets.Add(null);
                            }
                            if (!hasSource)
                            {
                                throw new InvalidContentException(Messages.SpriteSheet_NeedsSource);
                            }

                            #endregion
                        }
                    }

                    //First check to see if out of order
                    bool process = false;
                    for (int i = 0; i < map.TextureIDs.Count; i++)
                    {
                        if (map.TextureIDs[i] != i)
                        {
                            process = true;
                            break;
                        }
                    }
                    if (process)
                    {
                        //Need to sort the textures.
                        List<int> ids = new List<int>();
                        List<object> texs = new List<object>();
                        for (int i = 0; i < map.TextureIDs.Count; i++)
                        {
                            ids.Add(i);
                            texs.Add(map.Textures[map.TextureIDs.IndexOf(i)]);
                        }
                        map.TextureIDs.Clear();
                        map.TextureIDs.AddRange(ids);
                        map.Textures.Clear();
                        map.Textures.AddRange(texs);
                    }

                    #endregion
                }
                else if (ContentTagManager.TagMatches("SPRITESHEET_FONTS", spriteMaps.Name, input.Version))
                {
                    #region SpriteFonts

                    if (compile)
                    {
                        foreach (XmlNode font in spriteMaps)
                        {
                            if (ContentTagManager.TagMatches("SPRITESHEET_FONT", font.Name, input.Version))
                            {
                                //Get the name
                                XmlAttribute at = ContentTagManager.GetXMLAtt("SPRITESHEET_FONT_NAME", input.Version, font);
                                string name = at == null ? null : at.Value;
                                if (string.IsNullOrWhiteSpace(name))
                                {
                                    throw new ArgumentException(Messages.SpriteSheet_FontRequiresName);
                                }

                                //Create the Font XML file and load it
                                XmlDocument doc = new XmlDocument();
                                doc.AppendChild(doc.CreateXmlDeclaration("1.0", "utf-8", null));

                                XmlElement el = doc.CreateElement("XnaContent");
                                doc.AppendChild(el);
                                at = doc.CreateAttribute("xmlns:Graphics");
                                el.Attributes.Append(at);
                                at.Value = "Microsoft.Xna.Framework.Content.Pipeline.Graphics";

                                el.AppendChild(doc.CreateElement("Asset"));
                                el = el["Asset"];
                                at = doc.CreateAttribute("Type");
                                el.Attributes.Append(at);
                                at.Value = "Graphics:FontDescription";

                                //Copy the current element over to the new element
                                if (!CopyElement(el, font, "FontName"))
                                {
                                    throw new ArgumentException(Messages.SpriteSheet_FontMissingFontName);
                                }
                                if (!CopyElement(el, font, "Size"))
                                {
                                    AddElement(el, "Size", "14");
                                }
                                if (!CopyElement(el, font, "Spacing"))
                                {
                                    AddElement(el, "Spacing", "0");
                                }
                                if (!CopyElement(el, font, "UseKerning"))
                                {
                                    AddElement(el, "UseKerning", "true");
                                }
                                if (!CopyElement(el, font, "Style"))
                                {
                                    AddElement(el, "Style", "Regular");
                                }
                                CopyElement(el, font, "DefaultCharacter");
                                if (!CopyElement(el, font, "CharacterRegions", true))
                                {
                                    XmlElement cr = doc.CreateElement("CharacterRegions");
                                    el.AppendChild(cr);
                                    el = doc.CreateElement("CharacterRegion");
                                    cr.AppendChild(el);
                                    cr = el;
                                    el = doc.CreateElement("Start");
                                    cr.AppendChild(el);
                                    el.InnerText = ((char)32).ToString();
                                    el = doc.CreateElement("End");
                                    cr.AppendChild(el);
                                    el.InnerText = ((char)126).ToString();
                                }

                                //Save and deserialize the description
                                FontDescription description = null;
                                using (MemoryStream spritefontStream = new MemoryStream())
                                {
                                    doc.Save(spritefontStream);
                                    spritefontStream.Position = 0;

                                    //Create the FontDescription
                                    using (XmlReader reader = XmlReader.Create(spritefontStream))
                                    {
                                        description = Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateSerializer.Deserialize<FontDescription>(reader, input.Identity.SourceFilename);
                                    }
                                }
                                description.Identity = input.Identity;

                                //Add the font
                                map.Fonts.Add(name, Utils.Process<FontDescription, Microsoft.Xna.Framework.Content.Pipeline.Processors.SpriteFontContent, Microsoft.Xna.Framework.Content.Pipeline.Processors.FontDescriptionProcessor>(description, context));
                            }
                        }
                    }

                    #endregion
                }
            }
            if (!compile)
            {
                //Means that SpriteSheetTypes was set
                Utils.Serialize(SpriteSheetProcessor.SpriteSheetTypes, SPRITE_TYPE_FILE, context);
            }
            return map;
        }
Exemplo n.º 4
0
 public static Map Process(Content input, ContentProcessorContext context)
 {
     return Process(input.document.DocumentElement, input.Version, context);
 }
Exemplo n.º 5
0
 public static SpriteSheet Process(Content input, ContentProcessorContext context)
 {
     return Process(input, context, true);
 }