Exemple #1
0
 /// <summary>
 /// UnloadContent will be called once per game and is the place to unload
 /// game-specific content.
 /// </summary>
 protected override void UnloadContent()
 {
     DebugLog.LogInfo("Flushed all Textures and unloaded all content.");
     // TODO: Unload any non ContentManager content here
     TextureContent.FlushAllTextures();
     FontContent.FlushAllFonts();
 }
Exemple #2
0
        public unsafe Font(FontContent font)
        {
            Content = font;
            Sources = new StructuredBuffer <GlyphSource>(BufferTarget.ShaderStorageBuffer, font.Characters.Count, font.Name + " Glyph Sources");

            GL.BindTexture(TextureTarget.Texture2D, Atlas);
            var data = font.Atlas.Pin();

            for (int mipLevel = 0; mipLevel < font.Atlas.MipLevels; ++mipLevel)
            {
                GL.TexImage2D(TextureTarget.Texture2D, mipLevel, PixelInternalFormat.R8Snorm, font.Atlas.Width >> mipLevel, font.Atlas.Height >> mipLevel, 0, PixelFormat.Red, PixelType.Byte, new IntPtr(data + font.Atlas.GetMipStartIndex(mipLevel)));
            }
            font.Atlas.Unpin();
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMaxLevel, font.Atlas.MipLevels - 1);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
            GL.BindTexture(TextureTarget.Texture2D, 0);

            int nextSourceId = 0;
            var sourcesData  = new GlyphSource[font.Characters.Count];

            foreach (var character in font.Characters)
            {
                sourceIds.Add(character.Key, nextSourceId);
                sourcesData[nextSourceId] = new GlyphSource {
                    Minimum       = new Vector2(character.Value.SourceMinimum.X, character.Value.SourceMinimum.Y),
                    PackedSpan    = character.Value.SourceSpan.X | (character.Value.SourceSpan.Y << 16),
                    DistanceScale = character.Value.DistanceScale
                };
                ++nextSourceId;
            }
            Sources.Update(sourcesData);
        }
Exemple #3
0
 public void AddName(string name, Color color, FontContent font)
 {
     Caption = new Label(name);
     Caption.Initialize();
     Caption.TextFont  = font;
     Caption.TextColor = color;
     Caption.Position  = Position;
 }
        override public void Draw(SpriteBatch spriteBatch)
        {
            if (Sprite != null)
            {
                Sprite.DrawAnimation(spriteBatch, GetDrawingLocation(), Depth);
            }

            spriteBatch.DrawString(FontContent.GetFont("FontArial16"), OnGround.ToString(), new Vector2(Location.X, Location.Y - 100), Color.White);
        }
Exemple #5
0
        public override LocaleContent Process(LocaleSource input, ContentProcessorContext context)
        {
            KeyboardLayoutContent klc  = ProcessKeyboardLayout(input, context);
            FontContent           font = ProcessFont(input, klc, context);

            return(new LocaleContent(
                       input.CultureInfo,
                       klc,
                       font
                       ));
        }
 public FontType GetType(FontContent content)
 {
     foreach (var item in _fonts)
     {
         if (item.Value == content)
         {
             return(item.Key);
         }
     }
     return(FontType.STANDARD);
 }
        public RendererParameters(IXnaGameTime gameTime, SpriteBatch spriteBatch, FontContent fontContent, TextureContent textureContent)
        {
            gameTime.ThrowIfNull("gameTime");
            spriteBatch.ThrowIfNull("spriteBatch");
            fontContent.ThrowIfNull("fontContent");
            textureContent.ThrowIfNull("textureContent");

            _gameTime = gameTime;
            _spriteBatch = spriteBatch;
            _fontContent = fontContent;
            _textureContent = textureContent;
        }
Exemple #8
0
        public RendererParameters(IXnaGameTime gameTime, SpriteBatch spriteBatch, FontContent fontContent, TextureContent textureContent)
        {
            gameTime.ThrowIfNull("gameTime");
            spriteBatch.ThrowIfNull("spriteBatch");
            fontContent.ThrowIfNull("fontContent");
            textureContent.ThrowIfNull("textureContent");

            _gameTime       = gameTime;
            _spriteBatch    = spriteBatch;
            _fontContent    = fontContent;
            _textureContent = textureContent;
        }
        public void Render(SpriteBatch spriteBatch, IXnaGameTime gameTime, FontContent fontContent, TextureContent textureContent)
        {
            spriteBatch.ThrowIfNull("spriteBatch");
            gameTime.ThrowIfNull("gameTime");
            fontContent.ThrowIfNull("fontContent");
            textureContent.ThrowIfNull("textureContent");

            var parameters = new RendererParameters(gameTime, spriteBatch, fontContent, textureContent);

            // Must call ToArray() because collection could be modified during iteration
            foreach (IRenderer renderer in _renderers.ToArray())
            {
                renderer.Render(parameters);
            }
        }
