Text scale in GUITextBlocks and ItemLabels can be changed, text wrapping fix (words that are too wide for one line shouldn't cause overflows anymore)

This commit is contained in:
Regalis
2017-03-22 23:22:54 +02:00
parent 7c6ea5b1c0
commit 885a8c610c
3 changed files with 50 additions and 26 deletions
+18 -1
View File
@@ -10,6 +10,8 @@ namespace Barotrauma
protected Alignment textAlignment;
private float textScale;
protected Vector2 textPos;
protected Vector2 origin;
@@ -88,6 +90,19 @@ namespace Barotrauma
get { return textPos; }
}
public float TextScale
{
get { return textScale; }
set
{
if (value != textScale)
{
textScale = value;
SetTextPos();
}
}
}
public Vector2 Origin
{
get { return origin; }
@@ -162,6 +177,8 @@ namespace Barotrauma
SetTextPos();
TextScale = 1.0f;
if (rect.Height == 0 && !string.IsNullOrEmpty(Text))
{
this.rect.Height = (int)Font.MeasureString(wrappedText).Y;
@@ -267,7 +284,7 @@ namespace Barotrauma
Wrap ? wrappedText : text,
new Vector2(rect.X, rect.Y) + textPos + offset,
textColor * (textColor.A / 255.0f),
0.0f, origin, 1.0f,
0.0f, origin, TextScale,
SpriteEffects.None, textDepth);
}