public void DrawTextLines(IEnumerable <string> lines, HorizontalAlignment horizontalAlignment, object objectRequestingChange, int requiredWidth, List <int> widths, SpriteRenderer spriteRenderer,
Color color,
float xOffset = 0, float yOffset = 0, float rotation = 0, float scaleX = 1, float scaleY = 1)
{
Point point = new Point();
int lineNumber = 0;
int xOffsetAsInt = MathFunctions.RoundToInt(xOffset);
int yOffsetAsInt = MathFunctions.RoundToInt(yOffset);
if (Renderer.NormalBlendState == BlendState.AlphaBlend)
{
// this is premultiplied, so premulitply the color value
float multiple = color.A / 255.0f;
color.R = (byte)(color.R * multiple);
color.G = (byte)(color.G * multiple);
color.B = (byte)(color.B * multiple);
}
foreach (string line in lines)
{
// scoot over to leave room for the outline
point.X = mOutlineThickness;
if (horizontalAlignment == HorizontalAlignment.Right)
{
point.X = requiredWidth - widths[lineNumber];
}
else if (horizontalAlignment == HorizontalAlignment.Center)
{
point.X = (requiredWidth - widths[lineNumber]) / 2;
}
foreach (char c in line)
{
Rectangle destRect;
int pageIndex;
var sourceRect = GetCharacterRect(c, lineNumber, ref point, out destRect, out pageIndex, scaleX);
// todo: rotation, because that will impact destination rectangle too
if (Text.TextRenderingPositionMode == TextRenderingPositionMode.FreeFloating)
{
spriteRenderer.Draw(mTextures[pageIndex], new Vector2(destRect.X + xOffset, destRect.Y + yOffset), sourceRect, color, 0, Vector2.Zero, Vector2.One, SpriteEffects.None, 0, this);
}
else
{
// position:
destRect.X += xOffsetAsInt;
destRect.Y += yOffsetAsInt;
spriteRenderer.Draw(mTextures[pageIndex], destRect, sourceRect, color, this);
}
}
point.X = 0;
lineNumber++;
}
}