From f3304d843053d0a22e9cdaf0bcecd13d5ab48325 Mon Sep 17 00:00:00 2001 From: Victor Date: Sat, 24 Feb 2024 07:06:05 -0700 Subject: [PATCH] Another fix to newlines Dismiss now clears pages so a dialog box can be re-used. fixes #1375 fixes #1370 --- .../FlatRedBall.Forms.Shared/Controls/Games/DialogBox.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Engines/Forms/FlatRedBall.Forms/FlatRedBall.Forms.Shared/Controls/Games/DialogBox.cs b/Engines/Forms/FlatRedBall.Forms/FlatRedBall.Forms.Shared/Controls/Games/DialogBox.cs index aafd6bc98..2baf7938b 100644 --- a/Engines/Forms/FlatRedBall.Forms/FlatRedBall.Forms.Shared/Controls/Games/DialogBox.cs +++ b/Engines/Forms/FlatRedBall.Forms/FlatRedBall.Forms.Shared/Controls/Games/DialogBox.cs @@ -443,8 +443,13 @@ private string[] ConvertToPages(string text) { toAppend = BbCodeParser.AddTags(toAppend, foundTagsWithoutNewlines, strippedTextCount); } + strippedTextCount += sizeBeforeTags; - stringBuilder.Append(toAppend); + if(toAppend?.EndsWith(" ") == true) + { + toAppend = toAppend.Substring(0, toAppend.Length - 1); + } + stringBuilder.Append(toAppend + "\n"); absoluteLineNumber++; } pages.Add(stringBuilder.ToString()); @@ -532,6 +537,7 @@ public void Dismiss() LastTimeDismissed = TimeManager.CurrentTime; PageAdvanced?.Invoke(this, null); FinishedShowing?.Invoke(this, null); + this.Pages.Clear(); IsFocused = false; }