From 32038a1907598a89e059a7600bff775d956beb8d Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Fri, 30 Oct 2026 10:41:02 +0000 Subject: [PATCH] Decompile 4 functions in Source/UI/Text/UIStaticText.cpp, Source/UI/Text/UIStaticText.h, ... Batch #5352 by ragnarok-clanker: 0 byte-identical, 4 confirmed by peer review. - fn_10948 UIStaticText::SetTextWithinWidth: logic confirmed by peer review - fn_10962 UIBmpTextButton::AddTextStyle: logic confirmed by peer review - fn_10963 UIStaticText::SetTextAutoWidth: logic confirmed by peer review - fn_10964 UIStaticText::SetNumber: logic confirmed by peer review Peer-reviewed-by: alisonrag, tayoba, Millenium Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/UI/Buttons/UIBmpTextButton.h | 1 + Source/UI/Text/UIStaticText.cpp | 72 +++++++++++++++++++++++++++++ Source/UI/Text/UIStaticText.h | 3 ++ 3 files changed, 76 insertions(+) diff --git a/Source/UI/Buttons/UIBmpTextButton.h b/Source/UI/Buttons/UIBmpTextButton.h index a0bfdf0a5..ff277a979 100644 --- a/Source/UI/Buttons/UIBmpTextButton.h +++ b/Source/UI/Buttons/UIBmpTextButton.h @@ -21,6 +21,7 @@ public: ~UIBmpTextButton() override; void Paint() override; void SetText(std::string value); + void AddTextStyle(int state, int height, std::uint32_t color, unsigned char bold, unsigned char shadow, int x, int y); /* 0120 */ std::string text; /* 0138 */ std::vector styles; diff --git a/Source/UI/Text/UIStaticText.cpp b/Source/UI/Text/UIStaticText.cpp index 0fc82cdfb..e56754ad5 100644 --- a/Source/UI/Text/UIStaticText.cpp +++ b/Source/UI/Text/UIStaticText.cpp @@ -1,7 +1,10 @@ #include "Render/DeviceContext/DeviceContext.h" #include "UI/Buttons/UIButton.h" +#include "UI/Buttons/UIBmpTextButton.h" #include "UI/Text/UIStaticText.h" +#include + // OFFSET: 0x00850550 // FUNCTION: fn_10678 UIStaticText::UIStaticText(UIWindowContext& windows, UIButtonContext& controls) @@ -232,3 +235,72 @@ void UIStaticText::SetFont(int family, int height, unsigned char bold, unsigned this->bold = bold; this->italic = italic; } + +// OFFSET: 0x008685E0 +// FUNCTION: fn_10962 +void UIBmpTextButton::AddTextStyle(int state, int height, std::uint32_t color, unsigned char bold, unsigned char shadow, int x, int y) { + if (x == -1000) { + const int width = this->TextWidth( + this->m_buttonContext->fonts, this->m_buttonContext->locale, this->text.c_str(), this->text.size(), 0, height, bold, 0 + ); + x = static_cast((this->geometry.width - width) * 0.5); + } + + if (y == -1000) { + const int textHeight = this->TextHeight( + this->m_buttonContext->fonts, this->m_buttonContext->locale, this->text.c_str(), this->text.size(), 0, height, bold, 0 + ); + y = static_cast((this->geometry.height - textHeight) * 0.5); + } + + for (const BitmapButtonTextStyle& style : this->styles) { + if (style.state == state) { + return; + } + } + + this->styles.push_back(BitmapButtonTextStyle{state, x, y, height, bold, color, shadow}); +} + +// OFFSET: 0x00868750 +// FUNCTION: fn_10963 +void UIStaticText::SetTextAutoWidth(const char* value) { + this->tooltipEnabled = 0; + this->tooltip = value; + this->text = value; + this->Invalidate(); + + const int height = this->geometry.height; + const int width = this->TextWidth(this->m_controls->fonts, this->m_controls->locale, value, 0, this->fontFamily, this->fontHeight, this->bold, 0); + this->Resize(width + 2, height); +} + +// OFFSET: 0x008687F0 +// FUNCTION: fn_10964 +void UIStaticText::SetNumber(int value) { + char buffer[40]; + std::sprintf(buffer, "%d", value); + this->text = buffer; + this->tooltip = buffer; + this->tooltipEnabled = 0; + this->Invalidate(); +} + +// OFFSET: 0x00867CA0 +// FUNCTION: fn_10948 +void UIStaticText::SetTextWithinWidth(const char* value, int outlineValue) { + this->text = value; + this->tooltip = value; + this->outline = outlineValue; + this->tooltipEnabled = 0; + + const int width = this->TextWidth(this->m_controls->fonts, this->m_controls->locale, value, 0, 0, this->fontHeight, this->bold, 0); + if (this->geometry.width < width) { + this->SetTextFitted(value); + } else { + const int height = this->geometry.height; + const int textWidth = this->TextWidth(this->m_controls->fonts, this->m_controls->locale, value, 0, 0, this->fontHeight, this->bold, 0); + this->Resize(textWidth, height); + } + this->Invalidate(); +} diff --git a/Source/UI/Text/UIStaticText.h b/Source/UI/Text/UIStaticText.h index bd260fd56..d04e7de3a 100644 --- a/Source/UI/Text/UIStaticText.h +++ b/Source/UI/Text/UIStaticText.h @@ -25,6 +25,9 @@ public: void SetText(const char* value, int outline); void SetColor(int redValue, int greenValue, int blueValue); void SetTextFitted(const char* value); + void SetTextAutoWidth(const char* value); + void SetNumber(int value); + void SetTextWithinWidth(const char* value, int outlineValue); void SetFont(int family, int height, unsigned char bold, unsigned char italic); /* 007C */ int red;