mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-24 21:48:35 +01:00
defaults for string GetArea methods
This commit is contained in:
parent
fc2d705526
commit
dd9230abf0
4 changed files with 6 additions and 6 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -150,7 +150,7 @@ namespace MLEM.Formatting {
|
|||
}
|
||||
|
||||
/// <inheritdoc cref="GetArea(Microsoft.Xna.Framework.Vector2,Microsoft.Xna.Framework.Vector2)"/>
|
||||
public IEnumerable<RectangleF> GetArea(Vector2 stringPos, float scale) {
|
||||
public IEnumerable<RectangleF> GetArea(Vector2 stringPos = default, float scale = 1) {
|
||||
return this.GetArea(stringPos, new Vector2(scale));
|
||||
}
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ namespace MLEM.Formatting {
|
|||
/// <inheritdoc cref="GenericFont.MeasureString(string,bool)"/>
|
||||
[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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -149,7 +149,7 @@ namespace MLEM.Formatting {
|
|||
/// <param name="stringPos">The position that this string is being rendered at, which will offset the resulting <see cref="RectangleF"/>.</param>
|
||||
/// <param name="scale">The scale that this string is being rendered with, which will scale the resulting <see cref="RectangleF"/>.</param>
|
||||
/// <returns>The area that this tokenized string takes up.</returns>
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue