Exemple #1
0
        /// <summary>
        /// Draws text in specified coordinates.
        /// </summary>
        public static void Draw(string text, Vector2 position)
        {
            if (CurrentFont == null)
            {
                throw new NullReferenceException("CurrentFont is null! Did you forgot to set a font?");
            }

            CurrentFont.Draw(text, position, HorAlign, VerAlign);
        }
Exemple #2
0
        /// <summary>
        /// Draws text in specified coordinates.
        /// </summary>
        public static void Draw(string text, Vector2 position)
        {
            if (CurrentFont == null)
            {
                throw new NullReferenceException("CurrentFont is null! Did you forgot to set a font?");
            }

            /*
             * Font is a wrapper for MG's SpriteFont, which uses non-premultiplied alpha.
             * Using GraphicsMode.Sprites will result in black pixels everywhere.
             * TextureFont, on the other hand, is just a bunch of regular sprites,
             * so it's fine to draw with sprite mode.
             */
            if (CurrentFont is Font)
            {
                GraphicsMgr.SwitchGraphicsMode(GraphicsMode.SpritesNonPremultiplied);
            }
            else
            {
                GraphicsMgr.SwitchGraphicsMode(GraphicsMode.Sprites);
            }
            CurrentFont.Draw(GraphicsMgr.Batch, text, position, HorAlign, VerAlign);
        }
Exemple #3
0
        /// <summary>
        /// Draws text in specified coordinates.
        /// </summary>
        public static void DrawText(string text, Vector2 pos)
        {
            SwitchPipelineMode(PipelineMode.Sprites, null);

            CurrentFont.Draw(Batch, text, pos, HorAlign, VerAlign);
        }
Exemple #4
0
 public static void DrawString(this SpriteBatch spriteBatch, IFont font, string text, Vector2 position)
 {
     font.Draw(text, position, Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.0f, spriteBatch);
 }
Exemple #5
0
 public static void DrawString(this SpriteBatch spriteBatch, IFont font, string text, Vector2 position, Color color, float rotation, Vector2 origin, float scale, SpriteEffects spriteEffects, float layerDepth)
 {
     font.Draw(text, position, color, rotation, origin, scale, spriteEffects, layerDepth, spriteBatch);
 }
Exemple #6
0
 public static void DrawString(this SpriteBatch spriteBatch, IFont font, string text, Vector2 position, Color color, float scale)
 {
     font.Draw(text, position, color, 0.0f, Vector2.Zero, scale, SpriteEffects.None, 0.0f, spriteBatch);
 }
Exemple #7
0
 public static void DrawString(this SpriteBatch batch, IFont font, StringBuilder text, Vector2 position, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, float layerDepth)
 {
     font.Draw(batch, text, position, color, rotation, origin, scale, effects, layerDepth);
 }
Exemple #8
0
 public static void DrawString(this SpriteBatch batch, IFont font, StringBuilder text, Vector2 position, Color color)
 {
     font.Draw(batch, text, position, color);
 }