Exemple #10
0
        public void Render(SpriteBatch spriteBatch, IXnaGameTime gameTime, FontContent fontContent, TextureContent textureContent)
        {
            spriteBatch.ThrowIfNull("spriteBatch");
            gameTime.ThrowIfNull("gameTime");
            fontContent.ThrowIfNull("fontContent");
            textureContent.ThrowIfNull("textureContent");

            var parameters = new RendererParameters(gameTime, spriteBatch, fontContent, textureContent);

            // Must call ToArray() because collection could be modified during iteration
            foreach (IRenderer renderer in _renderers.ToArray())
            {
                renderer.Render(parameters);
            }
        }
        public FontContent AddFont(string name)
        {
            FontContent font = new FontContent(name);

            if (!_fonts.Contains(font))
            {
                _fonts.Add(font);
                return(font);
            }
            _fonts.Add(font);

            int index = _fonts.IndexOf(font);

            return(_fonts[index]);
        }
        public unsafe Font(Device device, DeviceContext context, FontContent font)
        {
            Content = font;
            Sources = new StructuredBuffer <GlyphSource>(device, font.Characters.Count, font.Name + " Glyph Sources");
            Atlas   = new Texture2D(device, new Texture2DDescription
            {
                ArraySize         = 1,
                BindFlags         = BindFlags.ShaderResource,
                CpuAccessFlags    = CpuAccessFlags.None,
                Format            = SharpDX.DXGI.Format.R8_SNorm,
                Height            = font.Atlas.Height,
                Width             = font.Atlas.Width,
                MipLevels         = font.Atlas.MipLevels,
                OptionFlags       = ResourceOptionFlags.None,
                SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0),
                Usage             = ResourceUsage.Default
            });
            Atlas.DebugName    = font.Name + " Atlas";
            AtlasSRV           = new ShaderResourceView(device, Atlas);
            AtlasSRV.DebugName = font.Name + " Atlas SRV";

            var data = font.Atlas.Pin();

            for (int mipLevel = 0; mipLevel < font.Atlas.MipLevels; ++mipLevel)
            {
                var databox = new DataBox(new IntPtr(data + font.Atlas.GetMipStartIndex(mipLevel)), font.Atlas.GetRowPitch(mipLevel), 0);
                context.UpdateSubresource(databox, Atlas, mipLevel);
            }
            font.Atlas.Unpin();

            sourceIds = new Dictionary <char, int>();
            int nextSourceId = 0;
            var sourcesData  = new GlyphSource[font.Characters.Count];

            foreach (var character in font.Characters)
            {
                sourceIds.Add(character.Key, nextSourceId);
                sourcesData[nextSourceId] = new GlyphSource
                {
                    Minimum       = new Vector2(character.Value.SourceMinimum.X, character.Value.SourceMinimum.Y),
                    PackedSpan    = character.Value.SourceSpan.X | (character.Value.SourceSpan.Y << 16),
                    DistanceScale = character.Value.DistanceScale
                };
                ++nextSourceId;
            }
            Sources.Update(context, sourcesData);
        }
Exemple #13
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);
            var deltaTime = gameTime.ElapsedGameTime;

            DrawTime = deltaTime.Milliseconds * 0.001;

            //Roll up shit
            GameCam.Update();
            spriteBatch.GraphicsDevice.Viewport = GameCam.MainView;
            spriteBatch.Begin(SpriteSortMode.BackToFront);

            SpriteFont font = FontContent.GetFont(@"FontArial16");

            spriteBatch.DrawString(font, "I like big butts and i cannot lie.", new Vector2(32, 32), Color.White);

            Entity[] list = Entities.ToArray();
            for (var i = 0; i < list.Length; i++)
            {
                if (list[i].Visible == true)
                {
                    list[i].Draw(spriteBatch);
                }

                if (list[i].Sprite != null)
                {
                    list[i].Sprite.Update(gameTime);
                }
            }

            if (DebugDraw == true)
            {
                Solid[] solids = CurrentMap.Solids.ToArray();
                for (var j = 0; j < solids.Length; j++)
                {
                    if (solids[j].Visible == true || DebugDraw == true)
                    {
                        solids[j].Draw(spriteBatch);
                    }
                }
            }


            spriteBatch.End();

            base.Draw(gameTime);
        }
 public void AddFontContent(FontContent fontPack)
 {
     _fonts.Add(fontPack);
 }
Exemple #15
0
 internal LocaleContent(CultureInfo cultureInfo, KeyboardLayoutContent keyboardLayout, FontContent font)
 {
     this.cultureInfo    = cultureInfo;
     this.keyboardLayout = keyboardLayout;
     this.font           = font;
 }
 protected override void LoadContent()
 {
     _fontContent = new FontContent(Content);
     _textureContent = new TextureContent(Content);
 }
 protected override void LoadContent()
 {
     _fontContent    = new FontContent(Content);
     _textureContent = new TextureContent(Content);
 }