Beispiel #1
0
        public override void LoadSurfaces()
        {
            var         fontSurface = content.Load <Texture2D>("Images/font");
            FontMetrics fontMetrics = BuildFontMetrics();

            var bitmapFont = new BitmapFontTexture(fontSurface,
                                                   fontMetrics,
                                                   "LotaFont");

            Font = new FontBuilder("LotaFont")
                   .AddFontTexture(new FontSettings(16, FontStyles.None), bitmapFont)
                   .Build();
            Font.Size = 16;

            Character = content.Load <Texture2D>("Images/character");
            Monsters  = content.Load <Texture2D>("Images/OverworldMonsters");

            Lob3DSurfaces.LoadSurfaces(content);

            foreach (var exinfo in data.ExhibitInfo.Values)
            {
                try
                {
                    exinfo.LoadImage(content);
                }
                catch (System.IO.FileNotFoundException)
                {
                    System.Diagnostics.Debug.Print("Image " + exinfo.ImageFile + " not found.");
                }
            }
        }
        /// <summary>
        /// Loads a font from the ContentManager.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static Font Load(IContentProvider content, string name)
        {
            var fontModel = ReadFont(content, name);

            var path = fontModel.ImagePath;

            Font result = new Font(name);

            foreach (var fontSurfaceModel in fontModel)
            {
                var image = fontSurfaceModel.Image;

                if (image.EndsWith(".png"))
                {
                    image = image.Substring(0, image.Length - 4);
                }

                var surface = content.Load <Texture2D>(Path.Combine(path, image));

                FontMetrics metrics = new FontMetrics();
                foreach (var glyph in fontSurfaceModel.Metrics)
                {
                    metrics.Add((char)glyph.Key, glyph.Value);
                }

                var fontSurface = new BitmapFontTexture(surface, metrics, name);

                result.Core.AddFontSurface(new FontSettings(fontSurfaceModel.Size, fontSurfaceModel.Style), fontSurface);
            }

            return(result);
        }
Beispiel #3
0
        public override void LoadSurfaces()
        {
            var         fontSurface = content.Load <Texture2D>("Images/font");
            FontMetrics fontMetrics = BuildFontMetrics();

            var bitmapFont = new BitmapFontTexture(fontSurface,
                                                   fontMetrics,
                                                   "LotaFont");

            Font = new FontBuilder("LotaFont")
                   .AddFontTexture(new FontSettings(16, FontStyles.None), bitmapFont)
                   .Build();
            Font.Size = 16;

            Character = content.Load <Texture2D>("Images/character");
            Monsters  = content.Load <Texture2D>("Images/OverworldMonsters");

            Lota3DSurfaces.LoadSurfaces(content);

            foreach (var exinfo in data.ExhibitInfo.Values)
            {
                exinfo.LoadImage(content);
            }
        }