From 246510fb80f6381e2998a8cc2bf553ce418dc078 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Sat, 31 Oct 2026 23:09:37 +0000 Subject: [PATCH] Decompile fn_12093 (UIFrameWnd::DrawFittedItemName) Batch #8935 by KWDev: 0 byte-identical, 1 confirmed by peer review. - fn_12093 UIFrameWnd::DrawFittedItemName: logic confirmed by peer review Peer-reviewed-by: Yommy, gordaoprogramas Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/UI/Window/UIFrameWnd.h | 1 + Source/UI/WindowOverlay.cpp | 56 +++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/Source/UI/Window/UIFrameWnd.h b/Source/UI/Window/UIFrameWnd.h index 742afe58..590608ee 100644 --- a/Source/UI/Window/UIFrameWnd.h +++ b/Source/UI/Window/UIFrameWnd.h @@ -58,6 +58,7 @@ public: const void* info, const char* text, const char* highlight, std::uint32_t color, std::uint32_t highlightColor, int width, const std::vector* breaks ); + int DrawFittedItemName(int x, int y, const ITEM_INFO* item, std::uint32_t color, int unused, int unused2, char option); void SplitHighlightText( const char* text, const char* highlight, const int& highlightColor, const int& color, const std::vector& breaks, std::vector>& segments diff --git a/Source/UI/WindowOverlay.cpp b/Source/UI/WindowOverlay.cpp index 64497867..1c3836a2 100644 --- a/Source/UI/WindowOverlay.cpp +++ b/Source/UI/WindowOverlay.cpp @@ -10,10 +10,13 @@ #include "UI/Chat/UIWhisperWnd.h" #include "UI/Items/UIEquipWnd.h" #include "UI/Skill/UISkillDescribeWnd.h" +#include "UI/Text/TextFitting.h" #include "Utility/Text/FormatString.h" #include #include +#include +#include #include // OFFSET: 0x008D0D80 @@ -111,6 +114,59 @@ namespace { }; } +// OFFSET: 0x008D13E0 +// FUNCTION: fn_12093 +int UIFrameWnd::DrawFittedItemName(int x, int y, const ITEM_INFO* item, std::uint32_t color, int, int, char option) { + std::vector breaks; + char buffer[256]; + std::memset(buffer, 0, sizeof(buffer)); + char* highlight = nullptr; + std::size_t remaining = sizeof(buffer); + char* cursor = buffer; + int highlightColor; + this->BuildItemName(item, &highlightColor, &breaks, &cursor, &remaining, &highlight, 0, option); + + char* text = buffer; + int offset = 0; + for (auto it = breaks.begin(); it != breaks.end(); ++it) { + std::string fitted = FitText(*this->geometry.surface, std::string(text), this->geometry.width - x - 10); + bool truncated; + char* end; + if (std::strcmp(fitted.c_str(), text) != 0) { + truncated = true; + strcpy_s(buffer, sizeof(buffer), fitted.c_str()); + end = text + std::strlen(text) + 1; + } else { + end = *it; + truncated = false; + } + + int bytes = static_cast(end - text); + if (bytes == 0) { + continue; + } + + if (text == highlight) { + this->DrawShadowedText(offset + x, y, text, bytes, static_cast(highlightColor), 0xE0E0E0, 0, 12, 0); + } else if (item->unknown_005D) { + this->DrawShadowedText(offset + x, y, text, bytes, color, 0x5050FA, 0, 12, 0); + } else { + std::uint32_t card = ItemCardColor(item); + if (card == 0x00ADFF2F) { + card = 0x00669900; + } + color = (card >> 16 & 0xFF) | ((card & 0xFF) << 16) | (card & 0x0000FF00); + this->DrawShadowedText(offset + x, y, text, bytes, color, 0xFFFFFF, 0, 12, 0); + } + offset += this->TextWidth(this->m_context->fonts, this->m_context->locale, text, bytes, 0, 12, 0, 0); + text = end; + if (truncated) { + break; + } + } + return offset; +} + // OFFSET: 0x008D17C0 // FUNCTION: fn_12094 int UIFrameWnd::DrawItemName(int x, int y, int width, const ITEM_INFO* item, int, int family, int height) {