Ejemplo n.º 1
0
        public override void Draw(SpriteBatch spriteBatch, int currentTop)
        {
            if (!visible)
            {
                return;
            }

            Vector2 origin = textDimension * scale * 0.5f;
            Vector2 center = globalRect.Center.ToVector2();

            if (alignment.HasFlag(UIAlignment.Left))
            {
                origin.X += globalRect.Width / 2 - textDimension.X / 2;
            }
            if (alignment.HasFlag(UIAlignment.Right))
            {
                origin.X -= globalRect.Width / 2 - textDimension.X / 2;
            }
            if (alignment.HasFlag(UIAlignment.Top))
            {
                origin.Y += globalRect.Height / 2 - textDimension.Y / 2;
            }
            if (alignment.HasFlag(UIAlignment.Bottom))
            {
                origin.Y -= globalRect.Height / 2 - textDimension.Y / 2;
            }

            spriteBatch.DrawString(font, text, center, color, 0, origin, scale, SpriteEffects.None, 0);
            base.Draw(spriteBatch, currentTop);
        }