1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-12-25 17:59:24 +01:00

Fixed ee62554 not working when the padding or scale changes

This commit is contained in:
Ell 2022-12-22 20:04:38 +01:00
parent ee62554fee
commit f5ff96d348

View file

@ -107,7 +107,8 @@ namespace MLEM.Ui.Elements {
private StyleProp<TextAlignment> alignment;
private StyleProp<GenericFont> regularFont;
private TokenizedString tokenizedText;
private Vector2? lastAlignSplitSize;
private float? lastAlignSplitWidth;
private float? lastAlignSplitScale;
/// <summary>
/// Creates a new paragraph with the given settings.
@ -195,7 +196,8 @@ namespace MLEM.Ui.Elements {
// tokenize the text
this.tokenizedText = this.System.TextFormatter.Tokenize(this.RegularFont, this.Text, this.Alignment);
this.lastAlignSplitSize = null;
this.lastAlignSplitWidth = null;
this.lastAlignSplitScale = null;
// add links to the paragraph
this.RemoveChildren(c => c is Link);
@ -204,11 +206,14 @@ namespace MLEM.Ui.Elements {
}
private void AlignAndSplitIfNecessary(Vector2 size) {
if (size == this.lastAlignSplitSize)
return;
this.lastAlignSplitSize = size;
var width = size.X - this.ScaledPadding.Width;
var scale = this.TextScale * this.TextScaleMultiplier * this.Scale;
if (this.lastAlignSplitWidth == width && this.lastAlignSplitScale == scale)
return;
this.lastAlignSplitWidth = width;
this.lastAlignSplitScale = scale;
if (this.TruncateIfLong) {
this.tokenizedText.Truncate(this.RegularFont, width, scale, this.Ellipsis, this.Alignment);
} else {