From f5ff96d3484182b67f2b1b55a5ddd3e2c8b50bf4 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Thu, 22 Dec 2022 20:04:38 +0100 Subject: [PATCH] Fixed ee62554 not working when the padding or scale changes --- MLEM.Ui/Elements/Paragraph.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/MLEM.Ui/Elements/Paragraph.cs b/MLEM.Ui/Elements/Paragraph.cs index 4239ed2..88512d4 100644 --- a/MLEM.Ui/Elements/Paragraph.cs +++ b/MLEM.Ui/Elements/Paragraph.cs @@ -107,7 +107,8 @@ namespace MLEM.Ui.Elements { private StyleProp alignment; private StyleProp regularFont; private TokenizedString tokenizedText; - private Vector2? lastAlignSplitSize; + private float? lastAlignSplitWidth; + private float? lastAlignSplitScale; /// /// 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 {