From cbc09b83585cabcf9ccd0b0ab637d41ae167a59b Mon Sep 17 00:00:00 2001 From: JappaWakka Date: Sun, 5 May 2024 21:18:40 +0200 Subject: [PATCH] Prevent impossible CropStringToWidth freeze --- P3D/Overworld/NotificationPopup.vb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/P3D/Overworld/NotificationPopup.vb b/P3D/Overworld/NotificationPopup.vb index f4dca1eb1..6875a1a90 100644 --- a/P3D/Overworld/NotificationPopup.vb +++ b/P3D/Overworld/NotificationPopup.vb @@ -153,11 +153,17 @@ Public Class NotificationPopup ''' Renders the NotificationPopup. ''' Public Sub Draw() - Dim TextHeader As String = _text.GetSplit(0, "*").Replace(CChar("~"), Environment.NewLine).CropStringToWidth(FontManager.InGameFont, CInt(_scale), CInt((_size.Width * (FrameSizeBack / 3) - FrameSizeBack / 3 * 4) * _scale)) + + Dim TextHeader As String = _text.GetSplit(0, "*").Replace(CChar("~"), Environment.NewLine) Dim TextBody As String = _text.GetSplit(1, "*").Replace(CChar("~"), Environment.NewLine) + While FontManager.InGameFont.MeasureString(TextHeader).X * CInt(_scale) > CInt((_size.Width * (FrameSizeBack / 3) - FrameSizeBack / 3 * 4) * _scale) + _size.Width += 1 + End While - While FontManager.InGameFont.MeasureString(TextHeader).Y * 2 + FontManager.InGameFont.MeasureString(TextBody).Y > CInt(((_size.Height * FrameSizeBack / 3) - FrameSizeBack / 3) * _scale - 5) + TextHeader = TextHeader.CropStringToWidth(FontManager.InGameFont, CInt(_scale), CInt((_size.Width * (FrameSizeBack / 3) - FrameSizeBack / 3 * 4) * _scale)) + + While FontManager.InGameFont.MeasureString(TextHeader).Y * CInt(_scale) + FontManager.InGameFont.MeasureString(TextBody).Y > CInt(((_size.Height * FrameSizeBack / 3) - FrameSizeBack / 3) * _scale - 5) _size.Height += 1 End While