From 247c27b7dbfa529abe8b6c614b149b4dfdc3fc97 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Sun, 8 Nov 2026 23:49:45 +0000 Subject: [PATCH] Decompile fn_10966 (UIStaticText::SetTextFittedCodePage) Batch #14952 by SapitoSucio: 1 byte-identical, 0 confirmed by peer review. - fn_10966 UIStaticText::SetTextFittedCodePage: byte-identical Merged automatically: every function is byte-identical to the original. --- Source/UI/Text/UIStaticText.cpp | 50 +++++++++++++++------------------ 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/Source/UI/Text/UIStaticText.cpp b/Source/UI/Text/UIStaticText.cpp index 2f70619e4..39adb6c94 100644 --- a/Source/UI/Text/UIStaticText.cpp +++ b/Source/UI/Text/UIStaticText.cpp @@ -96,36 +96,32 @@ void UIStaticText::SetTextFittedCodePage(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, 0, 0); + this->TextWidth("...", 0, this->fontFamily, this->fontHeight, 0, 0); + if (this->geometry.width >= width) { + this->text = value; + } else { + this->tooltipEnabled = 1; + this->text = value; + std::wstring truncated(ATL::CA2WEX<128>(value, CP_THREAD_ACP)); + while (this->geometry.width < width) { + if (truncated.size() <= 1) { + this->text = std::string(ATL::CW2AEX<128>(truncated.c_str(), CP_THREAD_ACP)) + "..."; + break; + } - int width = this->TextWidth(value, 0, this->fontFamily, this->fontHeight, 0, 0); - this->TextWidth("...", 0, this->fontFamily, this->fontHeight, 0, 0); - if (this->geometry.width >= width) { - this->text = value; - this->Invalidate(); - return; - } + if (truncated.size() >= 2) { + const std::size_t size = truncated.size(); + truncated.resize((truncated[size - 2] & 0x80) != 0 && (truncated[size - 1] & 0x80) != 0 ? size - 2 : size - 1); + } - this->tooltipEnabled = 1; - this->text = value; - std::wstring truncated(ATL::CA2WEX<128>(value, CP_THREAD_ACP)); - while (this->geometry.width < width) { - if (truncated.size() <= 1) { - this->text = std::string(ATL::CW2AEX<128>(truncated.c_str(), CP_THREAD_ACP)) + "..."; - break; + this->text = std::string(ATL::CW2AEX<128>(truncated.c_str(), CP_THREAD_ACP)) + "..."; + width = this->TextWidth(this->text.c_str(), 0, this->fontFamily, this->fontHeight, 0, 0); + } } - - if (truncated.size() >= 2) { - const std::size_t size = truncated.size(); - truncated.resize((truncated[size - 2] & 0x80) != 0 && (truncated[size - 1] & 0x80) != 0 ? size - 2 : size - 1); - } - - this->text = std::string(ATL::CW2AEX<128>(truncated.c_str(), CP_THREAD_ACP)) + "..."; - width = this->TextWidth(this->text.c_str(), 0, this->fontFamily, this->fontHeight, 0, 0); + } else { + this->text = value; } this->Invalidate();