From 430e96346fa0f693c304c7bde63e3d57d9d86e06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Sun, 9 Apr 2023 20:00:21 +0200 Subject: [PATCH] Fix inconsistent text wrapping of popup labels Round up the calculated text width to prevent inconsistent text wrapping in the popups in cases where the current text width is very close to the maximum line width. --- src/game/client/ui.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game/client/ui.cpp b/src/game/client/ui.cpp index 14aa7cea2..ae39b377d 100644 --- a/src/game/client/ui.cpp +++ b/src/game/client/ui.cpp @@ -1517,7 +1517,7 @@ CUI::EPopupMenuFunctionResult CUI::PopupMessage(void *pContext, CUIRect View, bo void CUI::ShowPopupMessage(float X, float Y, SMessagePopupContext *pContext) { - const float TextWidth = minimum(TextRender()->TextWidth(SMessagePopupContext::POPUP_FONT_SIZE, pContext->m_aMessage, -1, -1.0f), SMessagePopupContext::POPUP_MAX_WIDTH); + const float TextWidth = minimum(std::ceil(TextRender()->TextWidth(SMessagePopupContext::POPUP_FONT_SIZE, pContext->m_aMessage, -1, -1.0f)), SMessagePopupContext::POPUP_MAX_WIDTH); float TextHeight = 0.0f; TextRender()->TextWidth(SMessagePopupContext::POPUP_FONT_SIZE, pContext->m_aMessage, -1, TextWidth, 0, &TextHeight); pContext->m_pUI = this; @@ -1542,7 +1542,7 @@ void CUI::SConfirmPopupContext::YesNoButtons() void CUI::ShowPopupConfirm(float X, float Y, SConfirmPopupContext *pContext) { - const float TextWidth = minimum(TextRender()->TextWidth(SConfirmPopupContext::POPUP_FONT_SIZE, pContext->m_aMessage, -1, -1.0f), SConfirmPopupContext::POPUP_MAX_WIDTH); + const float TextWidth = minimum(std::ceil(TextRender()->TextWidth(SConfirmPopupContext::POPUP_FONT_SIZE, pContext->m_aMessage, -1, -1.0f)), SConfirmPopupContext::POPUP_MAX_WIDTH); float TextHeight = 0.0f; TextRender()->TextWidth(SConfirmPopupContext::POPUP_FONT_SIZE, pContext->m_aMessage, -1, TextWidth, 0, &TextHeight); const float PopupHeight = TextHeight + SConfirmPopupContext::POPUP_BUTTON_HEIGHT + SConfirmPopupContext::POPUP_BUTTON_SPACING + 10.0f;