diff --git a/Demos/TextFormattingDemo.cs b/Demos/TextFormattingDemo.cs index 54112a0..fc89a27 100644 --- a/Demos/TextFormattingDemo.cs +++ b/Demos/TextFormattingDemo.cs @@ -72,7 +72,7 @@ namespace Demos { // we draw the tokenized text in the center of the screen // since the text is already center-aligned, we only need to align it on the y axis here - var size = this.tokenizedText.GetArea(Vector2.Zero, this.Scale).Size; + var size = this.tokenizedText.GetArea(scale: this.Scale).Size; var pos = new Vector2(this.GraphicsDevice.Viewport.Width / 2, (this.GraphicsDevice.Viewport.Height - size.Y) / 2); var rotation = this.transform ? 0.25F : 0; diff --git a/MLEM.Ui/Elements/Paragraph.cs b/MLEM.Ui/Elements/Paragraph.cs index 3550bde..7655cb9 100644 --- a/MLEM.Ui/Elements/Paragraph.cs +++ b/MLEM.Ui/Elements/Paragraph.cs @@ -228,7 +228,7 @@ namespace MLEM.Ui.Elements { this.CheckTextChange(); this.TokenizeIfNecessary(); this.AlignAndSplitIfNecessary(size); - var textSize = this.tokenizedText.GetArea(Vector2.Zero, this.TextScale * this.TextScaleMultiplier * this.Scale).Size; + var textSize = this.tokenizedText.GetArea(scale: this.TextScale * this.TextScaleMultiplier * this.Scale).Size; // if we auto-adjust our width, then we would also split the same way with our adjusted width, so cache that if (this.AutoAdjustWidth) this.lastAlignSplitWidth = textSize.X; diff --git a/MLEM/Formatting/Token.cs b/MLEM/Formatting/Token.cs index 34dd6c3..eaa1faa 100644 --- a/MLEM/Formatting/Token.cs +++ b/MLEM/Formatting/Token.cs @@ -150,7 +150,7 @@ namespace MLEM.Formatting { } /// - public IEnumerable GetArea(Vector2 stringPos, float scale) { + public IEnumerable GetArea(Vector2 stringPos = default, float scale = 1) { return this.GetArea(stringPos, new Vector2(scale)); } diff --git a/MLEM/Formatting/TokenizedString.cs b/MLEM/Formatting/TokenizedString.cs index 128795e..c6f07d9 100644 --- a/MLEM/Formatting/TokenizedString.cs +++ b/MLEM/Formatting/TokenizedString.cs @@ -140,7 +140,7 @@ namespace MLEM.Formatting { /// [Obsolete("Measure is deprecated. Use GetArea, which returns the string's total size measurement, instead.")] public Vector2 Measure(GenericFont font) { - return this.GetArea(Vector2.Zero, 1).Size; + return this.GetArea().Size; } /// @@ -149,7 +149,7 @@ namespace MLEM.Formatting { /// The position that this string is being rendered at, which will offset the resulting . /// The scale that this string is being rendered with, which will scale the resulting . /// The area that this tokenized string takes up. - public RectangleF GetArea(Vector2 stringPos, float scale) { + public RectangleF GetArea(Vector2 stringPos = default, float scale = 1) { return new RectangleF(stringPos + this.area.Location * scale, this.area.Size * scale); } @@ -185,7 +185,7 @@ namespace MLEM.Formatting { target = Vector2.Transform(target, Matrix.Invert(transform)); } foreach (var token in this.Tokens) { - foreach (var rect in font != null ? token.GetArea(Vector2.Zero, 1) : token.GetArea(stringPos, scale)) { + foreach (var rect in font != null ? token.GetArea() : token.GetArea(stringPos, scale)) { if (rect.Contains(target)) return token; }