Fixed positioning of new lines for rotated text

A fairly unimportant change, so I'll just commit it to new-netcode since I forgot to switch to master before making this change and I'm too lazy to just port things over :P
This commit is contained in:
juanjp600
2017-04-06 17:49:08 -03:00
parent 2873a79fe0
commit 84f8c6db22
+8 -8
View File
@@ -199,15 +199,15 @@ namespace Barotrauma
int lineNum = 0; int lineNum = 0;
Vector2 currentPos = position; Vector2 currentPos = position;
Vector2 advanceUnit = new Vector2((float)Math.Cos(rotation) * scale.X, (float)Math.Sin(rotation) * scale.Y); Vector2 advanceUnit = new Vector2((float)Math.Cos(rotation), (float)Math.Sin(rotation));
for (int i = 0; i < text.Length; i++) for (int i = 0; i < text.Length; i++)
{ {
if (text[i]=='\n') if (text[i]=='\n')
{ {
lineNum++; lineNum++;
currentPos = position; currentPos = position;
currentPos.X += baseHeight * 18 / 10 * lineNum * advanceUnit.Y; currentPos.X -= baseHeight * 1.8f * lineNum * advanceUnit.Y * scale.Y;
currentPos.Y += baseHeight * 18 / 10 * lineNum * advanceUnit.X; currentPos.Y += baseHeight * 1.8f * lineNum * advanceUnit.X * scale.Y;
continue; continue;
} }
uint charIndex = text[i]; uint charIndex = text[i];
@@ -218,12 +218,12 @@ namespace Barotrauma
{ {
Texture2D tex = textures[gd.texIndex]; Texture2D tex = textures[gd.texIndex];
Vector2 drawOffset; Vector2 drawOffset;
drawOffset.X = gd.drawOffset.X * advanceUnit.X - gd.drawOffset.Y * advanceUnit.Y; drawOffset.X = gd.drawOffset.X * advanceUnit.X * scale.X - gd.drawOffset.Y * advanceUnit.Y * scale.Y;
drawOffset.Y = gd.drawOffset.X * advanceUnit.Y + gd.drawOffset.Y * advanceUnit.X; drawOffset.Y = gd.drawOffset.X * advanceUnit.Y * scale.Y + gd.drawOffset.Y * advanceUnit.X * scale.X;
sb.Draw(tex, currentPos + drawOffset, null, gd.texCoords, origin, rotation, scale, color, se, layerDepth); sb.Draw(tex, currentPos + drawOffset, null, gd.texCoords, origin, rotation, scale, color, se, layerDepth);
} }
currentPos += gd.advance * advanceUnit; currentPos += gd.advance * advanceUnit * scale.X;
} }
} }
} }
@@ -243,7 +243,7 @@ namespace Barotrauma
if (text[i] == '\n') if (text[i] == '\n')
{ {
currentPos.X = position.X; currentPos.X = position.X;
currentPos.Y += baseHeight * 18 / 10; currentPos.Y += baseHeight * 1.8f;
continue; continue;
} }
uint charIndex = text[i]; uint charIndex = text[i];
@@ -264,7 +264,7 @@ namespace Barotrauma
{ {
float currentLineX = 0.0f; float currentLineX = 0.0f;
Vector2 retVal = Vector2.Zero; Vector2 retVal = Vector2.Zero;
retVal.Y = baseHeight*18/10; retVal.Y = baseHeight*1.8f;
for (int i = 0; i < text.Length; i++) for (int i = 0; i < text.Length; i++)
{ {
if (text[i] == '\n') if (text[i] == '\n')