mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-12-25 01:39:23 +01:00
finally center it
This commit is contained in:
parent
481074bcc3
commit
b42ec52017
3 changed files with 8 additions and 10 deletions
|
@ -12,11 +12,11 @@ namespace MLEM.Extended.Extensions {
|
|||
builder.Append(word).Append(' ');
|
||||
if (font.MeasureString(builder).Width * scale >= width) {
|
||||
var len = builder.Length - word.Length - 1;
|
||||
yield return builder.ToString(0, len);
|
||||
yield return builder.ToString(0, len - 1);
|
||||
builder.Remove(0, len);
|
||||
}
|
||||
}
|
||||
yield return builder.ToString();
|
||||
yield return builder.ToString(0, builder.Length - 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -44,16 +44,14 @@ namespace MLEM.Ui.Elements {
|
|||
|
||||
this.lineHeight = 0;
|
||||
this.longestLineLength = 0;
|
||||
var height = 0F;
|
||||
foreach (var strg in this.splitText) {
|
||||
var strgScale = this.font.MeasureString(strg) * this.TextScale * this.Scale;
|
||||
height += strgScale.Y + 1;
|
||||
if (strgScale.Y > this.lineHeight)
|
||||
this.lineHeight = strgScale.Y;
|
||||
if (strgScale.Y + 1 > this.lineHeight)
|
||||
this.lineHeight = strgScale.Y + 1;
|
||||
if (strgScale.X > this.longestLineLength)
|
||||
this.longestLineLength = strgScale.X;
|
||||
}
|
||||
return new Point(this.AutoAdjustWidth ? (this.longestLineLength + this.ScaledPadding.X * 2).Ceil() : size.X, height.Ceil() + this.ScaledPadding.Y * 2);
|
||||
return new Point(this.AutoAdjustWidth ? this.longestLineLength.Ceil() + this.ScaledPadding.X * 2 : size.X, (this.lineHeight * this.splitText.Length).Ceil() + this.ScaledPadding.Y * 2);
|
||||
}
|
||||
|
||||
public override void Draw(GameTime time, SpriteBatch batch, float alpha, Point offset) {
|
||||
|
@ -68,7 +66,7 @@ namespace MLEM.Ui.Elements {
|
|||
} else {
|
||||
this.font.DrawString(batch, line, pos + off, this.TextColor * alpha, 0, Vector2.Zero, this.TextScale * this.Scale, SpriteEffects.None, 0);
|
||||
}
|
||||
off.Y += this.lineHeight + 1;
|
||||
off.Y += this.lineHeight;
|
||||
}
|
||||
base.Draw(time, batch, alpha, offset);
|
||||
}
|
||||
|
|
|
@ -11,11 +11,11 @@ namespace MLEM.Extensions {
|
|||
builder.Append(word).Append(' ');
|
||||
if (font.MeasureString(builder).X * scale >= width) {
|
||||
var len = builder.Length - word.Length - 1;
|
||||
yield return builder.ToString(0, len);
|
||||
yield return builder.ToString(0, len - 1);
|
||||
builder.Remove(0, len);
|
||||
}
|
||||
}
|
||||
yield return builder.ToString();
|
||||
yield return builder.ToString(0, builder.Length - 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue