From 400e1cfade476a598ee05e9493e8e9f9f50ef5d2 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Sat, 7 Nov 2026 08:17:53 +0000 Subject: [PATCH] Decompile fn_10965 (UIStaticText::SetTextFitted) Batch #14111 by Yommy: 0 byte-identical, 1 confirmed by peer review. - fn_10965 UIStaticText::SetTextFitted: logic confirmed by peer review Peer-reviewed-by: secret, KWDev, codeplay Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/UI/Text/UIStaticText.cpp | 56 +++++++++++++++------------------ 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/Source/UI/Text/UIStaticText.cpp b/Source/UI/Text/UIStaticText.cpp index 54aa9e49e..15c308832 100644 --- a/Source/UI/Text/UIStaticText.cpp +++ b/Source/UI/Text/UIStaticText.cpp @@ -58,39 +58,35 @@ void UIStaticText::SetTextFitted(const char* value) { this->tooltip = value; this->tooltipEnabled = 0; - if (this->geometry.surface == nullptr) { - this->text = value; - this->Invalidate(); - return; + if (this->geometry.surface != nullptr) { + int width = this->TextWidth(value, 0, this->fontFamily, this->fontHeight, this->bold, 0); + this->TextWidth("...", 0, this->fontFamily, this->fontHeight, this->bold, 0); + + if (this->geometry.width < width) { + this->tooltipEnabled = 1; + this->text = value; + std::string truncated = value; + while (this->geometry.width < width) { + if (truncated.size() <= 1) { + this->text = truncated + "..."; + break; + } + + if (truncated.size() >= 2) { + const std::size_t size = truncated.size(); + truncated.resize(truncated[size - 2] < 0 && truncated[size - 1] < 0 ? size - 2 : size - 1); + } + + this->text = truncated + "..."; + width = this->TextWidth(this->text.c_str(), 0, this->fontFamily, this->fontHeight, this->bold, 0); + } + + this->Invalidate(); + return; + } } - int width = this->TextWidth(value, 0, this->fontFamily, this->fontHeight, this->bold, 0); - this->TextWidth("...", 0, this->fontFamily, this->fontHeight, this->bold, 0); - - if (this->geometry.width >= width) { - this->text = value; - this->Invalidate(); - return; - } - - this->tooltipEnabled = 1; this->text = value; - std::string truncated = value; - while (this->geometry.width < width) { - if (truncated.size() <= 1) { - this->text = truncated + "..."; - break; - } - - if (truncated.size() >= 2) { - const std::size_t size = truncated.size(); - truncated.resize(truncated[size - 2] < 0 && truncated[size - 1] < 0 ? size - 2 : size - 1); - } - - this->text = truncated + "..."; - width = this->TextWidth(this->text.c_str(), 0, this->fontFamily, this->fontHeight, this->bold, 0); - } - this->Invalidate(); }