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).
This commit is contained in:
ragnarok-clanker 2026-11-07 08:17:53 +00:00
commit 400e1cfade

View file

@ -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();
}